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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"ios": "cpp",
"locale": "cpp",
"queue": "cpp",
"stack": "cpp"
"stack": "cpp",
"future": "cpp"
}
}
1 change: 0 additions & 1 deletion CPSim_GUI/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/model/
/org/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified CPSim_GUI/bin/org/eclipse/cpsim/Diagram/util/CmdExecuter.class
Binary file not shown.
Binary file modified CPSim_GUI/bin/org/eclipse/cpsim/Diagram/util/DiagramUtil.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified CPSim_GUI/bin/org/eclipse/cpsim/menu/design/MakeUpProject.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified CPSim_GUI/bin/org/eclipse/cpsim/menu/simulation/RoIDialog.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33 changes: 33 additions & 0 deletions Engine/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void Executor::set_current_hyper_period_end(int current_hyper_period_end)
*/
bool Executor::run_simulation(JobVectorOfSimulator& job_vector_of_simulator, JobVectorsForEachECU& job_vectors_for_each_ECU, double start_time)
{
std::vector<event_t> events;
double end_time = start_time + utils::hyper_period;
move_ecus_jobs_to_simulator(job_vector_of_simulator, job_vectors_for_each_ECU); // Copies job vectors from ECUs to Sim.
if (!utils::real_workload)
Expand All @@ -114,6 +115,12 @@ bool Executor::run_simulation(JobVectorOfSimulator& job_vector_of_simulator, Job
if(job->get_actual_start_time() < 0 || job->get_actual_finish_time() > job->get_actual_deadline())
{
std::cout <<"DEADLINE MISS IN REAL CYBER SYSTEM" << std::endl;

event_t event;
event.time = job->get_actual_deadline();
event.jid = job->get_job_id();
event.event = "DEADLINE MISS";
events.push_back(event);
}
}
//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - utils::simulator_start_time).count() <<std::endl;
Expand Down Expand Up @@ -210,6 +217,32 @@ bool Executor::run_simulation(JobVectorOfSimulator& job_vector_of_simulator, Job
}

utils::current_time = end_time;

for (auto job : job_vector_of_simulator)
{
event_t e1,e2,e3;
e1.time=job->get_actual_release_time();
e1.jid=job->get_job_id();
e1.event="RELEASED";
events.push_back(e1);
e2.time=job->get_actual_release_time();
e2.jid=job->get_job_id();
e2.event="STARTED";
events.push_back(e2);
e3.time=job->get_actual_release_time();
e3.jid=job->get_job_id();
e3.event="FINISHED";
events.push_back(e3);
}
std::sort(events.begin(), events.end(), [](const event_t &a, const event_t &b){return a.time<b.time;});
std::ofstream aaaa;
aaaa.open(utils::cpsim_path + "/Log/2023-81117_schedule.log", std::ios::out);
for (auto event: events)
{
std::string s = (std::to_string(event.time) + " J" + std::to_string(event.jid) + " " + event.event + "\n");
aaaa.write(s.c_str(), s.size());
}
aaaa.close();
return true;
}

Expand Down
5 changes: 5 additions & 0 deletions Engine/Executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
*
*/

typedef struct {
int time, jid;
std::string event;
} event_t;

typedef struct OldData
{
int est;
Expand Down
3 changes: 3 additions & 0 deletions Engine/Initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ int Initializer::parsing_specificated_information()
*/
void Initializer::initialize(EcuVector& ecu_vector, TaskVector& task_vector, JobVectorsForEachECU& job_vectors_for_each_ECU)
{
/*Stay mad */
turbat::logg.open(utils::cpsim_path + "/Log/2023-81117_read_write.log", std::ios::out);
turbat::logg.close();
/**
* Speicification Initialization
*/
Expand Down
19 changes: 18 additions & 1 deletion Engine/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdlib>
#include <climits>
#include <cmath>

#include <future>

/**
* This file is the cpp file for the Job class.
Expand Down Expand Up @@ -569,9 +569,15 @@ void Job::add_history(std::shared_ptr<Job> new_deadline)

void Job::run_function()
{
//utils::mtx_data_log.lock();

//utils::mtx_data_log.unlock();
m_run_start = std::chrono::steady_clock::now();

if((get_is_read() == true) && (get_is_write() == true))
{

//shukar::PuscasuRazvanStefan_202381117_task_read_write_logger(utils::log_task);
if(!global_object::tagged_data_read.empty())
{
std::shared_ptr<TaggedData> current_data = global_object::tagged_data_read.at(global_object::tagged_data_read.size()-1);
Expand All @@ -585,7 +591,18 @@ void Job::run_function()
delayed_data->data_write3 = shared::rtY.write3;
delayed_data->data_write2 = shared::CC_Send_BRAKE;
delayed_data->data_write1 = shared::CC_Send_ACCEL;
if (( this->get_task_name() == "SWC1" && utils::log_task == "LK") || (this->get_task_name() == "SWC0" && utils::log_task == "CC") )//utils::log_task)
{
std::ofstream _log;
_log.open(utils::cpsim_path + "/Log/2023-81117_read_write.log", std::ios::app);
std::string out = "";
out += (std::to_string(m_actual_start_time) + " READ " + utils::log_task + " TARGET_SPEED" + "\n");
out += (std::to_string(m_actual_finish_time) + " WRITE " + utils::log_task + " ACCEL_VALUE" + "\n");
_log.write(out.c_str(), out.size());
_log.close();
}
}

else if((get_is_read() == true) && (get_is_write() == false))
{
if(!global_object::tagged_data_read.empty())
Expand Down
36 changes: 36 additions & 0 deletions Engine/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,42 @@ Logger::~Logger()

}


//open(utils::cpsim_path + "/Log/2023-81117_read_write.log", std::ios::out);

void PuscasuRazvanStefan_202381117_task_read_write_logger(std::string task_name)
{
//std::cout<<"AAAAAAAAAAAAAAAAAAAAAAAAAAA\n\n";

//while (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - utils::simulator_start_time).count() < utils::simulation_termination_time)
//{
//utils::mtx_data_log.lock();

if(global_object::schedule_data.size() > 10)
{
std::string out = "aaaaaaaaaaaaaaaaaaaaaaaaa\n";
auto job = global_object::running_job;
if (task_name != utils::log_task)
{
//utils::mtx_data_log.unlock();
return;
}
if (job->get_is_read())
{
out += (std::to_string(job->get_actual_start_time())) + " READ " + task_name + "TARGET_SPEED" "\n";
}
else
{
out += (std::to_string(job->get_actual_finish_time())) + " WRITE " + task_name + "ACCEL_VALUE" + "\n";
}

turbat::logg.write(out.c_str(), out.size());
//logg.close();
}
//utils::mtx_data_log.unlock();
//}
}

/**
* @fn void start_logging()
* @brief this function starts the logging of simulation events
Expand Down
3 changes: 3 additions & 0 deletions Engine/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ class Logger{
void set_schedule_log_info(std::vector<std::shared_ptr<Task>>&);
};

namespace shukar{
inline void PuscasuRazvanStefan_202381117_task_read_write_logger(std::string task_name);
}
#endif
4 changes: 4 additions & 0 deletions Engine/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ namespace global_object
inline int start_jobnum[6] = {0};
inline int finish_jobnum[6] = {0};
}
namespace turbat{
inline std::ofstream logg;
}

#ifdef CANMODE__
namespace can
{
Expand Down
Loading