#include "inputs.hpp" #include #include 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(); use_hint=d[node_name.c_str()]["use_hint"].GetBool(); max_attempts=d[node_name.c_str()]["max_attemps"].GetInt(); data_size=d[node_name.c_str()]["data_size"].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 << "\n"; pf << "\n"; pf << "\n \n"; pf << " \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 << " \n"; pf << " \n"; pf << " \n \n"; pf << " \n"; } pf << " \n\n"; pf.close(); }