The scheduler class contains the real time behavior of the class. It waits for events and then executes the real time action related to them. More...
#include <RTScheduler.h>
Public Member Functions | |
RTScheduler (const std::string &name, int32_t eventQueueSize) | |
void | post (boost::shared_ptr< RTEvent > &pEv) |
void | addRTAction (const std::string &eventName, AbstractRTAction *rtAction) |
const std::string & | getName () |
virtual | ~RTScheduler () |
void | printState (FesaStream *fesaStream, double elapsedTime) |
void | printConfig (FesaStream *fesaStream) |
void | cancel () |
Private Member Functions | |
void | run () |
void | schedule (RTEvent *event) |
void | logDiagnostics (RTEvent *&pEvent) |
creates a log entry for the diagnostics tool | |
Private Attributes | |
std::map< const std::string, std::vector< AbstractRTAction * > > | schedulingMap_ |
list of the actions which have to be executed per event | |
std::deque< boost::shared_ptr < RTEvent > > | eventQueue_ |
this member contains the queue for real time events | |
std::string | name_ |
name of the layer specified by the FESA developer | |
int32_t | queueSize_ |
queue size | |
Mutex | mutexQueue_ |
mutex for the queue | |
ConditionalVariable | conditionalVariableQueue_ |
variable for the queue | |
DiagnosticUtils::DiagStateCounter | postEventCount_ |
DiagnosticUtils::DiagStateCounter | scheduledEventCount_ |
DiagnosticUtils::DiagStateCounter | accumulatedEventCount_ |
uint32_t | lostEventCount_ |
The scheduler class contains the real time behavior of the class. It waits for events and then executes the real time action related to them.
Definition at line 30 of file RTScheduler.h.
fesa::RTScheduler::RTScheduler | ( | const std::string & | name, | |
int32_t | eventQueueSize | |||
) |
name | name of the scheduler | |
priorityLevel | priority of the scheduler | |
priorityOffset | ||
eventQueueSize | event queue size |
Definition at line 30 of file RTScheduler.cpp.
References accumulatedEventCount_, fesa::DiagnosticUtils::DiagStateCounter::current_, fesa::AbstractEquipment::getDeviceDataFileName(), fesa::AbstractEquipment::getInstance(), fesa::AbstractEquipment::getProcessConfiguration(), fesa::DiagnosticUtils::DiagStateCounter::last_, fesa::DiagnosticUtils::DiagStateCounter::max_, name_, postEventCount_, scheduledEventCount_, fesa::Thread::setDetachState(), and fesa::Thread::setPriority().
fesa::RTScheduler::~RTScheduler | ( | ) | [virtual] |
void fesa::RTScheduler::addRTAction | ( | const std::string & | eventName, | |
AbstractRTAction * | rtAction | |||
) |
This method links the RT action and the event passed by arguments
eventName | name of the event which fires the action | |
rtAction | to be executed when the event arrives |
Definition at line 300 of file RTScheduler.cpp.
References schedulingMap_.
Referenced by fesa::RTController::createAction().
void fesa::RTScheduler::cancel | ( | ) |
This call provokes the stop of the scheduler and an exit on the current thread
Definition at line 278 of file RTScheduler.cpp.
References conditionalVariableQueue_, fesa::Thread::hasFinished_, fesa::Thread::isRunning_, fesa::MAX_ATTEMPTS_STOP_THREAD, name_, fesa::ConditionalVariable::signal(), and fesa::Thread::stop().
const std::string & fesa::RTScheduler::getName | ( | ) | [inline] |
Definition at line 144 of file RTScheduler.h.
References name_.
Referenced by fesa::AbstractEventSource::addRTScheduler(), and fesa::RTController::createAction().
void fesa::RTScheduler::logDiagnostics | ( | RTEvent *& | pEvent | ) | [private] |
creates a log entry for the diagnostics tool
Definition at line 154 of file RTScheduler.cpp.
References fesa::DiagnosticUtils::framework, fesa::AbstractEquipment::getDiagnostics(), fesa::AbstractEquipment::getInstance(), fesa::RTEvent::getName(), fesa::DiagnosticUtils::DiagnosticMessage::msg, fesa::DiagnosticUtils::rt, fesa::DiagnosticUtils::DiagnosticMessage::side, and fesa::DiagnosticUtils::DiagnosticMessage::source.
Referenced by schedule().
void fesa::RTScheduler::post | ( | boost::shared_ptr< RTEvent > & | pEv | ) |
This method inserts the event passed by argument into the queue of the scheduler in order to process it
pEv | shared pointer to the RTevent |
Definition at line 74 of file RTScheduler.cpp.
References accumulatedEventCount_, conditionalVariableQueue_, fesa::DiagnosticUtils::DiagStateCounter::current_, eventQueue_, fesa::AbstractRTEquipment::getInstance(), fesa::AbstractRTEquipment::handleSchedulerError(), fesa::DiagnosticUtils::DiagStateCounter::max_, mutexQueue_, name_, postEventCount_, queueSize_, and fesa::ConditionalVariable::signal().
void fesa::RTScheduler::printConfig | ( | FesaStream * | fesaStream | ) |
fesaStream |
Definition at line 221 of file RTScheduler.cpp.
References fesa::Thread::getPriority(), name_, and schedulingMap_.
void fesa::RTScheduler::printState | ( | FesaStream * | fesaStream, | |
double | elapsedTime | |||
) |
Print some information about the actual state of the RTScheduler
fesaStream | ||
elapsedTime |
Definition at line 242 of file RTScheduler.cpp.
References accumulatedEventCount_, fesa::DiagnosticUtils::DiagStateCounter::current_, fesa::Thread::getID(), fesa::Thread::getPriority(), fesa::DiagnosticUtils::DiagStateCounter::last_, lostEventCount_, fesa::DiagnosticUtils::DiagStateCounter::max_, name_, postEventCount_, queueSize_, scheduledEventCount_, and schedulingMap_.
void fesa::RTScheduler::run | ( | ) | [private, virtual] |
This method is executed in an independent thread if the process is split.
Implements fesa::Thread.
Definition at line 110 of file RTScheduler.cpp.
References conditionalVariableQueue_, eventQueue_, fesa::Thread::hasFinished_, fesa::Thread::isRunning_, mutexQueue_, name_, schedule(), and fesa::ConditionalVariable::wait().
void fesa::RTScheduler::schedule | ( | RTEvent * | event | ) | [private] |
This method is in charge of scheduling the event to the proper RTActions
Definition at line 166 of file RTScheduler.cpp.
References fesa::DiagnosticUtils::DiagStateCounter::current_, fesa::FesaException::getMessage(), fesa::RTEvent::getName(), logDiagnostics(), name_, scheduledEventCount_, and schedulingMap_.
Referenced by run().
Definition at line 138 of file RTScheduler.h.
Referenced by post(), printState(), and RTScheduler().
variable for the queue
Definition at line 118 of file RTScheduler.h.
fesa::RTScheduler::eventQueue_ [private] |
this member contains the queue for real time events
Definition at line 94 of file RTScheduler.h.
uint32_t fesa::RTScheduler::lostEventCount_ [private] |
Definition at line 139 of file RTScheduler.h.
Referenced by printState().
fesa::RTScheduler::mutexQueue_ [private] |
fesa::RTScheduler::name_ [private] |
name of the layer specified by the FESA developer
Reimplemented from fesa::Thread.
Definition at line 100 of file RTScheduler.h.
Referenced by cancel(), getName(), post(), printConfig(), printState(), RTScheduler(), run(), and schedule().
Definition at line 136 of file RTScheduler.h.
Referenced by post(), printState(), and RTScheduler().
fesa::RTScheduler::queueSize_ [private] |
Definition at line 137 of file RTScheduler.h.
Referenced by printState(), RTScheduler(), and schedule().
fesa::RTScheduler::schedulingMap_ [private] |
list of the actions which have to be executed per event
Definition at line 88 of file RTScheduler.h.
Referenced by addRTAction(), printConfig(), printState(), schedule(), and ~RTScheduler().