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