diff options
Diffstat (limited to 'src/inputs.cc')
| -rw-r--r-- | src/inputs.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/inputs.cc b/src/inputs.cc new file mode 100644 index 0000000..066dcb0 --- /dev/null +++ b/src/inputs.cc @@ -0,0 +1,50 @@ +#include "inputs.hpp" +#include <iostream> +#include <fstream> + + +Inputs::Inputs(std::string node_name){ + FILE* input_file = fopen(INPUTS_FILE, "rb"); + char input_file_buffer[65536]; + rapidjson::FileReadStream is(input_file, input_file_buffer, sizeof(input_file_buffer)); + d.ParseStream(is); + fclose(input_file); + + wake_duration=d[node_name.c_str()]["wake_duration"].GetDouble(); + wake_interval=d[node_name.c_str()]["wake_interval"].GetDouble(); + startup_delay=d[node_name.c_str()]["startup_delay"].GetDouble(); + is_sender=d[node_name.c_str()]["is_sender"].GetBool(); + max_attempts=d[node_name.c_str()]["max_attemps"].GetInt(); + +} + +void Inputs::GeneratePlatform(std::string p){ + FILE* input_file = fopen(INPUTS_FILE, "rb"); + char input_file_buffer[65536]; + rapidjson::FileReadStream is(input_file, input_file_buffer, sizeof(input_file_buffer)); + rapidjson::Document d; + d.ParseStream(is); + fclose(input_file); + + // Write platform file + std::ofstream pf; + pf.open (p); + pf << "<?xml version='1.0'?>\n"; + pf << "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"; + pf << "<platform version=\"4.1\">\n <AS id=\"AS0\" routing=\"Cluster\">\n"; + pf << " <link id=\"link\" bandwidth=\"1Mbps\" latency=\"0ms\" sharing_policy=\"SHARED\"></link>\n"; + for (Value::ConstMemberIterator itr = d.MemberBegin(); itr != d.MemberEnd(); ++itr) + { + std::string name=itr->name.GetString(); + double power_on=d[itr->name.GetString()]["power_on"].GetDouble(); + double power_off=d[itr->name.GetString()]["power_off"].GetDouble(); + + //db=d[itr->name.GetString()]["wake_interval"].GetDouble(); + pf << " <host id=\""<<name<<"\" speed=\"100.0f,100.0f\" pstate=\"0\">\n"; + pf << " <prop id=\"wattage_per_state\" value=\""<< power_off<<":"<<power_off<<", "<< power_on<<":"<<power_on<<"\" />\n"; + pf << " <prop id=\"wattage_off\" value=\"0\" />\n </host>\n"; + pf << " <host_link id=\""<<name<<"\" up=\"link\" down=\"link\"/>\n"; + } + pf << " </AS>\n</platform>\n"; + pf.close(); +}
\ No newline at end of file |
