1 | #ifdef STATISTICS |
---|
2 | #include "Behavioural/include/Stat.h" |
---|
3 | |
---|
4 | namespace morpheo { |
---|
5 | namespace behavioural { |
---|
6 | |
---|
7 | std::string Stat::print (uint32_t depth) |
---|
8 | { |
---|
9 | end_simulation(); |
---|
10 | |
---|
11 | cycle_t _cycle_sum = sc_simulation_time(); |
---|
12 | |
---|
13 | morpheo::behavioural::XML xml (_name_instance); |
---|
14 | |
---|
15 | xml.balise_open_begin(_name_component); |
---|
16 | xml.attribut("name",_name_instance); |
---|
17 | xml.balise_open_end(); |
---|
18 | |
---|
19 | // Test special case |
---|
20 | if (_cycle_sum < _nb_cycle_before_begin) |
---|
21 | { |
---|
22 | xml.comment(_("Number of cycle is less than the number minimal")); |
---|
23 | } |
---|
24 | else |
---|
25 | { |
---|
26 | bool stop = false; |
---|
27 | cycle_t nb_cycle_min; |
---|
28 | cycle_t nb_cycle_max = _nb_cycle_before_begin-1; |
---|
29 | for (cycle_t period=0; stop==false; period++) |
---|
30 | { |
---|
31 | std::map<std::string, var_t>::iterator operand=_list_operand->begin(); |
---|
32 | |
---|
33 | if (operand->second.save_counter.size()==0) |
---|
34 | throw(ERRORMORPHEO("Stat::generate_file",_("Queue 'save_counter' is empty."))); |
---|
35 | |
---|
36 | bool last = operand->second.save_counter.size()==1; |
---|
37 | |
---|
38 | nb_cycle_min = nb_cycle_max+1; |
---|
39 | |
---|
40 | if (last) |
---|
41 | nb_cycle_max = static_cast<cycle_t>(_cycle_sum); |
---|
42 | else |
---|
43 | nb_cycle_max += _period; |
---|
44 | |
---|
45 | xml.balise_open_begin("period"); |
---|
46 | xml.attribut("number",toString(period)); |
---|
47 | xml.attribut("nb_cycle_min",toString(nb_cycle_min)); |
---|
48 | xml.attribut("nb_cycle_max",toString(nb_cycle_max)); |
---|
49 | xml.balise_open_end(); |
---|
50 | |
---|
51 | for (; |
---|
52 | operand!= _list_operand->end(); |
---|
53 | ++operand) |
---|
54 | { |
---|
55 | if (operand->second.type == TYPE_COUNTER) |
---|
56 | { |
---|
57 | xml.singleton_begin(operand->second.name); |
---|
58 | xml.attribut("value",toString(operand->second.save_counter.front())); |
---|
59 | xml.attribut("unit",operand->second.unit); |
---|
60 | xml.attribut("description",operand->second.description); |
---|
61 | xml.singleton_end(); |
---|
62 | } |
---|
63 | operand->second.save_counter.pop_front(); |
---|
64 | } |
---|
65 | |
---|
66 | xml.balise_close(); |
---|
67 | |
---|
68 | stop = last; |
---|
69 | } |
---|
70 | } |
---|
71 | xml.balise_close(); |
---|
72 | |
---|
73 | return xml.get_body(depth); |
---|
74 | } |
---|
75 | }; |
---|
76 | }; |
---|
77 | #endif |
---|