Commit 4e11bed0 authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Corrected bugs related to QE65000 driver and controller

parent 13bf7f44
......@@ -76,6 +76,10 @@ CountWithSpectro::~CountWithSpectro() {
delete[] m_yDataArray;
delete[] m_yDataArraySecondChannel;
delete[] m_yDataOddPositionArray;
delete[] m_yDataEvenPositionArray;
delete[] m_yDataArrayToSave;
}
void CountWithSpectro::postConfiguration() {
......@@ -85,6 +89,8 @@ void CountWithSpectro::postConfiguration() {
registerRefresher(numSpectroMeasures, &CountWithSpectro::refreshNumSpectroMeasures, this);
registerRefresher(useSwitcher, &CountWithSpectro::refreshUseSwitcher, this);
registerRefresher(inSequencerMode, &CountWithSpectro::refreshInSequenceMode, this);
registerUpdater(count->subtitle, &CountWithSpectro::updateSubtitle, this);
registerProgression(count, &CountWithSpectro::updateProgression, this);
......@@ -115,6 +121,14 @@ void CountWithSpectro::refreshUseSwitcher(bool value) {
measureDuration.resize(numTotalMeasures());
}
void CountWithSpectro::refreshInSequenceMode(bool inSequenceMode) {
if (inSequenceMode == true) {
spectro->mode = QE65000Controller::SEQUENCE;
} else {
spectro->mode = QE65000Controller::IDLE; // We do not know the mode so leave it as idle
}
}
void CountWithSpectro::updateProgression() {
//commandProgression = count->commandProgression();
}
......@@ -145,7 +159,9 @@ void CountWithSpectro::start() {
initArrays();
commandStatus.setRunning();
spectro->mode = QE65000Controller::COUNT_SINGLE;
if (inSequencerMode() != true) {
spectro->mode = QE65000Controller::COUNT_SINGLE;
}
//Launch count and spectro at the same time
// Run the threads in parallel in a group
......@@ -233,6 +249,8 @@ void CountWithSpectro::startSpectro() {
common::Duration duration = time - formerTime;
measureDuration.set(i, duration.getMilliseconds());
std::cout << "------------> Measure duration " << duration.getMilliseconds() << std::endl;
spectro->startCommand();
int32 ySize = spectro->size();
......@@ -344,7 +362,6 @@ void CountWithSpectro::saveSwitcherSpectroData() {
void CountWithSpectro::saveSpectroDataInShiftedMode() {
int32 size = spectro->size() * numSpectroMeasures();
if (actualPosition() % 2) {
// Save spectrum if there is any
std::copy(m_yDataEvenPositionArray, m_yDataEvenPositionArray + size, m_yDataArrayToSave);
......
......@@ -56,7 +56,6 @@ public:
Property<int32> actualPosition; // Property related to D22SampleSequencer
Property<bool> useSwitcher;
Property<bool> inSequencerMode; // When being in sequencer mode just shift the data two positions
Property<bool> useSequencer;
Property<std::string> timeType;
Property<float64> countTime;
......@@ -66,8 +65,6 @@ public:
Property<int32> ySize;
Property<int32> zSize;
Property<int32> slotNumber;
ArrayProperty<float64> yDataArray;
ArrayProperty<float64> yDataArraySecondChannel;
......@@ -76,6 +73,7 @@ public:
void refreshNumSpectroMeasures(int32 number);
void refreshUseSwitcher(bool value);
void refreshInSequenceMode(bool inSequenceMode);
void updateProgression();
void updateSubtitle();
void update();
......
......@@ -148,8 +148,6 @@ D22SpectroSampleSequencer::D22SpectroSampleSequencer(const D22SpectroSampleSeque
m_yDataArraySecondChannel1 = NULL;
m_yDataArray2 = NULL;
m_yDataArraySecondChannel2 = NULL;
}
void D22SpectroSampleSequencer::postConfiguration() {
......@@ -237,7 +235,8 @@ void D22SpectroSampleSequencer::start() {
commandProgression = 0;
commandStatus.setRunning();
countWithSpectro->useSequencer=true;
countWithSpectro->inSequencerMode = true;
for (int32 i = 0; i < apply_nbSlot; ++i) {
numSlot = i;
try {
......@@ -275,9 +274,7 @@ void D22SpectroSampleSequencer::start() {
m_CountStarted = true;
countWithSpectro->useSwitcher = false; //always in NO switcher mode
countWithSpectro->inSequencerMode = true;
countWithSpectro->slotNumber=i;
countWithSpectro->startCommand();
countWithSpectro->inSequencerMode = false;
m_CountStarted = false;
} else {
log(Level::s_Error) << name << emptycursor << "Cannot start acquisition controller" << endlog;
......@@ -291,7 +288,7 @@ void D22SpectroSampleSequencer::start() {
cerr << "Cannot set value" << endl;
}
}
countWithSpectro->useSequencer=false;
countWithSpectro->inSequencerMode = false;
countWithSpectro->cleanArrays();
......@@ -309,7 +306,7 @@ void D22SpectroSampleSequencer::stop() {
}
}
// log((logging ? Level::s_Info : Level::s_Debug)) << name << emptycursor << "stopped" << endlog;
countWithSpectro->useSequencer=false;
countWithSpectro->inSequencerMode = false;
commandStatus.setWarning();
}
......
/*
* 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 "HplcControllerTest.h"
#include "drivers/knauer/foxy/FoxyR1DriverDef.h"
namespace d22special {
const std::string HplcControllerTest::TYPE = "hplc_test";
const int32 HplcControllerTest::VALVE_LOAD_POS = 1;
const int32 HplcControllerTest::VALVE_INJECT_POS = 2;
const char HplcControllerTest::COLUMN_H[] = "H";
const char HplcControllerTest::COLUMN_D[] = "D";
HplcControllerTest::HplcControllerTest(const std::string& controllerName) :
ExperimentController(controllerName), controller::Stoppable(this) {
columnMeasured.init(this, SAVE | SPY, "column_measured", "Column");
valvePositionForElution.init(this, SAVE, "valve_pos_elution");
valvePositionForEquilibration.init(this, SAVE, "valve_pos_equilibration");
doEquilibrationPhase.init(this, SAVE, "doEquilibration_phase");
equilibrationFlowRate.init(this, SAVE, "equil_flowRate");
elutionFlowRate.init(this, SAVE, "elution_flowRate");
sampleName.init(this, NOSAVE, "sample_name");
sampleVolume.init(this, SAVE, "sample_volume");
samplePosition.init(this, SAVE, "sample_position");
collectSample.init(this, SAVE, "collect_sample");
collectInInitialPos.init(this, SAVE, "collect_in_initial_pos");
fractionVolume.init(this, SAVE, "fraction_volume");
numExposures.init(this, SAVE, "num_exposures");
exposureTime.init(this, SAVE, "exposure_time");
saveCountData.init(this, SAVE, "save_countData");
m_pumpH.init(this, "pumpH");
m_pumpD.init(this, "pumpD");
m_alias.init(this, "alias");
m_collector.init(this, "collector");
m_detector.init(this, "detector");
m_valveH.init(this, "valveH");
m_valveD.init(this, "valveD");
m_valvePOST.init(this, "valvePOST");
m_valveANTE.init(this, "valveANTE");
m_count.init(this, "count");
}
HplcControllerTest::~HplcControllerTest() {
}
void HplcControllerTest::start() {
commandStatus.setRunning();
// (1) Configure all controllers involved
configureControllers();
// (2) Start Injection + Elution in columnMeasured() and Equilibration (if setup) in the other column
// Move valves
m_valveANTE->start();
m_valvePOST->start();
m_valveH->start();
m_valveD->start();
// Start pumps
if (doEquilibrationPhase()) {
m_pumpH->start();
m_pumpD->start();
} else {
if (columnMeasured() == COLUMN_H) {
m_pumpH->start();
} else if (columnMeasured() == COLUMN_D) {
m_pumpD->start();
} else {
// Error
}
}
// Make autozero of detector once the pumps are running
// m_detector->calculateI0();
// Do injection (check order of execution)
m_alias->start();
// Check condition for data acquisition start -> this is done by the detector
// m_detector->flowRate = elutionFlowRate(); // IMPORTANT!! When the thresholdCondition is a slope, the detector needs to know the current flowRate
// Modification 06/02/2019: Start data acquisition measure from the start. Threshold condition ONLY USED to change flow rate.
doDataAcquisition();
// Stop everything
stop();
}
void HplcControllerTest::stop() {
if (m_pumpH->commandStatus.isRunning()) {
m_pumpH->stopParallel();
}
if (m_pumpD->commandStatus.isRunning()) {
m_pumpD->stopParallel();
}
m_detector->stopParallel();
m_count->stopParallel();
// if (m_alias->deviceStatus() != knauer_alias::NO_RUNNING_STATUS) {
//only stop alias if there is a problem
m_alias->stopParallel();
// }
// Pause behaviour of the collector has been changed!
if (m_collector->commandStatus.isRunning()) {
m_collector->stopAtPosition();
}
commandStatus.setIdle();
commandProgression = 100;
log(Level::s_Info) << name << emptycursor << "stopped " << endlog;
}
void HplcControllerTest::configureControllers() {
if (columnMeasured() == COLUMN_H) {
std::cout << "Doing measure in column H" << std::endl;
// ValveANTE = I, valvePOST = L. ValveH + PumpH->Elution + Data Measurement. ValveD + PumpD -> equilibration
// Set up valves
m_valveANTE->valveValue.setpoint = VALVE_INJECT_POS;
m_valvePOST->valveValue.setpoint = VALVE_LOAD_POS;
m_valveH->valveValue.setpoint = valvePositionForElution();
m_valveD->valveValue.setpoint = valvePositionForEquilibration();
// Set up pumps flow rates
m_pumpH->flowRate.setpoint = elutionFlowRate();
m_pumpD->flowRate.setpoint = equilibrationFlowRate();
// timeOutValue = (1.5 * columnVolumeH() / elutionFlowRate()) * 60;
} else if (columnMeasured() == COLUMN_D) {
std::cout << "Doing measure in column D" << std::endl;
// Set up valves
m_valveANTE->valveValue.setpoint = VALVE_LOAD_POS;
m_valvePOST->valveValue.setpoint = VALVE_INJECT_POS;
m_valveH->valveValue.setpoint = valvePositionForEquilibration();
m_valveD->valveValue.setpoint = valvePositionForElution();
// Set up pumps flow rates
m_pumpH->flowRate.setpoint = equilibrationFlowRate();
m_pumpD->flowRate.setpoint = elutionFlowRate();
// timeOutValue = (1.5 * columnVolumeD() / elutionFlowRate()) * 60;
} else {
// ERROR
}
// Set up Injector
m_alias->firstPosition = samplePosition();
m_alias->injectionVolume = sampleVolume();
// Set up Collector (this can be done later during the data acquisition phase)
if (collectSample()) {
m_collector->collectionMode = foxy_r1::TIME_MODE; // Default set up
m_collector->fractionVolume = fractionVolume() * 60; // In seconds
m_collector->flowDelay = 0;
if (collectInInitialPos()) {
m_collector->resetPosition();
}
}
std::cout << "setting flow delay to " << m_collector->flowDelay() << std::endl;
// Set up UV Detector -> simple case NO THRESHOLD
m_detector->timeOfMeasure = (numExposures() * exposureTime()) - 2; // timeOfMeasure is in seconds
// m_detector->timeOutValue = timeOutValue; //in seconds!
// Set up Count
m_count->time.setpoint = exposureTime();
m_count->timeType = "s";
m_count->totalReps = numExposures();
m_count->saveData = saveCountData();
m_count->subtitle = sampleName();
}
void HplcControllerTest::doDataAcquisition() {
// (1) Start collector if collectSample() == true
if (collectSample()) {
m_collector->start();
}
// (2) Do measure
boost::thread_group group;
group.create_thread(boost::bind(&HplcControllerTest::startCount, this));
group.create_thread(boost::bind(&HplcControllerTest::startDetector, this));
// Wait for the termination of the threads
group.join_all();
}
void HplcControllerTest::startCount() {
m_count->startCommand();
}
void HplcControllerTest::startDetector() {
m_detector->doContinuousMeasurement();
}
}
/*
* 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.
*/
#ifndef SRC_CONTROLLERS_LSS_D22SPECIAL_HPLCCONTROLLERTEST_H_
#define SRC_CONTROLLERS_LSS_D22SPECIAL_HPLCCONTROLLERTEST_H_
#include <Controller.h>
#include "controllers/lss/d22/hplc/PumpController.h"
#include "controllers/lss/d22/hplc/AliasController.h"
#include "controllers/lss/d22/hplc/CollectorController.h"
#include "controllers/spectrometer/QE65000Controller.h"
#include "controllers/lss/d22/hplc/HplcValveController.h"
#include "controllers/common/acquisition/TimeCount.h"
namespace d22special {
/*
* THIS CLASS IS USED TO DO TESTS USING THE QE65000 controller as a replacement of the Knauer detector!
*
*/
class HplcControllerTest : public ExperimentController, public controller::Stoppable {
public:
static const std::string TYPE;
HplcControllerTest(const std::string& controllerName);
virtual ~HplcControllerTest();
virtual void start();
virtual void stop();
Property<std::string> columnMeasured;
Property<int32> valvePositionForElution;
Property<int32> valvePositionForEquilibration;
Property<bool> doEquilibrationPhase;
Property<float64> equilibrationFlowRate;
Property<float64> elutionFlowRate;
Property<std::string> sampleName;
Property<std::string> samplePosition;
Property<int32> sampleVolume;
Property<bool> collectSample;
Property<bool> collectInInitialPos;
Property<float64> fractionVolume;
Property<int32> numExposures; // For count management
Property<int32> exposureTime; // For count management
Property<bool> saveCountData; // For count management
ControllerPtr<d22::PumpController> m_pumpH;
ControllerPtr<d22::PumpController> m_pumpD;
ControllerPtr<d22::AliasController> m_alias;
ControllerPtr<d22::CollectorController> m_collector;
ControllerPtr<spectrometer::QE65000Controller> m_detector; // Using QE65000 detector
ControllerPtr<ValveController> m_valveH; // Be careful with the type of valve
ControllerPtr<ValveController> m_valveD;
ControllerPtr<d22::HplcValveController> m_valvePOST;
ControllerPtr<d22::HplcValveController> m_valveANTE;
ControllerPtr<acquisition::TimeCount> m_count;
private:
void configureControllers();
void doDataAcquisition();
void startCount();
void startDetector();
static const int32 VALVE_LOAD_POS;
static const int32 VALVE_INJECT_POS;
static const char COLUMN_H[];
static const char COLUMN_D[];
};
}
#endif /* SRC_CONTROLLERS_LSS_D22SPECIAL_HPLCCONTROLLERTEST_H_ */
......@@ -3,5 +3,4 @@
<controller class="d22special::CountWithSpectro"/>
<controller class="d22special::DualSwitchSpectroController"/>
<controller class="d22special::D22SpectroSampleSequencer"/>
<controller class="d22special::HplcControllerTest" />
</module>
\ No newline at end of file
......@@ -42,10 +42,10 @@ QE65000Controller::QE65000Controller(const std::string& name) :
integrationTime.init(this, SAVE, "integration_time");
xData.init(this, NOSAVE, "x_data");
yData.init(this, NOSAVE, "y_data");
yDataBlock.init(this, NOSAVE, "y_data_block");
// yDataBlock.init(this, NOSAVE, "y_data_block");
size.init(this, SAVE, "size");
blockSize.init(this, SAVE, "block_size");
zSize.init(this, SAVE, "z_size");
// blockSize.init(this, SAVE, "block_size");
// zSize.init(this, SAVE, "z_size");
spectroStatus.init(this, SAVE, "spectro_status");
spectroStatusMessage.init(this, SAVE, "spectro_status_message");
spectroOpenErrorMessage.init(this, SAVE, "spectro_open_error_message");
......@@ -86,7 +86,7 @@ void QE65000Controller::postConfiguration() {
//Get size from driver
size = spectroDriver->size();
zSize = 1;
// zSize = 1;
}
void QE65000Controller::refreshIntegrationTime(int32 time) {
......@@ -228,8 +228,9 @@ void QE65000Controller::setPlotName(int32 plotId) {
}
/*
* This method is called from HPLC system
* This method is called from HPLC system. Delete after tests
*/
/*
void QE65000Controller::doContinuousMeasurement() {
m_StopActivated = false;
......@@ -276,25 +277,26 @@ void QE65000Controller::doContinuousMeasurement() {
xData.sendEvent();
yData.sendEvent();
// Clear content
// tempYData = {0};
}
// Update the content of the vector after each measure
int32 vectorSize = yDataVector.size();
float64* tempYBlockData = new float64[vectorSize];
memset(tempYBlockData, 0, vectorSize * sizeof(float64));
std::copy(yDataVector.begin(), yDataVector.end(), tempYBlockData);
// Once finished copy data in property
int32 vectorSize = yDataVector.size();
float64* tempYBlockData = new float64[vectorSize];
memset(tempYBlockData, 0, vectorSize * sizeof(float64));
yDataBlock.update(tempYBlockData);
yDataBlock.setSize(vectorSize);
std::copy(yDataVector.begin(), yDataVector.end(), tempYBlockData);
blockSize = vectorSize / size();
}
yDataBlock.update(tempYBlockData);
yDataBlock.setSize(vectorSize);
blockSize = vectorSize / size();
// Stop measurement
spectroDriver.execute("stop", false);
}
*/
}
......@@ -46,12 +46,12 @@ public:
Property<std::string> spectroOpenErrorMessage;
Property<int32> scansToAverage;
Property<int32> size;
Property<int32> blockSize;
Property<int32> zSize;
// Property<int32> blockSize;
// Property<int32> zSize;
ArrayProperty<float64> xData;
ArrayProperty<float64> yData;
ArrayProperty<float64> yDataBlock; // This property is used in continuous measurement
// ArrayProperty<float64> yDataBlock; // This property is used in continuous measurement
Property<std::string> mode; // This property is used for nexus files to indicate how was used the spectro when saving the data (when being used with a count)
// possible values are: SEQUENCE, COUNT_SINGLE, COUNT_SWITCHER and idle.
......@@ -65,7 +65,6 @@ public:
virtual void refreshIntegrationTime(int32 integrationTime);
//Important, this allows the connexion with the driver!
DriverPtr<QE65000Driver> spectroDriver;
virtual void start();
......@@ -80,7 +79,8 @@ public:
void setPlotName(int32 plotId);
void doContinuousMeasurement();
// Delete after tests
// void doContinuousMeasurement();
private:
bool m_StopActivated;
......
......@@ -28,20 +28,20 @@ const std::string QE65000Driver::TYPE = "QE65000";
const int32 QE65000Driver::PLUGGED = 1;
const int32 QE65000Driver::UNPLUGGED = 0;
QE65000Driver::QE65000Driver(const std::string& name) : DeviceDriver(name) {
QE65000Driver::QE65000Driver(const std::string& name) : d22::UVDetectorCommon(name) {
registerParentFunction(NONE_FUNCTION); //no parent function
//Register states --> up to now only RealState
//Register states
registerStates(new RealQE65000Driver(this), new SimulatedQE65000Driver(this), new SimulatedQE65000Driver(this));
//Init Properties
integrationTime.init(this, SAVE, "integration_time");
isActive.init(this, SAVE, "isActive");
openError.init(this, NOSAVE, "open_error");
xData.init(this, NOSAVE, "x_data");
yData.init(this, NOSAVE, "y_data");
size.init(this, SAVE, "size");
// xData.init(this, NOSAVE, "x_data");
// yData.init(this, NOSAVE, "y_data");
// size.init(this, SAVE, "size");
//Init functions
registerFunction(NONE_FUNCTION);
......
......@@ -21,10 +21,11 @@
#include <Driver.h>
#include "drivers/legacy/def/DriverErrorDef.h"