Commit c8337b55 authored by Locatelli's avatar Locatelli
Browse files

Add cyclops data path controller

parent ceb77f0e
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "controllers/common/family/Families.h"
#include "CyclopsDataPath.h"
namespace cyclops {
const string CyclopsDataPath::TYPE = "cyclops_datapath";
/*
* Constructor
*/
CyclopsDataPath::CyclopsDataPath(const string& name) :
ExperimentController(name), controller::Start(this) {
setFamily(family::ACQUISITION, family::SETTING);
datapath.init(this, SAVE, "datapath");
dataname.init(this, SAVE, "dataname");
registerFunction(TYPE);
m_CamDriver.init(this, "cammeraDriver");
m_Title.init(this, "title");
}
/*
* Destructor
*/
CyclopsDataPath::~CyclopsDataPath() {
}
/*
* postConfiguration
*/
void CyclopsDataPath::postConfiguration() {
registerUpdater(m_Title->numor, &CyclopsDataPath::updateNumor, this);
updateNumor();
}
/*
* start
*/
void CyclopsDataPath::start() {
m_CamDriver->fileDirectory = datapath();
m_CamDriver->fileName = dataname();
cout << "Dir -> " << datapath() << endl;
cout << "Name -> " << dataname() << endl;
}
/*
* updateNumor
*/
void CyclopsDataPath::updateNumor() {
cout << "Numor -> " << m_Title->numor() << endl;
m_CamDriver->numor = m_Title->numor();
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
/*!
* \brief class cyclops camera data settings
* \author J. Locatelli
* \date 21-11-2019
*/
#ifndef CYCLOPSDATAPATH_H
#define CYCLOPSDATAPATH_H
#include <Controller.h>
#include "controllers/common/acquisition/ExperimentData.h"
#include "drivers/photonic/psl/PslDriver.h"
namespace cyclops {
/*!
* \class cyclops data server path setiing
* \brief Configure data path and name for cyclops data server
*/
class CyclopsDataPath: public ExperimentController, public controller::Start {
public:
//! Type of controller
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the experiment controller
*/
CyclopsDataPath(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~CyclopsDataPath();
/*!
* Properties
*/
Property<std::string> dataname;
Property<std::string> datapath;
private:
/*!
* \brief Method called before changing the property value
* This method is called after setting configuration during the creation of controller.
*/
virtual void postConfiguration();
/*!
* \brief Start command
*/
virtual void start();
void updateNumor();
DriverPtr<psl::PslDriver> m_CamDriver;
ControllerPtr<acquisition::ExperimentData> m_Title;
};
}
#endif //CYCLOPSDATAPATH_H
<module name="cyclops">
<controller class="cyclops::CyclopsDataPath"/>
<controller class="cyclops::CyclopsSetting"/>
<parser class="cyclops::CyclopsParser"/>
<include path="$(NOMAD_HOME)/../NomadModules/src"/>
</module>
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
/*!
* \briefD19 Par command
* \author J.Locatelli
* \date 13-10-2017
*/
#include "CyclopsFileCmd.h"
#include "../CyclopsDataPath.h"
using namespace std;
namespace cyclops {
/*
* Constructor
*/
CyclopsFileCmd::CyclopsFileCmd(AbstractParser* aParser) :
AbstractCmd(aParser) {
// empty
}
/*
* Destructor
*/
CyclopsFileCmd::~CyclopsFileCmd() {
// empty
}
/*
* parse
*/
void CyclopsFileCmd::parse(Items& items) throw (CannotSetValue, CommonCmdDef::BadInput) {
CyclopsDataPath* controller = dynamic_cast<CyclopsDataPath*>(m_Parser->getControllerByType(CyclopsDataPath::TYPE));
if (controller == NULL) {
throw CommonCmdDef::BadInput("Controller " + CyclopsDataPath::TYPE + " not found");
}
++items;
if (items.end() == false) {
if (*items != "=") {
controller->datapath = *items;
}
++items;
if (items.end() == false) {
if (*items != "=") {
controller->dataname = *items;
}
}
}
ostringstream buf1;
buf1 << "Cyclops data directory : " << controller->datapath();
m_Parser->outputText(buf1.str());
m_Parser->outputEndl();
ostringstream buf2;
buf2 << "Cyclops data filename : " << controller->dataname();
m_Parser->outputText(buf2.str());
m_Parser->outputEndl();
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
/*!
* \brief Cyclops File command
* \author J.Locatelli
* \date 13-10-2017
*/
#ifndef CYCLOPSFILECMD_H
#define CYCLOPSFILECMD_H
#include "CommandSystem/CommandLine/Parsers/Common/AbstractCmd.h"
namespace cyclops {
/*!
* \class CyclopsFileCmd
* \brief Cyclops file command
* \par
* This class implement the cyclops ffile command.
*/
class CyclopsFileCmd: public AbstractCmd {
public:
/*!
* \brief Constructor
*/
CyclopsFileCmd(AbstractParser* aParser);
/*!
* \brief Destructor
*/
virtual ~CyclopsFileCmd();
/*!
* \brief Decode the command line
*
* \param[in] items list of item contains on the command line
* \throws bad_any_cast bad cast on boost any property
* \throws BadInput syntax error when paring line
* \throws PropertyNotFound property not found
* \throws ControllerNotFound controller not found
* \throws CannotSetValue could not set property value
*/
virtual void parse(Items& items) throw (CannotSetValue, CommonCmdDef::BadInput);
};
}
#endif // CYCLOPSFILECMD_H
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "controllers/dif/common/commandline/DiffCmdDef.h"
#include "Utilities/StringUtilities.h"
#include <iostream>
#include "CyclopsParser.h"
#include "CyclopsFileCmd.h"
using namespace std;
using namespace boost;
namespace cyclops {
const std::string CyclopsParser::TYPE = "cyclops";
CyclopsParser::CyclopsParser() : DiffParser() {
}
CyclopsParser::~CyclopsParser() {
}
bool CyclopsParser::decode(Items items) throw (CommonCmdDef::BadInput) {
bool found = true;
try {
if (items.end()) {
throw CommonCmdDef::BadInput();
}
if (!(*items).empty()) {
if (AbstractParser::decode(items)) {
// Already done
} else if (StringUtilities::cmp(*items, "file", 4) == true) {
// Par command
CyclopsFileCmd cmd(this);
cmd.parse(items);
} else {
found = DiffParser::decode(items);
}
} else {
found = false;
}
} catch (CannotSetValue& e) {
// Print Error
CommandLineManager::getInstance()->outputError(COMMAND_REFUSED_ERROR, "");
} catch (CommonCmdDef::BadInput& e) {
// Print Error
if (e.noerrormsg == false) {
CommandLineManager::getInstance()->outputError(COMMAND_LINE_ILLEGAL_PARAM, ": " + e.m_Input);
}
} catch (...) {
// Print Error
CommandLineManager::getInstance()->outputError(COMMAND_LINE_ILLEGAL_PARAM, "Unknown error");
}
return found;
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
/*!
* \brief Cyclops Parser implementation
* \author Locatelli
*/
#ifndef CYCLOPSPARSER_H
#define CYCLOPSPARSER_H
#include "controllers/dif/common/commandline/DiffParser.h"
namespace cyclops {
/**
* Class overloading DiffParser.
*/
class CyclopsParser : public dif::DiffParser {
public:
//! Controller type value
static const std::string TYPE;
/**
* Constructor.
*/
CyclopsParser();
/**
* Destructor.
*/
virtual ~CyclopsParser();
/**
* Decode the command line.
* throws BadInput
*/
virtual bool decode(Items items) throw (CommonCmdDef::BadInput);
};
}
#endif
cyclops_datapath.filePrefix=Tif
cyclops_datapath.datapathPrefix=Path
cyclops_datapath.datanamePrefix=Name
\ No newline at end of file
<plugin>
<controller type="cyclops_datapath" role="cyclops_datapath1"/>
<number_of_lines nb_lines="1"/>
<simple_label prefix="cyclops_datapath.filePrefix"/>
<file_text role="cyclops_datapath1" property="datapath" prefix="cyclops_datapath.datapathPrefix"/>
<text role="cyclops_datapath1" property="dataname" prefix="cyclops_datapath.datanamePrefix"/>
</plugin>
<controller_plugin_config type="cyclops_datapath">
<image key="SETTINGS"/>
<settings view="cyclops_datapathView.xml"/>
<command view="cyclops_datapathCommandView.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="cyclops_datapath">
<property name="datapath" type="String" max_length="40">
</property>
<property name="dataname" type="String" max_length="20">
</property>
</controller>
<plugin>
<controller type="cyclops_datapath" role="cyclops_datapath1"/>
<simple_label prefix="cyclops_datapath.filePrefix"/>
<file_text role="cyclops_datapath1" property="datapath" prefix="cyclops_datapath.datapathPrefix"/>
<text role="cyclops_datapath1" property="dataname" prefix="cyclops_datapath.datanamePrefix"/>
</plugin>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment