AbstractAction.cpp
Go to the documentation of this file.00001
00002 #include <fesa-core/Core/AbstractAction.h>
00003 #include <fesa-core/Core/AbstractDeviceClass.h>
00004 #include <fesa-core/Core/OnDemandProducer.h>
00005 #include <fesa-core/Core/AbstractServiceLocator.h>
00006 #include <fesa-core/Synchronization/MultiplexingContext.h>
00007 #include <fesa-core/DataStore/FieldSynchroManager.h>
00008 #include <fesa-core/Core/MessageTypes.h>
00009
00010 namespace fesa
00011 {
00012
00013 AbstractAction::AbstractAction(std::string& actionName, std::string& className, const AbstractServiceLocator* serviceLocator, const std::map<std::string, const AbstractServiceLocator*> serviceLocatorRelatedClasses):
00014 name_(actionName),
00015 className_(className),
00016 serviceLocator_(serviceLocator),
00017 serviceLocatorRelatedClasses_(serviceLocatorRelatedClasses)
00018 {
00019
00020 }
00021
00022 AbstractAction::~AbstractAction()
00023 {
00024
00025 }
00026
00027 void AbstractAction::triggerOnDemandEventSource(const std::string& sourceName, MultiplexingContext* pCtxt, uint32_t msgPrio)
00028 {
00029 triggerOnDemandEventSource(sourceName,pCtxt,0,0,msgPrio);
00030 }
00031
00032 void AbstractAction::triggerOnDemandEventSource(const std::string& sourceName, MultiplexingContext* pCtxt, const char* payload, uint32_t payloadSize, uint32_t msgPrio)
00033 {
00034 OnDemandEventProducerCollection::iterator iter = onDemandEventProducerCol_.find(sourceName);
00035
00036 if( iter == onDemandEventProducerCol_.end())
00037 throw FesaException(__FILE__, __LINE__, FesaErrorOnDemandEventProducerNotFound.c_str(),sourceName.c_str());
00038
00039 boost::shared_ptr<OnDemandProducer> producer = iter->second.onDemandProducer;
00040
00041 OnDemandMessage message( pCtxt->getCycleName(), payload, payloadSize, msgPrio );
00042
00043 FieldSynchroManager* pFieldSynchroManager = FieldSynchroManager::getInstance();
00044 pFieldSynchroManager->commitModifiedFieldSynchronization(pCtxt);
00045
00046 producer->sendMessage(message);
00047 }
00048
00049 void AbstractAction::triggerAllOnDemandEventSources(MultiplexingContext* pCtxt, uint32_t msgPrio)
00050 {
00051 FieldSynchroManager* pFieldSynchroManager = FieldSynchroManager::getInstance();
00052 pFieldSynchroManager->commitModifiedFieldSynchronization(pCtxt);
00053
00054 OnDemandEventProducerCollection::iterator iter;
00055 for(iter=onDemandEventProducerCol_.begin();iter!=onDemandEventProducerCol_.end();iter++)
00056 {
00057 OnDemandMessage message( pCtxt->getCycleName(), 0, 0, msgPrio );
00058 iter->second.onDemandProducer->sendMessage(message);
00059 }
00060 }
00061
00062 void AbstractAction::triggerAllAutomaticallyTriggeredOnDemandEventSources(MultiplexingContext* pCtxt, uint32_t msgPrio)
00063 {
00064 FieldSynchroManager* pFieldSynchroManager = FieldSynchroManager::getInstance();
00065 pFieldSynchroManager->commitModifiedFieldSynchronization(pCtxt);
00066
00067 OnDemandEventProducerCollection::iterator iter;
00068 for(iter=onDemandEventProducerCol_.begin();iter!=onDemandEventProducerCol_.end();iter++)
00069 {
00070 if(iter->second.triggerAutomatically == true)
00071 {
00072 OnDemandMessage message( pCtxt->getCycleName(), 0, 0, msgPrio );
00073 iter->second.onDemandProducer->sendMessage(message);
00074 }
00075 }
00076 }
00077
00078 }