Blame view

src/InternLib/ParamTableProcess.cc 3.26 KB
91edc9c0   Benjamin Renard   Add process to tr...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * ParamTableProcess.cc
 *
 *  Created on: Nov 23, 2022
 *      Author: AKKA
 */

#include "ParamTableProcess.hh"

#include <stdlib.h>
#include <string>

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

#include "ParameterManager.hh"
#include "ParamMgr.hh"
#include "ParamTableOperation.hh"


namespace AMDA {
	namespace Parameters {

		ParamTableProcess::ParamTableProcess(Parameter &parameter)
23cd82f6   Erdogan Furkan   Almost done
25
		  : MultiParamProcess_CRTP(parameter), _dim(0) {
91edc9c0   Benjamin Renard   Add process to tr...
26
27
28
		}

		ParamTableProcess::ParamTableProcess(const ParamTableProcess& pProcess, Parameter &parameter)
23cd82f6   Erdogan Furkan   Almost done
29
		: MultiParamProcess_CRTP(pProcess,parameter), _dim(pProcess._dim) {
91edc9c0   Benjamin Renard   Add process to tr...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
		  //Establish Connection Without Parse
		  MultiParamProcess::establishConnection();
		}

		ParamTableProcess::~ParamTableProcess() {
		}

		void ParamTableProcess::establishConnection() {
			std::vector<std::string> strs;
			boost::split(strs, _expression, boost::is_any_of("|"));
			if (strs.size() != 2) {
				BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ParamTableProcess::establishConnection cannot retrieve paramId or dim")));
			}
			std::string paramId = strs[0];
23cd82f6   Erdogan Furkan   Almost done
44
			_dim = std::stoi(strs[1].c_str());
91edc9c0   Benjamin Renard   Add process to tr...
45
46
47
48
49
50
			_paramSPtr = _parameter.getParameterManager().getParameter(paramId);
			_paramNameList[_paramSPtr->getId()].first = _paramSPtr;
			AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_paramSPtr->getInfoId());
			if (paramInfo == nullptr) {
				BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ParamTableProcess::establishConnection cannot retrieve param info")));
			}
23cd82f6   Erdogan Furkan   Almost done
51
			_paramTable = paramInfo->getTable(_dim);
91edc9c0   Benjamin Renard   Add process to tr...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

			std::map<std::string, std::string> tableParams = _paramTable->getTableParams(&_parameter.getParameterManager());
			for (std::map<std::string, std::string>::iterator it = tableParams.begin(); it != tableParams.end(); ++it) {
				
				AMDA::Parameters::ParameterSPtr p = _parameter.getParameterManager().getParameter(it->second);
				_paramNameList[it->second].first = p;
			}
			
			
			MultiParamProcess::establishConnection();
		}

		TimeStamp ParamTableProcess::init() {
			TimeStamp timeStamp = MultiParamProcess::init();
			//_parameter.init(this, _timeIntervalList);
91edc9c0   Benjamin Renard   Add process to tr...
67
					
9f975da0   Erdogan Furkan   CDF_ISTP working ...
68
			this->setOperation((Operation*)(new AMDA::Parameters::ParamTable::ParamTableOperation(*this)));
91edc9c0   Benjamin Renard   Add process to tr...
69
70
71
72
73
74
75
76
			this->getParamData().reset( this->getOperation()->getParamOutput());
			return timeStamp;
		}

		boost::shared_ptr<AMDA::Info::ParamTable> ParamTableProcess::getParamTable() {
			return _paramTable;
		}

23cd82f6   Erdogan Furkan   Almost done
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
		void ParamTableProcess::updateInfo(Parameter & parameter)
		{
			MultiParamProcess::updateInfo(parameter);
			LOG4CXX_DEBUG(_logger, "ParamTableProcess::updateInfo - " << parameter.getId());

			//Param info
			AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(parameter.getInfoId(),true);

			if (paramInfo != nullptr)
			{
				paramInfo->resetLinkedParamList();
				std::string processDescription = "Table of ";
				processDescription += _paramSPtr->getInfoId();
				processDescription += " dimension ";
				processDescription += std::to_string(_dim);

				paramInfo->setProcessDescription(processDescription);
			}
		}

91edc9c0   Benjamin Renard   Add process to tr...
97
98
	} /* namespace Parameters */
} /* namespace AMDA */