Commit 4a0dd059 authored by yannick legoc's avatar yannick legoc
Browse files

Updated D22AutoConfig

parent c470e175
......@@ -39,7 +39,7 @@ const std::string AutoConfig::REMOTE_APPLICATION = "autoconfig";
const std::string AutoConfig::RESPONDER = "responder";
AutoConfig::AutoConfig(const std::string& name) :
ExperimentController(name), controller::Start(this),
ExperimentController(name), controller::Stoppable(this),
m_countSpy(nullptr) {
setFamily(family::ACQUISITION, family::SETTING);
......@@ -70,7 +70,7 @@ AutoConfig::AutoConfig(const std::string& name) :
}
AutoConfig::AutoConfig(const AutoConfig& controller) :
ExperimentController(controller), controller::Start(this),
ExperimentController(controller), controller::Stoppable(this),
m_countSpy(nullptr) {
}
......@@ -89,6 +89,8 @@ AutoConfig::~AutoConfig() {
void AutoConfig::postConfiguration() {
registerProgression(m_d22settings, &AutoConfig::updateProgression, this);
if (m_server.get() == nullptr) {
// Create a new server if it is not already created.
// In case of a simulated server, avoid the real remote endpoint.
......@@ -222,10 +224,18 @@ float64 AutoConfig::getSampleBackground() {
void AutoConfig::start() {
// Start progression.
commandProgression = 0;
commandStatus.setRunning();
if (!initApplication()) {
commandProgression = 100;
commandStatus.setError();
return;
}
commandProgression = 10;
// Start date.
Date begin;
......@@ -271,6 +281,8 @@ void AutoConfig::start() {
int32* data = count->masterDetector->data();
request.set_data(string(reinterpret_cast<const char *>(data), sizeof(int32) * xSize * ySize));
log(Level::s_Debug) << "Calculate" << endlog;
// Send the request.
m_requester->sendTwoBinaryParts(requestType.SerializeAsString(), request.SerializeAsString());
......@@ -311,11 +323,23 @@ void AutoConfig::start() {
sampleParametersString += autoConfigResponse.sampleparameters(i).type() + " " + to_string(autoConfigResponse.sampleparameters(i).value());
sampleParameters = sampleParametersString;
// Intermediate progression.
commandProgression = 50;
log(Level::s_Debug) << "Apply" << endlog;
apply();
// End progression.
commandProgression = 100;
commandStatus.setIdle();
log(Level::s_Info) << "Finished auto settings" << endlog;
}
void AutoConfig::apply() {
// Set D22Settings.
int32 size = resultSize();
for (int i = 0; i < size; ++i) {
if (type.get(i) == wantedType()) {
......@@ -336,6 +360,21 @@ void AutoConfig::apply() {
}
}
}
// Start D22Settings.
m_d22settings->startCommand(true);
}
void AutoConfig::stop() {
m_d22settings->stopCommand();
}
void AutoConfig::updateProgression() {
if (commandStatus.isRunning()) {
if (commandProgression() >= 50) {
commandProgression = 50 + m_d22settings->commandProgression() / 2;
}
}
}
}
......@@ -29,7 +29,7 @@
namespace d22 {
class AutoConfig : public ExperimentController,
public controller::Start {
public controller::Stoppable {
public:
//! Type of controller
......@@ -43,7 +43,9 @@ public:
void apply();
virtual void start();
virtual void stop();
void updateProgression();
Property<std::string> serverEndpoint;
Property<bool> initialized;
......
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