Blame view

src/ExternLib/mexvex_els_decode/MexVexElsDecode.hh 3.27 KB
35de3ffa   Elena.Budnik   mexvex_els
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
/*
 * MexVexElsDecode.hh
 *
 *  Created on: Oct 13, 2016
 *      Author: elena / benjamin
 */

#ifndef MEXVEXELSDECODE_HH_
#define MEXVEXELSDECODE_HH_

#include "Parameter.hh"
#include "ParamData.hh"
#include "DataTypeMath.hh"
#include "Operation.hh"

namespace AMDA {
namespace Parameters {
namespace MexVexElsDecode {

/**
 * @class MexVexElsDecode
 * @brief 
 * @details This class implement the interface Operation.
 */

6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
26
template <typename TInputParamData> 
35de3ffa   Elena.Budnik   mexvex_els
27
28
class MexVexElsDecode : public Operation {
	
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
29
typedef typename TInputParamData::ElementType ElemType;
35de3ffa   Elena.Budnik   mexvex_els
30
31
32
33
34
35

public:
	/**
	 * @brief Constructor.
	 * @details Create the ParamData type of the input ParamData.
	 */
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
36
	MexVexElsDecode(Process& pProcess, TInputParamData& paramInput,  ParamDataScalaireShort& energyTableInput)
35de3ffa   Elena.Budnik   mexvex_els
37
38
	: Operation(pProcess),
	  _paramInput(paramInput),
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
39
40
	  _energyTableInput(energyTableInput),
	  _paramOutput(new TInputParamData()) {
35de3ffa   Elena.Budnik   mexvex_els
41
42
43
44
45
46
47
48
49
50
51
52
53
	  _paramDataOutput=_paramOutput;
	}

	virtual ~MexVexElsDecode() {
		
	}

	/**
	 * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
	 */
  
	void write(ParamDataIndexInfo &pParamDataIndexInfo) {
	  
35de3ffa   Elena.Budnik   mexvex_els
54
55
56
57
58
59
60
		for (unsigned int _index = pParamDataIndexInfo._startIndex ;
			_index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
			++_index)
		{
			double crtTime = _paramInput.getTime(_index);
			ElemType inputElt = _paramInput.get(_index);
		
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
61
			int mode = _energyTableInput.get(_index);
35de3ffa   Elena.Budnik   mexvex_els
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	     
			if (mode == 1) {
				for (int i = 0; i < 4; ++i){			       
					_paramOutput->pushTime(crtTime+i);
					pushDataForMode1 (inputElt, i);				 
				}
			}
			else if (mode == 0 || mode == 2)			
			{
				_paramOutput->pushTime(crtTime);
				_paramOutput->getDataList().push_back(inputElt);
			}
		}		
	}
3a91e5e3   Benjamin Renard   Fix mex/vex els p...
76

35de3ffa   Elena.Budnik   mexvex_els
77
	template<typename Type>
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
78
	void pushDataForMode1(Type& elt, int /*index*/) {
35de3ffa   Elena.Budnik   mexvex_els
79
80
		_paramOutput->getDataList().push_back(elt);
	}
3a91e5e3   Benjamin Renard   Fix mex/vex els p...
81

35de3ffa   Elena.Budnik   mexvex_els
82
83
	template<typename Type>
	void pushDataForMode1(std::vector<Type>& elt, int index) {
5fd5fc53   Elena.Budnik   ELS splitted 4,31
84
85
		typename std::vector<Type>::const_iterator first = elt.begin() + 32 * index;
		typename std::vector<Type>::const_iterator last = elt.begin() + 32 * (index + 1) - 1;
3a91e5e3   Benjamin Renard   Fix mex/vex els p...
86
		std::vector<Type> splitVec;
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
87
88
		splitVec.resize(128);
		splitVec << NotANumber();
3a91e5e3   Benjamin Renard   Fix mex/vex els p...
89
90
91
92
93
94
95

		int i = 0;
		for (typename std::vector<Type>::const_iterator it = first; it != last; ++it) {
			splitVec[i] = (*it);
			++i;
		}

35de3ffa   Elena.Budnik   mexvex_els
96
97
98
99
100
		_paramOutput->getDataList().push_back(splitVec);
	}		
	
	template<typename Type>  
	void pushDataForMode1(Tab2DData<Type>& elt, int index) {
5fd5fc53   Elena.Budnik   ELS splitted 4,31
101
		Tab2DData<Type> newElt(elt.getDim1Size(),31); 
35de3ffa   Elena.Budnik   mexvex_els
102
103
		for(int i = 0; i < elt.getDim1Size(); ++i) {                        			
			std::vector<Type> eltVector = elt[i].toVector();
5fd5fc53   Elena.Budnik   ELS splitted 4,31
104
105
			typename std::vector<Type>::const_iterator first = eltVector.begin() + 32 * index;
			typename std::vector<Type>::const_iterator last =  eltVector.begin() + 32 * (index + 1) - 1;
35de3ffa   Elena.Budnik   mexvex_els
106
107
108
109
110
111
112
113
114
115
			std::vector<Type> splitVec(first, last);
			newElt[i] = splitVec;
		}                
		_paramOutput->getDataList().push_back(newElt);
	}
  
private:
	/**<
	 * @brief It is the channel of data derived
	 */
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
116
117
118
	TInputParamData& _paramInput;

	ParamDataScalaireShort& _energyTableInput;
35de3ffa   Elena.Budnik   mexvex_els
119
120
121
122

	/**<
	 * @brief It is the channel of the data derived
	 */
6a28e3ab   Benjamin Renard   Fix Mex/Vex ELS p...
123
	TInputParamData* _paramOutput;
35de3ffa   Elena.Budnik   mexvex_els
124
125
126
127
128
129
};  

} /* namespace MexVexElsDecode */
} /* namespace Parameters */
} /* namespace AMDA */
#endif /* MEXVEXELSDECODE_HH_ */