Commit 84242f07 authored by yannick legoc's avatar yannick legoc
Browse files

Intermediate remote lss simulation during counts

parent 78bfc237
......@@ -170,6 +170,7 @@ void RemoteLSSSimulation::postConfiguration() {
if (m_CountSpy != nullptr) {
m_CountSpy->attach(this);
registerUpdater(m_CountSpy->statusMessage, &RemoteLSSSimulation::updateCountStatusMessage, this);
registerUpdater(m_CountSpy->detSum, &RemoteLSSSimulation::updateCountDetSum, this);
updateCountStatusMessage();
}
}
......@@ -895,147 +896,163 @@ void RemoteLSSSimulation::resizeAll(int32 size) {
* updateCountStatusMessage
*/
void RemoteLSSSimulation::updateCountStatusMessage() {
string statusmes = m_CountSpy->statusMessage();
//cout << "status " << statusmes << " " << m_CountSpy << endl;
if (useSimulatedData() == true) {
string statusmes = m_CountSpy->statusMessage();
if (statusmes == acquisition::Count::WRITING_DATA_MESSAGE) {
acquisition::ExperimentData* title =
dynamic_cast<acquisition::ExperimentData*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(
acquisition::ExperimentData::TYPE));
if (title == nullptr) {
log(Level::s_Error) << " missing controller Title in this instrument" << endlog;
updateDataFromSimulation();
}
}
}
void RemoteLSSSimulation::updateDataFromSimulation() {
acquisition::ExperimentData* title =
dynamic_cast<acquisition::ExperimentData*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(
acquisition::ExperimentData::TYPE));
if (title == nullptr) {
log(Level::s_Error) << " missing controller Title in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
// Re-write data to detector controller
acquisition::Count* count = nullptr;
try {
count = dynamic_cast<acquisition::Count*>(InstrumentManager::getInstance()->getExperimentController(
m_CountSpy->countControllerName()));
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller " << m_CountSpy->countControllerName() << " in this instrument"
<< endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
getData();
cout << "received monitor " << m_DataResponse.monitor() << endl;
cout << "received response " << m_DataResponse.datas_size() << endl;
if (count->nMonitors() > 0) {
if (count->monitors[0]->data.getSize() > 0) {
count->monitors[0]->data()[0] = m_DataResponse.monitor();
count->monitors[0]->detSum.update(m_DataResponse.monitor());
}
}
if (m_DataResponse.datas_size() >= 1) {
Data data = m_DataResponse.datas(0);
int32* detdata = count->masterDetector->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == count->masterDetector->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
count->masterDetector->detSum.update(sum);
}
if (title->instrumentName() == "D33") {
if (m_DataResponse.datas_size() >= 2) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector2"));
Data data = m_DataResponse.datas(1);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector2 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
// Re-write data to detector controller
acquisition::Count* count = nullptr;
}
if (m_DataResponse.datas_size() >= 3) {
try {
count = dynamic_cast<acquisition::Count*>(InstrumentManager::getInstance()->getExperimentController(
m_CountSpy->countControllerName()));
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector3"));
Data data = m_DataResponse.datas(2);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller " << m_CountSpy->countControllerName() << " in this instrument"
<< endlog;
log(Level::s_Error) << " missing controller MultiDetector3 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
getData();
cout << "received monitor " << m_DataResponse.monitor() << endl;
cout << "received response " << m_DataResponse.datas_size() << endl;
if (count->nMonitors() > 0) {
if (count->monitors[0]->data.getSize() > 0) {
count->monitors[0]->data()[0] = m_DataResponse.monitor();
count->monitors[0]->detSum.update(m_DataResponse.monitor());
}
}
if (m_DataResponse.datas_size() >= 1) {
Data data = m_DataResponse.datas(0);
int32* detdata = count->masterDetector->data();
}
if (m_DataResponse.datas_size() >= 4) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector4"));
Data data = m_DataResponse.datas(3);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == count->masterDetector->data.getSize()) {
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
count->masterDetector->detSum.update(sum);
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector4 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
if (title->instrumentName() == "D33") {
if (m_DataResponse.datas_size() >= 2) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector2"));
Data data = m_DataResponse.datas(1);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector2 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
}
if (m_DataResponse.datas_size() >= 3) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector3"));
Data data = m_DataResponse.datas(2);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector3 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
}
if (m_DataResponse.datas_size() >= 4) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector4"));
Data data = m_DataResponse.datas(3);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector4 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
}
if (m_DataResponse.datas_size() >= 5) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector5"));
Data data = m_DataResponse.datas(4);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector5 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
if (m_DataResponse.datas_size() >= 5) {
try {
acquisition::DetectorElement* det =
dynamic_cast<acquisition::DetectorElement*>(InstrumentManager::getInstance()->getExperimentController(
"MultiDetector5"));
Data data = m_DataResponse.datas(4);
int32* detdata = det->data();
float64 sum = 0.;
if ((data.sizex() * data.sizey()) == det->data.getSize()) {
for (int32 j = 0; j < data.data_size(); ++j) {
detdata[j] = data.data(j);
sum += detdata[j];
}
}
det->detSum.update(sum);
} catch (InstrumentManager::ControllerNotFound& e) {
log(Level::s_Error) << " missing controller MultiDetector5 in this instrument" << endlog;
commandStatus.setError();
commandProgression = 100;
return;
}
}
}
}
void RemoteLSSSimulation::updateCountDetSum() {
cout << "updateCountDetSum time " << m_CountSpy->time() << endl;
updateDataFromSimulation();
}
}
......@@ -102,6 +102,8 @@ private:
void refreshUseSimulatedDataProperty(bool value) throw(CannotSetValue);
void updateCountStatusMessage();
void updateDataFromSimulation();
void updateCountDetSum();
static const std::string MATLAB_APPLICATION;
static const std::string RESPONDER_NAME;
......
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