ProcessMexVexElsDecode.cc 2.5 KB
/*
 * ProcessMexVexElsDecode.cc
 *
 *  Created on: Oct 14, 2016
 *      Author: elena
 */
#include <stdlib.h>
#include <string>

#include <boost/lexical_cast.hpp>

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

#include "Operation.hh"
#include "ParameterManager.hh"
#include "ProcessMexVexElsDecode.hh"
#include "MexVexElsDecodeCreator.hh"
//#include "MexVexElsDecode.hh"
#include "ParamMgr.hh"
#include "ParameterCreatorFromExpression.hh"

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

namespace AMDA {
namespace Parameters {

  ProcessMexVexElsDecode::ProcessMexVexElsDecode(Parameter &parameter) : MultiParamProcess_CRTP(parameter) {
  }

  ProcessMexVexElsDecode::ProcessMexVexElsDecode(const ProcessMexVexElsDecode& pProcess, Parameter &parameter)
    : MultiParamProcess_CRTP(pProcess,parameter), _energyTableName(pProcess._energyTableName), _inputParamName(pProcess._inputParamName)  {
  }

  ProcessMexVexElsDecode::~ProcessMexVexElsDecode() {
  }

  void ProcessMexVexElsDecode::parse() {
  	ParameterCreatorFromExpression creator(_parameter.getParameterManager());
  	ParameterSPtr lParameter = creator.getOneParameterFromExpression(_parameter,_expression);
  	_paramNameList[lParameter->getId()].first = lParameter;
	_inputParamName = lParameter->getId();
  	if (_attributList.size() != 1) {
  		BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessMexVexElsDecode::parse require one attribute'")));
  	}
	if (_attributList[0] != _expression) {
		lParameter = creator.getOneParameterFromExpression(_parameter,_attributList[0]);
		_paramNameList[lParameter->getId()].first = lParameter;
		_energyTableName = lParameter->getId();
	}
	else {
		_energyTableName = lParameter->getId();
	}
  }

  void ProcessMexVexElsDecode::establishConnection() {
  	parse();
  	MultiParamProcess::establishConnection();
  }

  TimeStamp  ProcessMexVexElsDecode::init() {
	
	TimeStamp timeStamp = MultiParamProcess::init();

	ParamData* lmainParamInput = _paramNameList[_inputParamName].first->getParamData(this).get();

	ParamData* lenergyTableParamInput = _paramNameList[_energyTableName].first->getParamData(this).get();

	MexVexElsDecodeCreator lMexVexElsDecodeCreator(*this, *lmainParamInput, *lenergyTableParamInput);
	_operation = lMexVexElsDecodeCreator.getOperation();	
	_paramData = ParamDataSPtr(_operation->getParamOutput());
	_paramData->setMinSampling(lmainParamInput->getMinSampling());

	return timeStamp;
}

} /* namespace Parameters */
} /* namespace AMDA */