ServiceLocatorRealtimeSplitImplementation.cpp
Go to the documentation of this file.00001
00002
00003 #include <fesa-core/RealTime/ServiceLocatorRealtimeSplitImplementation.h>
00004
00005 #include <fesa-core/Exception/FesaException.h>
00006 #include <fesa-core/RealTime/AbstractRTEquipment.h>
00007 #include <fesa-core/RealTime/AbstractRTDeviceClass.h>
00008 #include <fesa-core/RealTime/AbstractEventSourceFactory.h>
00009 #include <fesa-core/RealTime/AbstractEventSource.h>
00010 #include <fesa-core/Server/AbstractServerEquipment.h>
00011 #include <fesa-core/Core/NotificationProducer.h>
00012 #include <fesa-core/DataStore/GlobalDevice.h>
00013
00014 namespace fesa
00015 {
00016
00017 ServiceLocatorRealtimeSplitImplementation::ServiceLocatorRealtimeSplitImplementation(const std::string& className) :
00018 AbstractServiceLocatorImplementation(className)
00019 {
00020
00021 }
00022
00023 ServiceLocatorRealtimeSplitImplementation::~ServiceLocatorRealtimeSplitImplementation()
00024 {
00025
00026 }
00027
00028 void ServiceLocatorRealtimeSplitImplementation::runClassSpecificInitRT() const
00029 {
00030 AbstractRTDeviceClass* pRTDeviceClass = AbstractRTEquipment::getInstance()->getRTDeviceClass(className_);
00031 if (pRTDeviceClass == NULL)
00032 {
00033 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00034 "runClassSpecificInitRT");
00035 }
00036 pRTDeviceClass->specificInit();
00037 }
00038
00039 void ServiceLocatorRealtimeSplitImplementation::runClassSpecificInitServer() const
00040 {
00041 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "classSpecificInitServer",
00042 "Realtime");
00043 }
00044
00045 void ServiceLocatorRealtimeSplitImplementation::runDeployUnitSpecificInitRT() const
00046 {
00047 AbstractRTEquipment::getInstance()->specificInit();
00048 }
00049
00050 void ServiceLocatorRealtimeSplitImplementation::runDeployUnitSpecificInitServer() const
00051 {
00052 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "deployUnitSpecificInitServer",
00053 "Realtime");
00054 }
00055
00056 void ServiceLocatorRealtimeSplitImplementation::enableEventSource(const std::string& eventSourceName) const
00057 {
00058 AbstractEventSource* pEventSource = AbstractEventSourceFactory::getEventSource(className_,eventSourceName);
00059 pEventSource->enable();
00060 }
00061
00062 void ServiceLocatorRealtimeSplitImplementation::disableEventSource(const std::string& eventSourceName) const
00063 {
00064 AbstractEventSource* pEventSource = AbstractEventSourceFactory::getEventSource(className_,eventSourceName);
00065 pEventSource->disable();
00066 }
00067
00068 void ServiceLocatorRealtimeSplitImplementation::enableRTEvent(const std::string& logicalEventName,const std::string& eventSourceName) const
00069 {
00070 AbstractEventSource* pEventSource = AbstractEventSourceFactory::getEventSource(className_,eventSourceName);
00071 pEventSource->enableEvent(logicalEventName);
00072 }
00073
00074 void ServiceLocatorRealtimeSplitImplementation::disableRTEvent(const std::string& logicalEventName,const std::string& eventSourceName) const
00075 {
00076 AbstractEventSource* pEventSource = AbstractEventSourceFactory::getEventSource(className_,eventSourceName);
00077 pEventSource->disableEvent(logicalEventName);
00078 }
00079
00080 bool ServiceLocatorRealtimeSplitImplementation::isEventEnabled(const std::string& logicalEventName,const std::string& eventSourceName) const
00081 {
00082 AbstractEventSource* pEventSource = AbstractEventSourceFactory::getEventSource(className_,eventSourceName);
00083 return pEventSource->isEventEnabled(logicalEventName);
00084 }
00085
00086 void ServiceLocatorRealtimeSplitImplementation::synchronizeSettingFields(const MultiplexingContext& context) const
00087 {
00088 AbstractRTDeviceClass* pRTDeviceClass = AbstractRTEquipment::getInstance()->getRTDeviceClass(className_);
00089 if (pRTDeviceClass == NULL)
00090 {
00091 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00092 "synchronizeSettingFields");
00093 }
00094 GlobalDevice* pGlobalDevice = pRTDeviceClass->getDeviceFactory()->getGlobalDevice();
00095 std::vector<AbstractDevice*> deviceCollection =
00096 pRTDeviceClass->getDeviceFactory()->getAbstractDeviceCollection();
00097
00098
00099 pGlobalDevice->synchronizeSettingFields(const_cast<MultiplexingContext&>(context));
00100 for (std::vector<AbstractDevice*>::iterator device = deviceCollection.begin(); device != deviceCollection.end();
00101 device++)
00102 {
00103
00104 (*device)->synchronizeSettingFields(const_cast<MultiplexingContext&>(context));
00105 }
00106 }
00107
00108 void ServiceLocatorRealtimeSplitImplementation::triggerPersistency() const
00109 {
00110 NotificationProducer::getInstance()->sendCommandMessage("PersistencyTrigger", className_, "");
00111 }
00112
00113 AbstractDevice* ServiceLocatorRealtimeSplitImplementation::getDevice(const std::string& deviceName) const
00114 {
00115 AbstractRTDeviceClass* pRTDeviceClass = AbstractRTEquipment::getInstance()->getRTDeviceClass(className_);
00116 if (pRTDeviceClass == NULL)
00117 {
00118 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "getDevice");
00119 }
00120 AbstractDevice* pDevice = pRTDeviceClass->getDeviceFactory()->getDevice(deviceName);
00121 if (pDevice == NULL)
00122 {
00123 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "getDevice");
00124 }
00125 return (pDevice);
00126 }
00127
00128 AbstractDevice* ServiceLocatorRealtimeSplitImplementation::getGlobalDevice() const
00129 {
00130 AbstractRTDeviceClass* pRTDeviceClass = AbstractRTEquipment::getInstance()->getRTDeviceClass(className_);
00131 if (pRTDeviceClass == NULL)
00132 {
00133 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00134 "getDeviceCollection");
00135 }
00136 return (pRTDeviceClass->getDeviceFactory()->getGlobalDevice());
00137 }
00138
00139 const std::vector<AbstractDevice*>& ServiceLocatorRealtimeSplitImplementation::getDeviceCollection() const
00140 {
00141 AbstractRTDeviceClass* pRTDeviceClass = AbstractRTEquipment::getInstance()->getRTDeviceClass(className_);
00142 if (pRTDeviceClass == NULL)
00143 {
00144 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00145 "getDeviceCollection");
00146 }
00147 return (pRTDeviceClass->getDeviceFactory()->getAbstractDeviceCollection());
00148 }
00149
00150 }