RTAction.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef RT_ACTION_H_
00004 #define RT_ACTION_H_
00005 
00006 #include <fesa-core/RealTime/AbstractRTAction.h>
00007 #include <fesa-core/Diagnostic/FesaStream.h>
00008 
00009 namespace fesa
00010 {
00011 
00018 template<typename DeviceType>
00019 class RTAction : public AbstractRTAction
00020 {
00021   public:
00022 
00027     RTAction(RTActionConfig& rtActionConfig, const AbstractServiceLocator* serviceLocator, const std::map<std::string, const AbstractServiceLocator*> serviceLocatorRelatedClasses);
00028 
00032     virtual ~RTAction();
00033 
00038     virtual void printConfig(FesaStream* configStream);
00039 
00045     virtual void printState(FesaStream* fesaStream, double elapsedTime);
00046 
00047 
00048 
00049   protected:
00050 
00055     std::vector<DeviceType*> deviceCol_;
00056 
00057 
00058 };
00059 
00060 template<typename DeviceType>
00061 RTAction<DeviceType>::RTAction(RTActionConfig& rtActionConfig, const AbstractServiceLocator* serviceLocator, const std::map<std::string, const AbstractServiceLocator*> serviceLocatorRelatedClasses) :
00062     AbstractRTAction(rtActionConfig, serviceLocator, serviceLocatorRelatedClasses)
00063 {
00064     for (uint32_t i = 0; i < rtActionConfig.deviceCol_.size(); i++)
00065     {
00066         deviceCol_.push_back((DeviceType*) rtActionConfig.deviceCol_[i]);
00067     }
00068 }
00069 
00070 template<typename DeviceType>
00071 RTAction<DeviceType>::~RTAction()
00072 {
00073     deviceCol_.clear();
00074 }
00075 
00076 template<typename DeviceType>
00077 void RTAction<DeviceType>::printConfig(FesaStream* configStream)
00078 {
00079     *configStream << "\t\t\t\t\t<rt-action name=\"" << name_ << "\">" << std::endl;
00080     *configStream << "\t\t\t\t\t\t<selection-criterion name=\"" << selectionCriterion_ << "\"/>" << std::endl;
00081     for (uint32_t i = 0; i < deviceCol_.size(); ++i)
00082     {
00083         *configStream << "\t\t\t\t\t\t<device name=\"" << deviceCol_[i]->getName() << "\"/>" << std::endl;
00084     }
00085     *configStream << "\t\t\t\t\t</rt-action>" << std::endl;
00086 }
00087 template<typename DeviceType>
00088 void RTAction<DeviceType>::printState(FesaStream* fesaStream, double elapsedTime)
00089 {
00090     float freq_completedActionCount = (float) ((completedActionCount_.current_ - completedActionCount_.last_)
00091                                                / elapsedTime);
00092     *fesaStream << "            rt-action name = \"" << name_ << "\"" << std::endl;
00093     *fesaStream << "                completed-action-count(last/current: freq):\t" << completedActionCount_.last_
00094                 << "/" << completedActionCount_.current_ << ": " << freq_completedActionCount << " Hz"
00095                 << std::endl;
00096     *fesaStream << "                aborted-action-count:\t" << abortedActionCount_ << std::endl;
00097     //completedActionCount.last = completedActionCount.current;
00098 }
00099 
00100 } // fesa
00101 
00102 #endif // RT_ACTION_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1