Skip to content
Snippets Groups Projects
Verified Commit 6ff16d56 authored by Tobias Triffterer's avatar Tobias Triffterer :house_with_garden:
Browse files

Add Method to Generate updateExperimentState Command

The ExperimentState class can now put its properties into the update
command. Only the token needs to be added later by the class that
requested the command object.
parent 4c8e29e2
No related branches found
No related tags found
No related merge requests found
Pipeline #2926 passed with stage
in 47 seconds
......@@ -34,5 +34,33 @@ ExperimentState::ExperimentState(const uint64_t experimentId)
ExperimentState::PressureTorr ExperimentState::convertHectoPascalToTorr(const PressureHectoPascal& pressure)
{
return pressure*76000.0/101325.0;
return pressure * 76000.0 / 101325.0;
}
Protocol::Command ExperimentState::getStateCommand() const
{
const QString adcstate = (adcState == AdcState::Running) ? QStringLiteral("running") : QStringLiteral("stopped");
const QString beamhole = [this]() -> QString {
switch (beamHoleState) {
case BeamHoleState::Closed:
default:
return QStringLiteral("closed");
case BeamHoleState::Open:
return QStringLiteral("open");
case BeamHoleState::GoldFoil:
return QStringLiteral("goldfoil"); }
}();
return Protocol::Command(
Protocol::Action::updateExperimentState,
Protocol::Command::Arguments {
std::make_pair(QStringLiteral("adcstate"), adcstate),
std::make_pair(QStringLiteral("beamhole"), beamhole),
std::make_pair(QStringLiteral("pressurehPa"), QString::number(pressure)),
std::make_pair(QStringLiteral("targetposition"), QString::number(targetPosition)),
std::make_pair(QStringLiteral("adcthreshold"), QString::number(adcThreshold)),
std::make_pair(QStringLiteral("vacuumvalve"), QString::number(vacuumValve))
},
QString() // Token will be added by class that requested the Command object
);
}
......@@ -30,6 +30,7 @@
#include <cinttypes>
#include "boundednumeral.h"
#include "command.h"
#include "fp311online_export.h"
namespace Fp311Online
......@@ -68,6 +69,8 @@ public:
static PressureTorr convertHectoPascalToTorr(const PressureHectoPascal& pressure);
Protocol::Command getStateCommand() const;
ExperimentState() = default;
ExperimentState(const uint64_t experimentId);
~ExperimentState() = default;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment