00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #ifndef ABSTRACT_RT_EQUIPMENT_H_ 00004 #define ABSTRACT_RT_EQUIPMENT_H_ 00005 00006 #include <fesa-core/Core/AbstractComponentEquipment.h> 00007 #include <fesa-core/Utilities/Thread.h> 00008 #include <fesa-core/Exception/FesaException.h> 00009 00010 namespace fesa 00011 { 00012 00013 class FesaStream; 00014 class AbstractEventSource; 00015 class RTScheduler; 00016 class AbstractRTDeviceClass; 00017 class RTController; 00018 00025 struct RTSchedulingUnitRef 00026 { 00031 std::string name_; 00032 00037 std::string className_; 00038 00043 bool perDeviceCollection_; 00044 00048 bool found_; 00049 00050 }; 00051 00058 struct RTLayerInfo 00059 { 00064 std::string layerName_; 00065 00070 int32_t queueSize_; 00071 00076 std::vector<RTSchedulingUnitRef> schedulingUnitRefCol_; 00077 00081 void print(); 00082 00083 }; 00084 00091 class AbstractRTEquipment: public AbstractComponentEquipment 00092 { 00093 public: 00094 00098 static AbstractRTEquipment* getInstance(); 00099 00104 // CRFESA-764 check whether we still need this method 00105 // virtual void concreteInit() = 0; 00106 00112 AbstractRTDeviceClass* getRTDeviceClass(const std::string& rtDeviceClass); 00113 00118 void initialize(); 00119 00125 void start(RunMode mode); 00126 00131 void printConfigAll(FesaStream* fesaStream); 00132 00137 void printStateAll(FesaStream* fesaStream, double elapsedTime); 00138 00144 virtual void handleEventSourceError (AbstractEventSource* eventSource,FesaException& exception) = 0; 00145 00146 00152 virtual void handleSchedulerError (RTScheduler* scheduler,FesaException& exception) = 0; 00153 00154 00155 00156 protected: 00157 friend class RTController; 00158 00159 typedef std::vector<RTLayerInfo*> RTLayerInfoCol; 00160 00164 AbstractRTEquipment(); 00165 00170 virtual ~AbstractRTEquipment(); 00171 00175 virtual void fillRTSchedulerInfo(std::vector<RTLayerInfo*>& layerCol); 00176 00180 void waitSignal(); 00181 00186 RTController* rtController_; 00187 00192 static AbstractRTEquipment* theInstance_; 00193 00194 }; 00195 00196 //****************************************************************** 00197 00198 00204 inline AbstractRTDeviceClass* AbstractRTEquipment::getRTDeviceClass(const std::string& rtDeviceClass) 00205 { 00206 return (AbstractRTDeviceClass*) this->getDeviceClass(rtDeviceClass); 00207 } 00208 00209 inline AbstractRTEquipment* AbstractRTEquipment::getInstance() 00210 { 00211 if (theInstance_ == NULL) 00212 throw FesaException(__FILE__, __LINE__, FesaErrorRTEquipmentNotCreated.c_str()); 00213 else 00214 return theInstance_; 00215 } 00216 00217 } // namespace end 00218 00219 #endif /* ABSTRACT_RT_EQUIPMENT_H_ */