From 0d63463851e75e15cd069c1e4b25e5907a9e1996 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Wed, 26 Dec 2018 20:33:30 -0500 Subject: [PATCH] Added new status command output and fixed a bug in macros --- mainwindow.cpp | 25 ++++++++++++++++++++++--- mainwindow.h | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index fd92225..93703c9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7379,7 +7379,8 @@ QMap MainWindow::buildMacroValues(){ {"", m_config.my_station()}, {"", m_config.my_qth()}, {"", m_config.cq_message()}, - {"", m_config.reply_message()} + {"", m_config.reply_message()}, + {"", generateStatus()}, }; auto selectedCall = callsignSelected(); @@ -7401,7 +7402,7 @@ QString MainWindow::replaceMacros(QString const &text, QMap va QString output = QString(text); foreach(auto key, values.keys()){ - output = output.replace(key, values[key]); + output = output.replace(key, values[key].toUpper()); } if(prune){ @@ -9187,6 +9188,22 @@ void MainWindow::processBufferedActivity() { } } +QString MainWindow::generateStatus() { + static const char* yes = "+"; + static const char* no = "-"; + + auto lastActive = DriftingDateTime::currentDateTimeUtc().addSecs(-m_idleMinutes*60); + + auto status = QString("%1 AUTO%2 HB%3 SPOT%4 RELAY%5 V%6"); + status = status.arg(since(lastActive).toUpper()); + status = status.arg(ui->autoReplyButton->isChecked() ? yes : no); + status = status.arg(ui->hbMacroButton->isChecked() && m_hbInterval > 0 ? yes : no); + status = status.arg(ui->spotButton->isChecked() ? yes : no); + status = status.arg(!m_config.relay_off() ? yes : no); + status = status.arg(version().replace("-devel", "").replace("-rc", "")); + return status; +} + void MainWindow::processCommandActivity() { #if 0 if (!m_txFrameQueue.isEmpty()) { @@ -9358,7 +9375,7 @@ void MainWindow::processCommandActivity() { // QUERIED ACTIVE else if (d.cmd == " STATUS?" && !isAllCall) { - reply = QString("%1 AUTO:%2 VER:%3").arg(d.from).arg(ui->autoReplyButton->isChecked() ? "ON" : "OFF").arg(version()); + reply = QString("%1 %2").arg(d.from).arg(generateStatus()); } // QUERIED GRID @@ -9501,6 +9518,8 @@ void MainWindow::processCommandActivity() { continue; } + // TODO: here is where we would process arbitrary queries if we wanted + auto callsigns = Varicode::parseCallsigns(who); if(callsigns.isEmpty()){ continue; diff --git a/mainwindow.h b/mainwindow.h index f016dc4..2311242 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -933,6 +933,7 @@ private: void processIdleActivity(); void processCompoundActivity(); void processBufferedActivity(); + QString generateStatus(); void processCommandActivity(); void writeDirectedCommandToFile(CommandDetail d); void processAlertReplyForCommand(CommandDetail d, QString from, QString cmd);