From 576b753ceda94cf2eb3c7326343c6441a51688c0 Mon Sep 17 00:00:00 2001
From: Tobias Triffterer <tobias@ep1.ruhr-uni-bochum.de>
Date: Wed, 11 Aug 2021 00:57:33 +0200
Subject: [PATCH] Show Number of Revolutions for Detector Position

In the real experiment and its manual, the detector position is mainly
measured in revolutions of the axis, one revolution moves the detector
by 2 mm.

To ease the understanding of the manual, the revolution number is added
to the GUI.
---
 src/clientgui.cpp | 2 +-
 src/clientgui.h   | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/clientgui.cpp b/src/clientgui.cpp
index f95b17a..63218e0 100644
--- a/src/clientgui.cpp
+++ b/src/clientgui.cpp
@@ -187,7 +187,7 @@ QString ClientGui::getBeamholeStateString(const ExperimentState::BeamHoleState s
 void ClientGui::displayExperimentState()
 {
     _ui.lblPressureValue->setText(QStringLiteral("%1 hPa\n%2 Torr").arg(_state.pressure).arg(_state.convertHectoPascalToTorr(_state.pressure)));
-    _ui.lblTargetPosition->setText(QStringLiteral("%1 mm from detector").arg(_state.targetPosition));
+    _ui.lblTargetPosition->setText(tr("%1 mm from detector (%L2 revolutions)").arg(_state.targetPosition).arg((_state.targetPosition - PositionZeroRevolutions) / TargetMovementMillimeterPerRevolution));
     _ui.pbValveStatus->setValue(_state.vacuumValve);
     _ui.pbAdcThreshold->setValue(_state.adcThreshold);
 
diff --git a/src/clientgui.h b/src/clientgui.h
index d98dbbf..334a3f7 100644
--- a/src/clientgui.h
+++ b/src/clientgui.h
@@ -66,6 +66,9 @@ public:
     ClientGui& operator=(ClientGui&& other) = delete;
 
 private:
+    static const constexpr double PositionZeroRevolutions = 14;
+    static const constexpr double TargetMovementMillimeterPerRevolution = 2;
+
     const QString _name;
     const QString _token;
     std::unique_ptr<QWebSocket> _socket;
-- 
GitLab