Added flag to halt Tx UDP reply

The  reply  can now  be  used  to  turn off  auto  Tx  or to  halt  Tx
immediately. Also enforced the accept UDP requests setting for halt Tx
and set free text message replies.

Merged from the wsjtx-1.5 branch.



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5336 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-05-06 22:25:56 +00:00
parent 3b3ef37848
commit 2e08443d08
7 changed files with 57 additions and 28 deletions

View File

@ -195,6 +195,7 @@ public:
, id_ {id}
, decodes_table_view_ {new QTableView}
, message_line_edit_ {new QLineEdit}
, auto_off_button_ {new QPushButton {tr ("&Auto Off")}}
, halt_tx_button_ {new QPushButton {tr ("&Halt Tx")}}
, mode_label_ {new QLabel}
, dx_call_label_ {new QLabel}
@ -221,9 +222,13 @@ public:
Q_EMIT do_free_text (id_, message_line_edit_->text ());
});
control_layout->addLayout (form_layout);
control_layout->addWidget (auto_off_button_);
control_layout->addWidget (halt_tx_button_);
connect (auto_off_button_, &QAbstractButton::clicked, [this] (bool /* checked */) {
Q_EMIT do_halt_tx (id_, true);
});
connect (halt_tx_button_, &QAbstractButton::clicked, [this] (bool /* checked */) {
Q_EMIT do_halt_tx (id_);
Q_EMIT do_halt_tx (id_, false);
});
content_layout->addLayout (control_layout);
@ -252,7 +257,7 @@ public:
}
Q_SLOT void update_status (QString const& id, Frequency f, QString const& mode, QString const& dx_call
, QString const& report, QString const& tx_mode, bool transmitting)
, QString const& report, QString const& tx_mode, bool tx_enabled, bool transmitting)
{
if (id == id_)
{
@ -261,6 +266,7 @@ public:
frequency_label_->setText ("QRG: " + Radio::pretty_frequency_MHz_string (f));
report_label_->setText ("SNR: " + report);
update_dynamic_property (frequency_label_, "transmitting", transmitting);
auto_off_button_->setEnabled (tx_enabled);
halt_tx_button_->setEnabled (transmitting);
}
}
@ -278,7 +284,7 @@ public:
}
Q_SIGNAL void do_reply (QModelIndex const&);
Q_SIGNAL void do_halt_tx (QString const& id);
Q_SIGNAL void do_halt_tx (QString const& id, bool auto_only);
Q_SIGNAL void do_free_text (QString const& id, QString const& text);
private:
@ -306,6 +312,7 @@ private:
QTableView * decodes_table_view_;
QLineEdit * message_line_edit_;
QAbstractButton * set_free_text_button_;
QAbstractButton * auto_off_button_;
QAbstractButton * halt_tx_button_;
QLabel * mode_label_;
QLabel * dx_call_label_;

View File

