mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 12:23:37 -05:00
2cfbb15b4f
The concept of a nominal receive and transmit frequency has been introduced. This is used as a base frequency for Doppler correction, frequency setting and reporting. The start up frequency is now zero which is updated by the first rig control status report. This needs more work to accommodate calling frequency plus working frequency operation as is used for random MS operation etc.. The main window frequency display now shows the transmit dial frequency while transmitting. The mode changing logic sequence has been changed such that the rig is correctly put into and taken out of split mode as required by the target mode. This also avoids the "other" VFO having its frequency changed when entering a mode that does not use split operating like WSPR. The main window band combo box edit may now be used to input an kHz offset from the current MHz dial frequency. This is intended for setting a sked or working frequency on the VHF and up bands. For example the working frequency for 23cms might be set to 1296MHz and a working frequency of 1296.3MHz would be selected by selecting the 23cms band with the combo box drop down list and then entering 300k into the band combo box edit widget. When using JT4 modes a CTRL+Click on the waterfall adjusts the nominal frequency such that the frequency clicked on becomes the Tx and Rx frequency using the fixed 1000Hz DF that JT4 modes use. This will probably be extended to all QSO modes when used in VHF & up mode. This assumes that 1000Hz is an optimal DF for both Tx and Rx and therefore one can "net" to an off frequency, but visible on the waterfall, caller with one click. Improvements to OmniRig rig control including use of the serial port control lines RTS or DTR, on the CAT serial port used by OmniRig, for PTT control. Incrementing transaction sequence numbers added to messages to and from the rig control thread. This enables round trip status to be tracked and associated with a request. For example a command that might cause several asynchronous status updates can now be tracked in the originating thread such that it is clear which updates are caused by executing the request. This in turn allows updates to be held until the request is complete i.e. the state is consistent with the results of the request. Messages to the rig control thread are now posted as a new state (Transceiver::TransceiverState) object. The rig control thread tracks requests and actions any differences between the prior requests and the new state. The rig control thread is now stored on the heap so that it can be closed down and released as needed. Along with this the rig control close down semantics are better defined avoiding some potential deadlock situations. If the rig is placed into split mode it will be reverted to simplex mode when the rig connection is closed. When using direct rig control via Hamlib, rigs that have A/B VFO arrangements and no method to query the current VFO like many Icoms and the Yaesu FT-817/857/897(D) series now have smarted frequency updating requiring no VFO changes when changing the frequency. This is particularly important when doing Tx Doppler correction to avoid glitches. The implementation of emulated split operating mode ("Fake It") is simplified and improved. A dummy Hamlib transceiver for PTT control on a separate port is no long instantiated if CAT or VOX PTT control is selected. The resolution and any rounding of the rig CAT frequency set and get commands is determined automatically upon opening the rig connection. This is needed to determine the rate of frequency updates for Doppler tracking. It also allows the rig to be more accurately controlled. Frequency calibration is calculated separately for the receive and transmit frequencies. Whether the rig modulation mode should be controlled is now a constructor argument rather than being passed with individual rig control requests. Doppler shift correction is considerably enhanced with simpler controls and much better rig control. A new mode of tracking called "receive only" is introduced for those with rigs that cannot be QSY:ed via CAT when transmitting. Such rigs have a Doppler correction calculated for the middle of the next transmit period just before transmission starts. While using Doppler tracking it is now possible to adjust the sked frequency either using the new kHz offset feature of the main window band combo box or by directly tuning the rig VFO knob while holding down the CTRL key. The astronomical data window that includes Doppler tracking control is now opened and closed using a checkable menu item to avoid it being accidentally closed. Debug configuration rig control diagnostic messages now have a facility argument for clearer and more standardized trace messages. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6590 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
176 lines
5.5 KiB
C++
176 lines
5.5 KiB
C++
#ifndef TRANSCEIVER_BASE_HPP__
|
|
#define TRANSCEIVER_BASE_HPP__
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <QString>
|
|
|
|
#include "Transceiver.hpp"
|
|
|
|
//
|
|
// Base Transceiver Implementation
|
|
//
|
|
// Behaviour common to all Transceiver implementations.
|
|
//
|
|
// Collaborations
|
|
//
|
|
// Implements the Transceiver abstract interface as template methods
|
|
// and provides a new abstract interface with similar functionality
|
|
// (do_XXXXX operations). Provides and calls abstract interface that
|
|
// gets called post the above operations (do_post_XXXXX) to allow
|
|
// caching implementation etc.
|
|
//
|
|
// A key factor is to catch all exceptions thrown by sub-class
|
|
// implementations where the template method is a Qt slot which is
|
|
// therefore likely to be called by Qt which doesn't handle
|
|
// exceptions. Any exceptions are converted to Transceiver::failure()
|
|
// signals.
|
|
//
|
|
// Sub-classes update the stored state via a protected interface.
|
|
//
|
|
// Responsibilities:
|
|
//
|
|
// Wrap incoming Transceiver messages catching all exceptions in Qt
|
|
// slot driven messages and converting them to Qt signals. This is
|
|
// done because exceptions make concrete Transceiver implementations
|
|
// simpler to write, but exceptions cannot cross signal/slot
|
|
// boundaries (especially across threads). This also removes any
|
|
// requirement for the client code to handle exceptions.
|
|
//
|
|
// Maintain the state of the concrete Transceiver instance that is
|
|
// passed back via the Transceiver::update(TransceiverState) signal,
|
|
// it is still the responsibility of concrete Transceiver
|
|
// implementations to emit the state_change signal when they have a
|
|
// status update.
|
|
//
|
|
// Maintain a go/no-go status for concrete Transceiver
|
|
// implementations ensuring only a valid sequence of messages are
|
|
// passed. A concrete Transceiver instance must be started before it
|
|
// can receive messages, any exception thrown takes the Transceiver
|
|
// offline.
|
|
//
|
|
// Implements methods that concrete Transceiver implementations use
|
|
// to update the Transceiver state. These do not signal state change
|
|
// to clients as this is the responsibility of the concrete
|
|
// Transceiver implementation, thus allowing multiple state component
|
|
// updates to be signalled together if required.
|
|
//
|
|
class TransceiverBase
|
|
: public Transceiver
|
|
{
|
|
Q_OBJECT;
|
|
|
|
private:
|
|
enum class Resolution {accurate, round, truncate};
|
|
|
|
protected:
|
|
TransceiverBase (QObject * parent)
|
|
: Transceiver {parent}
|
|
, resolution_ {Resolution::accurate}
|
|
, last_sequence_number_ {0}
|
|
{}
|
|
|
|
public:
|
|
//
|
|
// Implement the Transceiver abstract interface.
|
|
//
|
|
void start (unsigned sequence_number) noexcept override final;
|
|
void set (TransceiverState const&,
|
|
unsigned sequence_number) noexcept override final;
|
|
void stop () noexcept override final;
|
|
|
|
//
|
|
// Query operations
|
|
//
|
|
TransceiverState const& state () const {return actual_;}
|
|
|
|
protected:
|
|
//
|
|
// Error exception which is thrown to signal unexpected errors.
|
|
//
|
|
struct error
|
|
: public std::runtime_error
|
|
{
|
|
explicit error (char const * const msg) : std::runtime_error (msg) {}
|
|
explicit error (QString const& msg) : std::runtime_error (msg.toStdString ()) {}
|
|
};
|
|
|
|
// Template methods that sub classes implement to do what they need to do.
|
|
//
|
|
// These methods may throw exceptions to signal errors.
|
|
virtual int do_start () = 0; // returns resolution, See Transceiver::resolution
|
|
virtual void do_post_start () {}
|
|
|
|
virtual void do_stop () = 0;
|
|
virtual void do_post_stop () {}
|
|
|
|
virtual void do_frequency (Frequency, MODE, bool no_ignore) = 0;
|
|
virtual void do_post_frequency (Frequency, MODE) {}
|
|
|
|
virtual void do_tx_frequency (Frequency, bool no_ignore) = 0;
|
|
virtual void do_post_tx_frequency (Frequency) {}
|
|
|
|
virtual void do_mode (MODE) = 0;
|
|
virtual void do_post_mode (MODE) {}
|
|
|
|
virtual void do_ptt (bool = true) = 0;
|
|
virtual void do_post_ptt (bool = true) {}
|
|
|
|
virtual void do_sync (bool force_signal = false, bool no_poll = false) = 0;
|
|
|
|
virtual bool do_pre_update () {return true;}
|
|
|
|
// sub classes report rig state changes with these methods
|
|
void update_rx_frequency (Frequency);
|
|
void update_other_frequency (Frequency = 0);
|
|
void update_split (bool);
|
|
void update_mode (MODE);
|
|
void update_PTT (bool = true);
|
|
|
|
// Calling this eventually triggers the Transceiver::update(State) signal.
|
|
void update_complete (bool force_signal = false);
|
|
|
|
// sub class may asynchronously take the rig offline by calling this
|
|
void offline (QString const& reason);
|
|
|
|
private:
|
|
void startup ();
|
|
void shutdown ();
|
|
bool maybe_low_resolution (Frequency low_res, Frequency high_res);
|
|
|
|
// use this convenience class to notify in update methods
|
|
class may_update
|
|
{
|
|
public:
|
|
explicit may_update (TransceiverBase * self, bool force_signal = false)
|
|
: self_ {self}
|
|
, force_signal_ {force_signal}
|
|
{}
|
|
~may_update () {self_->update_complete (force_signal_);}
|
|
private:
|
|
TransceiverBase * self_;
|
|
bool force_signal_;
|
|
};
|
|
|
|
TransceiverState requested_;
|
|
TransceiverState actual_;
|
|
TransceiverState last_;
|
|
Resolution resolution_; // rig accuracy
|
|
unsigned last_sequence_number_; // from set state operation
|
|
};
|
|
|
|
// some trace macros
|
|
#if WSJT_TRACE_CAT
|
|
#define TRACE_CAT(FAC, MSG) qDebug () << QString {"%1::%2:"}.arg ((FAC)).arg (__func__) << MSG
|
|
#else
|
|
#define TRACE_CAT(FAC, MSG)
|
|
#endif
|
|
|
|
#if WSJT_TRACE_CAT && WSJT_TRACE_CAT_POLLS
|
|
#define TRACE_CAT_POLL(FAC, MSG) qDebug () << QString {"%1::%2:"}.arg ((FAC)).arg (__func__) << MSG
|
|
#else
|
|
#define TRACE_CAT_POLL(FAC, MSG)
|
|
#endif
|
|
|
|
#endif
|