mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-10-31 15:47:10 -04:00
12663c1fa1
A regression introduced in v1.5.0-rc1 where PTT on an alternate serial port when using no CAT control is resolved. A regression introduced in v1.5.0-rc1 where the network server field was not being restored in the settings dialog has been resolved. In settings the "Test PTT" button is now styled by checked state. The "Test PTT" button is enabled without needing click "Test CAT" first when no CAT rig control is selected. Various parts of the settings dialog are now disabled when no CAT rig control is selected. These are the "Mode" group, the "Split Operation" group and the "Monitor returns to last used frequency" check box. None of these have any visible impact nor make sense without CAT rig control. Initialization and teardown of rig control internals has been revised to avoid several problems related to timing and when switching between different CAT settings. This includes improvements in having the operating frequency restored between sessions when not using CAT rig control. The initialization of OmniRig connections has been improved, unfortunately it is still possible to get an exception when clicking the "Test CAT" button where just clicking "OK" and leaving the settings dialog will probably work. Some unnecessary CAT commands output during direct rig control have been elided to reduce the level of traffic a little. The handling of some automatically generated free text messages used when the station is a type 2 compound callsign or is working a type 2 compound callsign has been improved. This is related to how a double click on a message of the form "DE TI4/N0URE 73" is double clicked. The new behaviour depends on whether the current "DX Call" matches the call in the message. This resolves the ambiguity as to whether this message is a sign off at the end of a QSO with current operator (a 73 message is generated) or a tail end opportunity where the message should be treated the same as a CQ or QRZ message (WSJT-X QSYs to the frequency, generates messages and selects message one ready to call). This still leaves some potential ambiguous behaviors in this complex area but selecting "Clear DX call and grid after logging" should resolve most of them. Rig control trace messages have been cleaned up and are now more helpful, less verbose and, tidier in the source code. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.5@5297 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
182 lines
4.4 KiB
C++
182 lines
4.4 KiB
C++
#include "PollingTransceiver.hpp"
|
|
|
|
#include <exception>
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QTimer>
|
|
|
|
namespace
|
|
{
|
|
unsigned const polls_to_stabilize {3};
|
|
}
|
|
|
|
PollingTransceiver::PollingTransceiver (int poll_interval)
|
|
: interval_ {poll_interval * 1000}
|
|
, poll_timer_ {nullptr}
|
|
, retries_ {0}
|
|
{
|
|
}
|
|
|
|
void PollingTransceiver::start_timer ()
|
|
{
|
|
if (interval_)
|
|
{
|
|
if (!poll_timer_)
|
|
{
|
|
poll_timer_ = new QTimer {this}; // pass ownership to QObject which handles destruction for us
|
|
|
|
connect (poll_timer_, &QTimer::timeout, this, &PollingTransceiver::handle_timeout);
|
|
}
|
|
poll_timer_->start (interval_);
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::stop_timer ()
|
|
{
|
|
if (poll_timer_)
|
|
{
|
|
poll_timer_->stop ();
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::do_post_start ()
|
|
{
|
|
start_timer ();
|
|
if (!next_state_.online ())
|
|
{
|
|
// remember that we are expecting to go online
|
|
next_state_.online (true);
|
|
retries_ = polls_to_stabilize;
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::do_post_stop ()
|
|
{
|
|
// not much point waiting for rig to go offline since we are ceasing
|
|
// polls
|
|
stop_timer ();
|
|
}
|
|
|
|
void PollingTransceiver::do_post_frequency (Frequency f, MODE m)
|
|
{
|
|
// take care not to set the expected next mode to unknown since some
|
|
// callers use mode == unknown to signify that they do not know the
|
|
// mode and don't care
|
|
if (next_state_.frequency () != f || (m != UNK && next_state_.mode () != m))
|
|
{
|
|
// update expected state with new frequency and set poll count
|
|
next_state_.frequency (f);
|
|
if (m != UNK)
|
|
{
|
|
next_state_.mode (m);
|
|
}
|
|
retries_ = polls_to_stabilize;
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::do_post_tx_frequency (Frequency f, bool /* rationalize */)
|
|
{
|
|
if (next_state_.tx_frequency () != f)
|
|
{
|
|
// update expected state with new TX frequency and set poll
|
|
// count
|
|
next_state_.tx_frequency (f);
|
|
next_state_.split (f); // setting non-zero TX frequency means split
|
|
retries_ = polls_to_stabilize;
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::do_post_mode (MODE m, bool /*rationalize_mode*/)
|
|
{
|
|
// we don't ever expect mode to goto to unknown
|
|
if (m != UNK && next_state_.mode () != m)
|
|
{
|
|
// update expected state with new mode and set poll count
|
|
next_state_.mode (m);
|
|
retries_ = polls_to_stabilize;
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::do_post_ptt (bool p)
|
|
{
|
|
if (next_state_.ptt () != p)
|
|
{
|
|
// update expected state with new PTT and set poll count
|
|
next_state_.ptt (p);
|
|
retries_ = 0; // fast feedback on PTT
|
|
}
|
|
}
|
|
|
|
bool PollingTransceiver::do_pre_update ()
|
|
{
|
|
// if we are holding off a change then withhold the signal
|
|
if (retries_ && state () != next_state_)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void PollingTransceiver::do_sync (bool force_signal)
|
|
{
|
|
poll (); // tell sub-classes to update our
|
|
// state
|
|
|
|
// Signal new state if it is directly requested or, what we expected
|
|
// or, hasn't become what we expected after polls_to_stabilize
|
|
// polls. Unsolicited changes will be signalled immediately unless
|
|
// they intervene in a expected sequence where they will be delayed.
|
|
if (retries_)
|
|
{
|
|
--retries_;
|
|
if (force_signal || state () == next_state_ || !retries_)
|
|
{
|
|
// our client wants a signal regardless
|
|
// or the expected state has arrived
|
|
// or there are no more retries
|
|
force_signal = true;
|
|
}
|
|
}
|
|
else if (force_signal || state () != last_signalled_state_)
|
|
{
|
|
// here is the normal passive polling path
|
|
// either our client has requested a state update regardless of change
|
|
// or sate has changed asynchronously
|
|
force_signal = true;
|
|
}
|
|
|
|
if (force_signal)
|
|
{
|
|
// reset everything, record and signal the current state
|
|
retries_ = 0;
|
|
next_state_ = state ();
|
|
last_signalled_state_ = state ();
|
|
update_complete ();
|
|
}
|
|
}
|
|
|
|
void PollingTransceiver::handle_timeout ()
|
|
{
|
|
QString message;
|
|
|
|
// we must catch all exceptions here since we are called by Qt and
|
|
// inform our parent of the failure via the offline() message
|
|
try
|
|
{
|
|
do_sync (false);
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
message = e.what ();
|
|
}
|
|
catch (...)
|
|
{
|
|
message = tr ("Unexpected rig error");
|
|
}
|
|
if (!message.isEmpty ())
|
|
{
|
|
offline (message);
|
|
}
|
|
}
|