Commit 13c22fde authored by yannick legoc's avatar yannick legoc
Browse files

Added scan data in VEXPController

parent 480b56c2
...@@ -123,6 +123,8 @@ VEXPController::VEXPController(const string& name) : ...@@ -123,6 +123,8 @@ VEXPController::VEXPController(const string& name) :
a6Controller.init(this, "A6"); a6Controller.init(this, "A6");
scanController.init(this, "scan"); scanController.init(this, "scan");
vexpDetector.init(this, "vexp_detector");
} }
VEXPController::VEXPController(const VEXPController& controller) : VEXPController::VEXPController(const VEXPController& controller) :
...@@ -244,6 +246,8 @@ void VEXPController::updateScanStatus() { ...@@ -244,6 +246,8 @@ void VEXPController::updateScanStatus() {
updateFloat64PropertyValue(kfScan, kf()); updateFloat64PropertyValue(kfScan, kf());
updateInt32PropertyValue(fxScan, fx()); updateInt32PropertyValue(fxScan, fx());
updateInt32PropertyValue(ssScan, ss()); updateInt32PropertyValue(ssScan, ss());
m_scanData.clear();
} }
} }
else { else {
...@@ -251,6 +255,21 @@ void VEXPController::updateScanStatus() { ...@@ -251,6 +255,21 @@ void VEXPController::updateScanStatus() {
} }
} }
void VEXPController::updateDetector() {
// Update the scan data.
int i = scanController->actualStep.get(0);
if (i >= m_scanData.size()) {
m_scanData.resize(i);
}
if (i > 0) {
m_scanData[i - 1] = vexpDetector->detSum();
}
}
void VEXPController::updateProperties() { void VEXPController::updateProperties() {
// Copy the values. // Copy the values.
...@@ -390,6 +409,8 @@ void VEXPController::postConfiguration() { ...@@ -390,6 +409,8 @@ void VEXPController::postConfiguration() {
registerUpdater(scanController->nSteps, &VEXPController::updateNbPoints, this); registerUpdater(scanController->nSteps, &VEXPController::updateNbPoints, this);
registerStatus(scanController, &VEXPController::updateScanStatus, this); registerStatus(scanController, &VEXPController::updateScanStatus, this);
registerUpdater(vexpDetector->idata, &VEXPController::updateDetector, this);
updateProperties(); updateProperties();
m_spyPublisher = application::Publisher::create("vexp_spy"); m_spyPublisher = application::Publisher::create("vexp_spy");
...@@ -553,6 +574,12 @@ std::string VEXPController::getSpyData() { ...@@ -553,6 +574,12 @@ std::string VEXPController::getSpyData() {
writer.Key("nameScan"); writer.Int(scanController->numor()); writer.Key("nameScan"); writer.Int(scanController->numor());
writer.Key("startingTime"); writer.String(scanController->startingTime().c_str()); writer.Key("startingTime"); writer.String(scanController->startingTime().c_str());
writer.Key("dataScan"); writer.StartArray();
for (int i = 0; i < m_scanData.size(); ++i) {
writer.Double(m_scanData[i]);
}
writer.EndArray();
writer.EndObject(); writer.EndObject();
return s.GetString(); return s.GetString();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "controllers/tas/common/IncidentBeam.h" #include "controllers/tas/common/IncidentBeam.h"
#include "controllers/tas/common/TasScatteredBeam.h" #include "controllers/tas/common/TasScatteredBeam.h"
#include "controllers/common/scanlegacy/ParameterizableScan1D.h" #include "controllers/common/scanlegacy/ParameterizableScan1D.h"
#include "VEXPDetectorSimulator.h"
#include <cameo/cameo.h> #include <cameo/cameo.h>
#include <rapidjson/stringbuffer.h> #include <rapidjson/stringbuffer.h>
#include <memory> #include <memory>
...@@ -78,6 +79,8 @@ public: ...@@ -78,6 +79,8 @@ public:
void updateNbPoints(int index); void updateNbPoints(int index);
void updateScanStatus(); void updateScanStatus();
void updateDetector();
virtual void postConfiguration(); virtual void postConfiguration();
private: private:
...@@ -168,6 +171,8 @@ private: ...@@ -168,6 +171,8 @@ private:
std::mutex m_publisherMutex; std::mutex m_publisherMutex;
std::unique_ptr<std::thread> m_periodicUpdateThread; std::unique_ptr<std::thread> m_periodicUpdateThread;
std::vector<float64> m_scanData;
// Controllers. // Controllers.
ControllerPtr<tas::TasSettings> tasSettings; ControllerPtr<tas::TasSettings> tasSettings;
ControllerPtr<tas::Sample> sample; ControllerPtr<tas::Sample> sample;
...@@ -184,6 +189,8 @@ private: ...@@ -184,6 +189,8 @@ private:
ControllerPtr<axis::AxisController> a6Controller; ControllerPtr<axis::AxisController> a6Controller;
ControllerPtr<scan::ParameterizableScan1D> scanController; ControllerPtr<scan::ParameterizableScan1D> scanController;
ControllerPtr<DetectorSimulator> vexpDetector;
}; };
} }
......
...@@ -37,6 +37,8 @@ DetectorSimulator::DetectorSimulator(const string& name) : ...@@ -37,6 +37,8 @@ DetectorSimulator::DetectorSimulator(const string& name) :
simulationFile.init(this, SAVE, "simulation_file"); simulationFile.init(this, SAVE, "simulation_file");
intensity.init(this, NOSAVE, "intensity"); intensity.init(this, NOSAVE, "intensity");
detSum.init(this, NOSAVE, "detector_sum");
idata.init(this, NOSAVE, "idata");
} }
DetectorSimulator::DetectorSimulator(const DetectorSimulator& controller) : DetectorSimulator::DetectorSimulator(const DetectorSimulator& controller) :
...@@ -131,13 +133,18 @@ void DetectorSimulator::updateData() { ...@@ -131,13 +133,18 @@ void DetectorSimulator::updateData() {
m_accessor.querySqwTree(m_dataHandle, h, k, l, e, s); m_accessor.querySqwTree(m_dataHandle, h, k, l, e, s);
//detector->detSum = (scattering->qh() + scattering->qk() + scattering->ql()) * 10.0; // Update the detector sum applying the coef.
//m_detector->detSum = 200.0 - ((m_scattering->qh() - 1.0) * 1000.0); float64 sum = s * m_coef;
detSum = sum;
m_detector->detSum = sum;
m_detector->detSum = s * m_coef; // Increase idata to trigger VEXPController.
idata = idata() + 1;
cout << "updateData " << m_detector->detSum() cout << "updateData " << m_detector->detSum()
<< ", scattering " << m_scattering->qh() << ", " << m_scattering->qk() << ", " << m_scattering->ql() << ", " << m_scattering->en() << endl; << ", scattering " << m_scattering->qh() << ", " << m_scattering->qk() << ", " << m_scattering->ql() << ", " << m_scattering->en() << endl;
} }
} }
...@@ -39,6 +39,8 @@ public: ...@@ -39,6 +39,8 @@ public:
Property<std::string> simulationFile; Property<std::string> simulationFile;
Property<float64> intensity; Property<float64> intensity;
Property<float64> detSum;
Property<int32> idata; // Incremented to trigger the updater of VEXPController.
private: private:
void loadSimulationFile(); void loadSimulationFile();
......
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