Commit b04793f1 authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Same changes now in branch

parent 77368c94
......@@ -30,9 +30,7 @@ D22SampleSequencer::D22SampleSequencer(const std::string& name) :
//init properties
useSpectro.init(this, SAVE, "useSpectro");
spectroController.init(this, "spectro");
}
;
D22SampleSequencer::~D22SampleSequencer() {
}
......@@ -40,13 +38,11 @@ D22SampleSequencer::~D22SampleSequencer() {
void D22SampleSequencer::execute(const string& command, bool blocking, bool logging) { //necessary?
spectroController->mode = QE65000Controller::SEQUENCE;
SampleSequencer::execute(command, blocking, logging);
//testing last measure
//Once the last count is done force to do another spectro measure
if (command == START_COMMAND) {
doLastMeasure();
}
spectroController->mode = QE65000Controller::ALONE;
//cout << "executing command " << command << " in D22SampleSequencer" << endl;
}
void D22SampleSequencer::postConfiguration() {
......@@ -62,19 +58,15 @@ void D22SampleSequencer::updateProperty(ChangeAspect* aChangeAspect) {
if (propertyName == "actual_cha") {
int32 actualSlot = any_cast<int32>(m_sampleChanger->getValue(propertyName));
spectroController->setPlotName(actualSlot);
cout << "Doing count number: " << actualSlot << endl;
actualSlotNumber = actualSlot;
} else if (propertyName == "status_message") {
std::string countStatus = any_cast<std::string>(m_Count->getValue(propertyName));
cout << "count status: " << countStatus << endl;
if (countStatus == "Idle") {
//Get the spectro at the end of each count
getSpectro();
}
} else if (propertyName == "numor") {
cout << "numor property changed: " << endl;
lastNumor = any_cast<int32>(m_Count->getValue(propertyName));
}
}
......@@ -86,19 +78,15 @@ void D22SampleSequencer::refreshSetValue(string propertyName, const boost::any a
void D22SampleSequencer::getSpectro() {
spectroController->start();
//Remember the data copy is delayed
int32 maxSlotNumber = any_cast<int32>(getValue(WANTED_NBPOSITION_PROPERTY)); //move that from here
//Copy data in nexus file (remember it is delayed in one position)
if (actualSlotNumber > 1) {
//Copy data in nexus file
int32 numor = any_cast<int32>(m_Count->getValue("numor"));
NexusDataFile::appendTo(numor - 1, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml");
}
}
void D22SampleSequencer::doLastMeasure() {
//Last measure = move sample (using sampleChanger) + get spectro
//Last measure = move sample (using sampleChanger) + get spectro + save data in nexus file
Sender<ClientCommand>::begin();
Sender<ClientCommand>::post(ClientCommand(m_sampleChanger, START_COMMAND));
Sender<ClientCommand>::endIf();
......@@ -106,8 +94,7 @@ void D22SampleSequencer::doLastMeasure() {
spectroController->start();
int32 numor = any_cast<int32>(m_Count->getValue("numor"));
NexusDataFile::appendTo(numor, "NxD22SpecialServerFile.xml", "NxD22SpecialClientFile.xml");
cout << "adding new data (theoretically) in data file: " << numor << " value of last numor: " << lastNumor << endl;
// cout << "adding new data (theoretically) in data file: " << numor << " value of last numor: " << lastNumor << endl;
}
}
......
......@@ -52,9 +52,6 @@ DualSwitchSpectroController::~DualSwitchSpectroController() {
void DualSwitchSpectroController::postConfiguration() {
registerProgression(spectroController, &DualSwitchSpectroController::updateProgression, this);
//Set up measuring mode in spectro controller
// spectroController->mode = QE65000Controller::SWITCH;
}
void DualSwitchSpectroController::start() {
......@@ -69,9 +66,9 @@ void DualSwitchSpectroController::start() {
executionStatus.update("idle");
int32 cyclesNumber = numberOfCycles();
while (cyclesNumber > 0) {
while (cyclesNumber > 0 && !m_StopActivated) {
cout << "executing cycle: " << cyclesNumber << endl;
commandProgression = (numberOfCycles() - cyclesNumber) * 100 / numberOfCycles();
// First: start switcher -> we begin for LEFT position (== IN)
m_dualSwitcher->setValue(AbstractIOController::IO_WANTED_VALUE_PROPERTY, string(IO_SHUTTER_IN_DEVICE_CONTAINER));
......@@ -127,12 +124,13 @@ void DualSwitchSpectroController::start() {
}
void DualSwitchSpectroController::stop() {
m_StopActivated = true;
commandProgression = 100;
}
void DualSwitchSpectroController::updateProgression() {
int32 progression = 0;
commandProgression = progression;
// int32 progression = 0;
// commandProgression = progression;
}
void DualSwitchSpectroController::updateData() {
......
......@@ -44,13 +44,6 @@ QE65000Controller::QE65000Controller(const std::string& name) :
registerFunction(TYPE);
spectroDriver.init(this, "driver");
}
QE65000Controller::~QE65000Controller() {
......@@ -58,14 +51,18 @@ QE65000Controller::~QE65000Controller() {
void QE65000Controller::postConfiguration() {
//Pass info to the driver
registerRefresher(integrationTime, &QE65000Controller::refreshIntegrationTime, this);
registerRefresher(integrationTime,
&QE65000Controller::refreshIntegrationTime, this);
//Get info from driver
registerUpdater(spectroDriver->yData, &QE65000Controller::updateYData, this);
registerUpdater(spectroDriver->status, &QE65000Controller::updateStatus, this);
registerUpdater(spectroDriver->yData, &QE65000Controller::updateYData,
this);
registerUpdater(spectroDriver->status, &QE65000Controller::updateStatus,
this);
//need to register the progression to see it??
registerProgression(spectroDriver, &QE65000Controller::updateProgression, this);
registerProgression(spectroDriver, &QE65000Controller::updateProgression,
this);
//Set initial property values
spectroStatusMessage.update("UNPLUGGED");
......@@ -99,8 +96,8 @@ void QE65000Controller::updateProgression() {
void QE65000Controller::start() {
commandProgression = 0;
m_StopActivated = false;
cout << "execution mode" << mode() << endl;
if (mode() != SEQUENCE) {
numor.update(0);
}
......@@ -110,9 +107,14 @@ void QE65000Controller::start() {
delete[] yData();
//Take into account number of scans to average
if (scansToAverage() == 0) {
if (scansToAverage() == 1) {
commandProgression = 50;
spectroDriver.execute("start", false); //ask Yannick that!
commandProgression = 75;
//x data
int32 xSize = spectroDriver->xData.getSize();
xData.update(spectroDriver->xData());
......@@ -139,36 +141,48 @@ void QE65000Controller::start() {
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];
}
if (!m_StopActivated) {
commandProgression = i * 100 / scansToAverage();
spectroDriver.execute("start", false);
//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];
//to avoid problems with incorrect initial values initialize content of both arrays to zero
for (int32 j = 0; j < ySize; j++) {
tempYData[j] = 0;
finalYData[j] = 0;
}
}
//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;
//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();
}
}
}
}
int32 xSize = spectroDriver->xData.getSize();
xData.update(spectroDriver->xData());
xData.setSize(xSize);
if (!m_StopActivated) {
int32 xSize = spectroDriver->xData.getSize();
xData.update(spectroDriver->xData());
xData.setSize(xSize);
yData.update(finalYData);
yData.setSize(ySize);
yData.update(finalYData);
yData.setSize(ySize);
//To take those changes into account do the following:
xData.sendEvent();
yData.sendEvent();
//To take those changes into account do the following:
xData.sendEvent();
yData.sendEvent();
}
commandProgression = 99;
spectroDriver.execute("stop", false);
......@@ -178,6 +192,7 @@ void QE65000Controller::start() {
void QE65000Controller::stop() {
spectroDriver.execute("stop", false);
m_StopActivated = true;
commandProgression = 100;
}
......@@ -191,7 +206,7 @@ void QE65000Controller::setPlotName(int32 plotId) {
// plotName.update(plotNameStream.str());
numor.update(plotId);
cout << "setting plotName to: " << plotId << endl;
//cout << "setting plotName to: " << plotId << endl;
}
}
......
......@@ -67,6 +67,9 @@ public:
void setPlotName(int32 plotId);
private:
bool m_StopActivated;
};
......
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