Many improvements to decode double click and auoto-sequencing behaviour

Double-clicks on 73 messages fixed.  Fixed issue with incorrect decode
being  selected  by  double-click. Refined  auto-sequencing  sign  off
handling, any 73 or rr73 free text  near Rx or Tx frequency taken as a
73 from QSO  partner but if a  standard message then must  be from QSO
partner.

Moved functionality from MainWindow to DecodedText class.

More  efficient  picking of  messages  from  decoded text  windows  by
extracting the text block directly.

Tighten up  use of RR73 and  skipping Tx1, these are  now disabled for
relevant compound calls where they would break the QSO exchange.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8056 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2017-09-01 05:11:57 +00:00
parent 4c3b9d025f
commit bda874be89
7 changed files with 242 additions and 223 deletions

View File

@ -7,6 +7,11 @@ extern "C" {
bool stdmsg_(const char* msg, int len); bool stdmsg_(const char* msg, int len);
} }
namespace
{
QRegularExpression words_re {R"(^(?:(?<word1>(?:CQ|DE|QRZ)(?:\s?DX|\s(?:[A-Z]{2}|\d{3}))|[A-Z0-9/]+)\s)(?:(?<word2>[A-Z0-9/]+)(?:\sR\s)?(?:\s(?<word3>[-+A-Z0-9]+)(?:\s(?<word4>OOO))?)?)?)"};
}
DecodedText::DecodedText (QString const& the_string) DecodedText::DecodedText (QString const& the_string)
: string_ {the_string} : string_ {the_string}
, padding_ {the_string.indexOf (" ") > 4 ? 2 : 0} // allow for , padding_ {the_string.indexOf (" ") > 4 ? 2 : 0} // allow for
@ -14,28 +19,39 @@ DecodedText::DecodedText (QString const& the_string)
, message_ {string_.mid (column_qsoText + padding_).trimmed ()} , message_ {string_.mid (column_qsoText + padding_).trimmed ()}
, is_standard_ {false} , is_standard_ {false}
{ {
string_ = string_.left (column_qsoText + padding_ + 25);
if (message_.length() >= 1) if (message_.length() >= 1)
{ {
message_ = message_.left (22).remove (QRegularExpression {"[<>]"}); message_ = message_.left (21).remove (QRegularExpression {"[<>]"});
int i1 = message_.indexOf ('\r'); int i1 = message_.indexOf ('\r');
if (i1 > 0) if (i1 > 0)
{ {
message_ = message_.left (i1 - 1); message_ = message_.left (i1 - 1);
} }
if (message_.contains (QRegularExpression {"^(CQ|QRZ)\\s"}))
{
// TODO this magic position 16 is guaranteed to be after the
// last space in a decoded CQ or QRZ message but before any
// appended DXCC entity name or worked before information
auto eom_pos = message_.indexOf (' ', 16);
// we always want at least the characters to position 16
if (eom_pos < 16) eom_pos = message_.size () - 1;
// remove DXCC entity and worked B4 status. TODO need a better way to do this
message_ = message_.left (eom_pos + 1);
}
// stdmsg is a fortran routine that packs the text, unpacks it and compares the result // stdmsg is a fortran routine that packs the text, unpacks it and compares the result
is_standard_ = stdmsg_ ((message_ + " ").toLatin1 ().constData (),22); is_standard_ = stdmsg_ ((message_ + " ").toLatin1 ().constData (),22);
} }
}; };
void DecodedText::removeAddedInfo () QStringList DecodedText::messageWords () const
{ {
if (string_.indexOf (" CQ ") > 0) { if (is_standard_)
// TODO this magic 37 characters is also referenced in DisplayText::_appendDXCCWorkedB4() {
auto eom_pos = string_.indexOf (' ', 37); // extract up to the first four message words
if (eom_pos < 37) eom_pos = string_.size () - 1; // we always want at least the characters return words_re.match (message_).capturedTexts ();
// to position 37
string_ = string_.left (eom_pos + 1); // remove DXCC entity and worked B4 status. TODO need a better way to do this
} }
return message_.split (' '); // simple word split for free text messages
} }
QString DecodedText::CQersCall() const QString DecodedText::CQersCall() const
@ -132,35 +148,38 @@ bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /
// get the first text word, usually the call // get the first text word, usually the call
QString DecodedText::call() const QString DecodedText::call() const
{ {
auto call = string_; return words_re.match (message_).captured ("word1");
call = call.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_);
int i = call.indexOf(" ");
return call.mid(0,i);
} }
// get the second word, most likely the de call and the third word, most likely grid // get the second word, most likely the de call and the third word, most likely grid
void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) const void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) const
{ {
auto msg = string_; auto const& match = words_re.match (message_);
if(msg.mid(4,1)!=" ") msg=msg.mid(0,4)+msg.mid(6,-1); //Remove seconds from UTC call = match.captured ("word2");
msg = msg.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_); grid = match.captured ("word3");
int i1 = msg.indexOf (" ");
call = msg.mid (i1 + 1); // auto msg = string_;
int i2 = call.indexOf (" "); // if(msg.mid(4,1)!=" ") msg=msg.mid(0,4)+msg.mid(6,-1); //Remove seconds from UTC
if (" R " == call.mid (i2, 3)) // MSK144 contest mode report // msg = msg.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_);
{ // int i1 = msg.indexOf (" ");
grid = call.mid (i2 + 3, 4); // call = msg.mid (i1 + 1);
} // int i2 = call.indexOf (" ");
else // if (" R " == call.mid (i2, 3)) // MSK144 contest mode report
{ // {
grid = call.mid (i2 + 1, 4); // grid = call.mid (i2 + 3, 4);
} // }
call = call.left (i2).replace (">", ""); // else
// {
// grid = call.mid (i2 + 1, 4);
// }
// call = call.left (i2).replace (">", "");
} }
int DecodedText::timeInSeconds() const unsigned DecodedText::timeInSeconds() const
{ {
return 60*string_.mid(column_time,2).toInt() + string_.mid(2,2).toInt(); return 3600 * string_.mid (column_time, 2).toUInt ()
+ 60 * string_.mid (column_time + 2, 2).toUInt()
+ (padding_ ? string_.mid (column_time + 2 + padding_, 2).toUInt () : 0U);
} }
/* /*

View File

@ -14,8 +14,10 @@
/* /*
0123456789012345678901234567890123456789 012345678901234567890123456789012345678901
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
2343 -11 0.8 1259 # CQ VP2X/GM4WJS GL33
2343 -11 0.8 1259 # CQ 999 VP2V/GM4WJS
2343 -11 0.8 1259 # YV6BFE F6GUU R-08 2343 -11 0.8 1259 # YV6BFE F6GUU R-08
2343 -19 0.3 718 # VE6WQ SQ2NIJ -14 2343 -19 0.3 718 # VE6WQ SQ2NIJ -14
2343 -7 0.3 815 # KK4DSD W7VP -16 2343 -7 0.3 815 # KK4DSD W7VP -16
@ -30,7 +32,7 @@ public:
explicit DecodedText (QString const&); explicit DecodedText (QString const&);
QString string() const { return string_; }; QString string() const { return string_; };
void removeAddedInfo (); QStringList messageWords () const;
int indexOf(QString s) const { return string_.indexOf(s); }; int indexOf(QString s) const { return string_.indexOf(s); };
int indexOf(QString s, int i) const { return string_.indexOf(s,i); }; int indexOf(QString s, int i) const { return string_.indexOf(s,i); };
QString mid(int f, int t) const { return string_.mid(f,t); }; QString mid(int f, int t) const { return string_.mid(f,t); };
@ -58,7 +60,7 @@ public:
// get the second word, most likely the de call and the third word, most likely grid // get the second word, most likely the de call and the third word, most likely grid
void deCallAndGrid(/*out*/QString& call, QString& grid) const; void deCallAndGrid(/*out*/QString& call, QString& grid) const;
int timeInSeconds() const; unsigned timeInSeconds() const;
// returns a string of the SNR field with a leading + or - followed by two digits // returns a string of the SNR field with a leading + or - followed by two digits
QString report() const; QString report() const;

