voltando a versao de n aberturas e fechamentos de sockets data 19/09
Dependencies: EthernetInterface NTPClient mbed-rtos mbed EALib
Fork of header_main_publish by
Diff: timeslice.cpp
- Revision:
- 0:4d17cd9c8f9d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/timeslice.cpp Tue Sep 09 20:01:24 2014 +0000 @@ -0,0 +1,35 @@ +#include "timeslice.h" + +Timeslice::Timeslice(){ + for( register int i = 0; i < __MAX_TIMESLICES__; i++ ) timeslice[ i ] = 0x00; +} + +Timeslice::~Timeslice(){ + // do something here +} + +uint8_t Timeslice::get_timeslice(){ + for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ) + if( timeslice[ i ] == 0x00 ){ + timeslice[ i ] = 0x01; + return( i + 1 ); + } + return( 0x00 ); +} + +void Timeslice::return_timeslice( uint8_t ts ){ + if( ts <= __MAX_TIMESLICES__ && ts > 0 ) timeslice[ ts - 1 ] = 0x00; +} + +void Timeslice::reset(){ + for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ) + timeslice[ i ] = 0x00; +} + +uint8_t Timeslice::remain_timeslices( void ){ + uint8_t sum = 0x00; + for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ){ + if( timeslice[ i ] == 0x00 ) sum++; + } + return( sum ); +} \ No newline at end of file