Commit a72e2423 authored by legoc's avatar legoc
Browse files

Updated RemoteMcStas controller for Thales

parent 1a3d1e80
......@@ -29,6 +29,7 @@
#include "controllers/common/acquisition/Count.h"
#include "controllers/common/acquisition/TimeCount.h"
#include "controllers/common/acquisition/mode/TimeAcquisitionController.h"
#include "controllers/common/axis/AxisController.h"
#include <cameo_mcstas_client/sim_result.hh>
#include <cameo_mcstas_client/sim_request_answer.hh>
#include <iostream>
......@@ -42,6 +43,11 @@ using namespace cameo;
const std::string RemoteMcStas::TYPE = "remote_mcstas";
const std::string RemoteMcStas::D11 = "D11";
const std::string RemoteMcStas::D22 = "D22";
const std::string RemoteMcStas::D33 = "D33";
const std::string RemoteMcStas::THALES = "THALES";
const std::string RemoteMcStas::D11_COLLIMATION_TYPE = "d11collimationsetting";
const std::string RemoteMcStas::D22_COLLIMATION_TYPE = "d22collimationsetup";
const std::string RemoteMcStas::D33_COLLIMATION_TYPE = "lsscollimationsetting";
......@@ -151,17 +157,17 @@ void RemoteMcStas::postConfiguration() {
m_instrumentName = title->instrumentName();
// Select instrument.
if (m_instrumentName == "D22") {
if (m_instrumentName == D22) {
m_requestInstrument = panosc::D22;
}
else if (m_instrumentName == "THALES") {
else if (m_instrumentName == THALES) {
m_requestInstrument = panosc::THALES;
}
else if (m_instrumentName == "D11") {
else if (m_instrumentName == D11) {
//m_requestInstrument = panosc::D11;
log(Level::s_Error) << " D11 not yet implemented" << endlog;
}
else if (m_instrumentName == "D33") {
else if (m_instrumentName == D33) {
//m_requestInstrument = panosc::D33;
log(Level::s_Error) << " D33 not yet implemented" << endlog;
}
......@@ -415,7 +421,7 @@ double RemoteMcStas::getWavelength() {
// %'wav' : 6 [angs] (monochromatic) or [1,2,3,4,5,6,....] (array of wavelength bin-centres for tof)
if (m_instrumentName == "THALES") {
if (m_instrumentName == THALES) {
return 3.0;
}
......@@ -431,7 +437,7 @@ double RemoteMcStas::getWavelength() {
double RemoteMcStas::getCollimation() {
// %'col' . : e.g. 12.8, 10.3, 7.8, 5.3, or 2.8 [m]
if (m_instrumentName == "D11") {
if (m_instrumentName == D11) {
lss::CollimationProperties* collimation = dynamic_cast<lss::CollimationProperties*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(D11_COLLIMATION_TYPE, m_Clone));
if (collimation == nullptr) {
log(Level::s_Error) << " Collimation controller is missing" << endlog;
......@@ -439,7 +445,7 @@ double RemoteMcStas::getCollimation() {
}
return collimation->collimation();
}
else if (m_instrumentName == "D22") {
else if (m_instrumentName == D22) {
lss::CollimationProperties* collimation = dynamic_cast<lss::CollimationProperties*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(D22_COLLIMATION_TYPE, m_Clone));
if (collimation == nullptr) {
log(Level::s_Error) << " Collimation controller is missing" << endlog;
......@@ -447,7 +453,7 @@ double RemoteMcStas::getCollimation() {
}
return collimation->selectedColSetup();
}
else if (m_instrumentName == "D33") {
else if (m_instrumentName == D33) {
lss::CollimationProperties* collimation = dynamic_cast<lss::CollimationProperties*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(D33_COLLIMATION_TYPE, m_Clone));
if (collimation == nullptr) {
log(Level::s_Error) << " Collimation controller is missing" << endlog;
......@@ -455,13 +461,37 @@ double RemoteMcStas::getCollimation() {
}
return collimation->collimation();
}
else if (m_instrumentName == "THALES") {
else if (m_instrumentName == THALES) {
return 2.8;
}
return 0;
}
double RemoteMcStas::getA2() {
axis::AxisController* a2 = dynamic_cast<axis::AxisController*>(InstrumentManager::getInstance()->getExperimentController("A2"));
if (a2 != nullptr) {
return a2->position();
}
return 0.0;
}
double RemoteMcStas::getA4() {
axis::AxisController* a4 = dynamic_cast<axis::AxisController*>(InstrumentManager::getInstance()->getExperimentController("A4"));
if (a4 != nullptr) {
return a4->position();
}
return 0.0;
}
double RemoteMcStas::getA6() {
axis::AxisController* a6 = dynamic_cast<axis::AxisController*>(InstrumentManager::getInstance()->getExperimentController("A6"));
if (a6 != nullptr) {
return a6->position();
}
return 0.0;
}
bool RemoteMcStas::getCountTime() {
string countName = m_countSpy->countControllerName();
......@@ -583,8 +613,16 @@ bool RemoteMcStas::initSimulate() {
m_request->set_measurement_time(time);
// Other parameters.
m_request->add_parameter(sim_request::pWAVELENGTH, getWavelength());
m_request->add_parameter(sim_request::pCOLLIMATION, getCollimation());
if (m_instrumentName == THALES) {
m_request->add_parameter(panosc::sim_request::pA2, getA2());
m_request->add_parameter(panosc::sim_request::pA4, getA4());
m_request->add_parameter(panosc::sim_request::pA6, getA6());
}
else {
m_request->add_parameter(sim_request::pWAVELENGTH, getWavelength());
m_request->add_parameter(sim_request::pCOLLIMATION, getCollimation());
}
string materialValue = material();
if (materialValue == MATERIAL_H2O) {
......@@ -707,7 +745,14 @@ void RemoteMcStas::updateData(const sim_result& result) {
log(Level::s_Error) << " Bad detector size: got " << resultSize << ", expected " << detSize << endlog;
}
count->detectors[0]->detSum.update(sum);
if (count->detectors.empty()) {
count->masterDetector->detSum.update(sum);
}
else {
count->detectors[0]->detSum.update(sum);
}
if (!result.wait_pub()) {
......
......@@ -114,6 +114,10 @@ private:
double getWavelength();
double getCollimation();
double getA2();
double getA4();
double getA6();
bool getCountTime();
void stopCount();
void stopRemote();
......@@ -141,6 +145,11 @@ private:
std::unique_ptr<std::thread> m_subscriberThread;
static const std::string D11;
static const std::string D22;
static const std::string D33;
static const std::string THALES;
static const std::string D11_COLLIMATION_TYPE;
static const std::string D22_COLLIMATION_TYPE;
static const std::string D33_COLLIMATION_TYPE;
......
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