Skip to content
Snippets Groups Projects
Commit 3b4730a0 authored by karim.moussaoui's avatar karim.moussaoui
Browse files

Update main.cpp, parsing,ajout du type carbon_co2... : Fait par Karim/Adem

parent 06530205
No related branches found
No related tags found
No related merge requests found
Pipeline #8636 failed
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
#include "algo/fcfs.hpp" #include "algo/fcfs.hpp"
#include "algo/rejecter.hpp" #include "algo/rejecter.hpp"
#include "algo/sequencer.hpp" #include "algo/sequencer.hpp"
#include "algo/psc.hpp" // Inclusion de l'algorithme Psc #include "algo/carbone.hpp"
using namespace std; using namespace std;
using namespace boost; using namespace boost;
namespace n = network; namespace n = network;
namespace r = rapidjson; namespace r = rapidjson;
//Modification : Karim/Adem
void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision &d, void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision &d,
Workload &workload, bool call_make_decisions_on_single_nop = true); Workload &workload, bool call_make_decisions_on_single_nop = true);
...@@ -56,13 +56,12 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision &d, ...@@ -56,13 +56,12 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision &d,
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
const set<string> variants_set = {"easy_bf", "fcfs", "rejecter", "sequencer", "psc" }; // Ajout de Psc const set<string> variants_set = {"easy_bf", "fcfs", "rejecter", "sequencer", "carbone"};
const set<string> policies_set = {"basic", "contiguous"}; const set<string> policies_set = {"basic", "contiguous"};
const set<string> queue_orders_set = {"fcfs", "lcfs", "desc_bounded_slowdown", "desc_slowdown", const set<string> queue_orders_set = {"fcfs", "lcfs", "desc_bounded_slowdown", "desc_slowdown",
"asc_size", "desc_size", "asc_walltime", "desc_walltime"}; "asc_size", "desc_size", "asc_walltime", "desc_walltime"};
const set<string> verbosity_levels_set = {"debug", "info", "quiet", "silent"}; const set<string> verbosity_levels_set = {"debug", "info", "quiet", "silent"};
const string variants_string = "{" + boost::algorithm::join(variants_set, ", ") + "}"; const string variants_string = "{" + boost::algorithm::join(variants_set, ", ") + "}";
const string policies_string = "{" + boost::algorithm::join(policies_set, ", ") + "}"; const string policies_string = "{" + boost::algorithm::join(policies_set, ", ") + "}";
const string queue_orders_string = "{" + boost::algorithm::join(queue_orders_set, ", ") + "}"; const string queue_orders_string = "{" + boost::algorithm::join(queue_orders_set, ", ") + "}";
...@@ -243,9 +242,8 @@ int main(int argc, char ** argv) ...@@ -243,9 +242,8 @@ int main(int argc, char ** argv)
algo = new Rejecter(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options); algo = new Rejecter(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options);
else if (scheduling_variant == "sequencer") else if (scheduling_variant == "sequencer")
algo = new Sequencer(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options); algo = new Sequencer(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options);
else if (scheduling_variant == "psc") // Ajout de psc else if (scheduling_variant == "carbone")
algo = new Psc(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options); algo = new CarboneAlgorithm(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options);
// Network // Network
Network n; Network n;
n.bind(socket_endpoint); n.bind(socket_endpoint);
...@@ -316,6 +314,7 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision & d, ...@@ -316,6 +314,7 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision & d,
current_date = event_object["timestamp"].GetDouble(); current_date = event_object["timestamp"].GetDouble();
const r::Value & event_data = event_object["data"]; const r::Value & event_data = event_object["data"];
if (event_type == "SIMULATION_BEGINS") if (event_type == "SIMULATION_BEGINS")
{ {
int nb_resources; int nb_resources;
...@@ -444,6 +443,28 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision & d, ...@@ -444,6 +443,28 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision & d,
} }
} }
else if (event_type == "carbon_co2") {
int val_dcA = 0, val_dcB = 0, val_dcC = 0; // Initialisation
if (event_data.HasMember("some_field_dcA")) {
val_dcA = event_data["some_field_dcA"].GetInt();
}
if (event_data.HasMember("another_field_dcB")) {
val_dcB = event_data["another_field_dcB"].GetInt();
}
if (event_data.HasMember("additional_field_dcC")) {
val_dcC = event_data["additional_field_dcC"].GetInt();
}
CarboneAlgorithm* carboneAlgo = dynamic_cast<CarboneAlgorithm*>(algo);
if (carboneAlgo != nullptr) {
carboneAlgo->updateCarbonFootprint(val_dcA, val_dcB, val_dcC);
}
else {
std::cerr << "Erreur : l'algorithme en cours n'est pas une instance de CarboneAlgorithm." << std::endl;
}
}
else else
{ {
throw runtime_error("Unknown event received. Type = " + event_type); throw runtime_error("Unknown event received. Type = " + event_type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment