blob: 066dcb03bc5045c2ede9205f8b321f602b7cc821 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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();
}
|