From d63dd8d081a6fcd0715cd13f26df59fb831769d2 Mon Sep 17 00:00:00 2001 From: "Iain R. Learmonth" Date: Sun, 18 Oct 2015 18:51:00 +0100 Subject: Imported Upstream version 1.5.0 --- EmulateSplitTransceiver.hpp | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 EmulateSplitTransceiver.hpp (limited to 'EmulateSplitTransceiver.hpp') diff --git a/EmulateSplitTransceiver.hpp b/EmulateSplitTransceiver.hpp new file mode 100644 index 00000000..d0888715 --- /dev/null +++ b/EmulateSplitTransceiver.hpp @@ -0,0 +1,53 @@ +#ifndef EMULATE_SPLIT_TRANSCEIVER_HPP__ +#define EMULATE_SPLIT_TRANSCEIVER_HPP__ + +#include + +#include "Transceiver.hpp" + +// +// Emulate Split Transceiver +// +// Helper decorator class that encapsulates the emulation of split TX +// operation. +// +// Responsibilities +// +// Delegates all but setting of other (split) frequency to the +// wrapped Transceiver instance. Also routes failure signals from the +// wrapped Transceiver instance to this instances failure signal. +// +// Intercepts status updates from the wrapped Transceiver instance +// and re-signals it with the emulated status. +// +// Generates a status update signal if the other (split) frequency is +// changed, this is necessary since the wrapped transceiver instance +// never receives other frequency changes. +// +class EmulateSplitTransceiver final + : public Transceiver +{ +public: + // takes ownership of wrapped Transceiver + explicit EmulateSplitTransceiver (std::unique_ptr wrapped); + + void start () noexcept override; + void frequency (Frequency, MODE) noexcept override; + void tx_frequency (Frequency, bool rationalise_mode) noexcept override; + void ptt (bool on) noexcept override; + + // forward everything else to wrapped Transceiver + void stop () noexcept override {wrapped_->stop (); Q_EMIT finished ();} + void mode (MODE m, bool /* rationalise */) noexcept override {wrapped_->mode (m, false);} + void sync (bool force_signal) noexcept override {wrapped_->sync (force_signal);} + +private: + void handle_update (TransceiverState); + + std::unique_ptr wrapped_; + Frequency frequency_[2]; // [0] <- RX, [1] <- other + Frequency pre_tx_frequency_; // return to this on switching to Rx + bool tx_; +}; + +#endif -- cgit v1.2.3