Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.metadata/
22 changes: 21 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,30 @@
"options": {
"cwd": "/usr/bin"
},
"group": "build"
},
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
Expand Down
42 changes: 42 additions & 0 deletions 201914388/201914388_CC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "CC.h"

void sim_main()
{
unsigned int read1;
int read2;
int read3;
int read4;
int write5;
int write6;

/********************************************/
/***************** Data Read ****************/
/********************************************/
read1 = *CC_Recv_ACCEL_VALUE;
read2 = *CC_Recv_TARGET_SPEED;
read3 = *CC_Recv_SPEED;
read4 = *CC_Recv_CC_TRIGGER;

/********************************************/
/***************** Processing ***************/
/********************************************/
write5 = 0;
write6 = 0;
read2 = read2 / 100;

if(read4 > 6000) {

write6 = read1;

if (read3 - read2 < 0)
write6 = read2;
else if(read3 > read2)
write6 = 0;
}

/********************************************/
/***************** Data Write ***************/
/********************************************/
*CC_Send_BRAKE = write5;
*CC_Send_ACCEL = write6;
}
46 changes: 46 additions & 0 deletions 201914388/201914388_LK.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "LK.h"

void sim_main()
{
if (rtU->read2 <= 5000.0)
{
rtDW->w3 = 0.0;
rtDW->w4 = 0.0;
}
else
{
if (rtU->read1 > 0.0)
{
rtDW->w3 = 0.0;
}
else if ((rtU->read1 < 0.0) && (rtU->read1 < -10000.0))
{
rtDW->w3 = 10000.0;
}
else
{
if ((rtU->read1 < 0.0) && (rtU->read1 >= -10000.0))
{
rtDW->w3 = rtU->read1 * -1;
}
}

if ((rtU->read1 > 0.0) && (rtU->read1 > 10000.0))
{
rtDW->w4 = 10000.0;
}
else if ((rtU->read1 > 0.0) && (rtU->read1 <= 10000.0))
{
rtDW->w4 = rtU->read1;
}
else
{
if (rtU->read1 < 0.0)
{
rtDW->w4 = 0.0;
}
}
}
rtY->write3 = rtDW->w3;
rtY->write4 = rtDW->w4;
}
48 changes: 48 additions & 0 deletions 201914388/201914388_design.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?><hyundaiDesignTool>
<ETHs>
<ETH IP="192.168.0.100">
<link rid="ECU0" type="ECU"/>
<link rid="CAR" type="CAR"/>
</ETH>
</ETHs>
<CAR IP="CAR">
<link rid="192.168.0.100" type="ETH"/>
</CAR>
<SWCs>
<SWC BCET="20" IP="SWC_CC" Virtual="1" WCET="20" consumer="" deadline="100" period="100" phase="0" readCon="1" writeCon="1">
<impl path="/home/rubis/ComputerModeling2023/sharedObjectFiles/CC/CC.cpp" type="MANUAL"/>
<link idxCore="0" rid="ECU0" type="ECU"/>
</SWC>
<SWC BCET="30" IP="SWC_LK" Virtual="1" WCET="30" consumer="" deadline="60" period="60" phase="0" readCon="1" writeCon="1">
<impl path="/home/rubis/ComputerModeling2023/sharedObjectFiles/LK/LK.cpp" type="MANUAL"/>
<link idxCore="0" rid="ECU0" type="ECU"/>
</SWC>
<SWC BCET="50" IP="SWC_SENSING" Virtual="1" WCET="50" consumer="" deadline="500" period="500" phase="0" readCon="0" writeCon="0">
<impl path="/home/rubis/ComputerModeling2023/sharedObjectFiles/SENSING/SENSING.cpp" type="MANUAL"/>
<link idxCore="0" rid="ECU0" type="ECU"/>
</SWC>
<SWC BCET="50" IP="SWC_BRAKE" Virtual="1" WCET="50" consumer="" deadline="500" period="500" phase="0" readCon="0" writeCon="0">
<impl path="/home/rubis/ComputerModeling2023/sharedObjectFiles/BRAKE/BRAKE.cpp" type="MANUAL"/>
<link idxCore="0" rid="ECU0" type="ECU"/>
</SWC>
<SWC BCET="50" IP="SWC_POWER" Virtual="1" WCET="50" consumer="" deadline="500" period="500" phase="0" readCon="0" writeCon="0">
<impl path="/home/rubis/ComputerModeling2023/sharedObjectFiles/POWER/POWER.cpp" type="MANUAL"/>
<link idxCore="0" rid="ECU0" type="ECU"/>
</SWC>
<SWC BCET="50" IP="SWC_LOCAL" Virtual="1" WCET="50" consumer="" deadline="500" period="500" phase="0" readCon="0" writeCon="0">
<impl path="/home/rubis/ComputerModeling2023/sharedObjectFiles/LOCAL/LOCAL.cpp" type="MANUAL"/>
<link idxCore="0" rid="ECU0" type="ECU"/>
</SWC>
</SWCs>
<ECUs>
<ECU IP="ECU0" Virtual="1" numCores="1" schedPolicy="RM" sysClock="100" targetArch="SPC56EL70">
<link idxCore="0" rid="SWC_LK" type="SWC"/>
<link idxCore="0" rid="SWC_CC" type="SWC"/>
<link idxCore="0" rid="SWC_SENSING" type="SWC"/>
<link idxCore="0" rid="SWC_BRAKE" type="SWC"/>
<link idxCore="0" rid="SWC_POWER" type="SWC"/>
<link idxCore="0" rid="SWC_LOCAL" type="SWC"/>
<link rid="192.168.0.100" type="ETH"/>
</ECU>
</ECUs>
</hyundaiDesignTool>
72 changes: 72 additions & 0 deletions 201914388/EthernetClient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "EthernetClient.h"
#include "Utils.h"

