#include <TimerPulse.hpp>
Inheritance diagram for TimerPulse::
Public Methods | |
TimerPulse (ULONG nsec=Period_500_ms, ULONG sec=0) | |
virtual __inline void | stop () |
void | set (ULONG nsec=Period_500_ms, ULONG sec=0) |
__inline int | getChid () |
Protected Methods | |
virtual void | tick (int signo)=0 |
virtual void | run () |
Protected Attributes | |
int | pulse_id |
int | timer_pid |
int | chid |
timer_t | timer_id |
_pulse | pulse |
sigevent | event |
_clockperiod | clkper |
itimerspec | t |
|
Definition at line 8 of file TimerPulse.cpp. 00009 : pulse_id( TimerSignalEvent ), chid( ~0 ) 00010 { 00011 memset( &event, 0, sizeof( event ) ); 00012 00013 // Set priority to max, so we don't get disrupted 00014 // by anything else then interrupts 00015 00016 printf( "Creating channel" ); 00017 00018 // Create a channel to receive the timer event 00019 chid = ChannelCreate( 0 ); 00020 assert( chid != -1 ); 00021 00022 // Setup timer and timer event 00023 event.sigev_notify = SIGEV_PULSE; 00024 event.sigev_coid = ConnectAttach( ND_LOCAL_NODE, 0, chid, 0, 0 ); 00025 event.sigev_priority = getprio( 0 ); // fixprio( 20 ); 00026 event.sigev_code = 1023; 00027 event.sigev_value.sival_ptr = (void*)pulse_id; 00028 00029 assert( event.sigev_coid != -1 ); 00030 00031 // Create the timer, binding it to the event 00032 00033 if ( timer_create( CLOCK_REALTIME, &event, &timer_id ) == -1 ) 00034 { 00035 MC_OnError( errno, Error, "while creating a timer." ) 00036 perror( "Can't create timer.\n" ); 00037 exit( 1 ); 00038 } 00039 00040 memset( &t, 0, sizeof( t ) ); 00041 00042 set( nsec, sec ); 00043 00044 } |
|
Definition at line 64 of file TimerPulse.hpp. 00064 { return chid; } |
|
Reimplemented from Basic_PThread. Definition at line 63 of file TimerPulse.cpp. 00064 { 00065 // Start the timer 00066 if ( timer_settime( timer_id, 0, &t, NULL ) == -1 ) 00067 { 00068 MC_OnError( errno, Error, "Can't start timer." ) 00069 perror( "Can't start timer\n" ); 00070 exit( 1 ); 00071 } 00072 00073 for(;;) 00074 { 00075 // Wait for pulse 00076 if ( MsgReceivePulse( chid, &pulse, sizeof( pulse ), NULL ) ) 00077 { 00078 MC_OnError( errno, Error, "Invalid pulse received by TimerPulse.\n" ) 00079 } 00080 tick( pulse_id ); 00081 } 00082 } |
|
Definition at line 46 of file TimerPulse.cpp. Referenced by TimerPulse(), and stop().
00047 { 00048 // Change timer request to alter behavior 00049 t.it_value.tv_sec = sec; 00050 t.it_value.tv_nsec = nsec; 00051 t.it_interval.tv_sec = sec; 00052 t.it_interval.tv_nsec = nsec; 00053 00054 // Start the timer 00055 if ( timer_settime( timer_id, 0, &t, NULL ) == -1 ) 00056 { 00057 MC_OnError( errno, Error, "Can't start timer." ) 00058 perror( "Can't start timer\n" ); 00059 exit( 1 ); 00060 } 00061 } |
|
Reimplemented from Basic_PThread. Definition at line 57 of file TimerPulse.hpp. 00058 { 00059 set( 0, 0 ); 00060 } |
|
Reimplemented in TimerPulseTest. Referenced by run().
|
|
Definition at line 75 of file TimerPulse.hpp. |
|
Definition at line 81 of file TimerPulse.hpp. |
|
Definition at line 80 of file TimerPulse.hpp. |
|
Definition at line 79 of file TimerPulse.hpp. |
|
Definition at line 73 of file TimerPulse.hpp. |
|
Definition at line 82 of file TimerPulse.hpp. |
|
Definition at line 77 of file TimerPulse.hpp. |
|
Definition at line 74 of file TimerPulse.hpp. |