Commit 0612d73d authored by Abdelali Elaazzouzi's avatar Abdelali Elaazzouzi

Merge branch 'V3.2_191' of https://code.ill.fr/instrument-control/nomad-modules.git into V3.2_191

parents 4b5af2ff 742450ce
......@@ -262,9 +262,15 @@ void DopplerFullAcquisitionController::updateParams() {
* actual values back from the hardware
*/
if (useMasterAcq() == true) {
m_MasterAcqDriver.execute(GateCommon::READ_PARAMETERS_COMMAND, true);
actualT2TofValidation.update(m_MasterAcqDriver->actualChannelWidthsArray()[m_MasterAcqBlockIndex] * 1000000);
actualT1Delay.update(m_MasterAcqDriver->actualDelaysArray()[m_MasterAcqBlockIndex] * 1000000);
// Modification of 16/09/2019 -> No need to read values because they will be always the same as the setpoint.
// m_MasterAcqDriver.execute(GateCommon::READ_PARAMETERS_COMMAND, true);
// actualT2TofValidation.update(m_MasterAcqDriver->actualChannelWidthsArray()[m_MasterAcqBlockIndex] * 1000000);
// actualT1Delay.update(m_MasterAcqDriver->actualDelaysArray()[m_MasterAcqBlockIndex] * 1000000);
actualT2TofValidation.update(wantedT2TofValidation());
actualT1Delay.update(wantedT1Delay());
} else {
// Sender<ClientCommand>::begin();
// for (long i = 0; i < m_nDrivers; ++i) {
......
......@@ -24,16 +24,11 @@ namespace acquisition {
const std::string RemoteAcquisitionController::TYPE = "remoteacquisition_setup";
const string RemoteAcquisitionController::TIME_MODE = "time";
const string RemoteAcquisitionController::HOUR = "h";
const string RemoteAcquisitionController::MINUTE = "m";
const string RemoteAcquisitionController::SECOND = "s";
/*
* Constructor
*/
RemoteAcquisitionController::RemoteAcquisitionController(const string& name) :
AcquisitionController(name) , controller::SynchronizeRead(this) {
TimeAcquisitionController(name) {
/*
* Register properties
......@@ -64,27 +59,9 @@ RemoteAcquisitionController::RemoteAcquisitionController(const string& name) :
void RemoteAcquisitionController::postConfiguration() {
cout << "start postConfiguration" << endl;
AcquisitionController::postConfiguration();
TimeAcquisitionController::postConfiguration();
cout << "end postConfiguration" << endl;
// Copy local ptr for setting the write type cast
if (useMasterAcq() == true) {
m_TimeGateDriver.copy(m_MasterAcqDriver);
}
else {
m_TimeGateDriver.copy(m_GateDriver);
}
cout << "end copy" << endl;
registerUpdater(m_TimeGateDriver->time, &RemoteAcquisitionController::updateActualTime, this);
cout << "end registerUpdater" << endl;
}
/*
* updateActualTime
*/
void RemoteAcquisitionController::updateActualTime() {
time.update(m_TimeGateDriver->time());
}
/*
......@@ -117,6 +94,9 @@ void RemoteAcquisitionController::startCounting() {
statusMessage.update("Counting");
ostringstream s1;
s1 << remoteCommand() << " " << actual_numor << " " << remoteParameters();
log(Level::s_Debug) << name << "execute: " << s1.str() << endlog;
::system(s1.str().c_str());
// Write data file
......@@ -130,55 +110,14 @@ void RemoteAcquisitionController::startCounting() {
s2 << "Numor: " << actual_numor << " Parameters: " << remoteParameters();
log(Level::s_Info) << name << cursor << s2.str() << endlog;
m_TimeGateDriver->mode = GateCommon::TIME_MODE;
float64 factor = 1.;
if (timeType() == RemoteAcquisitionController::HOUR) {
factor = 3600.;
} else if (timeType() == RemoteAcquisitionController::MINUTE) {
factor = 60.;
}
m_TimeGateDriver->time.setpoint = time.setpoint() * factor;
// Start gate
m_TimeGateDriver.execute(driver::START_COMMAND, true);
}
/*
* stop
*/
void RemoteAcquisitionController::stop() {
m_TimeGateDriver.execute(driver::STOP_COMMAND, false);
}
/*
* pause
*/
void RemoteAcquisitionController::pause() {
m_TimeGateDriver.execute(driver::PAUSE_COMMAND, false);
}
/*
* resume
*/
void RemoteAcquisitionController::resume() {
m_TimeGateDriver.execute(driver::RESUME_COMMAND, false);
}
/*
* synchronizeRead
*/
void RemoteAcquisitionController::synchronizeRead() {
m_TimeGateDriver.execute(driver::SYNCHRONIZE_READ_COMMAND, true);
TimeAcquisitionController::startCounting();
}
void RemoteAcquisitionController::resize() throw (CannotOpenFile, SlicesFileError, TooManySlices, SliceTooBig) {}
void RemoteAcquisitionController::writeParams() {}
void RemoteAcquisitionController::updateParams() {}
bool RemoteAcquisitionController::useEnergy() const {}
bool RemoteAcquisitionController::useEnergy() const {
return false;
}
}
......@@ -19,7 +19,7 @@
#ifndef ACQUISITION_REMOTEACQUISITIONCONTROLLER_H
#define ACQUISITION_REMOTEACQUISITIONCONTROLLER_H
#include "AcquisitionController.h"
#include "TimeAcquisitionController.h"
#include "../gate/TimeGateCommon.h"
#include "../ExperimentData.h"
......@@ -29,7 +29,7 @@ namespace acquisition {
* \class RemoteAcquisitionController
* \brief Abstract class described the acquisition mode
*/
class RemoteAcquisitionController : public AcquisitionController , public controller::SynchronizeRead {
class RemoteAcquisitionController : public TimeAcquisitionController {
public:
......@@ -58,14 +58,8 @@ public:
Property<std::string> datafileConfig;
Property<std::string> timeType;
static const std::string TIME_MODE;
static const std::string HOUR;
static const std::string MINUTE;
static const std::string SECOND;
protected:
DriverPtr<TimeGateCommon> m_TimeGateDriver;
ControllerPtr<ExperimentData> m_ExperimentData;
/*!
......@@ -73,30 +67,7 @@ protected:
*/
virtual void startCounting();
/*!
* \brief Stop command
*/
virtual void stop();
private :
void updateActualTime();
/*!
* \brief Pause command
*/
virtual void pause();
/*!
* \brief resume command
*/
virtual void resume();
/*!
* \brief synchronize read command
*/
virtual void synchronizeRead();
virtual void resize() throw (CannotOpenFile, SlicesFileError, TooManySlices, SliceTooBig);
virtual void writeParams();
virtual void updateParams();
......
remoteacquisition_setup.remote_command=Command
remoteacquisition_setup.remote_parameters=Parameters
\ No newline at end of file
<plugin default_command_role="remoteacquisition_setup1" default_command_name="count">
<controller type="remoteacquisition_setup" role="remoteacquisition_setup1"/>
<number_of_lines nb_lines="2"/>
<text role="remoteacquisition_setup1" property="remote_command" prefix="remoteacquisition_setup.remote_command"/>
<newLine/>
<text role="remoteacquisition_setup1" property="remote_parameters" prefix="remoteacquisition_setup.remote_parameters"/>
</plugin>
<controller_plugin_config type="remoteacquisition_setup">
<image key="ACQUISITION"/>
<settings view="remoteacquisition_setupView.xml"/>
<command view="remoteacquisition_setupCommandView.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="remoteacquisition_setup">
<property name="remote_command" type="String" max_length="50">
</property>
<property name="remote_parameters" type="String" max_length="50">
</property>
</controller>
<plugin>
<controller type="remoteacquisition_setup" role="remoteacquisition_setup1"/>
<text role="remoteacquisition_setup1" property="remote_command" prefix="remoteacquisition_setup.remote_command"/>
<newLine/>
<text role="remoteacquisition_setup1" property="remote_parameters" prefix="remoteacquisition_setup.remote_parameters"/>
</plugin>
/*
* 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 describes the cryopad stuff
* \author J. Locatelli
* \date 06-09-2019
*/
#include "HomingController.h"
#include "controllers/common/family/Families.h"
#include <InstrumentManager/InstrumentManager.h>
using namespace std;
namespace axis {
const string HomingController::TYPE = "axis_homing_controller";
const char HomingController::IDLE[] = "Idle";
const char HomingController::MOVE_TO_LOW_SWITCH[] = "Move to Low switch";
const char HomingController::MOVE_TO_HIGH_SWITCH[] = "Move to High switch";
const char HomingController::SET_REFERENCE_POSITION[] = "Set Reference Position";
const char HomingController::MOVE_TO_POSITION[] = "Move to Final Position";
const char HomingController::STOPPED[] = "Stopped";
const char HomingController::FINISHED[] = "Finished";
const char HomingController::NOT_CONFIGURED[] = "Not Configured";
/*
* Constructor
*/
HomingController::HomingController(const string& name) :
ExperimentController(name), controller::Stoppable(this), controller::Pausable(this) {
setFamily(family::AXIS, family::SETTING);
registerFunction(TYPE);
nbAxis.init(this, SAVE, "nb_axis");
names.init(this, SAVE, "names");
doAxis.init(this, SAVE, "do_axis");
switchTypes.init(this, SAVE, "switch_types");
refPositions.init(this, SAVE, "ref_positions");
movePositions.init(this, SAVE, "move_positions");
statusMessage.init(this, NOSAVE, "status_message");
// Do here because need to init a role peharps
registerRefresher(nbAxis, &HomingController::refreshNbAxisProperty, this);
}
/*
* Destructor
*/
HomingController::~HomingController() {
}
/*
* refreshNElementsProperty
*/
void HomingController::refreshNbAxisProperty(int32 value) throw (CannotSetValue) {
names.resize(value);
doAxis.resize(value);
switchTypes.resize(value);
refPositions.resize(value);
movePositions.resize(value);
statusMessage.resize(value);
m_Axis.resize(value);
}
/*
* postConfiguration
*/
void HomingController::postConfiguration() {
for (int32 i = 0; i < nbAxis(); ++i) {
try {
m_Axis[i] = dynamic_cast<axis::AxisController*>(InstrumentManager::getInstance()->getExperimentController(names(i)));
}
catch (...) {
}
if (m_Axis[i] == nullptr) {
statusMessage.update(i, NOT_CONFIGURED);
}
else {
statusMessage.update(i, IDLE);
}
}
}
/*
* start
*/
void HomingController::start() {
commandProgression = 0;
commandStatus.setRunning();
log(Level::s_Info) << "started" << endlog;
try {
for (int32 i = 0; i < nbAxis(); ++i) {
if (m_Axis[i] != nullptr) {
if (doAxis(i) == true) {
if (isStopped() == true) {
break;
}
if (switchTypes(i) == SWITCH_LOW) {
statusMessage.update(i, MOVE_TO_LOW_SWITCH);
m_Axis[i]->moveToLowSwitchCommand(true);
}
else if (switchTypes(i) == SWITCH_HIGH) {
statusMessage.update(i, MOVE_TO_HIGH_SWITCH);
m_Axis[i]->moveToHighSwitchCommand(true);
}
else {
commandStatus.setError();
commandProgression = 100;
return;
}
commandProgression = 100 / (nbAxis() * 2) ;
if (isStopped() == true) {
break;
}
statusMessage.update(i, SET_REFERENCE_POSITION);
m_Axis[i]->referencePosition = refPositions(i);
m_Axis[i]->writeEncoderCommand(true);
if (isStopped() == true) {
break;
}
statusMessage.update(i, MOVE_TO_POSITION);
m_Axis[i]->position.setpoint = movePositions(i);
m_Axis[i]->startCommand(true);
if (isStopped() == true) {
break;
}
statusMessage.update(i, IDLE);
commandProgression = 100 / (nbAxis() * 2) + 100 / nbAxis();
}
if (isStopped() == true) {
statusMessage.update(i, STOPPED);
break;
}
}
if (isStopped() == true) {
break;
}
}
} catch (...) {
commandStatus.setError();
}
commandProgression = 100;
}
/*
* stop
*/
void HomingController::stop() {
log(Level::s_Info) << "stopped" << endlog;
for (int32 i = 0; i < nbAxis(); ++i) {
if (m_Axis[i] != nullptr) {
m_Axis[i]->stopParallel(true);
}
}
}
/*
* pause
*/
void HomingController::pause() {
if (isStarted() == true) {
log(Level::s_Info) << "pause" << endlog;
for (int32 i = 0; i < nbAxis(); ++i) {
if (m_Axis[i] != nullptr) {
if (m_Axis[i]->isStarted()) {
m_Axis[i]->pauseParallel(true);
}
}
}
}
}
/*
* resume
*/
void HomingController::resume() {
if (isPaused() == true) {
log(Level::s_Info) << "continue" << endlog;
for (int32 i = 0; i < nbAxis(); ++i) {
if (m_Axis[i] != nullptr) {
if (m_Axis[i]->isStarted()) {
m_Axis[i]->resumeParallel(true);
}
}
}
}
}
}
/*
* 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 describes
* \author J. Locatelli
* \date 06-09-2019
*/
#ifndef HOMINGCONTROLLER_H
#define HOMINGCONTROLLER_H
#include <Controller.h>
#include "AxisController.h"
namespace axis {
/*!
* \class HomingController
*/
class HomingController: public ExperimentController, public controller::Stoppable, public controller::Pausable {
public:
//! Type of controller
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the experiment controller
*/
HomingController(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~HomingController();
/*!
* \brief Method called before changing the property value
* This method is called after setting configuration during the creation of controller.
*/
virtual void postConfiguration();
Property<int32> nbAxis;
DynamicProperty<std::string> names;
DynamicProperty<bool> doAxis;
DynamicProperty<int32> switchTypes;
DynamicProperty<float64> refPositions;
DynamicProperty<float64> movePositions;
DynamicProperty<std::string> statusMessage;
private:
//! Controller Ptr
std::vector<axis::AxisController* > m_Axis;
virtual void start();
virtual void stop();
virtual void pause();
virtual void resume();
/*!
* \brief Method called before changing the number of axis property value
* \param[in] value the property value
* \throws CannotSetValue the value isn't corrected, or property couldn't be changed
*/
void refreshNbAxisProperty(int32 value) throw (CannotSetValue);
static const int32 SWITCH_LOW = 0;
static const int32 SWITCH_HIGH = 1;
static const char IDLE[];
static const char MOVE_TO_LOW_SWITCH[];
static const char MOVE_TO_HIGH_SWITCH[];
static const char SET_REFERENCE_POSITION[];
static const char MOVE_TO_POSITION[];
static const char STOPPED[];
static const char FINISHED[];
static const char NOT_CONFIGURED[];
};
}
#endif //LADI_HOMINGCONTROLLER_H
......@@ -5,6 +5,7 @@
<controller class="axis::CompositeAxisController"/>
<controller class="axis::ShuttleAxisController"/>
<controller class="axis::GenericChangerController"/>
<controller class="axis::HomingController"/>
<controller class="axis::ShearRateController"/>
<controller class="axis::InOutController"/>
<controller class="axis::SetEncoderController"/>
......
axis_homing_controller.namePrefix=Name
axis_homing_controller.doPrefix=Do Homing
axis_homing_controller.switchTypePrefix=Switch to go
axis_homing_controller.refPositionPrefix=Reference Position
axis_homing_controller.movePositionPrefix=Final Position
axis_homing_controller.statusPrefix=Status
axis_homing_controller.do_axisCheckedValue=true
axis_homing_controller.do_axisUncheckedValue=false
axis_homing_controller.switchLowValue=0
axis_homing_controller.switchLowLabel=Low
axis_homing_controller.switchHighValue=1
axis_homing_controller.switchHighLabel=High
<controller_plugin_config type="axis_homing_controller">
<image key="SETTINGS"/>
<settings view="axis_homing_controllerView.xml">
</settings>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="axis_homing_controller">
<property name="nb_axis" type="int32">
</property>
<dynamic_property size_property="nb_axis" name="names" type="string" max_length="20">
</dynamic_property>
<dynamic_property size_property="nb_axis" name="do_axis" type="boolean">
</dynamic_property>
<dynamic_property size_property="nb_axis" name="switch_types" type="int32">
<specific_values values="0,1"/>
</dynamic_property>
<dynamic_property size_property="nb_axis" name="ref_positions" type="float64" max_length="7">
<decimal_format nb_decimal_places="3"/>
</dynamic_property>
<dynamic_property size_property="nb_axis" name="move_positions" type="float64" max_length="7">
<decimal_format nb_decimal_places="3"/>
</dynamic_property>
<dynamic_property size_property="nb_axis" name="status_message" type="string" max_length="30">
</dynamic_property>
</controller>
<plugin>
<controller type="axis_homing_controller" role="axis_homing_controller1"/>
<table_composite nbColumns="6">
<simple_label prefix="axis_homing_controller.namePrefix"/>
<simple_label prefix="axis_homing_controller.doPrefix"/>
<simple_label prefix="axis_homing_controller.switchTypePrefix"/>
<simple_label prefix="axis_homing_controller.refPositionPrefix"/>
<simple_label prefix="axis_homing_controller.movePositionPrefix"/>
<simple_label prefix="axis_homing_controller.statusPrefix"/>
<dynamic_composite role="axis_homing_controller1" properties="names,do_axis,switch_types,ref_positions, move_positions, status_message">
<property_switcher role="axis_homing_controller1" property="do_axis" switcher_key="axis_homing_controller.do_axisSwitcher"/>
<label role="axis_homing_controller1" property="names"/>
<check role="axis_homing_controller1" property="do_axis" checkBoxValues="axis_homing_controller.do_axis" />
<switchable_composite switch_values="true" switcher_key="axis_homing_controller.do_axisSwitcher">
<combo role="axis_homing_controller1" property="switch_types" valuesAndLabels="axis_homing_controller.switchLow,axis_homing_controller.switchHigh"/>
</switchable_composite>
<switchable_composite switch_values="false" switcher_key="axis_homing_controller.do_axisSwitcher">
<label role="axis_homing_controller1" property="switch_types" valuesAndLabels="axis_homing_controller.switchLow,axis_homing_controller.switchHigh"/>
</switchable_composite>
<switchable_composite switch_values="true" switcher_key="axis_homing_controller.do_axisSwitcher">
<text role="axis_homing_controller1" property="ref_positions"/>
</switchable_composite>
<switchable_composite switch_values="false" switcher_key="axis_homing_controller.do_axisSwitcher">
<label role="axis_homing_controller1" property="ref_positions"/>
</switchable_composite>
<switchable_composite switch_values="true" switcher_key="axis_homing_controller.do_axisSwitcher">
<text role="axis_homing_controller1" property="move_positions"/>
</switchable_composite>