Commit 24b47b37 authored by Abdelali Elaazzouzi's avatar Abdelali Elaazzouzi
Browse files

next controller

parent 9845c3e0
/*
* 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 <boost/filesystem/operations.hpp>
#include "NextDataPath.h"
using namespace std;
namespace next{
const string NextDataPath::TYPE = "next_datapath";
/*
* Constructor
*/
NextDataPath::NextDataPath(const string& name) :
ExperimentController(name), controller::Start(this) {
setFamily(family::ACQUISITION, family::SETTING);
datadrive.init(this, SAVE, "datadrive");
datapath.init(this, SAVE, "datapath");
dataname.init(this, SAVE, "dataname");
registerFunction(TYPE);
m_CamDriver.init(this, "cammeraDriver");
m_Title.init(this, "title");
}
/*
* Destructor
*/
NextDataPath::~NextDataPath() {
}
/*
* postConfiguration
*/
void NextDataPath::postConfiguration() {
registerUpdater(m_Title->numor, &NextDataPath::updateNumor, this);
updateNumor();
}
/*
* start
*/
void NextDataPath::start() {
commandProgression = 0;
commandStatus.setRunning();
// Create path in /users/data if not existed
boost::filesystem::path path = "/users/data";
path /= datapath();
if (boost::filesystem::is_regular_file(path)) {
log(Level::s_Error) << "error path name existed as regular file " << path.string() << endlog;
commandStatus.setError();
}
else {
if (boost::filesystem::is_directory(path) == false) {
boost::filesystem::create_directory(path);
log(Level::s_Info) << "create local data path " << path.string() << endlog;
}
m_CamDriver->tomoNFolder =datadrive()+":\\"+datapath();
m_CamDriver->tomoNFileName = dataname();
log(Level::s_Info) << "set data path " << datapath() << " and name " << dataname() << endlog;
commandStatus.setIdle();
}
commandProgression = 0;
}
/*
* updateNumor
*/
void NextDataPath::updateNumor() {
m_CamDriver->numor = m_Title->numor();
}
/*
* test
*/
void NextDataPath::test() {
using namespace utilities;
UnitTest test(this);
boost::filesystem::path tmp = "/users/data/NextDataPathTest";
ofstream ofs;
ofs.open(tmp.string().c_str());
if (ofs.is_open()) {
ofs << "TEST" << endl;
ofs.close();
}
datapath = "NextDataPathTest";
dataname = "nomad";
this->startCommand();
test.checkTrue(commandStatus.isError());
boost::filesystem::remove(tmp);
this->startCommand();
test.checkTrue(commandStatus.isIdle());
test.checkTrue(boost::filesystem::is_directory(tmp));
this->startCommand();
test.checkTrue(commandStatus.isIdle());
boost::filesystem::remove(tmp);
}
}
/*
* 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 NEXTDATAPATH_H
#define NEXTDATAPATH_H
#include <Controller.h>
#include "controllers/common/acquisition/ExperimentData.h"
#include "drivers/xactcomputer/XActComputerDriver.h"
namespace next {
/*!
* \class cyclops data server path setiing
* \brief Configure data path and name for cyclops data server
*/
class NextDataPath: 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
*/
NextDataPath(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~NextDataPath();
/*!
* Properties
*/
Property<std::string> dataname;
Property<std::string> datapath;
Property<std::string> datadrive;
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<xactcomputer::XActComputerDriver> m_CamDriver; //! Axis driver link
ControllerPtr<acquisition::ExperimentData> m_Title;
/*!
* \brief implement unitary test
*/
virtual void test();
};
}
#endif //NEXTDATAPATH_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/common/family/Families.h"
#include <boost/lexical_cast.hpp>
#include "NextSetting.h"
using namespace boost;
using namespace std;
namespace next {
const std::string NextSetting::TYPE = "Nextsetting";
const std::string NextSetting::SNAPSHOT_COMMAND = "snapshot";
NextSetting::NextSetting(const string& name) :
ExperimentController(name), controller::Start(this) {
controller::Read::init(this);
setFamily(family::ACQUISITION, family::SETTING);
tomoNFolder.init(this, SAVE, "tomoNFolder");
tomoNFileName.init(this, SAVE, "tomoNFileName");
SnapFileName.init(this, SAVE, "SnapFileName");
numberOfTomos.init(this, SAVE, "numberOfTomos");
numberOfImagesFastTomo .init(this, SAVE, "numberOfImagesFastTomo");
commandtype .init(this, SAVE, "commandtype");
exposureHighSpeed.init(this, SAVE, "exposureHighSpeed");
averageHighSpeed.init(this, SAVE, "averageHighSpeed");
binningHighSpeed.init(this, SAVE, "binningHighSpeed");
tomoType.init(this, SAVE, "tomoType"); ;
tomoNumberOfImages.init(this, SAVE, "tomoNumberOfImages"); ;
m_CamDriver.init(this, "cammeraDriver");
registerFunction(TYPE);
}
NextSetting::~NextSetting() {
}
void NextSetting::postConfiguration() {
// mode=m_CamDriver->acqmode();
//stringmode=MODE[mode()];
// registerRefresher(mode, &NextSetting::refreshMode, this);
// registerUpdater(m_CamDriver->acqmode, &NextSetting::updateMode, this);
}
void NextSetting::start() {
// Test speed BOB
//hbinning.setpoint = 1;
//vbinning.setpoint = 2088;
m_CamDriver->tomoNFolder= tomoNFolder();
m_CamDriver->tomoNFileName=tomoNFileName();
m_CamDriver->SnapFileName=SnapFileName();
m_CamDriver->numberOfTomos=numberOfTomos();
m_CamDriver->numberOfImagesFastTomo=numberOfImagesFastTomo();
m_CamDriver->commandtype=commandtype();
m_CamDriver->exposureHighSpeed=exposureHighSpeed();
m_CamDriver->averageHighSpeed=averageHighSpeed();
m_CamDriver->binningHighSpeed=binningHighSpeed();
m_CamDriver->tomoType=tomoType() ;
m_CamDriver->tomoNumberOfImages=tomoNumberOfImages();
m_CamDriver->execute("writeParam");
}
void NextSetting::refreshMode(int32 value) {
// if (mode.setpoint()==0){
// nbKine=1;
// m_CamDriver->nbSlicesAcq = 1;
// }
}
void NextSetting::updateMode() {
// mode=m_CamDriver->acqmode();
}
void NextSetting::read() {
m_CamDriver->execute(SNAPSHOT_COMMAND);
}
}
/*
* 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 described the camera setting
* \author elaazzouzi
* \date 02-11-2016
*/
#ifndef CAMERASETTING_H
#define CAMERASETTING_H
#include "controllers/common/acquisition/detector/DetectorElement.h"
#include "controllers/common/acquisition/detector/DetectorController.h"
#include "drivers/xactcomputer/XActComputerDriver.h"
#include <Controller.h>
namespace next {
/**
* Class providing the Camera parameters.
*/
class NextSetting : public ExperimentController, public controller::Start,public controller::Read {
public:
//! Type of controller
static const std::string TYPE;
static const std::string BINNING[5];
static const std::string MODE[5];
static const std::string SNAPSHOT_COMMAND;
/**
* Constructor.
*/
NextSetting(const std::string& name);
/**
* Destructor.
*/
virtual ~NextSetting();
/**
* Configuration after controller assignments.
*/
virtual void postConfiguration();
/**
* Start command.
*/
virtual void start();
/**
* Refreshes binning.
*/
void refreshMode(int32 value);
void updateMode();
void updateTemperature();
void read();
//
// Property<int32> hflip;
// Property<int32> vflip;
// Property<int32> rotate;
Property<std::string> tomoNFolder ;
Property<std::string> tomoNFileName ;
Property<std::string> SnapFileName ;
Property<int32> numberOfTomos ;
Property<int32> numberOfImagesFastTomo ;
Property<float64> exposureHighSpeed ;
Property<int32> averageHighSpeed ;
Property<int32> binningHighSpeed ;
Property<int32> tomoType ;
Property<int32> tomoNumberOfImages ;
Property<int32> commandtype ;
DriverPtr<xactcomputer::XActComputerDriver> m_CamDriver; //! Axis driver link
};
}
#endif
#Prefixes
Nextsetting.computerStatusPrefix=Computer Status
# Commands
Nextsetting.writeParam=Write Param
Nextsetting.manualMove=Manual Move
Nextsetting.stop=Stop
Nextsetting.start=Move
Nextsetting.Snap=SnapShot
# Labels
Nextsetting.acquisitionLabel=Acquisition
Nextsetting.acquisitionValue=0
Nextsetting.tomoType=Tomo Type
Nextsetting.tomoNFolder= Folder
Nextsetting.tomoNFileName=Filename
Nextsetting.SnapFileName=File saved
Nextsetting.numberOfTomos=Nb of Tomos
Nextsetting.numberOfImagesFastTomo=Nb images Fast Tomo
Nextsetting.tomoNumberOfImages=Nb images
Nextsetting.exposureHighSpeed=Exposure
Nextsetting.averageHighSpeed=Average
Nextsetting.binningHighSpeed=Binning
Nextsetting.NormalValue=0
Nextsetting.6passValue=1
Nextsetting.NormalRefValue=2
Nextsetting.6passRefValue= 3
Nextsetting.ContinousValue=4
Nextsetting.ContinousRefValue=5
Nextsetting.4passRefValue=6
Nextsetting.NormalLabel=Normal
Nextsetting.6passLabel=6 pass
Nextsetting.NormalRefLabel=NormalRef
Nextsetting.6passRefLabel= 6passRef
Nextsetting.ContinousLabel=Continous
Nextsetting.ContinousRefLabel=ContinousRef
Nextsetting.4passRefLabel=4passRef
<plugin>
<controller type="Nextsetting" role="Nextsetting1" />
<number_of_lines nb_lines="3"/>
<combo role="Nextsetting1" property="tomoType" sortOnLabels="false" valuesAndLabels="Nextsetting.Normal,Nextsetting.6pass,Nextsetting.NormalRef,Nextsetting.6passRef,Nextsetting.Continous,Nextsetting.ContinousRef,Nextsetting.4passRef" />
<text role="Nextsetting1" property="tomoNFolder" prefix="Nextsetting.tomoNFolder" />
<text role="Nextsetting1" property="tomoNFileName" prefix="Nextsetting.tomoNFileName" />
<newLine />
<text role="Nextsetting1" property="numberOfTomos" prefix="Nextsetting.numberOfTomos" />
<text role="Nextsetting1" property="numberOfImagesFastTomo" prefix="Nextsetting.numberOfImagesFastTomo" />
<text role="Nextsetting1" property="tomoNumberOfImages" prefix="Nextsetting.tomoNumberOfImages" />
<newLine />
<text role="Nextsetting1" property="exposureHighSpeed" prefix="Nextsetting.exposureHighSpeed" />
<text role="Nextsetting1" property="averageHighSpeed" prefix="Nextsetting.averageHighSpeed" />
<text role="Nextsetting1" property="binningHighSpeed" prefix="Nextsetting.binningHighSpeed" />
</plugin>
<controller_plugin_config type="Nextsetting">
<image key="HARDWARE_MMODULE"/>
<settings view="NextsettingView.xml"/>
<command view="NextsettingCommandView.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="Nextsetting">
<property name="tomoNFolder" type="string" max_length="20" >
</property>
<property name="tomoNFileName" type="string" max_length="20" >
</property>
<property name="SnapFileName" type="string" max_length="20" >
</property>
<property name="numberOfTomos" type="long">
</property>
<property name="numberOfImagesFastTomo" type="long">
</property>
<property name="commandtype" type="long">
</property>
<property name="exposureHighSpeed" type="double">
</property>
<property name="averageHighSpeed" type="long">
</property>
<property name= "binningHighSpeed" type="long">
</property>
<property name="tomoType" type="long">
</property>
<property name= "tomoNumberOfImages" type="long">
</property>
<property name="computer_status" type="string" max_length="50" >
</property>
<property name="status" type="long">
</property>
</controller>
<plugin>
<controller type="Nextsetting" role="Nextsetting1" />
<group title="Nextsetting.acquisition">
<combo role="Nextsetting1" property="tomoType" sortOnLabels="false" valuesAndLabels="Nextsetting.Normal,Nextsetting.6pass,Nextsetting.NormalRef,Nextsetting.6passRef,Nextsetting.Continous,Nextsetting.ContinousRef,Nextsetting.4passRef" />
<newLine />
<text role="Nextsetting1" property="tomoNFolder" prefix="Nextsetting.tomoNFolder" />
<text role="Nextsetting1" property="tomoNFileName" prefix="Nextsetting.tomoNFileName" />
<newLine />
<text role="Nextsetting1" property="numberOfTomos" prefix="Nextsetting.numberOfTomos" />
<text role="Nextsetting1" property="numberOfImagesFastTomo" prefix="Nextsetting.numberOfImagesFastTomo" />
<newLine />
<text role="Nextsetting1" property="tomoNumberOfImages" prefix="Nextsetting.tomoNumberOfImages" />
<text role="Nextsetting1" property="exposureHighSpeed" prefix="Nextsetting.exposureHighSpeed" />
<newLine />
<text role="Nextsetting1" property="averageHighSpeed" prefix="Nextsetting.averageHighSpeed" />
<text role="Nextsetting1" property="binningHighSpeed" prefix="Nextsetting.binningHighSpeed" />
<newLine />
<text role="Nextsetting1" property="SnapFileName" prefix="Nextsetting.SnapFileName" />
<button role="Nextsetting1" command="read" prefix="Nextsetting.Snap"/>
</group>
</plugin>
\ No newline at end of file
next_datapath.filePrefix=Tif file :
next_datapath.datapathPrefix=Path
next_datapath.datanamePrefix=Name
next_datapath.datadrivePrefix= Drive
next_datapath.fileWarningPrefix=Use Lower Case!
<plugin>
<controller type="next_datapath" role="next_datapath1"/>
<number_of_lines nb_lines="2"/>
<simple_label prefix="next_datapath.filePrefix"/>
<text role="next_datapath1" property="datadrive" prefix="next_datapath.datadrivePrefix"/>
<text role="next_datapath1" property="datapath" prefix="next_datapath.datapathPrefix"/>
<text role="next_datapath1" property="dataname" prefix="next_datapath.datanamePrefix"/>
<newLine/>
</plugin>
<controller_plugin_config type="next_datapath">
<image key="SETTINGS"/>
<settings view="next_datapathView.xml"/>
<command view="next_datapathCommandView.xml"/>
</controller_plugin_config>