This class represents an event source on the system. Event sources are responsible for firing events and sending them to the right scheduler. More...
#include <AbstractEventSource.h>
Classes | ||||
struct | SubscribedScheduler | |||
Public Member Functions | ||||
virtual void | enable () | |||
enable the event-source activity (for all of the related events)
| ||||
virtual void | disable () | |||
disable the event-source activity (for all of the related events)
| ||||
virtual void | enableEvent (const std::string &logicalEventName) | |||
enable one particular event of the event-source | ||||
virtual void | disableEvent (const std::string &logicalEventName) | |||
disable one particular event on the event-source | ||||
void | printConfig (FesaStream *fesaStream) const | |||
method to print the event source configuration | ||||
void | printState (FesaStream *fesaStream, double elapsedTime) | |||
Internal method to print the event source configuration. | ||||
virtual | ~AbstractEventSource () | |||
destructor | ||||
const std::string & | getName () const | |||
EventSourceType | getType () const | |||
Retrieve the type of the event source. | ||||
uint32_t | getEvtSrcPriority () const | |||
returns the priority | ||||
uint32_t | getEvtSrcID () const | |||
returns the process ID | ||||
bool | isEventEnabled (const std::string &logicalEventName) const | |||
returns true if the event passed by argument is enabled | ||||
Protected Member Functions | ||||
AbstractEventSource (const std::string eventSourceName, EventSourceType type_) | ||||
Constructor of the class. | ||||
void | run () | |||
This method is executed by the thread to post the event in the schedulers. | ||||
virtual void | addRTScheduler (boost::shared_ptr< fesa::EventElement > &element, RTScheduler *scheduler) | |||
this method adds a scheduler to the list of schedulers | ||||
virtual RTEvent * | wait ()=0 | |||
This method has to be overridden in order to provide the RTEvent
| ||||
virtual void | connect (boost::shared_ptr< fesa::EventElement > &eventElement)=0 | |||
Connects the new discrete event source. It is up to each derived event source to perform the right actions to connect the event.
| ||||
Private Types | ||||
typedef std::string | ConcreteEventName | |||
typedef std::map < ConcreteEventName, std::vector < SubscribedScheduler > > | ConcreteEventMap | |||
Private Member Functions | ||||
void | postEventToSchedulers (boost::shared_ptr< RTEvent > &event) | |||
Posts an incoming RTEvent to all schedulers which are registered. | ||||
void | waitTillSourceEnabled () | |||
Waits that source gets woken up, if disabled. | ||||
void | setLogicalEventEnableState (bool newState, const std::string &logicalEventName) | |||
Enables / Disables all logical events of the given name. | ||||
Private Attributes | ||||
ConcreteEventMap | eventMap_ | |||
List of events triggered by this event-source and specific info. | ||||
bool | sourceIsEnabled_ | |||
used to enable/disable event-firing of this source in general | ||||
ConditionalVariable | waitIfDisabled_ | |||
used to wait for the enable-signal, if source is disabled | ||||
Mutex | mutex_waitIfDisabled_ | |||
std::string | eventSourceName_ | |||
name of the event source | ||||
EventSourceType | type_ | |||
concrete type of the source | ||||
DiagnosticUtils::DiagStateCounter | firedEventCount_ | |||
number of event fired by this event-source. | ||||
Friends | ||||
class | RTEvent | |||
class | RTController | |||
class | AbstractEventSourceFactory |
This class represents an event source on the system. Event sources are responsible for firing events and sending them to the right scheduler.
Definition at line 33 of file AbstractEventSource.h.
typedef std::map< ConcreteEventName, std::vector< SubscribedScheduler > > fesa::AbstractEventSource::ConcreteEventMap [private] |
Definition at line 162 of file AbstractEventSource.h.
typedef std::string fesa::AbstractEventSource::ConcreteEventName [private] |
Definition at line 161 of file AbstractEventSource.h.
fesa::AbstractEventSource::~AbstractEventSource | ( | ) | [virtual] |
fesa::AbstractEventSource::AbstractEventSource | ( | const std::string | eventSourceName, | |
EventSourceType | type_ | |||
) | [protected] |
Constructor of the class.
name | of the event source | |
key | to define a particular occurrence (custom event-source only) | |
type | of event source |
Definition at line 29 of file AbstractEventSource.cpp.
References fesa::DiagnosticUtils::DiagStateCounter::current_, eventSourceName_, firedEventCount_, fesa::AbstractEquipment::getDeviceDataFileName(), fesa::Thread::getID(), fesa::AbstractEquipment::getInstance(), fesa::AbstractEquipment::getProcessConfiguration(), fesa::DiagnosticUtils::DiagStateCounter::last_, fesa::DiagnosticUtils::DiagStateCounter::max_, fesa::Thread::registerThreadIdName(), and fesa::Thread::setPriority().
void fesa::AbstractEventSource::addRTScheduler | ( | boost::shared_ptr< fesa::EventElement > & | element, | |
RTScheduler * | scheduler | |||
) | [protected, virtual] |
this method adds a scheduler to the list of schedulers
eventName | contains the information about the event that will be passed to the scheduler | |
scheduler | the object that is added to the list of schedulers |
FesaException | Can be thrown on errors. (Also derived, lab specific errors can be caught, catching for that type) the scheduler cannot be null |
Definition at line 135 of file AbstractEventSource.cpp.
References connect(), eventMap_, fesa::RTScheduler::getName(), fesa::AbstractEventSource::SubscribedScheduler::isEnabled_, fesa::AbstractEventSource::SubscribedScheduler::logicalEventName_, and fesa::AbstractEventSource::SubscribedScheduler::scheduler_.
Referenced by fesa::RTController::createEventSource().
virtual void fesa::AbstractEventSource::connect | ( | boost::shared_ptr< fesa::EventElement > & | eventElement | ) | [protected, pure virtual] |
Connects the new discrete event source. It is up to each derived event source to perform the right actions to connect the event.
FesaException. |
Implemented in fesa::OnDemandEventSource, fesa::OnSubscriptionEventSource, and fesa::TimerEventSource.
Referenced by addRTScheduler().
void fesa::AbstractEventSource::disable | ( | ) | [virtual] |
disable the event-source activity (for all of the related events)
FesaException |
Definition at line 233 of file AbstractEventSource.cpp.
References eventSourceName_, and sourceIsEnabled_.
Referenced by fesa::ServiceLocatorRealtimeSplitImplementation::disableEventSource(), fesa::ServiceLocatorUnsplitImplementation::disableEventSource(), and fesa::OnDemandEventSource::OnDemandEventSource().
void fesa::AbstractEventSource::disableEvent | ( | const std::string & | logicalEventName | ) | [virtual] |
disable one particular event on the event-source
logicalEventName | logical name of the event that will be disable |
FesaException |
Definition at line 249 of file AbstractEventSource.cpp.
References eventSourceName_, and setLogicalEventEnableState().
Referenced by fesa::ServiceLocatorRealtimeSplitImplementation::disableRTEvent(), and fesa::ServiceLocatorUnsplitImplementation::disableRTEvent().
void fesa::AbstractEventSource::enable | ( | ) | [virtual] |
enable the event-source activity (for all of the related events)
FesaException |
Definition at line 221 of file AbstractEventSource.cpp.
References eventSourceName_, mutex_waitIfDisabled_, fesa::ConditionalVariable::signal(), sourceIsEnabled_, and waitIfDisabled_.
Referenced by fesa::OnDemandEventSource::connect(), fesa::ServiceLocatorRealtimeSplitImplementation::enableEventSource(), and fesa::ServiceLocatorUnsplitImplementation::enableEventSource().
void fesa::AbstractEventSource::enableEvent | ( | const std::string & | logicalEventName | ) | [virtual] |
enable one particular event of the event-source
logicalEventName | logical name of the event that will be enabled |
FesaException |
Definition at line 241 of file AbstractEventSource.cpp.
References eventSourceName_, and setLogicalEventEnableState().
Referenced by fesa::ServiceLocatorRealtimeSplitImplementation::enableRTEvent(), and fesa::ServiceLocatorUnsplitImplementation::enableRTEvent().
uint32_t fesa::AbstractEventSource::getEvtSrcID | ( | ) | const |
returns the process ID
Definition at line 216 of file AbstractEventSource.cpp.
References fesa::Thread::getID().
uint32_t fesa::AbstractEventSource::getEvtSrcPriority | ( | ) | const |
returns the priority
Definition at line 211 of file AbstractEventSource.cpp.
References fesa::Thread::getPriority().
Referenced by printState().
const std::string & fesa::AbstractEventSource::getName | ( | ) | const |
Definition at line 201 of file AbstractEventSource.cpp.
References eventSourceName_.
Referenced by postEventToSchedulers(), and fesa::OnDemandEventSource::wait().
EventSourceType fesa::AbstractEventSource::getType | ( | ) | const |
Retrieve the type of the event source.
Definition at line 206 of file AbstractEventSource.cpp.
References type_.
bool fesa::AbstractEventSource::isEventEnabled | ( | const std::string & | logicalEventName | ) | const |
returns true if the event passed by argument is enabled
logicalEventName | logical name of the event from which the enabled property is retrieved |
Definition at line 257 of file AbstractEventSource.cpp.
References eventMap_, and FesaErrorEventNotFound.
Referenced by fesa::ServiceLocatorRealtimeSplitImplementation::isEventEnabled(), and fesa::ServiceLocatorUnsplitImplementation::isEventEnabled().
void fesa::AbstractEventSource::postEventToSchedulers | ( | boost::shared_ptr< RTEvent > & | event | ) | [private] |
void fesa::AbstractEventSource::printConfig | ( | FesaStream * | fesaStream | ) | const |
method to print the event source configuration
fesaStream | in which the configuration will be shown |
Definition at line 180 of file AbstractEventSource.cpp.
References eventMap_, and eventSourceName_.
void fesa::AbstractEventSource::printState | ( | FesaStream * | fesaStream, | |
double | elapsedTime | |||
) |
Internal method to print the event source configuration.
fesaStream | in which the configuration will be shown |
Definition at line 191 of file AbstractEventSource.cpp.
References fesa::DiagnosticUtils::DiagStateCounter::current_, eventSourceName_, firedEventCount_, getEvtSrcPriority(), fesa::Thread::getID(), and fesa::DiagnosticUtils::DiagStateCounter::last_.
void fesa::AbstractEventSource::run | ( | ) | [protected, virtual] |
This method is executed by the thread to post the event in the schedulers.
Implements fesa::Thread.
Definition at line 60 of file AbstractEventSource.cpp.
References fesa::DiagnosticUtils::DiagStateCounter::current_, eventSourceName_, firedEventCount_, fesa::AbstractRTEquipment::getInstance(), fesa::FesaException::getMessage(), fesa::AbstractRTEquipment::handleEventSourceError(), fesa::Thread::hasFinished_, fesa::Thread::isRunning_, postEventToSchedulers(), wait(), and waitTillSourceEnabled().
void fesa::AbstractEventSource::setLogicalEventEnableState | ( | bool | newState, | |
const std::string & | logicalEventName | |||
) | [private] |
Enables / Disables all logical events of the given name.
Definition at line 277 of file AbstractEventSource.cpp.
References eventMap_, and FesaErrorEventNotFound.
Referenced by disableEvent(), and enableEvent().
virtual RTEvent* fesa::AbstractEventSource::wait | ( | ) | [protected, pure virtual] |
This method has to be overridden in order to provide the RTEvent
FesaException | Can be thrown on errors. (Also derived, lab specific errors can be caught, catching for that type). |
Implemented in fesa::OnDemandEventSource, fesa::OnSubscriptionEventSource, and fesa::TimerEventSource.
Referenced by run().
void fesa::AbstractEventSource::waitTillSourceEnabled | ( | ) | [private] |
Waits that source gets woken up, if disabled.
Definition at line 171 of file AbstractEventSource.cpp.
References mutex_waitIfDisabled_, sourceIsEnabled_, fesa::ConditionalVariable::wait(), and waitIfDisabled_.
Referenced by run().
friend class AbstractEventSourceFactory [friend] |
Reimplemented in fesa::OnSubscriptionEventSource, and fesa::TimerEventSource.
Definition at line 115 of file AbstractEventSource.h.
friend class RTController [friend] |
Definition at line 114 of file AbstractEventSource.h.
friend class RTEvent [friend] |
Definition at line 113 of file AbstractEventSource.h.
Referenced by fesa::TimerEventSource::fireNextEvent(), and fesa::OnSubscriptionEventSource::wait().
List of events triggered by this event-source and specific info.
Definition at line 167 of file AbstractEventSource.h.
Referenced by addRTScheduler(), isEventEnabled(), postEventToSchedulers(), printConfig(), and setLogicalEventEnableState().
std::string fesa::AbstractEventSource::eventSourceName_ [private] |
name of the event source
Definition at line 183 of file AbstractEventSource.h.
Referenced by AbstractEventSource(), disable(), disableEvent(), enable(), enableEvent(), getName(), printConfig(), printState(), run(), and ~AbstractEventSource().
number of event fired by this event-source.
Definition at line 193 of file AbstractEventSource.h.
Referenced by AbstractEventSource(), printState(), and run().
Definition at line 178 of file AbstractEventSource.h.
Referenced by enable(), and waitTillSourceEnabled().
bool fesa::AbstractEventSource::sourceIsEnabled_ [private] |
used to enable/disable event-firing of this source in general
Definition at line 172 of file AbstractEventSource.h.
Referenced by disable(), enable(), and waitTillSourceEnabled().
concrete type of the source
Definition at line 188 of file AbstractEventSource.h.
Referenced by getType().
used to wait for the enable-signal, if source is disabled
Definition at line 177 of file AbstractEventSource.h.
Referenced by enable(), and waitTillSourceEnabled().