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