/* * VirtualInstrument.hh * * Created on: Jan 17, 2013 * Author: f.casimir */ #ifndef VIRTUALINSTRUMENT_HH_ #define VIRTUALINSTRUMENT_HH_ #include #include #include "DD.hh" #include "VirtualInstrumentManager.hh" #include "ParamFlow.hh" #include "Pusher.hh" namespace TimeTableCatalog { class TimeInterval; } namespace AMDA { namespace DDServerInterface { typedef std::vector InfoValues; typedef boost::shared_ptr InfoValuesSPtr; typedef std::map InfoList; typedef std::map InfoMap; typedef std::list TimeIntervalList; typedef boost::shared_ptr TimeIntervalListSPtr; class VirtualInstrumentInterval; /* * @class VirtualInstrument * @brief Storage of Calibration information and VirtualInstrumentInterval. * @details During the program only one instance is created by DDServer VirtualInstrument. */ class VirtualInstrument { public: /** * @brief Class used to identify if a TimeIntervalList is already added to the map or not. */ class CompKey { public: bool operator()(const TimeIntervalListSPtr& a, const TimeIntervalListSPtr& b) { if (a->size() != b->size()) { return true; } else { TimeIntervalList::const_iterator itA = a->begin(); TimeIntervalList::const_iterator itB = b->begin(); while (itA != a->end()) { if ( (itA->_startTime != itB->_startTime) || (itA->_stopTime != itB->_stopTime) ) { return true; } else { ++itA; ++itB; } } return false; } } }; typedef boost::shared_ptr VirtualIntrumentIntervalSPtr; typedef std::map IntervalList; VirtualInstrument(VirtualInstrumentManager& piVrtualInstrumentManager, const std::string& viName); virtual ~VirtualInstrument(); // Getter methods const std::string& getViName() const { return _viName; } float getFillValue() { return _fillValue; } double getMinSampling() { return _minSampling; } double getMaxSampling() { return _maxSampling; } double getGlobalStartTime() { return _globalStartTime; } double getGlobalStopTime() { return _globalStopTime; } // Setter methods void setViName(const std::string& pVIName) { _viName = pVIName; } /** * @brief Responsible push data into the good container. */ AMDA::Parameters::Base::Pusher* getParamPusher(const std::string& pParName, int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim3Num, int dim3CutIndex, int minSumIndex, int maxSumIndex, double timeRestriction); /** * @return a ParamFlowSPtr on the specified interval. * @details If this interval not exist into _intervalList an object VirtualInstrumentInterval is created. * The ParamFlowSPtr return listen the corresponding interval. */ VI::ParamFlowSPtr getParamFlow(const std::string& pParamName, TimeIntervalListSPtr pTimeIntervalList); /** * @return a vector of double * @details Retrieve the info from DDServer and store them into */ const InfoList& getDDInfo(const char* infoName); protected: template void setInfoValues( InfoList& storage, const std::string& pInfoName, unsigned int pNbData, void* data); template void recurseInfoValues( InfoList& storage, const std::string& pInfoName, unsigned int pNbDimension, int* pDimensions, void* data); /** * @brief get time info (used for global start and global stop) */ double getDDTimeInfo(const char *timeTag); /** * @brief get container type from a DD_data structure */ AMDA::Parameters::ContainerType getParamContainerType(DD_data_t *data, int dim3Num); private: VirtualInstrumentManager& _virtualInstrumentManager; /*!< VirtualInstrumentManager reference */ std::string _viName ; /*!< virtual instrument name */ DD_Client _ddClient; /*!< DDCLient connection */ int _id; /*!< id of param in DD_server */ double _minSampling; double _maxSampling; double _globalStartTime; double _globalStopTime; float _fillValue = NAN; /*!< fillValue, bydefault Nan */ InfoMap _infoMap; /*!< Calibration information */ IntervalList _intervalList; /*!< List of VirtualInstrumentInterval about the current Virtual Instrument */ }; } /* namespace DDServerInterface */ } /* namespace AMDA */ #endif /* VIRTUALINSTRUMENT_HH_ */