2021-07-09 07:06:23 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 06:02:48 -05:00
|
|
|
// Copyright (C) 2021-2023 Jon Beniston, M7RCE <jon@beniston.com> //
|
|
|
|
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
2021-07-09 07:06:23 -04:00
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QRegExp>
|
|
|
|
#include <QClipboard>
|
2021-11-04 08:33:43 -04:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
2022-03-01 12:20:35 -05:00
|
|
|
#include <QScrollBar>
|
2024-10-11 06:01:43 -04:00
|
|
|
#include <QProcess>
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
#include "pagerdemodgui.h"
|
|
|
|
|
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "ui_pagerdemodgui.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/db.h"
|
2021-11-04 08:33:43 -04:00
|
|
|
#include "util/csv.h"
|
2024-10-11 06:01:43 -04:00
|
|
|
#include "util/units.h"
|
|
|
|
#include "gui/crightclickenabler.h"
|
2021-07-09 07:06:23 -04:00
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
|
|
|
#include "dsp/dspengine.h"
|
2022-12-20 05:31:15 -05:00
|
|
|
#include "gui/dialogpositioner.h"
|
2021-07-09 07:06:23 -04:00
|
|
|
#include "maincore.h"
|
|
|
|
|
|
|
|
#include "pagerdemod.h"
|
2021-07-19 12:57:13 -04:00
|
|
|
#include "pagerdemodcharsetdialog.h"
|
2024-10-11 06:01:43 -04:00
|
|
|
#include "pagerdemodnotificationdialog.h"
|
|
|
|
#include "pagerdemodfilterdialog.h"
|
|
|
|
|
|
|
|
#include "SWGMapItem.h"
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
void PagerDemodGUI::resizeTable()
|
|
|
|
{
|
|
|
|
// Fill table with a row of dummy data that will size the columns nicely
|
|
|
|
// Trailing spaces are for sort arrow
|
|
|
|
int row = ui->messages->rowCount();
|
|
|
|
ui->messages->setRowCount(row + 1);
|
2024-10-11 06:15:34 -04:00
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_DATE, new QTableWidgetItem("Fri Apr 15 2016--"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_TIME, new QTableWidgetItem("10:17:00"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_ADDRESS, new QTableWidgetItem("1000000"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_MESSAGE, new QTableWidgetItem("ABCEDGHIJKLMNOPQRSTUVWXYZABCEDGHIJKLMNOPQRSTUVWXYZ"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_FUNCTION, new QTableWidgetItem("0"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_ALPHA, new QTableWidgetItem("ABCEDGHIJKLMNOPQRSTUVWXYZABCEDGHIJKLMNOPQRSTUVWXYZ"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_NUMERIC, new QTableWidgetItem("123456789123456789123456789123456789123456789123456789"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_EVEN_PE, new QTableWidgetItem("0"));
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_BCH_PE, new QTableWidgetItem("0"));
|
2021-07-09 07:06:23 -04:00
|
|
|
ui->messages->resizeColumnsToContents();
|
|
|
|
ui->messages->removeRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Columns in table reordered
|
|
|
|
void PagerDemodGUI::messages_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex)
|
|
|
|
{
|
|
|
|
(void) oldVisualIndex;
|
|
|
|
|
|
|
|
m_settings.m_messageColumnIndexes[logicalIndex] = newVisualIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Column in table resized (when hidden size is 0)
|
|
|
|
void PagerDemodGUI::messages_sectionResized(int logicalIndex, int oldSize, int newSize)
|
|
|
|
{
|
|
|
|
(void) oldSize;
|
|
|
|
|
|
|
|
m_settings.m_messageColumnSizes[logicalIndex] = newSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Right click in table header - show column select menu
|
|
|
|
void PagerDemodGUI::messagesColumnSelectMenu(QPoint pos)
|
|
|
|
{
|
|
|
|
messagesMenu->popup(ui->messages->horizontalHeader()->viewport()->mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hide/show column when menu selected
|
|
|
|
void PagerDemodGUI::messagesColumnSelectMenuChecked(bool checked)
|
|
|
|
{
|
|
|
|
(void) checked;
|
|
|
|
|
|
|
|
QAction* action = qobject_cast<QAction*>(sender());
|
|
|
|
if (action != nullptr)
|
|
|
|
{
|
|
|
|
int idx = action->data().toInt(nullptr);
|
|
|
|
ui->messages->setColumnHidden(idx, !action->isChecked());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create column select menu item
|
|
|
|
QAction *PagerDemodGUI::createCheckableItem(QString &text, int idx, bool checked, const char *slot)
|
|
|
|
{
|
|
|
|
QAction *action = new QAction(text, this);
|
|
|
|
action->setCheckable(true);
|
|
|
|
action->setChecked(checked);
|
|
|
|
action->setData(QVariant(idx));
|
|
|
|
connect(action, SIGNAL(triggered()), this, slot);
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
PagerDemodGUI* PagerDemodGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
|
|
|
|
{
|
|
|
|
PagerDemodGUI* gui = new PagerDemodGUI(pluginAPI, deviceUISet, rxChannel);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray PagerDemodGUI::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PagerDemodGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-11 06:01:43 -04:00
|
|
|
QString PagerDemodGUI::selectMessage(int functionBits, const QString &numericMessage, const QString &alphaMessage) const
|
2021-07-09 07:06:23 -04:00
|
|
|
{
|
2024-10-11 06:01:43 -04:00
|
|
|
QString message;
|
2022-03-01 12:20:35 -05:00
|
|
|
|
2021-07-09 07:06:23 -04:00
|
|
|
// Standard way of choosing numeric or alpha decode isn't followed widely
|
|
|
|
if (m_settings.m_decode == PagerDemodSettings::Standard)
|
|
|
|
{
|
|
|
|
// Encoding is based on function bits
|
2021-11-04 08:33:43 -04:00
|
|
|
if (functionBits == 0) {
|
2024-10-11 06:01:43 -04:00
|
|
|
message = numericMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
} else {
|
2024-10-11 06:01:43 -04:00
|
|
|
message = alphaMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_settings.m_decode == PagerDemodSettings::Inverted)
|
|
|
|
{
|
|
|
|
// Encoding is based on function bits, but inverted from standard
|
2021-11-04 08:33:43 -04:00
|
|
|
if (functionBits == 3) {
|
2024-10-11 06:01:43 -04:00
|
|
|
message = numericMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
} else {
|
2024-10-11 06:01:43 -04:00
|
|
|
message = alphaMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_settings.m_decode == PagerDemodSettings::Numeric)
|
|
|
|
{
|
|
|
|
// Always display as numeric
|
2024-10-11 06:01:43 -04:00
|
|
|
message = numericMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
else if (m_settings.m_decode == PagerDemodSettings::Alphanumeric)
|
|
|
|
{
|
|
|
|
// Always display as alphanumeric
|
2024-10-11 06:01:43 -04:00
|
|
|
message = alphaMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Guess at what the encoding is
|
2021-11-04 08:33:43 -04:00
|
|
|
QString numeric = numericMessage;
|
|
|
|
QString alpha = alphaMessage;
|
2021-07-09 07:06:23 -04:00
|
|
|
bool done = false;
|
|
|
|
if (!done)
|
|
|
|
{
|
|
|
|
// If alpha contains control characters, possibly numeric
|
|
|
|
for (int i = 0; i < alpha.size(); i++)
|
|
|
|
{
|
|
|
|
if (iscntrl(alpha[i].toLatin1()) && !isspace(alpha[i].toLatin1()))
|
|
|
|
{
|
2024-10-11 06:01:43 -04:00
|
|
|
message = numeric;
|
2021-07-09 07:06:23 -04:00
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!done) {
|
|
|
|
// Possibly not likely to get only longer than 15 digits
|
|
|
|
if (numeric.size() > 15)
|
|
|
|
{
|
|
|
|
done = true;
|
2024-10-11 06:01:43 -04:00
|
|
|
message = alpha;
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!done) {
|
|
|
|
// Default to alpha
|
2024-10-11 06:01:43 -04:00
|
|
|
message = alpha;
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
}
|
2024-10-11 06:01:43 -04:00
|
|
|
|
|
|
|
return message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add row to table
|
|
|
|
void PagerDemodGUI::messageReceived(const QDateTime dateTime, int address, int functionBits,
|
|
|
|
const QString &numericMessage, const QString &alphaMessage,
|
|
|
|
int evenParityErrors, int bchParityErrors)
|
|
|
|
{
|
|
|
|
QString message = selectMessage(functionBits, numericMessage, alphaMessage);
|
|
|
|
QString addressString = QString("%1").arg(address, 7, 10, QChar('0'));
|
|
|
|
|
|
|
|
// Should we ignore the message if it is a duplicate?
|
|
|
|
if (m_settings.m_filterDuplicates && (ui->messages->rowCount() > 0))
|
|
|
|
{
|
|
|
|
int startRow = m_settings.m_duplicateMatchLastOnly ? ui->messages->rowCount() - 1 : 0;
|
|
|
|
for (int row = startRow; row < ui->messages->rowCount(); row++)
|
|
|
|
{
|
2024-10-11 06:15:34 -04:00
|
|
|
QString prevAddress = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_ADDRESS)->text();
|
|
|
|
QString prevMessage = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_MESSAGE)->text();
|
2024-10-11 06:01:43 -04:00
|
|
|
|
|
|
|
if ((message == prevMessage) && (m_settings.m_duplicateMatchMessageOnly || (addressString == prevAddress)))
|
|
|
|
{
|
|
|
|
// Ignore this message
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is scroll bar at bottom
|
|
|
|
QScrollBar *sb = ui->messages->verticalScrollBar();
|
|
|
|
bool scrollToBottom = sb->value() == sb->maximum();
|
|
|
|
|
|
|
|
// Add to messages table
|
|
|
|
ui->messages->setSortingEnabled(false);
|
|
|
|
int row = ui->messages->rowCount();
|
|
|
|
ui->messages->setRowCount(row + 1);
|
|
|
|
|
|
|
|
QTableWidgetItem *dateItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *timeItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *addressItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *messageItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *functionItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *alphaItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *numericItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *evenPEItem = new QTableWidgetItem();
|
|
|
|
QTableWidgetItem *bchPEItem = new QTableWidgetItem();
|
2024-10-11 06:15:34 -04:00
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_DATE, dateItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_TIME, timeItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_ADDRESS, addressItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_MESSAGE, messageItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_FUNCTION, functionItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_ALPHA, alphaItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_NUMERIC, numericItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_EVEN_PE, evenPEItem);
|
|
|
|
ui->messages->setItem(row, PagerDemodSettings::MESSAGE_COL_BCH_PE, bchPEItem);
|
2024-10-11 06:01:43 -04:00
|
|
|
dateItem->setText(dateTime.date().toString());
|
|
|
|
timeItem->setText(dateTime.time().toString());
|
|
|
|
addressItem->setText(addressString);
|
|
|
|
messageItem->setText(message);
|
2021-11-04 08:33:43 -04:00
|
|
|
functionItem->setText(QString("%1").arg(functionBits));
|
|
|
|
alphaItem->setText(alphaMessage);
|
|
|
|
numericItem->setText(numericMessage);
|
|
|
|
evenPEItem->setText(QString("%1").arg(evenParityErrors));
|
|
|
|
bchPEItem->setText(QString("%1").arg(bchParityErrors));
|
2023-05-15 11:44:02 -04:00
|
|
|
filterRow(row);
|
2021-07-09 07:06:23 -04:00
|
|
|
ui->messages->setSortingEnabled(true);
|
2022-03-01 12:20:35 -05:00
|
|
|
if (scrollToBottom) {
|
|
|
|
ui->messages->scrollToBottom();
|
|
|
|
}
|
2024-10-11 06:01:43 -04:00
|
|
|
checkNotification(row);
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PagerDemodGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (PagerDemod::MsgConfigurePagerDemod::match(message))
|
|
|
|
{
|
|
|
|
qDebug("PagerDemodGUI::handleMessage: PagerDemod::MsgConfigurePagerDemod");
|
2024-10-11 06:01:43 -04:00
|
|
|
const PagerDemod::MsgConfigurePagerDemod& cfg = (const PagerDemod::MsgConfigurePagerDemod&) message;
|
2021-07-09 07:06:23 -04:00
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
2021-12-02 17:54:39 -05:00
|
|
|
ui->scopeGUI->updateSettings();
|
|
|
|
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
|
2021-07-09 07:06:23 -04:00
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (PagerDemod::MsgPagerMessage::match(message))
|
|
|
|
{
|
2024-10-11 06:01:43 -04:00
|
|
|
const PagerDemod::MsgPagerMessage& report = (const PagerDemod::MsgPagerMessage&) message;
|
2021-11-04 08:33:43 -04:00
|
|
|
messageReceived(report.getDateTime(), report.getAddress(), report.getFunctionBits(),
|
|
|
|
report.getNumericMessage(), report.getAlphaMessage(),
|
|
|
|
report.getEvenParityErrors(), report.getBCHParityErrors());
|
2021-07-09 07:06:23 -04:00
|
|
|
return true;
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
else if (DSPSignalNotification::match(message))
|
|
|
|
{
|
2024-10-11 06:01:43 -04:00
|
|
|
const DSPSignalNotification& notif = (const DSPSignalNotification&) message;
|
2022-04-13 05:08:21 -04:00
|
|
|
m_deviceCenterFrequency = notif.getCenterFrequency();
|
|
|
|
m_basebandSampleRate = notif.getSampleRate();
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -m_basebandSampleRate/2, m_basebandSampleRate/2);
|
|
|
|
ui->deltaFrequencyLabel->setToolTip(tr("Range %1 %L2 Hz").arg(QChar(0xB1)).arg(m_basebandSampleRate/2));
|
|
|
|
updateAbsoluteCenterFrequency();
|
|
|
|
return true;
|
|
|
|
}
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::channelMarkerChangedByCursor()
|
|
|
|
{
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::channelMarkerHighlightedByCursor()
|
|
|
|
{
|
2022-04-25 18:42:26 -04:00
|
|
|
setHighlighted(m_channelMarker.getHighlighted());
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_deltaFrequency_changed(qint64 value)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(value);
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2021-07-09 07:06:23 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_rfBW_valueChanged(int value)
|
|
|
|
{
|
|
|
|
float bw = value * 100.0f;
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
m_channelMarker.setBandwidth(bw);
|
|
|
|
m_settings.m_rfBandwidth = bw;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_fmDev_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->fmDevText->setText(QString("%1k").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
m_settings.m_fmDeviation = value * 100.0;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_baud_currentIndexChanged(int index)
|
|
|
|
{
|
2021-07-09 08:40:31 -04:00
|
|
|
(void)index;
|
2021-07-09 07:06:23 -04:00
|
|
|
m_settings.m_baud = ui->baud->currentText().toInt();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_decode_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_decode = (PagerDemodSettings::Decode)index;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_filterAddress_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_filterAddress = ui->filterAddress->text();
|
|
|
|
filter();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_clearTable_clicked()
|
|
|
|
{
|
|
|
|
ui->messages->setRowCount(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_udpEnabled_clicked(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_udpEnabled = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_udpAddress_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_udpAddress = ui->udpAddress->text();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_udpPort_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_udpPort = ui->udpPort->text().toInt();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_channel1_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_scopeCh1 = index;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_channel2_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_scopeCh2 = index;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::filterRow(int row)
|
|
|
|
{
|
|
|
|
bool hidden = false;
|
|
|
|
if (m_settings.m_filterAddress != "")
|
|
|
|
{
|
|
|
|
QRegExp re(m_settings.m_filterAddress);
|
2024-10-11 06:15:34 -04:00
|
|
|
QTableWidgetItem *fromItem = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_ADDRESS);
|
2021-07-09 07:06:23 -04:00
|
|
|
if (!re.exactMatch(fromItem->text())) {
|
|
|
|
hidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ui->messages->setRowHidden(row, hidden);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::filter()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ui->messages->rowCount(); i++) {
|
|
|
|
filterRow(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
2022-11-09 11:59:02 -05:00
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
|
|
|
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
getRollupContents()->saveState(m_rollupState);
|
2021-11-24 04:50:42 -05:00
|
|
|
applySettings();
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::onMenuDialogCalled(const QPoint &p)
|
|
|
|
{
|
2024-08-25 17:36:46 -04:00
|
|
|
if (m_contextMenuType == ContextMenuType::ContextMenuChannelSettings)
|
2021-07-09 07:06:23 -04:00
|
|
|
{
|
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
|
2022-04-17 19:42:03 -04:00
|
|
|
dialog.setDefaultTitle(m_displayedName);
|
|
|
|
|
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
dialog.setNumberOfStreams(m_pagerDemod->getNumberOfDeviceStreams());
|
|
|
|
dialog.setStreamIndex(m_settings.m_streamIndex);
|
|
|
|
}
|
|
|
|
|
2021-07-09 07:06:23 -04:00
|
|
|
dialog.move(p);
|
2022-12-20 05:31:15 -05:00
|
|
|
new DialogPositioner(&dialog, false);
|
2021-07-09 07:06:23 -04:00
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_title = m_channelMarker.getTitle();
|
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
|
|
|
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
|
|
|
|
|
|
|
|
setWindowTitle(m_settings.m_title);
|
2022-04-12 10:20:45 -04:00
|
|
|
setTitle(m_channelMarker.getTitle());
|
2021-07-09 07:06:23 -04:00
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
2022-04-17 19:42:03 -04:00
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
|
|
|
|
m_channelMarker.clearStreamIndexes();
|
|
|
|
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
|
|
|
|
updateIndexLabel();
|
|
|
|
}
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
|
|
|
}
|
|
|
|
|
|
|
|
PagerDemodGUI::PagerDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
|
|
|
|
ChannelGUI(parent),
|
|
|
|
ui(new Ui::PagerDemodGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceUISet(deviceUISet),
|
|
|
|
m_channelMarker(this),
|
2022-04-13 05:08:21 -04:00
|
|
|
m_deviceCenterFrequency(0),
|
|
|
|
m_basebandSampleRate(1),
|
2021-07-09 07:06:23 -04:00
|
|
|
m_doApplySettings(true),
|
2024-10-11 06:01:43 -04:00
|
|
|
m_tickCount(0),
|
|
|
|
m_speech(nullptr)
|
2021-07-09 07:06:23 -04:00
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2022-04-24 06:28:56 -04:00
|
|
|
m_helpURL = "plugins/channelrx/demodpager/readme.md";
|
|
|
|
RollupContents *rollupContents = getRollupContents();
|
|
|
|
ui->setupUi(rollupContents);
|
|
|
|
setSizePolicy(rollupContents->sizePolicy());
|
|
|
|
rollupContents->arrangeRollups();
|
|
|
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2021-07-09 07:06:23 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
|
|
|
|
|
|
|
m_pagerDemod = reinterpret_cast<PagerDemod*>(rxChannel);
|
|
|
|
m_pagerDemod->setMessageQueueToGUI(getInputMessageQueue());
|
|
|
|
|
|
|
|
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
|
|
|
|
|
|
|
|
m_scopeVis = m_pagerDemod->getScopeSink();
|
|
|
|
m_scopeVis->setGLScope(ui->glScope);
|
|
|
|
m_scopeVis->setLiveRate(PagerDemodSettings::m_channelSampleRate);
|
|
|
|
ui->glScope->connectTimer(MainCore::instance()->getMasterTimer());
|
|
|
|
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
2021-07-13 12:03:12 -04:00
|
|
|
ui->scopeGUI->setSampleRate(PagerDemodSettings::m_channelSampleRate);
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
|
|
|
|
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setColor(Qt::yellow);
|
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle("Pager Demodulator");
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
|
|
|
m_settings.setScopeGUI(ui->scopeGUI);
|
2022-01-08 23:27:12 -05:00
|
|
|
m_settings.setRollupState(&m_rollupState);
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
|
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
|
|
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
|
|
|
2024-10-11 06:01:43 -04:00
|
|
|
CRightClickEnabler *filterDuplicatesRightClickEnabler = new CRightClickEnabler(ui->filterDuplicates);
|
|
|
|
connect(filterDuplicatesRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(on_filterDuplicates_rightClicked(const QPoint &)));
|
|
|
|
|
2021-07-09 07:06:23 -04:00
|
|
|
// Resize the table using dummy data
|
|
|
|
resizeTable();
|
|
|
|
// Allow user to reorder columns
|
|
|
|
ui->messages->horizontalHeader()->setSectionsMovable(true);
|
|
|
|
// Allow user to sort table by clicking on headers
|
|
|
|
ui->messages->setSortingEnabled(true);
|
|
|
|
// Add context menu to allow hiding/showing of columns
|
|
|
|
messagesMenu = new QMenu(ui->messages);
|
|
|
|
for (int i = 0; i < ui->messages->horizontalHeader()->count(); i++)
|
|
|
|
{
|
|
|
|
QString text = ui->messages->horizontalHeaderItem(i)->text();
|
|
|
|
messagesMenu->addAction(createCheckableItem(text, i, true, SLOT(messagesColumnSelectMenuChecked())));
|
|
|
|
}
|
|
|
|
ui->messages->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(ui->messages->horizontalHeader(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(messagesColumnSelectMenu(QPoint)));
|
|
|
|
// Get signals when columns change
|
|
|
|
connect(ui->messages->horizontalHeader(), SIGNAL(sectionMoved(int, int, int)), SLOT(messages_sectionMoved(int, int, int)));
|
|
|
|
connect(ui->messages->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), SLOT(messages_sectionResized(int, int, int)));
|
|
|
|
ui->messages->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(ui->messages, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customContextMenuRequested(QPoint)));
|
|
|
|
|
|
|
|
ui->scopeContainer->setVisible(false);
|
|
|
|
|
|
|
|
displaySettings();
|
2022-04-12 10:20:45 -04:00
|
|
|
makeUIConnections();
|
2021-07-09 07:06:23 -04:00
|
|
|
applySettings(true);
|
2023-11-13 15:51:03 -05:00
|
|
|
m_resizer.enableChildMouseTracking();
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::customContextMenuRequested(QPoint pos)
|
|
|
|
{
|
|
|
|
QTableWidgetItem *item = ui->messages->itemAt(pos);
|
|
|
|
if (item)
|
|
|
|
{
|
|
|
|
QMenu* tableContextMenu = new QMenu(ui->messages);
|
|
|
|
connect(tableContextMenu, &QMenu::aboutToHide, tableContextMenu, &QMenu::deleteLater);
|
|
|
|
QAction* copyAction = new QAction("Copy", tableContextMenu);
|
|
|
|
const QString text = item->text();
|
|
|
|
connect(copyAction, &QAction::triggered, this, [text]()->void {
|
|
|
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
|
|
|
clipboard->setText(text);
|
|
|
|
});
|
|
|
|
tableContextMenu->addAction(copyAction);
|
|
|
|
tableContextMenu->popup(ui->messages->viewport()->mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PagerDemodGUI::~PagerDemodGUI()
|
|
|
|
{
|
2024-10-11 06:01:43 -04:00
|
|
|
clearFromMap();
|
2021-07-09 07:06:23 -04:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::applySettings(bool force)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
PagerDemod::MsgConfigurePagerDemod* message = PagerDemod::MsgConfigurePagerDemod::create( m_settings, force);
|
|
|
|
m_pagerDemod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::displaySettings()
|
|
|
|
{
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
setWindowTitle(m_channelMarker.getTitle());
|
2022-04-12 10:20:45 -04:00
|
|
|
setTitle(m_channelMarker.getTitle());
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
|
|
|
|
if (m_settings.m_baud == 512) {
|
|
|
|
ui->baud->setCurrentIndex(0);
|
|
|
|
} else if (m_settings.m_baud == 1200) {
|
|
|
|
ui->baud->setCurrentIndex(1);
|
|
|
|
} else {
|
|
|
|
ui->baud->setCurrentIndex(2);
|
|
|
|
}
|
|
|
|
ui->decode->setCurrentIndex((int)m_settings.m_decode);
|
|
|
|
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg(m_settings.m_rfBandwidth / 1000.0, 0, 'f', 1));
|
|
|
|
ui->rfBW->setValue(m_settings.m_rfBandwidth / 100.0);
|
|
|
|
|
|
|
|
ui->fmDevText->setText(QString("%1k").arg(m_settings.m_fmDeviation / 1000.0, 0, 'f', 1));
|
|
|
|
ui->fmDev->setValue(m_settings.m_fmDeviation / 100.0);
|
|
|
|
|
2022-04-17 19:42:03 -04:00
|
|
|
updateIndexLabel();
|
2021-07-09 07:06:23 -04:00
|
|
|
|
|
|
|
ui->filterAddress->setText(m_settings.m_filterAddress);
|
|
|
|
|
|
|
|
ui->udpEnabled->setChecked(m_settings.m_udpEnabled);
|
|
|
|
ui->udpAddress->setText(m_settings.m_udpAddress);
|
|
|
|
ui->udpPort->setText(QString::number(m_settings.m_udpPort));
|
|
|
|
|
|
|
|
ui->channel1->setCurrentIndex(m_settings.m_scopeCh1);
|
|
|
|
ui->channel2->setCurrentIndex(m_settings.m_scopeCh2);
|
|
|
|
|
2021-11-04 08:33:43 -04:00
|
|
|
ui->logFilename->setToolTip(QString(".csv log filename: %1").arg(m_settings.m_logFilename));
|
|
|
|
ui->logEnable->setChecked(m_settings.m_logEnabled);
|
|
|
|
|
2024-10-11 06:01:43 -04:00
|
|
|
ui->filterDuplicates->setChecked(m_settings.m_filterDuplicates);
|
|
|
|
|
2021-07-09 07:06:23 -04:00
|
|
|
// Order and size columns
|
|
|
|
QHeaderView *header = ui->messages->horizontalHeader();
|
2022-01-08 23:27:12 -05:00
|
|
|
|
2021-07-09 07:06:23 -04:00
|
|
|
for (int i = 0; i < PAGERDEMOD_MESSAGE_COLUMNS; i++)
|
|
|
|
{
|
|
|
|
bool hidden = m_settings.m_messageColumnSizes[i] == 0;
|
|
|
|
header->setSectionHidden(i, hidden);
|
|
|
|
messagesMenu->actions().at(i)->setChecked(!hidden);
|
|
|
|
if (m_settings.m_messageColumnSizes[i] > 0)
|
|
|
|
ui->messages->setColumnWidth(i, m_settings.m_messageColumnSizes[i]);
|
|
|
|
header->moveSection(header->visualIndex(i), m_settings.m_messageColumnIndexes[i]);
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
|
2021-07-09 07:06:23 -04:00
|
|
|
filter();
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
getRollupContents()->restoreState(m_rollupState);
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2021-07-09 07:06:23 -04:00
|
|
|
blockApplySettings(false);
|
2024-10-11 06:01:43 -04:00
|
|
|
enableSpeechIfNeeded();
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
2022-04-22 13:21:24 -04:00
|
|
|
void PagerDemodGUI::leaveEvent(QEvent* event)
|
2021-07-09 07:06:23 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::leaveEvent(event);
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
2022-11-17 09:36:12 -05:00
|
|
|
void PagerDemodGUI::enterEvent(EnterEventType* event)
|
2021-07-09 07:06:23 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::enterEvent(event);
|
2021-07-09 07:06:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::tick()
|
|
|
|
{
|
|
|
|
double magsqAvg, magsqPeak;
|
|
|
|
int nbMagsqSamples;
|
|
|
|
m_pagerDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
|
|
|
|
double powDbAvg = CalcDb::dbPower(magsqAvg);
|
|
|
|
double powDbPeak = CalcDb::dbPower(magsqPeak);
|
|
|
|
|
|
|
|
ui->channelPowerMeter->levelChanged(
|
|
|
|
(100.0f + powDbAvg) / 100.0f,
|
|
|
|
(100.0f + powDbPeak) / 100.0f,
|
|
|
|
nbMagsqSamples);
|
|
|
|
|
|
|
|
if (m_tickCount % 4 == 0) {
|
|
|
|
ui->channelPower->setText(QString::number(powDbAvg, 'f', 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_tickCount++;
|
|
|
|
}
|
2021-07-19 12:57:13 -04:00
|
|
|
|
|
|
|
void PagerDemodGUI::on_charset_clicked()
|
|
|
|
{
|
|
|
|
PagerDemodCharsetDialog dialog(&m_settings);
|
2024-10-11 06:01:43 -04:00
|
|
|
new DialogPositioner(&dialog, true);
|
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_notifications_clicked()
|
|
|
|
{
|
|
|
|
PagerDemodNotificationDialog dialog(&m_settings);
|
|
|
|
new DialogPositioner(&dialog, true);
|
2021-07-19 12:57:13 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
2024-10-11 06:01:43 -04:00
|
|
|
enableSpeechIfNeeded();
|
2021-07-19 12:57:13 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
2021-11-04 08:33:43 -04:00
|
|
|
|
2024-10-11 06:01:43 -04:00
|
|
|
void PagerDemodGUI::on_filterDuplicates_clicked(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_filterDuplicates = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_filterDuplicates_rightClicked(const QPoint &p)
|
|
|
|
{
|
|
|
|
(void) p;
|
|
|
|
|
|
|
|
PagerDemodFilterDialog dialog(&m_settings);
|
|
|
|
new DialogPositioner(&dialog, true);
|
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
2021-11-04 08:33:43 -04:00
|
|
|
|
|
|
|
void PagerDemodGUI::on_logEnable_clicked(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_logEnabled = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::on_logFilename_clicked()
|
|
|
|
{
|
|
|
|
// Get filename to save to
|
|
|
|
QFileDialog fileDialog(nullptr, "Select file to log received messages to", "", "*.csv");
|
|
|
|
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
if (fileDialog.exec())
|
|
|
|
{
|
|
|
|
QStringList fileNames = fileDialog.selectedFiles();
|
|
|
|
if (fileNames.size() > 0)
|
|
|
|
{
|
|
|
|
m_settings.m_logFilename = fileNames[0];
|
|
|
|
ui->logFilename->setToolTip(QString(".csv log filename: %1").arg(m_settings.m_logFilename));
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read .csv log and process as received messages
|
|
|
|
void PagerDemodGUI::on_logOpen_clicked()
|
|
|
|
{
|
|
|
|
QFileDialog fileDialog(nullptr, "Select .csv log file to read", "", "*.csv");
|
|
|
|
if (fileDialog.exec())
|
|
|
|
{
|
|
|
|
QStringList fileNames = fileDialog.selectedFiles();
|
|
|
|
if (fileNames.size() > 0)
|
|
|
|
{
|
|
|
|
QFile file(fileNames[0]);
|
|
|
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
|
|
{
|
|
|
|
QTextStream in(&file);
|
|
|
|
QString error;
|
|
|
|
QHash<QString, int> colIndexes = CSV::readHeader(in, {"Date", "Time", "Address", "Function Bits", "Alpha", "Numeric", "Even Parity Errors", "BCH Parity Errors"}, error);
|
|
|
|
if (error.isEmpty())
|
|
|
|
{
|
|
|
|
int dateCol = colIndexes.value("Date");
|
|
|
|
int timeCol = colIndexes.value("Time");
|
|
|
|
int addressCol = colIndexes.value("Address");
|
|
|
|
int functionCol = colIndexes.value("Function Bits");
|
|
|
|
int alphaCol = colIndexes.value("Alpha");
|
|
|
|
int numericCol = colIndexes.value("Numeric");
|
|
|
|
int evenCol = colIndexes.value("Even Parity Errors");
|
|
|
|
int bchCol = colIndexes.value("BCH Parity Errors");
|
|
|
|
int maxCol = std::max({dateCol, timeCol, addressCol, functionCol, alphaCol, numericCol, evenCol, bchCol});
|
|
|
|
|
|
|
|
QMessageBox dialog(this);
|
|
|
|
dialog.setText("Reading messages");
|
|
|
|
dialog.addButton(QMessageBox::Cancel);
|
|
|
|
dialog.show();
|
|
|
|
QApplication::processEvents();
|
|
|
|
int count = 0;
|
|
|
|
bool cancelled = false;
|
|
|
|
|
|
|
|
QStringList cols;
|
|
|
|
while (!cancelled && CSV::readRow(in, &cols))
|
|
|
|
{
|
|
|
|
if (cols.size() > maxCol)
|
|
|
|
{
|
|
|
|
QDate date = QDate::fromString(cols[dateCol]);
|
|
|
|
QTime time = QTime::fromString(cols[timeCol]);
|
|
|
|
QDateTime dateTime(date, time);
|
|
|
|
int address = cols[addressCol].toInt();
|
|
|
|
int functionBits = cols[functionCol].toInt();
|
|
|
|
int evenErrors = cols[evenCol].toInt();
|
|
|
|
int bchErrors = cols[bchCol].toInt();
|
|
|
|
|
|
|
|
messageReceived(dateTime, address, functionBits,
|
|
|
|
cols[numericCol], cols[alphaCol],
|
|
|
|
evenErrors, bchErrors);
|
|
|
|
|
|
|
|
if (count % 1000 == 0)
|
|
|
|
{
|
|
|
|
QApplication::processEvents();
|
|
|
|
if (dialog.clickedButton()) {
|
|
|
|
cancelled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Pager Demod", error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Pager Demod", QString("Failed to open file %1").arg(fileNames[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
void PagerDemodGUI::makeUIConnections()
|
|
|
|
{
|
|
|
|
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &PagerDemodGUI::on_deltaFrequency_changed);
|
|
|
|
QObject::connect(ui->rfBW, &QSlider::valueChanged, this, &PagerDemodGUI::on_rfBW_valueChanged);
|
|
|
|
QObject::connect(ui->fmDev, &QSlider::valueChanged, this, &PagerDemodGUI::on_fmDev_valueChanged);
|
|
|
|
QObject::connect(ui->baud, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PagerDemodGUI::on_baud_currentIndexChanged);
|
|
|
|
QObject::connect(ui->decode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PagerDemodGUI::on_decode_currentIndexChanged);
|
|
|
|
QObject::connect(ui->charset, &QToolButton::clicked, this, &PagerDemodGUI::on_charset_clicked);
|
|
|
|
QObject::connect(ui->filterAddress, &QLineEdit::editingFinished, this, &PagerDemodGUI::on_filterAddress_editingFinished);
|
|
|
|
QObject::connect(ui->clearTable, &QToolButton::clicked, this, &PagerDemodGUI::on_clearTable_clicked);
|
|
|
|
QObject::connect(ui->udpEnabled, &QCheckBox::clicked, this, &PagerDemodGUI::on_udpEnabled_clicked);
|
|
|
|
QObject::connect(ui->udpAddress, &QLineEdit::editingFinished, this, &PagerDemodGUI::on_udpAddress_editingFinished);
|
|
|
|
QObject::connect(ui->udpPort, &QLineEdit::editingFinished, this, &PagerDemodGUI::on_udpPort_editingFinished);
|
2024-10-11 06:01:43 -04:00
|
|
|
QObject::connect(ui->notifications, &QToolButton::clicked, this, &PagerDemodGUI::on_notifications_clicked);
|
|
|
|
QObject::connect(ui->filterDuplicates, &ButtonSwitch::clicked, this, &PagerDemodGUI::on_filterDuplicates_clicked);
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(ui->logEnable, &ButtonSwitch::clicked, this, &PagerDemodGUI::on_logEnable_clicked);
|
|
|
|
QObject::connect(ui->logFilename, &QToolButton::clicked, this, &PagerDemodGUI::on_logFilename_clicked);
|
|
|
|
QObject::connect(ui->logOpen, &QToolButton::clicked, this, &PagerDemodGUI::on_logOpen_clicked);
|
2023-08-30 12:34:54 -04:00
|
|
|
QObject::connect(ui->channel1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PagerDemodGUI::on_channel1_currentIndexChanged);
|
|
|
|
QObject::connect(ui->channel2, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PagerDemodGUI::on_channel2_currentIndexChanged);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
|
|
|
|
void PagerDemodGUI::updateAbsoluteCenterFrequency()
|
|
|
|
{
|
|
|
|
setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
|
|
|
|
}
|
2024-10-11 06:01:43 -04:00
|
|
|
|
|
|
|
// Initialise text to speech engine
|
|
|
|
// This takes 10 seconds on some versions of Linux, so only do it, if user actually
|
|
|
|
// has speech notifications configured
|
|
|
|
void PagerDemodGUI::enableSpeechIfNeeded()
|
|
|
|
{
|
|
|
|
#ifdef QT_TEXTTOSPEECH_FOUND
|
|
|
|
if (m_speech) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (const auto& notification : m_settings.m_notificationSettings)
|
|
|
|
{
|
|
|
|
if (!notification->m_speech.isEmpty())
|
|
|
|
{
|
|
|
|
qDebug() << "PagerDemodGUI: Enabling text to speech";
|
|
|
|
m_speech = new QTextToSpeech(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::checkNotification(int row)
|
|
|
|
{
|
2024-10-11 06:15:34 -04:00
|
|
|
QString address = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_ADDRESS)->text();
|
|
|
|
QString message = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_MESSAGE)->text();
|
2024-10-11 06:01:43 -04:00
|
|
|
|
|
|
|
for (int i = 0; i < m_settings.m_notificationSettings.size(); i++)
|
|
|
|
{
|
|
|
|
QString match;
|
|
|
|
switch (m_settings.m_notificationSettings[i]->m_matchColumn)
|
|
|
|
{
|
2024-10-11 06:15:34 -04:00
|
|
|
case PagerDemodSettings::MESSAGE_COL_ADDRESS:
|
2024-10-11 06:01:43 -04:00
|
|
|
match = address;
|
|
|
|
break;
|
2024-10-11 06:15:34 -04:00
|
|
|
case PagerDemodSettings::MESSAGE_COL_MESSAGE:
|
2024-10-11 06:01:43 -04:00
|
|
|
match = message;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!match.isEmpty())
|
|
|
|
{
|
|
|
|
if (m_settings.m_notificationSettings[i]->m_regularExpression.isValid())
|
|
|
|
{
|
|
|
|
QRegularExpressionMatch matchResult = m_settings.m_notificationSettings[i]->m_regularExpression.match(match);
|
|
|
|
if (matchResult.hasMatch())
|
|
|
|
{
|
|
|
|
if (m_settings.m_notificationSettings[i]->m_highlight) {
|
2024-10-11 06:15:34 -04:00
|
|
|
ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_MESSAGE)->setTextColor(m_settings.m_notificationSettings[i]->m_highlightColor);
|
2024-10-11 06:01:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_settings.m_notificationSettings[i]->m_speech.isEmpty())
|
|
|
|
{
|
|
|
|
QString speech = subStrings(address, message, matchResult, m_settings.m_notificationSettings[i]->m_speech);
|
|
|
|
|
|
|
|
speechNotification(speech);
|
|
|
|
}
|
|
|
|
if (!m_settings.m_notificationSettings[i]->m_command.isEmpty())
|
|
|
|
{
|
|
|
|
QString command = subStrings(address, message, matchResult, m_settings.m_notificationSettings[i]->m_command);
|
|
|
|
|
|
|
|
commandNotification(command);
|
|
|
|
}
|
|
|
|
if (m_settings.m_notificationSettings[i]->m_plotOnMap)
|
|
|
|
{
|
|
|
|
float latitude;
|
|
|
|
float longitude;
|
|
|
|
|
|
|
|
if (Units::stringToLatitudeAndLongitude(message, latitude, longitude, false))
|
|
|
|
{
|
|
|
|
QDateTime dateTime;
|
|
|
|
|
2024-10-11 06:15:34 -04:00
|
|
|
dateTime.setDate(QDate::fromString(ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_DATE)->text()));
|
|
|
|
dateTime.setTime(QTime::fromString(ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_TIME)->text()));
|
2024-10-11 06:01:43 -04:00
|
|
|
|
|
|
|
sendToMap(address, message, latitude, longitude, dateTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PagerDemodGUI::subStrings(const QString& address, const QString& message, const QRegularExpressionMatch& match, const QString &string) const
|
|
|
|
{
|
|
|
|
QString s = string;
|
|
|
|
s = s.replace("${address}", address);
|
|
|
|
s = s.replace("${message}", message);
|
|
|
|
for (int i = 0; i < match.capturedTexts().size(); i++)
|
|
|
|
{
|
|
|
|
QString escape = QString("${%1}").arg(i);
|
|
|
|
s = s.replace(escape, match.capturedTexts()[i]);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::speechNotification(const QString &speech)
|
|
|
|
{
|
|
|
|
#ifdef QT_TEXTTOSPEECH_FOUND
|
|
|
|
if (m_speech) {
|
|
|
|
m_speech->say(speech);
|
|
|
|
} else {
|
|
|
|
qWarning() << "PagerDemodGUI::speechNotification: Unable to say " << speech;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
qWarning() << "PagerDemodGUI::speechNotification: TextToSpeech not supported. Unable to say " << speech;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::commandNotification(const QString &command)
|
|
|
|
{
|
|
|
|
#if QT_CONFIG(process)
|
|
|
|
QStringList allArgs = QProcess::splitCommand(command);
|
|
|
|
|
|
|
|
if (allArgs.size() > 0)
|
|
|
|
{
|
|
|
|
QString program = allArgs[0];
|
|
|
|
allArgs.pop_front();
|
|
|
|
QProcess::startDetached(program, allArgs);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
qWarning() << "PagerDemodGUI::commandNotification: QProcess not supported. Can't run: " << command;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagerDemodGUI::sendToMap(const QString& address, const QString& message, float latitude, float longitude, QDateTime dateTime)
|
|
|
|
{
|
|
|
|
QList<ObjectPipe*> mapPipes;
|
|
|
|
MainCore::instance()->getMessagePipes().getMessagePipes(m_pagerDemod, "mapitems", mapPipes);
|
|
|
|
|
|
|
|
for (const auto& pipe : mapPipes)
|
|
|
|
{
|
|
|
|
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
|
|
|
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
|
|
|
swgMapItem->setName(new QString(address));
|
|
|
|
swgMapItem->setLatitude(latitude);
|
|
|
|
swgMapItem->setLongitude(longitude);
|
|
|
|
swgMapItem->setAltitude(0);
|
|
|
|
swgMapItem->setAltitudeReference(1); // CLAMP_TO_GROUND
|
|
|
|
swgMapItem->setFixedPosition(false);
|
|
|
|
swgMapItem->setPositionDateTime(new QString(dateTime.toString(Qt::ISODateWithMs)));
|
|
|
|
|
|
|
|
swgMapItem->setImageRotation(0);
|
|
|
|
swgMapItem->setText(new QString(message));
|
|
|
|
swgMapItem->setImage(new QString(QString("pager.png")));
|
|
|
|
|
|
|
|
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_pagerDemod, swgMapItem);
|
|
|
|
messageQueue->push(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mapItems.insert(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear all items from map
|
|
|
|
void PagerDemodGUI::clearFromMap()
|
|
|
|
{
|
|
|
|
for (const auto& address : m_mapItems)
|
|
|
|
{
|
|
|
|
QList<ObjectPipe*> mapPipes;
|
|
|
|
MainCore::instance()->getMessagePipes().getMessagePipes(m_pagerDemod, "mapitems", mapPipes);
|
|
|
|
|
|
|
|
for (const auto& pipe : mapPipes)
|
|
|
|
{
|
|
|
|
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
|
|
|
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
|
|
|
swgMapItem->setName(new QString(address));
|
|
|
|
swgMapItem->setImage(new QString(QString("")));
|
|
|
|
|
|
|
|
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_pagerDemod, swgMapItem);
|
|
|
|
messageQueue->push(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mapItems.clear();
|
|
|
|
}
|