OpenDaVINCI  4.15.3
odcore::base::RealtimeService Class Referenceabstract

#include <RealtimeService.h>

Inheritance diagram for odcore::base::RealtimeService:
Inheritance graph

Public Types

enum  PERIOD {
  ONEMILLISECOND = 1 * THOUSANDMICROSECONDS, TWOMILLISECONDS = 2 * THOUSANDMICROSECONDS, FIVEMILLISECONDS = 5 * THOUSANDMICROSECONDS, TENMILLISECONDS = 10 * ONEMILLISECOND,
  TWENTYMILLISECONDS = 20 * ONEMILLISECOND, FIFTYMILLISECONDS = 50 * ONEMILLISECOND, ONEHUNDREDMILLISECONDS = 100 * ONEMILLISECOND, TWOHUNDREDMILLISECONDS = 200 * ONEMILLISECOND,
  FIVEHUNDREDMILLISECONDS = 500 * ONEMILLISECOND, ONESECOND = 1000 * ONEMILLISECOND, TWOSECONDS = 2 * ONESECOND, FIVESECONDS = 5 * ONESECOND
}
 

Public Member Functions

 RealtimeService (const enum PERIOD &period) throw (exceptions::ThreadException)
 
virtual ~RealtimeService ()
 
void start ()
 
void stop ()
 

Protected Member Functions

virtual void nextTimeSlice ()=0
 
virtual bool isRunning ()
 

Detailed Description

This class combines wrapper::RealtimeRunnable and wrapper::Thread for convenience. A binary using RealtimeService MUST be run with super user privileges!

It can be used as follows:

class MyRealtimeService : public RealtimeService {
MyRealtimeService(long periodInMicroseconds) :
RealtimeService(long periodInMicroseconds)
{}
void nextTimeSlice() {
// Do something.
}
};
int32_t main(int32_t argc, char **argv) {
MyService s(periodInMicroseconds);
s.start();
s.stop();
}

Member Enumeration Documentation

Enumerator
ONEMILLISECOND 
TWOMILLISECONDS 
FIVEMILLISECONDS 
TENMILLISECONDS 
TWENTYMILLISECONDS 
FIFTYMILLISECONDS 
ONEHUNDREDMILLISECONDS 
TWOHUNDREDMILLISECONDS 
FIVEHUNDREDMILLISECONDS 
ONESECOND 
TWOSECONDS 
FIVESECONDS 

Constructor & Destructor Documentation

odcore::base::RealtimeService::RealtimeService ( const enum PERIOD period)
throw (exceptions::ThreadException
)

Constructor.

Parameters
periodDuration for the slice.
Exceptions
ThreadExceptionif the thread can not be created.

References odcore::wrapper::ConcurrencyFactory::createThread(), and OPENDAVINCI_CORE_THROW_EXCEPTION.

odcore::base::RealtimeService::~RealtimeService ( )
virtual

Member Function Documentation

bool odcore::base::RealtimeService::isRunning ( )
protectedvirtual

This method returns true, iff this runnable is in its internal state for running.

Returns
true iff this runnable is in its internal state for running.

Implements odcore::wrapper::Runnable.

virtual void odcore::base::RealtimeService::nextTimeSlice ( )
protectedpure virtual

This method is called periodically and must be implemented in derived classes.

Implements odcore::wrapper::RealtimeRunnable.

void odcore::base::RealtimeService::start ( )

This method starts the service.

void odcore::base::RealtimeService::stop ( )

This method stops the service. A stopped service CANNOT get restarted.