/* * VirtualInstrument.hh * * Created on: Nov 21, 2014 * Author: AKKA */ #ifndef VIRTUALINSTRUMENT_HH_ #define VIRTUALINSTRUMENT_HH_ #include #include #include #include #include #include "FileReaderAbstract.hh" #include "Pusher.hh" #include "ParamFlow.hh" #include "TimeTable.hh" namespace AMDA { namespace LocalFileInterface { typedef std::list TimeIntervalList; typedef boost::shared_ptr TimeIntervalListSPtr; typedef std::vector InfoValues; typedef boost::shared_ptr InfoValuesSPtr; typedef std::map InfoMap; class VirtualInstrumentManager; class VirtualInstrumentInterval; /* * @brief File formats */ typedef enum { FORMAT_UNKNOWN, FORMAT_ASCII, FORMAT_CDF, FORMAT_VOT, FORMAT_NETCDF } VIFileFormat; /* * @class VirtualInstrument * @brief Storage of file associated to a local virtual instrument. */ 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; /* * @brief Constructor */ VirtualInstrument(VirtualInstrumentManager& piVrtualInstrumentManager, const std::string& VIId); /* * @brief Destructor */ virtual ~VirtualInstrument(); /* * @brief get Virtual Instrument ID */ const std::string& getVIId() const { return _VIId; } /* * @brief set Virtual Instrument ID */ void setVIId(const std::string& pVIId) { _VIId = pVIId; } /* * @brief get global start */ double getGlobalStartTime() { return _globalStartTime; } /* * @brief set global start time */ void setGlobalStartTime(double start) { _globalStartTime = start; } /* * @brief get global stop time */ double getGlobalStopTime() { return _globalStopTime; } /* * @brief set global start time */ void setGlobalStopTime(double stop) { _globalStopTime = stop; } /* * @brief get files format for the Virtual Instrument */ VIFileFormat getFilesFormat() { return _filesFormat; } /* * @brief set files format for the virtual instrument */ void setFilesFormat(VIFileFormat format) { _filesFormat = format; } /* * @brief Add a file definition in the virtual instrument */ void addFileDefinition(const char* pName, double pStart,double pStop); /* * @brief Create file reader associated to the VirtualInstrument files format */ bool createFileReader(LocalTimeFormat timeFormat); /* * @brief Get file reader */ FileReaderAbstract* getFileReader() { return _fileReaderPtr; } /* * @brief Create pusher associated to the paramId */ PusherBase* createPusher(std::string& paramId, LocalParamType ¶mType, int& dim1Size, int& dim2Size); /* * @brief Get param flow associated to the paramId */ ParamFlowSPtr getParamFlow(const std::string& pParamId, TimeIntervalListSPtr pTimeIntervalList, LocalParamType paramType, int dim1Size, int dim2Size); /* * @brief Get data position in the Virtual Instrument from time */ bool getDataPosition(double &startTime, double &stopTime, int& fileIndex, int& recordIndex); /* * @brief Get one param data packet */ FileReaderStatus getParamPacketData(std::string& paramId, int fileIndex, int recordIndex, double stopTime, LocalParamDataPacket *packet); /* * @brief Get the time param id */ bool updateTimeId(); /* * @brief Get info */ InfoValuesSPtr& getFileInfo(const char* pInfoName); protected : /* * @brief Get file full path from file index */ std::string getFileFullPath(int fileIndex); private: /* * @brief Structure used to define a file attached to the virtual instrument */ typedef struct { std::string _name; double _start; double _stop; } LocalFileDefinition; /* * @brief VirtualInstrumentManager reference */ VirtualInstrumentManager& _virtualInstrumentManager; /* * @brief Virtual Instrument ID */ std::string _VIId ; /* * @brief Virtual Instrument Global Start */ double _globalStartTime; /* * @brief Virtual Instrument Global Stop */ double _globalStopTime; /* * @brief Virtual Instrument files format */ VIFileFormat _filesFormat; /* * @brief Vector of attached files */ std::vector _files; /* * @brief timeId */ std::string _timeId; /* * @brief Pointer to the file reader */ FileReaderAbstract* _fileReaderPtr; /* * @brief List of VirtualInstrumentInterval about the current Virtual Instrument */ IntervalList _intervalList; /* * @brief Calibration information */ InfoMap _infoMap; }; typedef boost::weak_ptr VirtualInstrumentWPtr; typedef boost::shared_ptr VirtualInstrumentSPtr; } /* namespace LocalFileInterface */ } /* namespace AMDA */ #endif /* VIRTUALINSTRUMENT_HH_ */