Main.cc 2.74 KB
/**
 * Main.cc
 *  Created on: 15 oct. 2012
 *      Author: AKKA IS
 */


//includes boost
#include <boost/shared_ptr.hpp>

#include "Application.hh"

#include "ParseMainArguments.hh"

// DD_Client_r_lib module includes
#include "TimeUtil.hh"

// Plugin module include
#include "PluginManager.hh"

// Parameters module include
#include "ParameterManager.hh"
#include "Parameter.hh"
#include "Process.hh"
#include "DownloadOutput.hh"
#include "ServicesServer.hh"

// XMLParameterConfigurator module include
#include "XMLParameterConfigurator.hh"

using namespace std;
using namespace AMDA::Main;
using namespace AMDA::Parameters;
using namespace AMDA::ParamOutputImpl::Download;

int amdaOutputASCIIFile(int argc, char *argv[], AMDA::helpers::Properties& /*lProperties*/) {
		int result = AMDA_EXIT_OK;
		boost::shared_ptr<ParseMainArguments> parseArg;

		/// Parse command line parameters
		parseArg = boost::shared_ptr<ParseMainArguments>( new ParseMainArguments(argc, argv));
		if (!parseArg->isStopProcess()) {
			///Create ParameterManager and configuration
			ParameterManager parameterManager;

			double lStartTime = DD_Time2Double(parseArg->getStartTime().c_str());
			double lTimeInt = DD_Time2Double(parseArg->getIntervalTime().c_str());
			std::string emptyStr;
			parameterManager.addInputInterval(lStartTime, lStartTime + lTimeInt, 0, emptyStr, emptyStr, 0);

			///Create Parameter
			parameterManager.createParameter(parseArg->getParamName());

			///Create DownloadOutput
			DownloadOutput* lDownloadOutput = new DownloadOutput(parameterManager);
			ParamOutputSPtr lParamOutput(lDownloadOutput);

			///Configure previous DownloadOutput created
			lDownloadOutput->getDownloadProperties().setFileFormat(OutputFileFormat::ASCII_FILE_FORMAT);
			lDownloadOutput->getDownloadProperties().setTimeFormat( parseArg->getFormatOutputTime());
			lDownloadOutput->setSampling(parseArg->getSamplingMode(), parseArg->getSampling(), parseArg->getGapThreshold());
			lDownloadOutput->getDownloadProperties().setTimeResolution(parseArg->getSampling());

			//Configure parameter
			ParamProperties *paramProperties = new ParamProperties();
			paramProperties->setOriginalId(parseArg->getParamName());
			for (auto clbInfo : parseArg->getCalibrationInfoNameList())
				paramProperties->addCalibrationInfo(clbInfo);

			//Add param properties to download output
			lDownloadOutput->getDownloadProperties().addParamProperties(paramProperties);

			//Add output to the parameter manager
			parameterManager.getParamOutputList().push_back(lParamOutput);

			/// launch request
			parameterManager.execute(parseArg->getWorkPath());
		}
		return result;
	}
/**
 * Main function
 */
int main(int argc, char *argv[]) {

	AMDA::Common::Application lMain;

	return lMain.main(argc,argv,amdaOutputASCIIFile);
}