00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "C_ProtocolStats.hpp"
00021
00022 #define max(a,b) ((a)>(b)) ? (a) : (b)
00023
00024 #define DISPLAY_CROSS_LINE()\
00025 printf("|--------------------------------+---------------------+-----------------------|\r\n")
00026
00027 #define DISPLAY_NEXT()\
00028 printf("|----------------------------------------- Next screen : Press the same key ---|\r\n")
00029
00030
00031
00032 #define DISPLAY_3TXT(T1, T2, T3)\
00033 printf("| %-30s | %19s | %21s |\r\n", (T1), (T2), (T3))
00034
00035 #define DISPLAY_COUNTERS(T,V1,V2,V3,V4) \
00036 printf("| %-30s | %8d | %8d | %9d | %9d |\r\n", (T), (V1), (V2), (V3), (V4))
00037
00038 #define DISPLAY_5TXT(T1, T2, T3, T4, T5)\
00039 printf("| %-30s | %8s | %8s | %9s | %9s |\r\n", (T1), (T2), (T3), (T4), (T5))
00040
00041
00042 C_ProtocolStats::C_ProtocolStats(C_ProtocolFrame *P_protocol)
00043
00044 : C_ProtocolStatsFrame(P_protocol, (C_DisplayObject*)this) {
00045
00046 T_pNameAndIdList L_list_message = NULL ;
00047 T_pNameAndIdList L_list_comp_message = NULL ;
00048 int L_i, L_id ;
00049 T_NameAndIdList::iterator L_elt_it ;
00050
00051
00052 m_id_msg_table = NULL ;
00053 m_counter_msg_table = NULL ;
00054 m_message_names = NULL ;
00055 m_id_msg_comp_table = NULL ;
00056 m_counter_msg_comp_table = NULL ;
00057 m_message_component_names = NULL ;
00058
00059 m_counter_message = 0 ;
00060 m_counter_message_comp = 0 ;
00061
00062
00063 m_nb_counter_msg = 0 ;
00064 m_nb_counter_msg_comp = 0 ;
00065
00066
00067 m_other_msg_screen = false ;
00068 m_other_msg_screen_comp = false ;
00069
00070
00071 m_message_name = m_protocol->message_name () ;
00072
00073 m_message_component_name = m_protocol->message_component_name () ;
00074
00075
00076 L_list_message = m_protocol->message_name_list () ;
00077 if((L_list_message != NULL) && (!L_list_message -> empty())) {
00078 m_nb_counter_msg = L_list_message->size() ;
00079 if (m_nb_counter_msg > 0 ) {
00080
00081 m_max_id_msg = 0 ;
00082 for(L_elt_it=L_list_message->begin();
00083 L_elt_it != L_list_message->end();
00084 L_elt_it++) {
00085 m_max_id_msg = max(m_max_id_msg,(L_elt_it->m_id));
00086 }
00087
00088
00089 ALLOC_TABLE(m_id_msg_table,
00090 int*,
00091 sizeof(int),
00092 m_max_id_msg+1);
00093
00094 ALLOC_TABLE(m_counter_msg_table,
00095 C_pCounterData*,
00096 sizeof(C_pCounterData),
00097 m_nb_counter_msg);
00098
00099 ALLOC_TABLE(m_message_names,
00100 char**,
00101 sizeof(char*),
00102 m_nb_counter_msg);
00103
00104 for (L_i = 0 ; L_i < m_nb_counter_msg; L_i++) {
00105 NEW_TABLE (m_counter_msg_table[L_i], C_CounterData, (size_t)E_NB_ACTIONS);
00106 }
00107
00108 L_id = 0 ;
00109 for(L_elt_it = L_list_message->begin();
00110 L_elt_it != L_list_message->end();
00111 L_elt_it++) {
00112
00113 m_id_msg_table[(L_elt_it->m_id)] = L_id ;
00114 ALLOC_TABLE(m_message_names[L_id],
00115 char*, sizeof(char),
00116 strlen(L_elt_it->m_name)+1);
00117
00118 strcpy(m_message_names[L_id],(L_elt_it->m_name));
00119 m_counter_msg_table[L_id][(int)E_SEND].m_counter_value = 0;
00120 m_counter_msg_table[L_id][(int)E_RECEIVE].m_counter_value = 0;
00121
00122 m_counter_msg_table[L_id][(int)E_SEND].m_counter_periodic_value = 0;
00123 m_counter_msg_table[L_id][(int)E_RECEIVE].m_counter_periodic_value = 0;
00124
00125 m_counter_msg_table[L_id][(int)E_SEND].m_counter_log_value = 0;
00126 m_counter_msg_table[L_id][(int)E_RECEIVE].m_counter_log_value = 0;
00127
00128 m_counter_msg_table[L_id][(int)E_SEND].m_counter_periodic_log_value = 0;
00129 m_counter_msg_table[L_id][(int)E_RECEIVE].m_counter_periodic_log_value = 0;
00130
00131 L_id ++ ;
00132 }
00133
00134
00135 m_current_proto_stat_id = -1 ;
00136 m_nb_stat_proto_id = 2 ;
00137 ALLOC_TABLE(m_current_proto_stat_table,
00138 T_DisplayProtocolFct*,
00139 sizeof(T_DisplayProtocolFct), 2);
00140 m_current_proto_stat_table[0] = &C_ProtocolStats::display_stats_message ;
00141 m_current_proto_stat_table[1] = &C_ProtocolStats::display_stats_sub_message ;
00142 m_current_proto_stat_display = m_current_proto_stat_table[0];
00143
00144 }
00145 }
00146
00147
00148 L_list_comp_message = m_protocol->message_component_name_list () ;
00149 if((L_list_comp_message != NULL) && (!L_list_comp_message -> empty())) {
00150 m_nb_counter_msg_comp = L_list_comp_message->size() ;
00151 if (m_nb_counter_msg_comp > 0 ) {
00152
00153 m_max_id_msg_comp = 0 ;
00154 for(L_elt_it=L_list_comp_message->begin();
00155 L_elt_it != L_list_comp_message->end();
00156 L_elt_it++) {
00157 m_max_id_msg_comp = max(m_max_id_msg_comp,(L_elt_it->m_id));
00158 }
00159
00160
00161 ALLOC_TABLE(m_id_msg_comp_table,
00162 int*,
00163 sizeof(int),
00164 m_max_id_msg_comp+1);
00165
00166 ALLOC_TABLE(m_counter_msg_comp_table,
00167 C_pCounterData*,
00168 sizeof(C_pCounterData),
00169 m_nb_counter_msg_comp);
00170
00171
00172 ALLOC_TABLE(m_message_component_names,
00173 char**,
00174 sizeof(char*),
00175 m_nb_counter_msg_comp);
00176
00177 for (L_i = 0 ; L_i < m_nb_counter_msg_comp; L_i++) {
00178 NEW_TABLE (m_counter_msg_comp_table[L_i], C_CounterData,
00179 (size_t) E_NB_ACTIONS);
00180 }
00181
00182 L_id = 0 ;
00183 for(L_elt_it = L_list_comp_message->begin();
00184 L_elt_it != L_list_comp_message->end();
00185 L_elt_it++) {
00186
00187 m_id_msg_comp_table[(L_elt_it->m_id)] = L_id ;
00188 ALLOC_TABLE(m_message_component_names[L_id],
00189 char*, sizeof(char),
00190 strlen(L_elt_it->m_name)+1);
00191
00192 strcpy(m_message_component_names[L_id],(L_elt_it->m_name));
00193 m_counter_msg_comp_table[L_id][(int)E_SEND].m_counter_value = 0;
00194 m_counter_msg_comp_table[L_id][(int)E_RECEIVE].m_counter_value = 0;
00195 m_counter_msg_comp_table[L_id][(int)E_SEND].m_counter_periodic_value = 0;
00196 m_counter_msg_comp_table[L_id][(int)E_RECEIVE].m_counter_periodic_value = 0;
00197
00198 m_counter_msg_comp_table[L_id][(int)E_SEND].m_counter_log_value = 0;
00199 m_counter_msg_comp_table[L_id][(int)E_RECEIVE].m_counter_log_value = 0;
00200
00201 m_counter_msg_comp_table[L_id][(int)E_SEND].m_counter_periodic_log_value = 0;
00202 m_counter_msg_comp_table[L_id][(int)E_RECEIVE].m_counter_periodic_log_value = 0;
00203
00204 L_id ++ ;
00205 }
00206 }
00207 }
00208
00209 m_fileName = NULL ;
00210 m_initDone = false ;
00211 m_do_log = false ;
00212
00213
00214 }
00215
00216
00217 C_ProtocolStats::~C_ProtocolStats(){
00218 int L_i ;
00219
00220 if (m_message_names != NULL){
00221 for(L_i = 0; L_i < m_nb_counter_msg; L_i++) {
00222 FREE_TABLE(m_message_names[L_i]);
00223 }
00224 FREE_TABLE(m_message_names);
00225 }
00226
00227 if (m_message_component_names!= NULL){
00228 for(L_i = 0; L_i < m_nb_counter_msg_comp; L_i++) {
00229 FREE_TABLE(m_message_component_names[L_i]);
00230 }
00231 FREE_TABLE(m_message_component_names);
00232 }
00233
00234 for (L_i = 0 ; L_i < m_nb_counter_msg; L_i++) {
00235 DELETE_TABLE(m_counter_msg_table[L_i]);
00236 }
00237 FREE_TABLE(m_counter_msg_table);
00238 m_nb_counter_msg = 0 ;
00239
00240 for (L_i = 0 ; L_i < m_nb_counter_msg_comp; L_i++) {
00241 DELETE_TABLE(m_counter_msg_comp_table[L_i]);
00242 }
00243 FREE_TABLE(m_counter_msg_comp_table);
00244 m_nb_counter_msg_comp = 0 ;
00245
00246 FREE_TABLE(m_id_msg_table);
00247 FREE_TABLE(m_id_msg_comp_table);
00248 m_max_id_msg = 0 ;
00249 m_max_id_msg_comp = 0 ;
00250
00251 FREE_TABLE(m_current_proto_stat_table);
00252
00253
00254 FREE_TABLE(m_fileName);
00255 m_initDone = false ;
00256
00257 DELETE_VAR(m_outputStream);
00258
00259 }
00260
00261 void C_ProtocolStats::updateStats (T_ProtocolStatDataType P_type,
00262 T_ProtocolStatDataAction P_action,
00263 int P_id) {
00264 switch (P_type) {
00265 case E_MESSAGE : {
00266 if ((P_id >= 0) && (P_id <= m_max_id_msg)) {
00267 m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_sem.P();
00268 (m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_counter_value)++ ;
00269 (m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_counter_periodic_value)++ ;
00270 m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_sem.V();
00271
00272
00273 if (m_do_log) {
00274 m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_sem_log.P();
00275 (m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_counter_log_value)++ ;
00276 (m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_counter_periodic_log_value)++ ;
00277 m_counter_msg_table[m_id_msg_table[P_id]][P_action].m_sem_log.V();
00278 }
00279 }
00280 }
00281 break ;
00282 case E_MESSAGE_COMPONENT : {
00283 if ((P_id >= 0) && (P_id <= m_max_id_msg_comp)) {
00284
00285 m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_sem.P();
00286 (m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_counter_value)++ ;
00287 (m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_counter_periodic_value)++ ;
00288 m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_sem.V();
00289
00290 if (m_do_log) {
00291 m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_sem_log.P();
00292 (m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_counter_log_value)++ ;
00293 (m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_counter_periodic_log_value)++ ;
00294 m_counter_msg_comp_table[m_id_msg_comp_table[P_id]][P_action].m_sem_log.V();
00295 }
00296 }
00297 }
00298 break ;
00299 default:
00300 break ;
00301 }
00302
00303 }
00304
00305 iostream_output& C_ProtocolStats::display (iostream_output& P_stream) {
00306
00307 int L_i ;
00308
00309 P_stream << m_message_name << " sent received" << iostream_endl ;
00310 for(L_i = 0 ; L_i < m_nb_counter_msg; L_i ++) {
00311 P_stream << m_message_names[L_i] << " " ;
00312
00313 m_counter_msg_table[L_i][(int)E_SEND].m_sem.P();
00314 P_stream << m_counter_msg_table[L_i][(int)E_SEND].m_counter_value << " " ;
00315 m_counter_msg_table[L_i][(int)E_SEND].m_sem.V();
00316
00317 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem.P();
00318 P_stream << m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_value ;
00319 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem.V();
00320
00321 P_stream << iostream_endl ;
00322 }
00323
00324 P_stream << m_message_component_name << " sent received" << iostream_endl ;
00325 for(L_i = 0 ; L_i < m_nb_counter_msg_comp; L_i ++) {
00326 P_stream << m_message_component_names[L_i] << " " ;
00327
00328 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem.P();
00329 P_stream << m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_value << " " ;
00330 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem.V();
00331
00332 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem.P();
00333 P_stream << m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_value ;
00334 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem.V();
00335
00336 P_stream << iostream_endl ;
00337 }
00338
00339 return (P_stream);
00340 }
00341
00342
00343
00344 void C_ProtocolStats::setCurrentScreen(bool P_first) {
00345
00346 if (P_first == true) {
00347
00348 m_counter_message = 0 ;
00349 m_counter_message_comp = 0 ;
00350
00351 m_other_msg_screen = false ;
00352 m_other_msg_screen_comp = false ;
00353
00354 m_current_proto_stat_id = 0 ;
00355
00356 } else {
00357
00358
00359 m_current_proto_stat_id ++ ;
00360
00361 if (m_other_msg_screen == true) {
00362 m_counter_message += 18;
00363 if (m_counter_message >= m_nb_counter_msg) {
00364 m_counter_message = 0 ;
00365 m_other_msg_screen = false ;
00366 } else {
00367 m_current_proto_stat_id --;
00368 }
00369 }
00370
00371
00372 if (m_other_msg_screen_comp == true) {
00373 m_counter_message_comp += 18 ;
00374 if (m_counter_message_comp >= m_nb_counter_msg_comp) {
00375 m_counter_message_comp = 0 ;
00376 m_other_msg_screen_comp = false ;
00377 } else {
00378 m_current_proto_stat_id --;
00379 }
00380 }
00381
00382 if (m_current_proto_stat_id == m_nb_stat_proto_id) {
00383 m_current_proto_stat_id = 0 ;
00384 }
00385 }
00386 m_current_proto_stat_display
00387 = m_current_proto_stat_table[m_current_proto_stat_id];
00388
00389 }
00390
00391
00392 void C_ProtocolStats::displayScreen() {
00393
00394 ((this)->*(m_current_proto_stat_display))();
00395
00396 }
00397
00398 void C_ProtocolStats::display_stats_message() {
00399
00400 int L_i ;
00401
00402 int L_count ;
00403
00404 DISPLAY_CROSS_LINE ();
00405 printf("| | Periodic value | Cumulative value |\r\n");
00406 DISPLAY_5TXT(m_message_name, "sent", "received", "sent", "received");
00407 DISPLAY_CROSS_LINE ();
00408
00409 L_count = 0 ;
00410
00411 for(L_i = m_counter_message ; L_i < m_nb_counter_msg; L_i ++) {
00412 m_counter_msg_table[L_i][(int)E_SEND].m_sem.P();
00413 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem.P();
00414
00415 DISPLAY_COUNTERS(m_message_names[L_i],
00416 m_counter_msg_table[L_i][(int)E_SEND].m_counter_periodic_value,
00417 m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_periodic_value,
00418 m_counter_msg_table[L_i][(int)E_SEND].m_counter_value,
00419 m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_value);
00420
00421
00422 m_counter_msg_table[L_i][(int)E_SEND].m_counter_periodic_value = 0;
00423 m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_periodic_value = 0;
00424
00425 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem.V();
00426 m_counter_msg_table[L_i][(int)E_SEND].m_sem.V();
00427
00428 L_count++ ;
00429 if (L_count > 18) {
00430 DISPLAY_NEXT() ;
00431 if (m_other_msg_screen == false) {
00432 m_other_msg_screen = true ;
00433 }
00434 break ;
00435 }
00436 }
00437
00438 if (L_count < 19) {
00439 for (L_i = L_count ; L_i < 19 ; L_i ++) {
00440 DISPLAY_3TXT("","","");
00441 }
00442 DISPLAY_NEXT() ;
00443 }
00444
00445 }
00446
00447
00448 void C_ProtocolStats::display_stats_sub_message() {
00449
00450 int L_i ;
00451
00452 int L_count ;
00453
00454 DISPLAY_CROSS_LINE ();
00455 printf("| | Periodic value | Cumulative value |\r\n");
00456
00457 DISPLAY_5TXT(m_message_component_name, "sent", "received", "sent", "received");
00458
00459 DISPLAY_CROSS_LINE ();
00460
00461 L_count = 0 ;
00462 for(L_i = m_counter_message_comp ; L_i < m_nb_counter_msg_comp; L_i ++) {
00463 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem.P();
00464 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem.P();
00465
00466 DISPLAY_COUNTERS(m_message_component_names[L_i],
00467 m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_periodic_value,
00468 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_periodic_value,
00469 m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_value,
00470 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_value);
00471
00472
00473 m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_periodic_value = 0;
00474 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_periodic_value = 0;
00475
00476 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem.V();
00477 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem.V();
00478 L_count ++ ;
00479
00480 if (L_count > 18) {
00481 DISPLAY_NEXT() ;
00482 if (m_other_msg_screen_comp == false) {
00483 m_other_msg_screen_comp = true ;
00484 }
00485 break ;
00486 }
00487 }
00488
00489 if (L_count < 19) {
00490 for (L_i = L_count ; L_i < 19 ; L_i ++) {
00491 DISPLAY_3TXT("","","");
00492 }
00493 DISPLAY_NEXT() ;
00494 }
00495 }
00496
00497
00498 void C_ProtocolStats::set_file_name(char * P_name)
00499 {
00500 int sizeOf;
00501
00502 if(P_name != NULL) {
00503 sizeOf = strlen(P_name);
00504 if(sizeOf > 0) {
00505 ALLOC_TABLE(m_fileName, char*,
00506 sizeof(char), sizeOf+1);
00507 strcpy(m_fileName, P_name);
00508 } else {
00509 iostream_error << "new file name length is null " << iostream_endl;
00510 }
00511 } else {
00512 iostream_error <<
00513 "new file name is NULL ! " << iostream_endl;
00514 }
00515 }
00516
00517 int C_ProtocolStats::init () {
00518 if (m_initDone == false) {
00519 GET_TIME (&m_startTime);
00520 memcpy (&m_plStartTime, &m_startTime, sizeof (struct timeval));
00521 m_outputStream = NULL;
00522 m_headerAlreadyDisplayed = false;
00523 m_initDone = true ;
00524 }
00525 return(1);
00526 }
00527
00528
00529 void C_ProtocolStats::make_first_log () {
00530
00531 int L_i ;
00532 if(m_outputStream == NULL) {
00533
00534 NEW_VAR(m_outputStream,
00535 fstream_output(m_fileName));
00536 m_headerAlreadyDisplayed = false;
00537
00538 if(m_outputStream == NULL) {
00539 iostream_error << "Unable to open log file !" << iostream_endl;
00540 exit(-1);
00541 }
00542
00543 if(!m_outputStream->good()) {
00544 iostream_error << "Unable to open log file !" << iostream_endl;
00545 exit(-1);
00546 }
00547 }
00548
00549
00550 (*m_outputStream) << "StartTime;"
00551 << "LastResetTime;"
00552 << "CurrentTime;"
00553 << "ElapsedTime(P);"
00554 << "ElapsedTime(C);" ;
00555
00556
00557 for(L_i = 0 ; L_i < m_nb_counter_msg; L_i ++) {
00558 (*m_outputStream) << m_message_names[L_i] << " received(P);" ;
00559 (*m_outputStream) << m_message_names[L_i] << " received(C);" ;
00560
00561 (*m_outputStream) << m_message_names[L_i] << " sent(P);" ;
00562 (*m_outputStream) << m_message_names[L_i] << " sent(C);" ;
00563 }
00564
00565
00566 for(L_i = 0 ; L_i < m_nb_counter_msg_comp; L_i ++) {
00567
00568 (*m_outputStream) << m_message_component_names[L_i] << " received(P);" ;
00569 (*m_outputStream) << m_message_component_names[L_i] << " received(C);" ;
00570
00571 (*m_outputStream) << m_message_component_names[L_i] << " sent(P);" ;
00572 (*m_outputStream) << m_message_component_names[L_i] << " sent(C);" ;
00573
00574 }
00575
00576
00577 (*m_outputStream) << iostream_endl;
00578
00579 (*m_outputStream).flush();
00580
00581 }
00582
00583 void C_ProtocolStats::make_log () {
00584 int L_i ;
00585 long localElapsedTime ;
00586 long globalElapsedTime ;
00587 struct timeval currentTime ;
00588
00589
00590 GET_TIME (¤tTime);
00591
00592 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
00593 localElapsedTime = ms_difftime (¤tTime, &m_plStartTime);
00594
00595 (*m_outputStream) << formatTime(&m_startTime) << ";";
00596 (*m_outputStream) << formatTime(&m_plStartTime) << ";";
00597 (*m_outputStream) << formatTime(¤tTime) << ";"
00598 << msToHHMMSS(localElapsedTime) << ";";
00599 (*m_outputStream) << msToHHMMSS(globalElapsedTime) << ";";
00600
00601
00602 for(L_i = 0 ; L_i < m_nb_counter_msg; L_i ++) {
00603 m_counter_msg_table[L_i][(int)E_SEND].m_sem_log.P();
00604 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem_log.P();
00605
00606 (*m_outputStream)
00607 << m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_periodic_log_value << ";"
00608 << m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_log_value << ";"
00609 << m_counter_msg_table[L_i][(int)E_SEND].m_counter_periodic_log_value << ";"
00610 << m_counter_msg_table[L_i][(int)E_SEND].m_counter_log_value << ";" ;
00611
00612
00613 m_counter_msg_table[L_i][(int)E_SEND].m_counter_periodic_log_value = 0;
00614 m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_periodic_log_value = 0;
00615
00616 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem_log.V();
00617 m_counter_msg_table[L_i][(int)E_SEND].m_sem_log.V();
00618 }
00619
00620 for(L_i = 0 ; L_i < m_nb_counter_msg_comp; L_i ++) {
00621 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem_log.P();
00622 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem_log.P();
00623
00624 (*m_outputStream)
00625 << m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_periodic_log_value << ";"
00626 << m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_log_value << ";"
00627 << m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_periodic_log_value << ";"
00628 << m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_log_value << ";" ;
00629
00630
00631 m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_periodic_log_value = 0;
00632 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_periodic_log_value = 0;
00633
00634 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem_log.V();
00635 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem_log.V();
00636 }
00637
00638 GET_TIME (&m_plStartTime);
00639
00640 (*m_outputStream) << iostream_endl;
00641
00642 (*m_outputStream).flush();
00643
00644
00645
00646 }
00647
00648
00649
00650
00651 char* C_ProtocolStats::formatTime (struct timeval* P_tv) {
00652
00653 static char L_time [TIME_LENGTH];
00654 struct tm * L_currentDate;
00655
00656
00657 L_currentDate = localtime ((const time_t *)&P_tv->tv_sec);
00658
00659
00660 if (L_currentDate == NULL) {
00661 memset (L_time, 0, TIME_LENGTH);
00662 } else {
00663 sprintf(L_time, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
00664 L_currentDate->tm_year + 1900,
00665 L_currentDate->tm_mon + 1,
00666 L_currentDate->tm_mday,
00667 L_currentDate->tm_hour,
00668 L_currentDate->tm_min,
00669 L_currentDate->tm_sec);
00670 }
00671 return (L_time);
00672 }
00673
00674
00675 char* C_ProtocolStats::msToHHMMSS (unsigned long P_ms)
00676 {
00677 static char L_time [TIME_LENGTH];
00678 unsigned long hh, mm, ss;
00679
00680 P_ms = P_ms / 1000;
00681 hh = P_ms / 3600;
00682 mm = (P_ms - hh * 3600) / 60;
00683 ss = P_ms - (hh * 3600) - (mm * 60);
00684 sprintf (L_time, "%2.2ld:%2.2ld:%2.2ld", hh, mm, ss);
00685 return (L_time);
00686 }
00687
00688 void C_ProtocolStats::do_log() {
00689 m_do_log = true ;
00690 }
00691
00692
00693 void C_ProtocolStats::reset_cumul_counters() {
00694
00695 int L_i ;
00696
00697 for(L_i = 0 ; L_i < m_nb_counter_msg; L_i ++) {
00698 m_counter_msg_table[L_i][(int)E_SEND].m_sem.P();
00699 m_counter_msg_table[L_i][(int)E_SEND].m_counter_value = 0 ;
00700 m_counter_msg_table[L_i][(int)E_SEND].m_sem.V();
00701
00702 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem.P();
00703 m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_value = 0 ;
00704 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem.V();
00705
00706
00707 if (m_do_log) {
00708 m_counter_msg_table[L_i][(int)E_SEND].m_sem_log.P();
00709 m_counter_msg_table[L_i][(int)E_SEND].m_counter_log_value = 0 ;
00710 m_counter_msg_table[L_i][(int)E_SEND].m_sem_log.V();
00711
00712 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem_log.P();
00713 m_counter_msg_table[L_i][(int)E_RECEIVE].m_counter_log_value = 0 ;
00714 m_counter_msg_table[L_i][(int)E_RECEIVE].m_sem_log.V();
00715 }
00716 }
00717
00718 for(L_i = 0 ; L_i < m_nb_counter_msg_comp; L_i ++) {
00719 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem.P();
00720 m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_value = 0 ;
00721 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem.V();
00722
00723 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem.P();
00724 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_value = 0 ;
00725 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem.V();
00726
00727 if (m_do_log) {
00728 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem_log.P();
00729 m_counter_msg_comp_table[L_i][(int)E_SEND].m_counter_log_value = 0 ;
00730 m_counter_msg_comp_table[L_i][(int)E_SEND].m_sem_log.V();
00731
00732 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem_log.P();
00733 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_counter_log_value = 0 ;
00734 m_counter_msg_comp_table[L_i][(int)E_RECEIVE].m_sem_log.V();
00735
00736 }
00737 }
00738 }