Blame view

src/ExternLib/Tsyganenko96/ProcessTsyganenko96.cc 5.34 KB
8819b2bc   Benjamin Renard   Add plugin Tsygan...
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
/*
 * ProcessTsyganenko96.cc
 *
 *  Created on: Nov 05, 2017
 *      Author: benjamin
 */
#include <stdlib.h>
#include <string>

#include <boost/lexical_cast.hpp>

#include "DicError.hh"
#include "AMDA_exception.hh"

#include "Operation.hh"
#include "ParameterManager.hh"
#include "ProcessTsyganenko96.hh"
#include "ParamMgr.hh"
#include "ParameterCreatorFromExpression.hh"

using namespace std;
using namespace boost;
using namespace log4cxx;

namespace AMDA {
namespace Parameters {

d5d85a78   Benjamin Renard   Add process to co...
28
  ProcessTsyganenko96::ProcessTsyganenko96(Parameter &parameter, bool inGSE) : SingleParamProcess_CRTP(parameter), _inGSE(inGSE) {
8819b2bc   Benjamin Renard   Add plugin Tsygan...
29
30
31
  }

  ProcessTsyganenko96::ProcessTsyganenko96(const ProcessTsyganenko96& pProcess, Parameter &parameter)
d5d85a78   Benjamin Renard   Add process to co...
32
    : SingleParamProcess_CRTP(pProcess,parameter), _inGSE(pProcess._inGSE) {
8819b2bc   Benjamin Renard   Add plugin Tsygan...
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
86
87
88
89
  }

  ProcessTsyganenko96::~ProcessTsyganenko96() {
	if (_inputImfParam != nullptr) {
		_inputImfParam->closeConnection(this);
	}
	if (_inputPswParam != nullptr) {
		_inputPswParam->closeConnection(this);
	}
	if (_inputDstParam != nullptr) {
		_inputDstParam->closeConnection(this);
	}
  }

  void ProcessTsyganenko96::establishConnection() {
	if (_attributList.size() != 3) {
		BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessTsyganenko96::parse require 3 attributes'")));
	}

	//Imf parameter
	_inputImfParam = _parameter.getParameterManager().getParameter(_attributList[0]);
	if (_inputImfParam == nullptr) {
		BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessTsyganenko96::parse cannot retrieve imf param")));
	}
	_inputImfParam->openConnection(this);

	//Psw parameter
	_inputPswParam = _parameter.getParameterManager().getParameter(_attributList[1]);
	if (_inputPswParam == nullptr) {
		BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessTsyganenko96::parse cannot retrieve psw param")));
	}
	_inputPswParam->openConnection(this);

	//Dst parameter
	_inputDstParam = _parameter.getParameterManager().getParameter(_attributList[2]);
	if (_inputDstParam == nullptr) {
		BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessTsyganenko96::parse cannot retrieve dst param")));
	}
	_inputDstParam->openConnection(this);

	SingleParamProcess::establishConnection();
  }

  TimeStamp  ProcessTsyganenko96::init() {
	TimeStamp time = _parameterInput->init( this, _timeIntervalList);

	_inputImfParam->init( this, _timeIntervalList);
	ParamData* lImfParamInput = _inputImfParam->getParamData(this).get();

	_inputPswParam->init( this, _timeIntervalList);
	ParamData* lPswParamInput = _inputPswParam->getParamData(this).get();

	_inputDstParam->init( this, _timeIntervalList);
	ParamData* lDstParamInput = _inputDstParam->getParamData(this).get();

	_paramInput = _parameterInput->getParamData(this).get();

d5d85a78   Benjamin Renard   Add process to co...
90
	Tsyganenko96Creator lCreator(*this, *_paramInput, *lImfParamInput, *lPswParamInput, *lDstParamInput, _inGSE);
8819b2bc   Benjamin Renard   Add plugin Tsygan...
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
	_operation = lCreator.getOperation();	
	_paramData = ParamDataSPtr(_operation->getParamOutput());
	_paramData->setMinSampling(_paramInput->getMinSampling());
	return time;
}

unsigned int ProcessTsyganenko96::write() {
	getImfData();
	getPswData();
	getDstData();	
	return SingleParamProcess::write();
}

void ProcessTsyganenko96::getImfData() {
	try {
		ParamDataIndexInfo lParamDataIndexInfo;
		lParamDataIndexInfo = _inputImfParam->getAsync(this).get();
		while ((!lParamDataIndexInfo._noMoreTimeInt && !lParamDataIndexInfo._timeIntToProcessChanged) || (lParamDataIndexInfo._nbDataToProcess > 0)) {
			reinterpret_cast<Tsyganenko96::Tsyganenko96Base*>(_operation)->pushImfData(lParamDataIndexInfo);
			if (lParamDataIndexInfo._timeIntToProcessChanged || lParamDataIndexInfo._noMoreTimeInt)
				break;
			lParamDataIndexInfo = _inputImfParam->getAsync(this).get();
		}
	}catch (...) {
		throw;
	}
}

void ProcessTsyganenko96::getPswData() {
	try {
		ParamDataIndexInfo lParamDataIndexInfo;
		lParamDataIndexInfo = _inputPswParam->getAsync(this).get();
		while ((!lParamDataIndexInfo._noMoreTimeInt && !lParamDataIndexInfo._timeIntToProcessChanged) || (lParamDataIndexInfo._nbDataToProcess > 0)) {
			reinterpret_cast<Tsyganenko96::Tsyganenko96Base*>(_operation)->pushPswData(lParamDataIndexInfo);
			if (lParamDataIndexInfo._timeIntToProcessChanged || lParamDataIndexInfo._noMoreTimeInt)
				break;
			lParamDataIndexInfo = _inputPswParam->getAsync(this).get();
		}
	}catch (...) {
		throw;
	}
		
}

void ProcessTsyganenko96::getDstData() {
	try {
		ParamDataIndexInfo lParamDataIndexInfo;
		lParamDataIndexInfo = _inputDstParam->getAsync(this).get();
		while ((!lParamDataIndexInfo._noMoreTimeInt && !lParamDataIndexInfo._timeIntToProcessChanged) || (lParamDataIndexInfo._nbDataToProcess > 0)) {
			reinterpret_cast<Tsyganenko96::Tsyganenko96Base*>(_operation)->pushDstData(lParamDataIndexInfo);
			if (lParamDataIndexInfo._timeIntToProcessChanged || lParamDataIndexInfo._noMoreTimeInt)
				break;
			lParamDataIndexInfo = _inputDstParam->getAsync(this).get();
		}
	}catch (...) {
		throw;
	}
}

d5d85a78   Benjamin Renard   Add process to co...
150
151
152
153
154
155
ProcessTsyganenko96GSM::ProcessTsyganenko96GSM(Parameter &parameter) : ProcessTsyganenko96(parameter,false) {
}

ProcessTsyganenko96GSE::ProcessTsyganenko96GSE(Parameter &parameter) : ProcessTsyganenko96(parameter,true) {
}

8819b2bc   Benjamin Renard   Add plugin Tsygan...
156
157
} /* namespace Parameters */
} /* namespace AMDA */