/* * VirtualInstrumentInterval.hh * * Created on: Nov 25, 2014 * Author: AKKA */ #ifndef VIRTUALINSTRUMENTINTERVAL_HH_ #define VIRTUALINSTRUMENTINTERVAL_HH_ #include #include #include #include #include #include "Worker.hh" #include "TimeInterval.hh" #include "LocalParamData.hh" namespace AMDA { namespace LocalFileInterface { class ParamFlow; typedef boost::shared_ptr ParamFlowSPtr; class VirtualInstrument; /** * @class VirtualInstrumentInterval * @brief Class responsible to get data from a time interval for dispatch them into some DataFlow. */ class VirtualInstrumentInterval : public AMDA::Helpers::Worker { public: typedef std::list TimeIntervalList; /** * @brief Constructor */ VirtualInstrumentInterval(VirtualInstrument& pVI, TimeIntervalList* pTimeIntervalList); /** * @brief Destructor */ virtual ~VirtualInstrumentInterval(); /* * @brief get ParamFlow for a given param ID */ ParamFlowSPtr getParamFlow(const std::string& pParamId, LocalParamType paramType, int dim1Size, int dim2Size); /** * @return nbData Available or 0 if no Data * blocking operation */ boost::shared_future getAsync() { AMDA::Helpers::Task* task = new AMDA::Helpers::Task( boost::bind(&VirtualInstrumentInterval::getOneDataBloc, this)); boost::shared_future future(task->getFuture()); _taskList.push(task); // assuming internal_queue member return future; } /** * @brief Define if time interval was set to another one. */ bool isTimeIntToProcessChanged() { return _timeIntToProcessChanged; } /** * @brief Define if time interval is the last one. */ bool isNoMoreTimeInt() { return _noMoreTimeInt; } protected: typedef boost::weak_ptr ParamFlowWPtr; typedef std::map ParamFlowList; /** * @brief Call _step pointer function which is different in function of the program step. */ unsigned int getOneDataBloc(); private: /** * @brief Load data and dispatch results to ParamFlow. * When no more data set the _step function pointer to writeEmptyData. */ unsigned int writeData(); /** * @brief write NULL Packet. */ unsigned int writeEmptyData(); unsigned int (VirtualInstrumentInterval::*_step)(); /* * @brief Set next TimeInterval to proceed */ bool setTimeInterval(); VirtualInstrument& _vi; /*!< Reference an associated Virtual Instrument */ TimeIntervalList& _timeIntervalList; TimeIntervalList::iterator _currentTimeIntToProcess; /** * @brief Define if data retrieving for a time interval changed. */ bool _timeIntToProcessChanged; /** * @brief Define if data retrieving is at the last interval. */ bool _noMoreTimeInt; ParamFlowSPtr _paramFlowSPtr; int _crtFileIndex; int _crtRecordIndex; }; } /* namespace LocalFileInterface */ } /* namespace AMDA */ #endif /* VIRTUALINSTRUMENTINTERVAL_HH_ */