Commit 6b526cfc authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Some modifications to spectro controller & friends

parent 08e9de46
......@@ -35,13 +35,16 @@ D22SampleSequencer::~D22SampleSequencer() {
}
void D22SampleSequencer::execute(const string& command, bool blocking, bool logging) {//necessary?
spectroController->mode = QE65000Controller::SEQUENCE;
SampleSequencer::execute(command, blocking, logging);
spectroController->mode = QE65000Controller::ALONE;
//cout << "executing command " << command << " in D22SampleSequencer" << endl;
}
void D22SampleSequencer::postConfiguration() {
SampleSequencer::postConfiguration();
//Set up measuring mode in spectro controller
// spectroController->mode = QE65000Controller::SEQUENCE;
}
......
......@@ -34,6 +34,7 @@ DualSwitchSpectroController::DualSwitchSpectroController(const std::string& name
executionStatus.init(this, SAVE, "execution_status");
xData.init(this, SAVE, "x_data");
xLeftData.init(this, SAVE, "x_left_data");
yLeftData.init(this, SAVE, "y_leftData");
yRightData.init(this, SAVE, "y_rightData");
......@@ -51,12 +52,16 @@ DualSwitchSpectroController::~DualSwitchSpectroController() {
void DualSwitchSpectroController::postConfiguration() {
registerProgression(spectroController, &DualSwitchSpectroController::updateProgression, this);
//Set up measuring mode in spectro controller
// spectroController->mode = QE65000Controller::SWITCH;
}
void DualSwitchSpectroController::start() {
m_StopActivated = false;
commandProgression = 0;
spectroController->mode = QE65000Controller::SWITCH;
//Before measuring spectrum check if the spectrometer is plugged in
if (spectroController->isConnected()) {
......@@ -107,7 +112,7 @@ void DualSwitchSpectroController::start() {
//Stop everything
m_dualSwitcher->execute(COMMAND_STOP_DEVICE_CONTAINER, true);
spectroController->stop();
// updateData();
updateData();
cyclesNumber = cyclesNumber - 1;
......@@ -115,7 +120,6 @@ void DualSwitchSpectroController::start() {
commandProgression = 99;
} else {
//here we should indicate the spectrometer is not plugged in
cout << "spectro disconnected" << endl;
executionStatus.update("disconnected");
......@@ -133,18 +137,24 @@ void DualSwitchSpectroController::updateProgression() {
void DualSwitchSpectroController::updateData() {
//should be done with an updater...
int32 xSize = spectroController->xData.getSize();
xData.update(spectroController->xData());
xData.setSize(xSize);
xData.sendEvent();
if (executionStatus() == "Measuring Right") {
int32 xSize = spectroController->xData.getSize();
xData.update(spectroController->xData());
xData.setSize(xSize);
xData.sendEvent();
int32 yRightSize = spectroController->yData.getSize();
yRightData.update(spectroController->yData());
yRightData.setSize(yRightSize);
yRightData.sendEvent();
} else {
//testing two x arrays of data
int32 xSize = spectroController->xData.getSize();
xLeftData.update(spectroController->xData());
xLeftData.setSize(xSize);
xLeftData.sendEvent();
int32 yLeftSize = spectroController->yData.getSize();
yLeftData.update(spectroController->yData());
yLeftData.setSize(yLeftSize);
......
......@@ -33,6 +33,7 @@ public:
Property<std::string> executionStatus;
ArrayProperty<float64> xData;
ArrayProperty<float64> xLeftData;
ArrayProperty<float64> yLeftData;
ArrayProperty<float64> yRightData;
......
......@@ -16,7 +16,6 @@
* limitations under the Licence.
*/
#include "QE65000Controller.h"
namespace spectrometer {
......@@ -26,25 +25,27 @@ const int32 QE65000Controller::ALONE = 0;
const int32 QE65000Controller::SWITCH = 1;
const int32 QE65000Controller::SEQUENCE = 2;
QE65000Controller::QE65000Controller(const std::string& name) : ExperimentController(TYPE, name), controller::Stoppable(this) {
QE65000Controller::QE65000Controller(const std::string& name) :
ExperimentController(TYPE, name), controller::Stoppable(this) {
// force register function to allow the controller to be used by the "classic" UVspectrometer controller.
registerFunction(SHUTTER_EXPERIMENT_CONTROLLER);
integrationTime.init(this, SAVE, "integration_time");
xData.init(this, SAVE, "x_data");
yData.init(this, SAVE, "y_data");
ySize.init(this, SAVE, "y_size");
spectroStatus.init(this, SAVE, "spectro_status");
spectroStatusMessage.init(this, SAVE, "spectro_status_message");
mode.init(this, SAVE, "mode");
plotName.init(this, SAVE, "plot_name");
numor.init(this, SAVE, "numor");
scansToAverage.init(this, SAVE, "scans_average");
registerFunction(TYPE);
spectroDriver.init(this, "driver");
}
QE65000Controller::~QE65000Controller() {
}
......@@ -62,7 +63,7 @@ void QE65000Controller::postConfiguration() {
//Set initial property values
spectroStatusMessage.update("UNPLUGGED");
mode.update(ALONE);
plotName.update("0"); //original value = empty
//plotName.update(""); //original value = empty
}
void QE65000Controller::refreshIntegrationTime(int32 time) {
......@@ -91,24 +92,81 @@ void QE65000Controller::updateProgression() {
void QE65000Controller::start() {
commandProgression = 0;
spectroDriver.execute("start", false); //ask Yannick that!
//x data
int32 xSize = spectroDriver->xData.getSize();
xData.update(spectroDriver->xData());
xData.setSize(xSize);
cout << "execution mode" << mode() << endl;
if (mode() != SEQUENCE) {
numor.update(0);
}
//y data
int32 ySize = spectroDriver->yData.getSize();
yData.update(spectroDriver->yData());
yData.setSize(ySize);
//Delete current arrays
delete[] xData();
delete[] yData();
//To take those changes into account do the following:
xData.sendEvent();
yData.sendEvent();
//Take into account number of scans to average
if (scansToAverage() == 0) {
spectroDriver.execute("start", false); //ask Yannick that!
//x data
int32 xSize = spectroDriver->xData.getSize();
xData.update(spectroDriver->xData());
xData.setSize(xSize);
//y data
int32 yDataSize = spectroDriver->yData.getSize();
yData.update(spectroDriver->yData());
yData.setSize(yDataSize);
//New set y data size
ySize.update(yDataSize);
//To take those changes into account do the following:
xData.sendEvent();
yData.sendEvent();
commandProgression = 99;
spectroDriver.execute("stop", false);
} else {
int32 ySize;
float64* tempYData;
float64* finalYData;
for (int32 i = 0; i < scansToAverage(); i++) {
spectroDriver.execute("start", false); //ask Yannick that!
//During first scan get size of array and initialize everything
if (i == 0) {
ySize = spectroDriver->yData.getSize();
tempYData = new float64[ySize];
finalYData = new float64[ySize];
}
//y data
tempYData = spectroDriver->yData();
for (int32 j = 0; j < ySize; j++) {
finalYData[j] = finalYData[j] + tempYData[j];
if (i == scansToAverage() - 1) {
finalYData[j] = finalYData[j] / scansToAverage();
cout << "final data: " << finalYData[j] << endl;
}
}
}
int32 xSize = spectroDriver->xData.getSize();
xData.update(spectroDriver->xData());
xData.setSize(xSize);
yData.update(finalYData);
yData.setSize(ySize);
//To take those changes into account do the following:
xData.sendEvent();
yData.sendEvent();
commandProgression = 99;
spectroDriver.execute("stop", false);
}
commandProgression = 99;
spectroDriver.execute("stop", false);
}
void QE65000Controller::stop() {
......@@ -126,11 +184,8 @@ void QE65000Controller::setPlotName(int32 plotId) {
// plotName.update(plotNameStream.str());
numor.update(plotId);
cout << "setting plotName to: " << plotId << endl;
//cout << "setting plotName to: " << plotId << endl;
}
}
......@@ -41,6 +41,8 @@ public:
Property<std::string> plotName;
Property<int32> numor;
Property<std::string> spectroStatusMessage;
Property<int32> scansToAverage;
Property<int32> ySize;
ArrayProperty<float64> xData;
ArrayProperty<float64> yData;
......
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