diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /OperatingFrequency.hpp | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'OperatingFrequency.hpp')
| -rw-r--r-- | OperatingFrequency.hpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/OperatingFrequency.hpp b/OperatingFrequency.hpp new file mode 100644 index 00000000..f511dc6d --- /dev/null +++ b/OperatingFrequency.hpp @@ -0,0 +1,65 @@ +#ifndef OPERATING_FREQUENCY_HPP +#define OPERATING_FREQUENCY_HPP + +#include <functional> +#include <optional> +#include "Radio.hpp" + +class OperatingFrequency +{ +public: + using Frequency = Radio::Frequency; + using Delta = Radio::FrequencyDelta; + // Acceptance permits a local commit; hardware confirmation arrives separately. + using Request = std::function<bool (Frequency)>; + struct Snapshot { Frequency rx; Frequency tx; Frequency remembered; }; + // Configuration supplies RF frequencies with Doppler correction still applied. + struct Observation + { + bool online; + bool transmitting; + bool split; + Frequency rx; + Frequency tx; + }; + struct Context + { + bool monitoring; + bool monitorAllowed; + bool monitorAtStartup; + bool restore; + bool echo; + Delta rxCorrection; + Delta txCorrection; + }; + struct Transition + { + Snapshot before; + Snapshot after; + std::optional<bool> monitor; + bool restorationAccepted = false; + }; + + explicit OperatingFrequency (Frequency remembered = 0) : remembered_ {remembered} {} + Frequency const& rx () const { return rx_; } + Frequency tx () const { return tx_; } + Frequency remembered () const { return remembered_; } + Snapshot snapshot () const { return {rx_, tx_, remembered_}; } + void loadRemembered (Frequency value) { remembered_ = value; } + bool requestNominal (Frequency, Delta, Request const&); + Transition enableMonitor (Context const&, Request const&); + Transition reconcile (Observation const& previous, Observation const& current, + Context const&, Request const&); + void commitAcceptedTx (Frequency value) { tx_ = value; } + Frequency correctedRx (Delta delta) const { return rx_ + delta; } + Frequency correctedTx (Delta delta) const { return tx_ + delta; } + +private: + void observe (Observation const&, bool monitoring, Delta rxCorrection, + Delta txCorrection); + Frequency rx_ = 0; + Frequency tx_ = 0; + Frequency remembered_; +}; + +#endif |
