[71] | 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 | |
---|
[74] | 19 | // Print component |
---|
| 20 | for (std::list<Stat *>::iterator stat=_list_stat->begin(); |
---|
| 21 | stat != _list_stat->end(); |
---|
| 22 | stat ++) |
---|
[75] | 23 | xml.text((*stat)->print(1)); |
---|
[74] | 24 | |
---|
| 25 | |
---|
[71] | 26 | // Test special case |
---|
[75] | 27 | |
---|
| 28 | if (have_counter()) |
---|
[71] | 29 | { |
---|
[75] | 30 | if (_cycle_sum < _nb_cycle_before_begin) |
---|
[71] | 31 | { |
---|
[75] | 32 | xml.comment(_("Number of cycle is less than the number minimal")); |
---|
| 33 | } |
---|
| 34 | else |
---|
| 35 | { |
---|
| 36 | bool stop = false; |
---|
| 37 | cycle_t nb_cycle_min; |
---|
| 38 | cycle_t nb_cycle_max = _nb_cycle_before_begin-1; |
---|
| 39 | for (cycle_t period=0; stop==false; period++) |
---|
| 40 | { |
---|
| 41 | std::map<std::string, var_t>::iterator operand=_list_operand->begin(); |
---|
| 42 | |
---|
| 43 | if (operand->second.save_counter.size()==0) |
---|
| 44 | throw(ERRORMORPHEO("Stat::generate_file",_("Queue 'save_counter' is empty."))); |
---|
| 45 | |
---|
| 46 | bool last = operand->second.save_counter.size()==1; |
---|
| 47 | |
---|
| 48 | nb_cycle_min = nb_cycle_max+1; |
---|
| 49 | |
---|
| 50 | if (last) |
---|
| 51 | nb_cycle_max = static_cast<cycle_t>(_cycle_sum); |
---|
| 52 | else |
---|
| 53 | nb_cycle_max += _period; |
---|
[71] | 54 | |
---|
[75] | 55 | xml.balise_open_begin("period"); |
---|
| 56 | xml.attribut("number",toString(period)); |
---|
| 57 | xml.attribut("nb_cycle_min",toString(nb_cycle_min)); |
---|
| 58 | xml.attribut("nb_cycle_max",toString(nb_cycle_max)); |
---|
| 59 | xml.balise_open_end(); |
---|
| 60 | |
---|
| 61 | for (; |
---|
| 62 | operand!= _list_operand->end(); |
---|
| 63 | ++operand) |
---|
[71] | 64 | { |
---|
[75] | 65 | if (operand->second.type == TYPE_COUNTER) |
---|
| 66 | { |
---|
| 67 | xml.singleton_begin(operand->second.name); |
---|
| 68 | xml.attribut("value",toString(operand->second.save_counter.front())); |
---|
| 69 | xml.attribut("unit",operand->second.unit); |
---|
| 70 | xml.attribut("description",operand->second.description); |
---|
| 71 | xml.singleton_end(); |
---|
| 72 | } |
---|
| 73 | operand->second.save_counter.pop_front(); |
---|
[71] | 74 | } |
---|
[75] | 75 | |
---|
| 76 | xml.balise_close(); |
---|
| 77 | |
---|
| 78 | stop = last; |
---|
[71] | 79 | } |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | xml.balise_close(); |
---|
| 83 | |
---|
| 84 | return xml.get_body(depth); |
---|
| 85 | } |
---|
| 86 | }; |
---|
| 87 | }; |
---|
| 88 | #endif |
---|