EthernetClient::EthernetClient()
{

}
EthernetClient::~EthernetClient()
{

}

void EthernetClient::ethernet_read_write()
{
int read_buf[6];
int read_length;
int packet_cnt = 0;
global_object::tagged_data_read.clear();
global_object::delayed_data_write.clear();
do
{
read_length = read(utils::socket_EHTERNET, read_buf, sizeof(read_buf));
if(read_length == -1)
{
continue;
}
else
{
int recv_accel = 0;
int recv_targe_speed = 0;
int recv_cc = 0;
int recv_speed = 0;
int read2 = 0.0;
int read1 = 0.0;

memcpy(&recv_accel, &read_buf[5], 4);
memcpy(&recv_targe_speed, &read_buf[4], 4);
memcpy(&recv_cc, &read_buf[0], 4);
memcpy(&recv_speed, &read_buf[2], 4);
memcpy(&read2, &read_buf[1], 4);
memcpy(&read1, &read_buf[3], 4);

shared::CC_Recv_ACCEL_VALUE = recv_accel;
shared::CC_Recv_TARGET_SPEED = recv_targe_speed;
shared::CC_Recv_CC_TRIGGER = recv_cc;
shared::CC_Recv_SPEED = recv_speed;
shared::rtU.read2 = read2;
shared::rtU.read1 = read1;

std::shared_ptr<TaggedData> tagged_data = std::make_shared<TaggedData>();
// tagged_data->data_time = utils::current_time;
tagged_data->data_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - utils::simulator_start_time).count();
tagged_data->data_read1 = recv_accel;
tagged_data->data_read2 = recv_targe_speed;
tagged_data->data_read3 = recv_cc;
tagged_data->data_read4 = recv_speed;
tagged_data->data_read5 = read2;
tagged_data->data_read6 = read1;

global_object::tagged_data_read.push_back(std::move(tagged_data));
}
} while(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - utils::simulator_start_time).count() < utils::simulation_termination_time);
}

int EthernetClient::SIGNEX(unsigned int _value, unsigned int _size)
{
int ret = 0;
ret |= _value;
ret <<= ((sizeof(int) * 8) - _size);
ret >>= ((sizeof(int) * 8) - _size);
return ret;
}
Loading