View File

@ -85,6 +85,8 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
QColor color_DXCC, QColor color_DXCC,
QColor color_NewCall) QColor color_NewCall)
{ {
// allow for seconds
unsigned padding {message.indexOf (" ") > 4 ? 2U : 0U};
QString call = callsign; QString call = callsign;
QString countryName; QString countryName;
bool callWorkedBefore; bool callWorkedBefore;
@ -100,16 +102,19 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message; if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message;
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore); logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
int charsAvail = 48; int charsAvail = 52 + padding;
// the decoder (seems) to always generate 41 chars. For a normal CQ call, the last five are spaces // the decoder (seems) to always generate 41 chars. For a normal CQ
// TODO this magic 37 characters is also referenced in MainWindow::doubleClickOnCall() // call, the last five are spaces
int nmin=37; //
int i=message.indexOf(" CQ "); // A maximum length call is "QRZ VP2X/GM4WJS IO91" "CQ AA ..." or CQ
int k=message.mid(i+4,3).toInt(); // nnn ..." don't allow grid squares so are not longer. Here we align
if(k>0 and k<999) nmin += 4; // the added info at least after the longest CQ/QRZ message plus one
int s3 = message.indexOf(" ",nmin); // space so that it can be stripped off algorithmically later.
if (s3 < nmin) s3 = nmin; // always want at least the characters to position 35 //
int nmin = 46 + padding;
int s3 = message.indexOf (" ", nmin);
if (s3 < nmin) s3 = nmin; // always want at least the characters to position 45
s3 += 1; // convert the index into a character count s3 += 1; // convert the index into a character count
message = message.left(s3); // reduce trailing white space message = message.left(s3); // reduce trailing white space
charsAvail -= s3; charsAvail -= s3;

View File

@ -6,7 +6,7 @@ logical*1 function stdmsg(msg0)
call packmsg(msg0,dat,itype) call packmsg(msg0,dat,itype)
call unpackmsg(dat,msg) call unpackmsg(dat,msg)
stdmsg=(msg.eq.msg0) .and. (itype.ge.0) stdmsg=(msg.eq.msg0) .and. (itype.ge.0) .and. itype.ne.6
return return
end function stdmsg end function stdmsg

View File

@ -101,8 +101,6 @@ extern "C" {
void geniscat_(char* msg, char* msgsent, int itone[], int len1, int len2); void geniscat_(char* msg, char* msgsent, int itone[], int len1, int len2);
bool stdmsg_(const char* msg, int len);
void azdist_(char* MyGrid, char* HisGrid, double* utch, int* nAz, int* nEl, void azdist_(char* MyGrid, char* HisGrid, double* utch, int* nAz, int* nEl,
int* nDmiles, int* nDkm, int* nHotAz, int* nHotABetter, int* nDmiles, int* nDkm, int* nHotAz, int* nHotABetter,
int len1, int len2); int len1, int len2);
@ -1431,12 +1429,11 @@ void MainWindow::fastSink(qint64 frames)
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(),
m_config.color_NewCall()); m_config.color_NewCall());
m_bDecoded=true; m_bDecoded=true;
auto_sequence (message, ui->sbFtol->value (), std::numeric_limits<unsigned>::max ()); auto_sequence (decodedtext, ui->sbFtol->value (), std::numeric_limits<unsigned>::max ());
if (m_mode != "ISCAT") postDecode (true, decodedtext.string ()); if (m_mode != "ISCAT") postDecode (true, decodedtext.string ());
writeAllTxt(message); writeAllTxt(message);
bool stdMsg = decodedtext.report(m_baseCall, bool stdMsg = decodedtext.report(m_baseCall,
Radio::base_callsign(ui->dxCallEntry->text()),m_rptRcvd); Radio::base_callsign(ui->dxCallEntry->text()),m_rptRcvd);
decodedtext = DecodedText {message.left (4) + message.mid (6, -1)};
if (stdMsg) pskPost (decodedtext); if (stdMsg) pskPost (decodedtext);
} }
@ -2554,16 +2551,13 @@ void MainWindow::decode() //decode()
void::MainWindow::fast_decode_done() void::MainWindow::fast_decode_done()
{ {
float t,tmax=-99.0; float t,tmax=-99.0;
QString msg0;
dec_data.params.nagain=false; dec_data.params.nagain=false;
dec_data.params.ndiskdat=false; dec_data.params.ndiskdat=false;
// if(m_msg[0][0]==0) m_bDecoded=false; // if(m_msg[0][0]==0) m_bDecoded=false;
for(int i=0; i<100; i++) { for(int i=0; m_msg[i][0] && i<100; i++) {
if (tmax >= 0.0) auto_sequence (msg0, ui->sbFtol->value (), ui->sbFtol->value ());
if(m_msg[i][0]==0) break;
QString message=QString::fromLatin1(m_msg[i]); QString message=QString::fromLatin1(m_msg[i]);
m_msg[i][0]=0; m_msg[i][0]=0;
if(message.length()>80) message=message.mid(0,80); if(message.length()>80) message=message.left (80);
if(narg[13]/8==narg[12]) message=message.trimmed().replace("<...>",m_calls); if(narg[13]/8==narg[12]) message=message.trimmed().replace("<...>",m_calls);
//Left (Band activity) window //Left (Band activity) window
@ -2576,7 +2570,6 @@ void::MainWindow::fast_decode_done()
t=message.mid(10,5).toFloat(); t=message.mid(10,5).toFloat();
if(t>tmax) { if(t>tmax) {
msg0=message;
tmax=t; tmax=t;
m_bDecoded=true; m_bDecoded=true;
} }
@ -2585,14 +2578,13 @@ void::MainWindow::fast_decode_done()
if(m_mode=="JT9" or m_mode=="MSK144") { if(m_mode=="JT9" or m_mode=="MSK144") {
// find and extract any report for myCall // find and extract any report for myCall
QString msg=message.mid(0,4) + message.mid(6,-1);
decodedtext = DecodedText {msg.replace (QChar::LineFeed, "")};
bool stdMsg = decodedtext.report(m_baseCall, bool stdMsg = decodedtext.report(m_baseCall,
Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd); Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd);
// extract details and send to PSKreporter // extract details and send to PSKreporter
if (stdMsg) pskPost (decodedtext); if (stdMsg) pskPost (decodedtext);
} }
if (tmax >= 0.0) auto_sequence (decodedtext, ui->sbFtol->value (), ui->sbFtol->value ());
} }
m_startAnother=m_loopall; m_startAnother=m_loopall;
m_nPick=0; m_nPick=0;
@ -2736,7 +2728,7 @@ void MainWindow::readFromStdout() //readFromStdout
// int snr=decodedtext.string().mid(6,4).toInt(); // int snr=decodedtext.string().mid(6,4).toInt();
m_bDoubleClicked=true; m_bDoubleClicked=true;
m_bAutoReply = true; m_bAutoReply = true;
processMessage (decodedtext.string (), decodedtext.string ().size ()); processMessage (decodedtext);
ui->cbFirst->setStyleSheet(""); ui->cbFirst->setStyleSheet("");
} else { } else {
if (for_us or (abs(audioFreq - m_wideGraph->rxFreq()) <= 10)) bDisplayRight=true; if (for_us or (abs(audioFreq - m_wideGraph->rxFreq()) <= 10)) bDisplayRight=true;
@ -2757,9 +2749,9 @@ void MainWindow::readFromStdout() //readFromStdout
if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked(); if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked();
if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked(); if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked();
} }
m_QSOText = decodedtext.string (); m_QSOText = decodedtext.string ().trimmed ();
} }
if(m_mode=="FT8" or m_mode=="QRA64") auto_sequence (decodedtext.string(), 25, 50); if(m_mode=="FT8" or m_mode=="QRA64") auto_sequence (decodedtext, 25, 50);
postDecode (true, decodedtext.string ()); postDecode (true, decodedtext.string ());
@ -2793,40 +2785,50 @@ void MainWindow::readFromStdout() //readFromStdout
// another caller and we are going to transmit within // another caller and we are going to transmit within
// +/- this value of the reply to another caller // +/- this value of the reply to another caller
// //
void MainWindow::auto_sequence (QString const& message, unsigned start_tolerance, unsigned stop_tolerance) void MainWindow::auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance)
{ {
auto const& parts = message.split (' ', QString::SkipEmptyParts); auto const& message_words = message.messageWords ();
if (parts.size () > 6) { auto is_73 = message_words.filter (QRegularExpression {"^(73|RR73)$"}).size ();
bool ok; if (message_words.size () > 2 && (message.isStandardMessage () || is_73)) {
auto df = parts[3].toInt (&ok); auto df = message.frequencyOffset ();
auto within_tolerance = ok auto within_tolerance =
&& (qAbs (ui->RxFreqSpinBox->value () - df) <= int (start_tolerance) (qAbs (ui->RxFreqSpinBox->value () - df) <= int (start_tolerance)
|| qAbs (ui->TxFreqSpinBox->value () - df) <= int (start_tolerance)); || qAbs (ui->TxFreqSpinBox->value () - df) <= int (start_tolerance));
bool acceptable_73 = is_73
&& m_QSOProgress >= ROGER_REPORT
&& ((message.isStandardMessage ()
&& (message_words.contains (m_baseCall)
|| message_words.contains (m_config.my_callsign ())
|| message_words.contains (ui->dxCallEntry->text ())
|| message_words.contains (Radio::base_callsign (ui->dxCallEntry->text ()))
|| message_words.contains ("DE")))
|| !message.isStandardMessage ()); // free text 73/RR73
if (m_auto if (m_auto
&& (REPLYING == m_QSOProgress && (REPLYING == m_QSOProgress
|| (!ui->tx1->isEnabled () && REPORT == m_QSOProgress)) || (!ui->tx1->isEnabled () && REPORT == m_QSOProgress))
&& qAbs (ui->TxFreqSpinBox->value () - df) <= int (stop_tolerance) && qAbs (ui->TxFreqSpinBox->value () - df) <= int (stop_tolerance)
&& !parts[5].contains (QRegularExpression {"(^(CQ|QRZ)$)|" + m_baseCall}) && !message_words.at (1).contains (QRegularExpression {"(^(CQ|QRZ))|" + m_baseCall})
&& parts[6].contains (Radio::base_callsign (ui->dxCallEntry->text ()))) { && message_words.at (2).contains (Radio::base_callsign (ui->dxCallEntry->text ()))) {
// auto stop to avoid accidental QRM // auto stop to avoid accidental QRM
auto_tx_mode (false); auto_tx_mode (false);
} }
else if (m_auto // transmit allowed else if (m_auto // transmit allowed
&& ui->cbAutoSeq->isVisible () && ui->cbAutoSeq->isChecked() // auto-sequencing allowed && ui->cbAutoSeq->isVisible () && ui->cbAutoSeq->isChecked() // auto-sequencing allowed
&& ((!m_bCallingCQ // not calling CQ/QRZ && ((!m_bCallingCQ // not calling CQ/QRZ
&& !m_sentFirst73 // finished QSO && !m_sentFirst73 // not finished QSO
&& ((parts[5].contains (m_baseCall) && ((message_words.at (1).contains (m_baseCall)
// being called and not already in a QSO // being called and not already in a QSO
&& parts[6].contains (Radio::base_callsign (ui->dxCallEntry->text ()))) && message_words.at (2).contains (Radio::base_callsign (ui->dxCallEntry->text ())))
// type 2 compound replies // type 2 compound replies
|| (within_tolerance || (within_tolerance
&& ((m_QSOProgress >= ROGER_REPORT && message_is_73 (0, parts)) && (acceptable_73
|| ("DE" == parts[5] && parts[6].contains (Radio::base_callsign (m_hisCall))))))) || ("DE" == message_words.at (1) && message_words.at (2).contains (Radio::base_callsign (m_hisCall)))))))
|| (m_bCallingCQ && m_bAutoReply || (m_bCallingCQ && m_bAutoReply
&& ((within_tolerance && "DE" == parts[5]) // look for type 2 compound call replies on our Tx and Rx offsets // look for type 2 compound call replies on our Tx and Rx offsets
|| parts[5].contains (m_baseCall))))) && ((within_tolerance && "DE" == message_words.at (1))
|| message_words.at (1).contains (m_baseCall)))))
{ {
processMessage (message, message.size ()); processMessage (message);
} }
} }
} }
@ -3478,7 +3480,10 @@ void MainWindow::on_txrb1_toggled (bool status)
void MainWindow::on_txrb1_doubleClicked () void MainWindow::on_txrb1_doubleClicked ()
{ {
ui->tx1->setEnabled (!ui->tx1->isEnabled ()); // skip Tx1, only allowed if not a type 2 compound callsign
auto const& my_callsign = m_config.my_callsign ();
auto is_compound = my_callsign != m_baseCall;
ui->tx1->setEnabled ((is_compound && shortList (my_callsign)) || !ui->tx1->isEnabled ());
if (!ui->tx1->isEnabled ()) { if (!ui->tx1->isEnabled ()) {
// leave time for clicks to complete before setting txrb2 // leave time for clicks to complete before setting txrb2
QTimer::singleShot (500, ui->txrb2, SLOT (click ())); QTimer::singleShot (500, ui->txrb2, SLOT (click ()));
@ -3512,7 +3517,10 @@ void MainWindow::on_txrb4_toggled (bool status)
void MainWindow::on_txrb4_doubleClicked () void MainWindow::on_txrb4_doubleClicked ()
{ {
m_send_RR73 = !m_send_RR73; // RR73 only allowed if not a type 2 compound callsign
auto const& my_callsign = m_config.my_callsign ();
auto is_compound = my_callsign != m_baseCall;
m_send_RR73 = !((is_compound && !shortList (my_callsign)) || m_send_RR73);
genStdMsgs (m_rpt); genStdMsgs (m_rpt);
} }
@ -3551,7 +3559,10 @@ void MainWindow::on_txb1_clicked()
void MainWindow::on_txb1_doubleClicked() void MainWindow::on_txb1_doubleClicked()
{ {
ui->tx1->setEnabled (!ui->tx1->isEnabled ()); // skip Tx1, only allowed if not a type 1 compound callsign
auto const& my_callsign = m_config.my_callsign ();
auto is_compound = my_callsign != m_baseCall;
ui->tx1->setEnabled ((is_compound && shortList (my_callsign)) || !ui->tx1->isEnabled ());
} }
void MainWindow::on_txb2_clicked() void MainWindow::on_txb2_clicked()
@ -3580,7 +3591,10 @@ void MainWindow::on_txb4_clicked()
void MainWindow::on_txb4_doubleClicked() void MainWindow::on_txb4_doubleClicked()
{ {
m_send_RR73 = !m_send_RR73; // RR73 only allowed if not a type 2 compound callsign
auto const& my_callsign = m_config.my_callsign ();
auto is_compound = my_callsign != m_baseCall;
m_send_RR73 = !((is_compound && !shortList (my_callsign)) || m_send_RR73);
genStdMsgs (m_rpt); genStdMsgs (m_rpt);
} }
@ -3627,28 +3641,18 @@ void MainWindow::doubleClickOnCall(bool alt, bool ctrl)
} else { } else {
cursor=ui->decodedTextBrowser2->textCursor(); cursor=ui->decodedTextBrowser2->textCursor();
} }
cursor.setPosition (cursor.selectionStart ());
cursor.select(QTextCursor::LineUnderCursor); DecodedText message {cursor.block ().text ()};
int position {cursor.position()}; m_bDoubleClicked = true;
processMessage (message, ctrl, alt);
QString messages;
if(!m_decodedText2) messages= ui->decodedTextBrowser2->toPlainText();
if(m_decodedText2) messages= ui->decodedTextBrowser->toPlainText();
if(ui->cbCQTx->isEnabled() && ui->cbCQTx->isChecked()) m_bDoubleClickAfterCQnnn=true;
m_bDoubleClicked=true;
processMessage(messages, position, ctrl, alt);
} }
void MainWindow::processMessage(QString const& messages, int position, bool ctrl, bool alt) void MainWindow::processMessage(DecodedText const& message, bool ctrl, bool alt)
{ {
QString t1 = messages.left(position); //contents up to \n on selected line
int i1=t1.lastIndexOf(QChar::LineFeed) + 1; //points to first char of line
QString t2 = messages.mid(i1,position-i1); //selected line
// basic mode sanity checks // basic mode sanity checks
auto const& parts = t2.split (' ', QString::SkipEmptyParts); auto const& parts = message.string ().split (' ', QString::SkipEmptyParts);
if (parts.size () < 5) return; if (parts.size () < 5) return;
auto const& mode = parts[4].mid(0,1); auto const& mode = parts.at (4).left (1);
if (("JT9+JT65" == m_mode && !("@" == mode || "#" == mode)) if (("JT9+JT65" == m_mode && !("@" == mode || "#" == mode))
|| ("JT65" == m_mode && mode != "#") || ("JT65" == m_mode && mode != "#")
|| ("JT9" == m_mode && mode != "@") || ("JT9" == m_mode && mode != "@")
@ -3657,22 +3661,21 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
return; return;
} }
QString t2a; // QString t2a;
int ntsec=3600*t2.mid(0,2).toInt() + 60*t2.mid(2,2).toInt(); // int ntsec=3600*t2.mid(0,2).toInt() + 60*t2.mid(2,2).toInt();
if(m_bFastMode or m_mode=="FT8") { // if(m_bFastMode or m_mode=="FT8") {
ntsec = ntsec + t2.mid(4,2).toInt(); // ntsec = ntsec + t2.mid(4,2).toInt();
t2a = t2.left (4) + t2.mid (6); //Change hhmmss to hhmm for the message parser // t2a = t2.left (4) + t2.mid (6); //Change hhmmss to hhmm for the message parser
} // }
t2a = t2.left (44); // strip any quality info trailing the //t2a = t2.left (44); // strip any quality info trailing the
// decoded message // decoded message
if(m_bFastMode or m_mode=="FT8") { if(m_bFastMode or m_mode=="FT8") {
i1=t2a.indexOf(" CQ "); auto i1=message.string ().indexOf(" CQ ");
if(i1>10) { if(i1>10) {
bool ok; bool ok;
Frequency kHz {t2a.mid (i1+4,3).toUInt (&ok)}; Frequency kHz {message.string ().mid (i1+4,3).toUInt (&ok)};
if(ok && kHz <= 999) { if(ok && kHz <= 999) {
t2a = t2a.mid (0, i1+4) + t2a.mid (i1+8, -1);
if (m_config.is_transceiver_online ()) { if (m_config.is_transceiver_online ()) {
//QSY Freq for answering CQ nnn //QSY Freq for answering CQ nnn
setRig (m_freqNominal / 1000000 * 1000000 + 1000 * kHz); setRig (m_freqNominal / 1000000 * 1000000 + 1000 * kHz);
@ -3681,74 +3684,58 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
} }
} }
} }
DecodedText decodedtext {t2a};
decodedtext.removeAddedInfo ();
auto t3 = decodedtext.string (); //Skip the rest if no decoded text extracted
auto t4 = t3.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").split (" ", QString::SkipEmptyParts); int frequency = message.frequencyOffset();
if(t4.size () < 6) return; //Skip the rest if no decoded text if (message.isTX()) {
int frequency = decodedtext.frequencyOffset();
if (ui->RxFreqSpinBox->isEnabled () and m_mode != "MSK144") {
ui->RxFreqSpinBox->setValue (frequency); //Set Rx freq
}
if (decodedtext.isTX()) {
if (!m_config.enable_VHF_features() && ctrl && ui->TxFreqSpinBox->isEnabled()) { if (!m_config.enable_VHF_features() && ctrl && ui->TxFreqSpinBox->isEnabled()) {
ui->TxFreqSpinBox->setValue(frequency); //Set Tx freq ui->TxFreqSpinBox->setValue(frequency); //Set Tx freq
} }
return; return;
} }
int nmod=ntsec % (2*m_TRperiod); int nmod = message.timeInSeconds () % (2*m_TRperiod);
m_txFirst=(nmod!=0); m_txFirst=(nmod!=0);
ui->txFirstCheckBox->setChecked(m_txFirst); ui->txFirstCheckBox->setChecked(m_txFirst);
auto const& message_words = message.messageWords ();
if (message_words.size () < 2) return;
QString hiscall; QString hiscall;
QString hisgrid; QString hisgrid;
decodedtext.deCallAndGrid(/*out*/hiscall,hisgrid); message.deCallAndGrid(/*out*/hiscall,hisgrid);
bool is_73 = t4.filter (QRegularExpression {"^(73|RR73)$"}).size (); auto is_73 = message_words.filter (QRegularExpression {"^(73|RR73)$"}).size ();
auto acceptable_73 = if (!is_73 && !message.isStandardMessage ())
m_QSOProgress >= ROGER_REPORT // && (!Radio::is_callsign (hiscall) // not interested if not from QSO partner
&& is_73 // && !(t4.size () == 7 // unless it is of the form
&& ((decodedtext.isStandardMessage () // && (t4.at (5) == m_baseCall // "<our-call> 73"
&& (t4.contains (m_baseCall) // || t4.at (5).startsWith (m_baseCall + '/')
|| t4.contains (m_config.my_callsign ()) // || t4.at (5).endsWith ('/' + m_baseCall))
|| t4.contains (ui->dxCallEntry->text ()) // && t4.at (6) == "73")))
|| t4.contains (Radio::base_callsign (ui->dxCallEntry->text ()))
|| t4.contains ("DE")))
|| !decodedtext.isStandardMessage ());
if ((is_73 && !acceptable_73)
|| (!Radio::is_callsign (hiscall) // not interested if not from QSO partner
&& !(t4.size () == 7 // unless it is of the form
&& (t4.at (5) == m_baseCall // "<our-call> 73"
|| t4.at (5).startsWith (m_baseCall + '/')
|| t4.at (5).endsWith ('/' + m_baseCall))
&& t4.at (6) == "73")))
{ {
qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid; qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid;
return; return;
} }
// only allow automatic mode changes between JT9 and JT65, and when not transmitting // only allow automatic mode changes between JT9 and JT65, and when not transmitting
if (!m_transmitting and m_mode == "JT9+JT65") { if (!m_transmitting and m_mode == "JT9+JT65") {
if (decodedtext.isJT9()) if (message.isJT9())
{ {
m_modeTx="JT9"; m_modeTx="JT9";
ui->pbTxMode->setText("Tx JT9 @"); ui->pbTxMode->setText("Tx JT9 @");
m_wideGraph->setModeTx(m_modeTx); m_wideGraph->setModeTx(m_modeTx);
} else if (decodedtext.isJT65()) { } else if (message.isJT65()) {
m_modeTx="JT65"; m_modeTx="JT65";
ui->pbTxMode->setText("Tx JT65 #"); ui->pbTxMode->setText("Tx JT65 #");
m_wideGraph->setModeTx(m_modeTx); m_wideGraph->setModeTx(m_modeTx);
} }
} else if ((decodedtext.isJT9 () and m_modeTx != "JT9" and m_mode != "JT4") or } else if ((message.isJT9 () and m_modeTx != "JT9" and m_mode != "JT4") or
(decodedtext.isJT65 () and m_modeTx != "JT65" and m_mode != "JT4")) { (message.isJT65 () and m_modeTx != "JT65" and m_mode != "JT4")) {
// if we are not allowing mode change then don't process decode // if we are not allowing mode change then don't process decode
return; return;
} }
QString firstcall = decodedtext.call(); QString firstcall = message.call();
if(!m_bFastMode and (!m_config.enable_VHF_features() or m_mode=="FT8")) { if(!m_bFastMode and (!m_config.enable_VHF_features() or m_mode=="FT8")) {
// Don't change Tx freq if in a fast mode, or VHF features enabled; also not if a // Don't change Tx freq if in a fast mode, or VHF features enabled; also not if a
// station is calling me, unless m_lockTxFreq is true or CTRL is held down. // station is calling me, unless m_lockTxFreq is true or CTRL is held down.
@ -3768,7 +3755,7 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
auto base_call = Radio::base_callsign (hiscall); auto base_call = Radio::base_callsign (hiscall);
// Determine appropriate response to received message // Determine appropriate response to received message
auto dtext = " " + decodedtext.string () + " "; auto dtext = " " + message.string () + " ";
int gen_msg {0}; int gen_msg {0};
if(dtext.contains (" " + m_baseCall + " ") if(dtext.contains (" " + m_baseCall + " ")
|| dtext.contains ("<" + m_baseCall + " ") || dtext.contains ("<" + m_baseCall + " ")
@ -3776,13 +3763,13 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
|| dtext.contains (" " + m_baseCall + "/") || dtext.contains (" " + m_baseCall + "/")
|| (firstcall == "DE" /*&& ((t4.size () > 7 && t4.at(7) != "73") || t4.size () <= 7)*/)) || (firstcall == "DE" /*&& ((t4.size () > 7 && t4.at(7) != "73") || t4.size () <= 7)*/))
{ {
if (t4.size () > 7 // enough fields for a normal msg if (message_words.size () > 3 // enough fields for a normal message
&& (t4.at (5).contains (m_baseCall) || "DE" == t4.at (5)) && (message_words.at (1).contains (m_baseCall) || "DE" == message_words.at (1))
&& t4.at (6).contains (qso_partner_base_call) && message_words.at (2).contains (qso_partner_base_call)
&& !t4.at (7).contains (grid_regexp)) // but no grid on end of msg && !message_words.at (3).contains (grid_regexp)) // but no grid on end of msg
{ {
QString r=t4.at (7); QString r=message_words.at (3);
if(m_QSOProgress >= ROGER_REPORT && (r.mid(0,3)=="RRR" || r.toInt()==73 || "RR73" == r)) { if(m_QSOProgress >= ROGER_REPORT && (r=="RRR" || r.toInt()==73 || "RR73" == r)) {
if(ui->tabWidget->currentIndex()==1) { if(ui->tabWidget->currentIndex()==1) {
gen_msg = 5; gen_msg = 5;
if (ui->rbGenMsg->isChecked ()) m_ntx=7; if (ui->rbGenMsg->isChecked ()) m_ntx=7;
@ -3819,7 +3806,7 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
} }
} }
else if (m_QSOProgress >= ROGERS else if (m_QSOProgress >= ROGERS
&& t4.size () >= 7 && t4.at (5).contains (m_baseCall) && t4.at (6) == "73") { && message_words.size () > 2 && message_words.at (1).contains (m_baseCall) && message_words.at (2) == "73") {
// 73 back to compound call holder // 73 back to compound call holder
if(ui->tabWidget->currentIndex()==1) { if(ui->tabWidget->currentIndex()==1) {
gen_msg = 5; gen_msg = 5;
@ -3833,7 +3820,7 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
m_QSOProgress = SIGNOFF; m_QSOProgress = SIGNOFF;
} }
else if (!(m_bAutoReply && m_QSOProgress > CALLING)) { else if (!(m_bAutoReply && m_QSOProgress > CALLING)) {
if ((t4.size () >= 9 && t4.at (5).contains (m_baseCall) && t4.at (8) == "OOO") if ((message_words.size () > 4 && message_words.at (1).contains (m_baseCall) && message_words.at (4) == "OOO")
|| ((m_mode=="MSK144" or m_mode=="FT8") && m_config.contestMode())) { || ((m_mode=="MSK144" or m_mode=="FT8") && m_config.contestMode())) {
// EME short code report or MSK144/FT8 contest mode reply, send back Tx3 // EME short code report or MSK144/FT8 contest mode reply, send back Tx3
m_ntx = 3; m_ntx = 3;
@ -3865,7 +3852,7 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
return; return;
} }
} }
else if (firstcall == "DE" && t4.size () >= 8 && t4.at (7) == "73") { else if (firstcall == "DE" && message_words.size () > 3 && message_words.at (3) == "73") {
if (m_QSOProgress >= ROGERS && base_call == qso_partner_base_call && m_currentMessageType) { if (m_QSOProgress >= ROGERS && base_call == qso_partner_base_call && m_currentMessageType) {
// 73 back to compound call holder // 73 back to compound call holder
if(ui->tabWidget->currentIndex()==1) { if(ui->tabWidget->currentIndex()==1) {
@ -3898,7 +3885,7 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
} }
} }
} }
else if (acceptable_73) { else if (is_73 && !message.isStandardMessage ()) {
if(ui->tabWidget->currentIndex()==1) { if(ui->tabWidget->currentIndex()==1) {
gen_msg = 5; gen_msg = 5;
if (ui->rbGenMsg->isChecked ()) m_ntx=7; if (ui->rbGenMsg->isChecked ()) m_ntx=7;
@ -3931,14 +3918,18 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
// if we get here then we are reacting to the message // if we get here then we are reacting to the message
if (m_bAutoReply) m_bCallingCQ = CALLING == m_QSOProgress; if (m_bAutoReply) m_bCallingCQ = CALLING == m_QSOProgress;
if (ui->RxFreqSpinBox->isEnabled () and m_mode != "MSK144") {
ui->RxFreqSpinBox->setValue (frequency); //Set Rx freq
}
QString s1 = m_QSOText.trimmed (); QString s1 = m_QSOText.trimmed ();
QString s2=t2.trimmed(); QString s2 = message.string ().trimmed();
if (s1!=s2 and !decodedtext.isTX()) { if (s1!=s2 and !message.isTX()) {
decodedtext = DecodedText {t2}; ui->decodedTextBrowser2->displayDecodedText(message, m_baseCall,
ui->decodedTextBrowser2->displayDecodedText(decodedtext, m_baseCall,
false, m_logBook,m_config.color_CQ(), m_config.color_MyCall(), false, m_logBook,m_config.color_CQ(), m_config.color_MyCall(),
m_config.color_DXCC(),m_config.color_NewCall()); m_config.color_DXCC(),m_config.color_NewCall());
m_QSOText = decodedtext.string (); m_QSOText = s1;
} }
if (hiscall != "73" if (hiscall != "73"
@ -3960,7 +3951,7 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
lookup(); lookup();
m_hisGrid = ui->dxGridEntry->text(); m_hisGrid = ui->dxGridEntry->text();
QString rpt = decodedtext.report(); QString rpt = message.report();
int n=rpt.toInt(); int n=rpt.toInt();
if(m_mode=="MSK144" and m_bShMsgs) { if(m_mode=="MSK144" and m_bShMsgs) {
int n=rpt.toInt(); int n=rpt.toInt();
@ -6118,7 +6109,9 @@ void MainWindow::replyToCQ (QTime time, qint32 snr, float delta_time, quint32 de
// find the linefeed at the end of the line // find the linefeed at the end of the line
position = ui->decodedTextBrowser->toPlainText().indexOf(QChar::LineFeed,position); position = ui->decodedTextBrowser->toPlainText().indexOf(QChar::LineFeed,position);
m_bDoubleClicked = true; m_bDoubleClicked = true;
processMessage (messages, position); auto start = messages.left (position).lastIndexOf (QChar::LineFeed) + 1;
DecodedText message {messages.mid (start, position - start)};
processMessage (message);
tx_watchdog (false); tx_watchdog (false);
QApplication::alert (this); QApplication::alert (this);
} }

View File

@ -304,7 +304,7 @@ private:
private: private:
void astroUpdate (); void astroUpdate ();
void writeAllTxt(QString message); void writeAllTxt(QString message);
void auto_sequence (QString const& message, unsigned start_tolerance, unsigned stop_tolerance); void auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance);
void hideMenus(bool b); void hideMenus(bool b);
NetworkAccessManager m_network_manager; NetworkAccessManager m_network_manager;
@ -591,7 +591,7 @@ private:
void pskPost(DecodedText const& decodedtext); void pskPost(DecodedText const& decodedtext);
void displayDialFrequency (); void displayDialFrequency ();
void transmitDisplay (bool); void transmitDisplay (bool);
void processMessage(QString const& messages, qint32 position, bool ctrl = false, bool alt = false); void processMessage(DecodedText const&, bool ctrl = false, bool alt = false);
void replyToCQ (QTime, qint32 snr, float delta_time, quint32 delta_frequency, QString const& mode, QString const& message_text); void replyToCQ (QTime, qint32 snr, float delta_time, quint32 delta_frequency, QString const& mode, QString const& message_text);
void replayDecodes (); void replayDecodes ();
void postDecode (bool is_new, QString const& message); void postDecode (bool is_new, QString const& message);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>876</width> <width>815</width>
<height>583</height> <height>548</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -1089,7 +1089,7 @@ QLabel[oob=&quot;true&quot;] {
<item row="1" column="1" alignment="Qt::AlignHCenter|Qt::AlignVCenter"> <item row="1" column="1" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="DoubleClickableRadioButton" name="txrb1"> <widget class="DoubleClickableRadioButton" name="txrb1">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Send this message in next Tx interval&lt;/p&gt;&lt;p&gt;Double click to toggle the use of the Tx1 message to start a QSO with a station&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Send this message in next Tx interval&lt;/p&gt;&lt;p&gt;Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -1111,7 +1111,7 @@ QLabel[oob=&quot;true&quot;] {
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Switch to this Tx message NOW&lt;/p&gt;&lt;p&gt;Double click to toggle the use of the Tx1 message to start a QSO with a station&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Switch to this Tx message NOW&lt;/p&gt;&lt;p&gt;Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compund call holders)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="layoutDirection"> <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LeftToRight</enum>
@ -1227,7 +1227,7 @@ QLabel[oob=&quot;true&quot;] {
<item row="4" column="1" alignment="Qt::AlignHCenter|Qt::AlignVCenter"> <item row="4" column="1" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="DoubleClickableRadioButton" name="txrb4"> <widget class="DoubleClickableRadioButton" name="txrb4">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Send this message in next Tx interval&lt;/p&gt;&lt;p&gt;Double-click to toggle between RRR and RR73 messages in Tx4&lt;/p&gt;&lt;p&gt;RR73 messages should only be used when you are reasonably confident that no message repititions will be required&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Send this message in next Tx interval&lt;/p&gt;&lt;p&gt;Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type 2 compound call holders)&lt;/p&gt;&lt;p&gt;RR73 messages should only be used when you are reasonably confident that no message repititions will be required&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -1249,7 +1249,7 @@ QLabel[oob=&quot;true&quot;] {
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Switch to this Tx message NOW&lt;/p&gt;&lt;p&gt;Double-click to toggle between RRR and RR73 messages in Tx4&lt;/p&gt;&lt;p&gt;RR73 messages should only be used when you are reasonably confident that no message repititions will be required&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Switch to this Tx message NOW&lt;/p&gt;&lt;p&gt;Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type2 compound call holders)&lt;/p&gt;&lt;p&gt;RR73 messages should only be used when you are reasonably confident that no message repititions will be required&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Tx &amp;4</string> <string>Tx &amp;4</string>
@ -2335,7 +2335,7 @@ QPushButton[state=&quot;ok&quot;] {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>876</width> <width>815</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>