![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: main_app_functions.cpp
- Revision:
- 123:1d395b5a4cad
- Parent:
- 122:480c44b0e205
- Child:
- 124:c1b6c893e1c3
diff -r 480c44b0e205 -r 1d395b5a4cad main_app_functions.cpp --- a/main_app_functions.cpp Mon May 11 15:16:36 2015 +0000 +++ b/main_app_functions.cpp Mon May 11 19:21:39 2015 +0000 @@ -263,7 +263,7 @@ return ( 0 ); } -int show_cb_long_list ( Vector * v_cb ) +int show_cb_long_list ( Vector * v_cb, bool show_time ) { uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); @@ -364,7 +364,7 @@ char cbx_to_string[ 254 ]; snprintf ( cbx_to_string, sizeof ( cbx_to_string ), - "Ext :: %i :: Port :: %i :: Status -- %s - %s", + "Ext :: %5i :: Port :: %5i :: Status -- %s - %s", cb->get_ext(), cb->get_port(), cb_status, cb_sip_status ); @@ -374,6 +374,32 @@ snprintf ( aux, sizeof ( aux ), " -- on TimeSlice :: %i", cb->get_timeslice() ); strcat( cbx_to_string, aux ); } + + if ( show_time ) + { + char get_timer_msg [ 128 ]; + + snprintf ( get_timer_msg, sizeof ( get_timer_msg ) -1, " -- timer %4i [ %s ", + cb -> get_timer (), + ( cb -> get_overflow_flag () ) ? "Overflow" : "Ok" + ); + + int get_overflow_times_tmp = cb -> get_overflow_times (); + + if ( get_overflow_times_tmp == 0 ) strcat ( get_timer_msg, "]" ); + + else { + char strcat_tmp [ 16 ]; + if ( get_overflow_times_tmp == 1 ) snprintf( strcat_tmp, sizeof ( strcat_tmp ) - 1, "1 time ]" ); + + else snprintf( strcat_tmp, sizeof ( strcat_tmp ) - 1, "%u times ]", get_overflow_times_tmp ); + + strcat ( get_timer_msg, strcat_tmp ); + } + + strcat ( cbx_to_string, get_timer_msg ); + } + send_msg( cbx_to_string ); } } @@ -457,7 +483,7 @@ char cbx_to_string[ 254 ]; snprintf ( cbx_to_string, sizeof ( cbx_to_string ), - "Ext :: %i :: Port :: %i :: Status -- %s - %s", + "Ext :: %5i :: Port :: %5i :: Status -- %s - %s", cb->get_ext(), cb->get_port(), cb_status, cb_sip_status ); @@ -482,13 +508,30 @@ { Call_Box * cb = ( Call_Box * ) v_cb -> get_element ( i ); - send_msg ( - "ext :: %d -- port :: %d -- timer %d [ %s ] ", + char tmp_send_msg [ 256 ]; + + snprintf ( tmp_send_msg, sizeof ( tmp_send_msg ) - 1, + "ext :: %5i -- port :: %5i -- timer %4i [ %s ", cb -> get_sip_ext (), cb -> get_sip_port (), cb -> get_timer (), ( cb -> get_overflow_flag () ) ? "Overflow" : "Ok" ); + + int get_overflow_times_tmp = cb -> get_overflow_times (); + + if ( get_overflow_times_tmp == 0 ) strcat ( tmp_send_msg, "]" ); + + else { + char strcat_tmp [ 16 ]; + if ( get_overflow_times_tmp == 1 ) snprintf( strcat_tmp, sizeof ( strcat_tmp ) - 1, "1 time ]" ); + + else snprintf( strcat_tmp, sizeof ( strcat_tmp ) - 1, "%d times ]", get_overflow_times_tmp ); + + strcat ( tmp_send_msg, strcat_tmp ); + } + + send_msg ( tmp_send_msg ); } return ( 0 ); @@ -1949,4 +1992,15 @@ } else type = DO_NOTHING; return 0; +} + +void update_all_cb_timer ( Vector * v_cb ) +{ + if ( v_cb == NULL ) return; + + for( register uint8_t i = 0; i < v_cb->size(); i++ ) + { + Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); + if ( cb != NULL ) cb -> update_time (); + } } \ No newline at end of file