Blame view

src/ParamGetImpl/DDServerInterface/VirtualInstrument.hh 4.38 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * VirtualInstrument.hh
 *
 *  Created on: Jan 17, 2013
 *      Author: f.casimir
 */

#ifndef VIRTUALINSTRUMENT_HH_
#define VIRTUALINSTRUMENT_HH_

#include <map>
#include <list>
#include "DD.hh"

#include "VirtualInstrumentManager.hh"
#include "ParamFlow.hh"
#include "Pusher.hh"

namespace TimeTableCatalog {
	class TimeInterval;
}

namespace AMDA {
namespace DDServerInterface {

typedef std::vector<double> InfoValues;
typedef boost::shared_ptr<InfoValues> InfoValuesSPtr;
typedef std::map<std::string,InfoValuesSPtr> InfoList;
typedef std::map<std::string,InfoList> InfoMap;

typedef std::list<TimeTableCatalog::TimeInterval> TimeIntervalList;
typedef boost::shared_ptr<TimeIntervalList> 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<VirtualInstrumentInterval> VirtualIntrumentIntervalSPtr;
	typedef std::map<TimeIntervalListSPtr, VirtualIntrumentIntervalSPtr, CompKey> 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.
	 */
193183ca   Benjamin Renard   Give the possibil...
86
	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);
fbe3c2bb   Benjamin Renard   First commit
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

	/**
	 * @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 <typename type>
	void setInfoValues( InfoList& storage, const std::string& pInfoName, unsigned int pNbData, void* data);
	template <typename type>
	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
	 */
ff482c31   Benjamin Renard   Give the possibil...
116
	AMDA::Parameters::ContainerType getParamContainerType(DD_data_t *data, int dim3Num);
fbe3c2bb   Benjamin Renard   First commit
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

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_ */