Blame view

src/ParamGetImpl/LocalFileInterface/VirtualInstrumentInterval.hh 3.01 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
/*
 * VirtualInstrumentInterval.hh
 *
 *  Created on: Nov 25, 2014
 *      Author: AKKA
 */

#ifndef VIRTUALINSTRUMENTINTERVAL_HH_
#define VIRTUALINSTRUMENTINTERVAL_HH_

#include <string>
#include <map>
#include <vector>

#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>

#include "Worker.hh"

#include "TimeInterval.hh"
#include "LocalParamData.hh"

namespace AMDA {

namespace LocalFileInterface {

class ParamFlow;

typedef boost::shared_ptr<ParamFlow> 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<TimeTableCatalog::TimeInterval> 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<unsigned int> getAsync() {
		AMDA::Helpers::Task<unsigned int>* task = new AMDA::Helpers::Task<unsigned int>(
				boost::bind(&VirtualInstrumentInterval::getOneDataBloc, this));
		boost::shared_future<unsigned int> 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; }

fa4b7852   Benjamin Renard   Fix bug around ti...
75
76
77
78
	/**
	 * @brief Define if time interval is the last one.
	 */
	bool isNoMoreTimeInt() { return _noMoreTimeInt; }
fbe3c2bb   Benjamin Renard   First commit
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

protected:
	typedef boost::weak_ptr<ParamFlow> ParamFlowWPtr;
	typedef std::map<std::string,ParamFlowWPtr> 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();

d85350c3   Benjamin Renard   Add no data supor...
102
103
	unsigned int writeNoData();

fbe3c2bb   Benjamin Renard   First commit
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
	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;

fa4b7852   Benjamin Renard   Fix bug around ti...
120
121
122
123
124
	/**
	 * @brief Define if data retrieving is at the last interval.
	 */
	bool _noMoreTimeInt;

fbe3c2bb   Benjamin Renard   First commit
125
126
127
128
129
	ParamFlowSPtr _paramFlowSPtr;

	int _crtFileIndex;

	int _crtRecordIndex;
d85350c3   Benjamin Renard   Add no data supor...
130
131

	bool _nodata;
fbe3c2bb   Benjamin Renard   First commit
132
133
134
135
136
};

} /* namespace LocalFileInterface */
} /* namespace AMDA */
#endif /* VIRTUALINSTRUMENTINTERVAL_HH_ */