@ -126,7 +126,9 @@ void MessageClient::impl::parse_message (QByteArray const& msg)
case NetworkMessage::HaltTx:
if (check_status (in))
{
Q_EMIT self_->halt_tx ();
bool auto_only;
in >> auto_only;
Q_EMIT self_->halt_tx (auto_only);
}
break;
@ -251,14 +253,15 @@ void MessageClient::send_raw_datagram (QByteArray const& message, QHostAddress c
}
void MessageClient::status_update (Frequency f, QString const& mode, QString const& dx_call
, QString const& report, QString const& tx_mode, bool transmitting)
, QString const& report, QString const& tx_mode
, bool tx_enabled, bool transmitting)
{
if (m_->server_port_ && !m_->server_.isNull ())
{
QByteArray message;
NetworkMessage::Builder out {&message, NetworkMessage::Status, m_->id_};
out << f << mode.toUtf8 () << dx_call.toUtf8 () << report.toUtf8 () << tx_mode.toUtf8 ()
<< transmitting;
<< tx_enabled << transmitting;
if (m_->check_status (out))
{
m_->writeDatagram (message, m_->server_, m_->server_port_);

View File

@ -46,7 +46,7 @@ public:
// outgoing messages
Q_SLOT void status_update (Frequency, QString const& mode, QString const& dx_call, QString const& report
, QString const& tx_mode, bool transmitting);
, QString const& tx_mode, bool tx_enabled, bool transmitting);
Q_SLOT void decode (bool is_new, QTime time, qint32 snr, float delta_time, quint32 delta_frequency
, QString const& mode, QString const& message);
Q_SLOT void clear_decodes ();
@ -69,9 +69,9 @@ public:
// all decodes
Q_SIGNAL void replay ();
// this signal is emitted if the server has requested transmission
// to halt immediately
Q_SIGNAL void halt_tx ();
// this signal is emitted if the server has requested immediate (or
// auto Tx if auto_only is true) transmission to halt
Q_SIGNAL void halt_tx (bool auto_only);
// this signal is emitted if the server has requested a new free
// message text

View File

@ -142,13 +142,14 @@ void MessageServer::impl::parse_message (QHostAddress const& sender, port_type s
QByteArray dx_call;
QByteArray report;
QByteArray tx_mode;
bool tx_enabled;
bool transmitting;
in >> f >> mode >> dx_call >> report >> tx_mode >> transmitting;
in >> f >> mode >> dx_call >> report >> tx_mode >> tx_enabled >> transmitting;
if (check_status (in))
{
Q_EMIT self_->status_update (id, f, QString::fromUtf8 (mode), QString::fromUtf8 (dx_call)
, QString::fromUtf8 (report), QString::fromUtf8 (tx_mode)
, transmitting);
, tx_enabled, transmitting);
}
}
break;
@ -316,13 +317,14 @@ void MessageServer::replay (QString const& id)
}
}
void MessageServer::halt_tx (QString const& id)
void MessageServer::halt_tx (QString const& id, bool auto_only)
{
auto iter = m_->clients_.find (id);
if (iter != std::end (m_->clients_))
{
QByteArray message;
NetworkMessage::Builder out {&message, NetworkMessage::HaltTx, id};
out << auto_only;
if (m_->check_status (out))
{
m_->writeDatagram (message, iter.value ().sender_address_, (*iter).sender_port_);

View File

@ -48,8 +48,9 @@ public:
// ask the client with identification 'id' to replay all decodes
Q_SLOT void replay (QString const& id);
// ask the client with identification 'id' to halt transmitting immediately
Q_SLOT void halt_tx (QString const& id);
// ask the client with identification 'id' to halt transmitting
// auto_only just disables auto Tx, otherwise halt is immediate
Q_SLOT void halt_tx (QString const& id, bool auto_only);
// ask the client with identification 'id' to set the free text message
Q_SLOT void free_text (QString const& id, QString const& text);
@ -58,7 +59,7 @@ public:
// matching message
Q_SIGNAL void client_opened (QString const& id);
Q_SIGNAL void status_update (QString const& id, Frequency, QString const& mode, QString const& dx_call
, QString const& report, QString const& tx_mode, bool transmitting);
, QString const& report, QString const& tx_mode, bool tx_enabled, bool transmitting);
Q_SIGNAL void client_closed (QString const& id);
Q_SIGNAL void decode (bool is_new, QString const& id, QTime time, qint32 snr, float delta_time
, quint32 delta_frequency, QString const& mode, QString const& message);

View File

@ -64,6 +64,7 @@
* DX call utf8
* Report utf8
* Tx Mode utf8
* Tx Enabled bool
* Transmitting bool
*
* Decode Out 2 quint32
@ -83,7 +84,7 @@
* Id (target unique key) utf8
* Time QTime
* snr qint32
* Delta time (S) float
* Delta time (S) float (serialized as double)
* Delta frequency (Hz) quint32
* Mode utf8
* Message utf8
@ -109,6 +110,7 @@
*
* Halt Tx In 8
* Id (unique key) utf8
* Auto Tx Only bool
*
* Free Text In 9
* Id (unique key) utf8

View File

@ -190,16 +190,29 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
// Network message handlers
connect (m_messageClient, &MessageClient::reply, this, &MainWindow::replyToCQ);
connect (m_messageClient, &MessageClient::replay, this, &MainWindow::replayDecodes);
connect (m_messageClient, &MessageClient::halt_tx, ui->stopTxButton, &QAbstractButton::click);
connect (m_messageClient, &MessageClient::halt_tx, [this] (bool auto_only) {
if (m_config.accept_udp_requests ()) {
if (auto_only) {
if (ui->autoButton->isChecked ()) {
ui->autoButton->click ();
}
} else {
ui->stopTxButton->click();
}
}
});
connect (m_messageClient, &MessageClient::error, this, &MainWindow::networkError);
connect (m_messageClient, &MessageClient::free_text, [this] (QString const& text) {
if (0 == ui->tabWidget->currentIndex ()) {
ui->tx5->setCurrentText (text);
ui->txrb5->click ();
} else {
ui->freeTextMsg->setCurrentText (text);
ui->rbFreeText->click ();
}});
if (m_config.accept_udp_requests ()) {
if (0 == ui->tabWidget->currentIndex ()) {
ui->tx5->setCurrentText (text);
ui->txrb5->click ();
} else {
ui->freeTextMsg->setCurrentText (text);
ui->rbFreeText->click ();
}
}
});
on_EraseButton_clicked ();
@ -837,6 +850,7 @@ void MainWindow::on_actionAbout_triggered() //Display "About"
void MainWindow::on_autoButton_clicked (bool checked)
{
m_auto = checked;
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
}
void MainWindow::auto_tx_mode (bool state)
@ -1030,7 +1044,7 @@ void MainWindow::displayDialFrequency ()
void MainWindow::statusChanged()
{
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, m_transmitting);
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
QFile f {m_config.temp_dir ().absoluteFilePath ("wsjtx_status.txt")};
if(f.open(QFile::WriteOnly | QIODevice::Text)) {
@ -1873,7 +1887,7 @@ void MainWindow::guiUpdate()
m_transmitting = true;
transmitDisplay (true);
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, m_transmitting);
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
}
if(!m_btxok && btxok0 && g_iptt==1) stopTx();
@ -2005,7 +2019,7 @@ void MainWindow::stopTx()
tx_status_label->setText("");
ptt0Timer->start(200); //Sequencer delay
monitor (true);
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, m_transmitting);
m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
}
void MainWindow::stopTx2()