Blame view

src/Parameters/Parameter.hh 7.53 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
/**
 * Parameter.hh
 *
 *  Created on: 16 oct. 2012
 *      Author: AKKA IS
 */

#ifndef PARAMETER_HH_
#define PARAMETER_HH_

#include <set>
#include <string>
#include <map>

#include <boost/thread/future.hpp>
#include <boost/shared_ptr.hpp>

#include "DataWriter.hh"
#include "ParamDataIndexInfo.hh"
#include "TimeStamp.hh"

namespace AMDA {
b31e7a52   Hacene SI HADJ MOHAND   working with mav_st
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    namespace Parameters {

        class Parameter;
        class ParamOutput;
        class ParamData;
        class DataClient;
        class ParameterManager;
        class ParamInterval;
        class CalibrationInfoWriter;

        typedef boost::shared_ptr<Parameter> ParameterSPtr;
        typedef boost::shared_ptr<ParamOutput> ParamOutputSPtr;
        typedef boost::shared_ptr<ParamData> ParamDataSPtr;
        typedef boost::shared_ptr<DataClient> DataClientSPtr;
        typedef boost::shared_ptr<DataWriter> DataWriterSPtr;

        struct SemiVariableTable {
            std::vector<std::string> tabHeader;
c0955cd4   Hacene SI HADJ MOHAND   ok for juno jedi
41
            std::map<std::string, std::vector<double>> tabValues;
84a560eb   Hacene SI HADJ MOHAND   no min max calcul...
42
            bool calculateBounds = false;
b31e7a52   Hacene SI HADJ MOHAND   working with mav_st
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
86
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
        };

        /**
         * AMDA::Parameters::Parameter
         */
        class Parameter {
        public:
            typedef std::set<ParameterSPtr> ParameterList;
            typedef std::list<CalibrationInfoWriter*> CalibrationInfoWriterList;
            typedef std::vector<double> InfoValues;
            typedef boost::shared_ptr<InfoValues> InfoValuesSPtr;
            typedef std::map<std::string, InfoValuesSPtr> InfoList;

            Parameter(ParameterManager& pParamMng, std::string idParam);

            virtual ~Parameter();

            // Get methods
            /**
             * Get ParamData for DataClient
             */
            ParamDataSPtr& getParamData(DataClient*);

            /**
             * get sampling value in sec
             */
            double getTimeResolution() {
                return _timeResolution;
            }

            /**
             * get gap threshold factor
             */
            double getGapThreshold() {
                return _gapThreshold;
            }

            /**
             * @brief get  list of CalibrationInfoWriter
             */
            const CalibrationInfoWriterList& getCalibrationInfoWriterList() const {
                return _calibrationInfoWriterList;
            }

            CalibrationInfoWriterList& getCalibrationInfoWriterList() {
                return _calibrationInfoWriterList;
            }

            /**
             * Get additional information list.
             */
            const InfoList& getInfoList() const {
                return _infoList;
            }

            InfoList& getInfoList() {
                return _infoList;
            }

            // Set methods

            /**
             * Set the DataWriter to fill the ParamData
             */
            void setDataWriter(const DataWriterSPtr& dataWriter) {
                _dataWriter = dataWriter;
            }

            /**
             * set sampling value in sec
             */
            void setTimeResolution(double pTimeResolution) {
                _timeResolution = pTimeResolution;
            }

            /**
             * set gap threshold factor
             */
            void setGapThreshold(double pGapThreshold) {
                _gapThreshold = pGapThreshold;
            }

            /**
             * Add additional Information values.
             */
            void setInfoValues(std::string pInfoName, InfoValuesSPtr& pInfoValues) {
                _infoList.insert(std::pair<std::string, InfoValuesSPtr>(pInfoName, pInfoValues));
            }

            // Others methods

            void openConnection(DataClient *);
            void closeConnection(DataClient *);

            const std::string& getId() const {
                return _id;
            }

            const std::string& getInfoId() const {
                return _infoId;
            }

            void setInfoId(const std::string& infoId) {
                _infoId = infoId;
            }

            /**
             *@brief  get _dataWriter
             *@details can be a copy after establishConnection phase
             */
            DataWriterSPtr& getDataWriterTemplate() {
                return _dataWriter;
            }

            /**
             * @brief Place interval on existing or creates
             * @return the last time of all file object which can modify the type of ParamData of Parameter
             */
            TimeStamp init(DataClient* pDataClient, TimeIntervalListSPtr pTimeIntervalList);

            /**
             * @return nbData Available or 0 if no Data
             *  blocking operation
             */
            boost::shared_future<ParamDataIndexInfo> getAsync(DataClient * pClient);

            ParameterManager& getParameterManager() {
                return _parameterManager;
            }

            void addParameter(ParameterSPtr pParentParameter) {
                _parameterList.insert(pParentParameter);
            }

            ParameterList& getParameterList() {
                return _parameterList;
            }

            void delegateOtherTaskTo(ParameterSPtr& pParam);

            void setIsTableIndexParam(bool isTableIndexParam) {
                _isTableIndexParam = isTableIndexParam;
            }

            bool isTableIndexParam() {
                return _isTableIndexParam;
            }

        protected:

            typedef std::map<DataClient *, ParamInterval*> DataClientList;
            typedef std::vector<ParamInterval*> IntervalList;

        private:

            /**
             * Id of parameter (name of xml file)
             */
            std::string _id;

            /**
             * info id of parameter
             */
            std::string _infoId;

            /**
             * The implementation is responssable to get Data
             * This acquisition must be make by ParamGet to get data in base
             * or Process to computed data.
             */
            DataWriterSPtr _dataWriter;

            /**
             * an instance of parameter manager
             */
            ParameterManager& _parameterManager;

            /**
             *
             */
            ParameterList _parameterList;

            /**
             * Stored for each DataClient, information of this DataClient (startTime, IntTime, ...)
             */
            IntervalList _intervalList;

            /**
             * DataClient list , this data client used ParamData. For each DataClient, Parameter stored data of this client.
             * The client  subscribe via openConnection. after, it's put information via init method.
             */
            DataClientList _dataClientList
            /**
             * when ( _clientInitCall == _dataClientList.size())  _intervalList is activ
             */;
            unsigned int _clientInitCall;

            /**
             * ask sampling, give by xml parameter file
             */
            double _timeResolution;

            /**
             * ask gap threshold, give by xml parameter file
             */
            double _gapThreshold;

            /**
             * list of functor to write callibration info
             */
            CalibrationInfoWriterList _calibrationInfoWriterList;

            /**
             * List of additional information
             */
            InfoList _infoList;

            static bool _isTableIndexParam;


        private:
            bool establishConnectionToDo;
        };

    } /* namespace Parameters */
fbe3c2bb   Benjamin Renard   First commit
268
269
} /* namespace AMDA */
#endif /* PARAMETER_HH_ */