diff --git a/src/experimentstate.cpp b/src/experimentstate.cpp index c819c3792d8905ceca0419908e358193cbd67cc9..c107795f3d6c598cc2bd752277900367a0aa25ea 100644 --- a/src/experimentstate.cpp +++ b/src/experimentstate.cpp @@ -31,3 +31,8 @@ using namespace Fp311Online; ExperimentState::ExperimentState(const uint64_t experimentId) : id(experimentId) {} + +ExperimentState::PressureTorr ExperimentState::convertHectoPascalToTorr(const PressureHectoPascal& pressure) +{ + return pressure*76000.0/101325.0; +} diff --git a/src/experimentstate.h b/src/experimentstate.h index 1aa311e476688c95424088046442c5374f1c07cd..6fe24de91750b2976969936b6acb8d612541f2a0 100644 --- a/src/experimentstate.h +++ b/src/experimentstate.h @@ -53,6 +53,7 @@ public: static const constexpr uint16_t NumberOfAdcChannels = 4096; using PressureHectoPascal = UInt32BoundedDouble<0, 1500>; + using PressureTorr = UInt32BoundedDouble<0, 1130>; // 1500 hPa ≈ 1125 Torr, so 1130 Torr as upper limit should make sure that the conversion from hPa to Torr never fails using TargetPositionMilliMeter = UInt32BoundedDouble<14, 200>; using AdcConversion = GenericBoundedNumeral<uint16_t, uint16_t, 0, NumberOfAdcChannels - 1>; @@ -63,6 +64,8 @@ public: TargetPositionMilliMeter targetPosition = TargetPositionMilliMeter::minimum; AdcConversion adcThreshold = AdcConversion::minimum; + static PressureTorr convertHectoPascalToTorr(const PressureHectoPascal& pressure); + ExperimentState() = default; ExperimentState(const uint64_t experimentId); ~ExperimentState() = default;