Continued refactoring of command processing
This commit is contained in:
parent
0a7c4a68de
commit
f0de2f2ba1
470
mainwindow.cpp
470
mainwindow.cpp
@ -222,6 +222,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int round(int numToRound, int multiple)
|
int round(int numToRound, int multiple)
|
||||||
{
|
{
|
||||||
if(multiple == 0)
|
if(multiple == 0)
|
||||||
@ -237,6 +238,7 @@ namespace
|
|||||||
|
|
||||||
return roundDown;
|
return roundDown;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int roundUp(int numToRound, int multiple)
|
int roundUp(int numToRound, int multiple)
|
||||||
{
|
{
|
||||||
@ -1121,6 +1123,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
|||||||
QMenu * menu = new QMenu(ui->tableWidgetCalls);
|
QMenu * menu = new QMenu(ui->tableWidgetCalls);
|
||||||
|
|
||||||
QString selectedCall = callsignSelected();
|
QString selectedCall = callsignSelected();
|
||||||
|
bool isAllCall = isAllCallIncluded(selectedCall);
|
||||||
bool missingCallsign = selectedCall.isEmpty();
|
bool missingCallsign = selectedCall.isEmpty();
|
||||||
if(!missingCallsign && m_callActivity.contains(selectedCall)){
|
if(!missingCallsign && m_callActivity.contains(selectedCall)){
|
||||||
setFreqForRestore(m_callActivity[selectedCall].freq, true);
|
setFreqForRestore(m_callActivity[selectedCall].freq, true);
|
||||||
@ -1132,10 +1135,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
|||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
removeStation->setDisabled(missingCallsign || callsignSelected() == "ALLCALL");
|
removeStation->setDisabled(missingCallsign || isAllCall);
|
||||||
menu->addAction(removeStation);
|
menu->addAction(removeStation);
|
||||||
|
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(clearAction4);
|
menu->addAction(clearAction4);
|
||||||
menu->addAction(clearActionAll);
|
menu->addAction(clearActionAll);
|
||||||
@ -4413,15 +4415,19 @@ void MainWindow::guiUpdate()
|
|||||||
|
|
||||||
m_sec0=nsec;
|
m_sec0=nsec;
|
||||||
|
|
||||||
|
|
||||||
// once per period
|
// once per period
|
||||||
if(m_sec0 % m_TRperiod == 0){
|
if(m_sec0 % m_TRperiod == 0){
|
||||||
|
// force rx dirty at least once pre period
|
||||||
m_rxDirty = true;
|
m_rxDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// once per second
|
// update the dial frequency once per second..
|
||||||
displayDialFrequency();
|
displayDialFrequency();
|
||||||
|
|
||||||
|
// process all received activity...
|
||||||
|
processActivity();
|
||||||
|
|
||||||
|
// once processed, lets update the display...
|
||||||
displayActivity();
|
displayActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5855,6 +5861,9 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
|
|||||||
// once we find a directed call, data encode the rest of the line.
|
// once we find a directed call, data encode the rest of the line.
|
||||||
bool hasDirected = false;
|
bool hasDirected = false;
|
||||||
|
|
||||||
|
// do the same for when we have sent data...
|
||||||
|
bool hasData = false;
|
||||||
|
|
||||||
// remove our callsign from the start of the line...
|
// remove our callsign from the start of the line...
|
||||||
if(line.startsWith(mycall + ":")){
|
if(line.startsWith(mycall + ":")){
|
||||||
line = lstrip(line.mid(mycall.length() + 1));
|
line = lstrip(line.mid(mycall.length() + 1));
|
||||||
@ -5889,21 +5898,22 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
|
|||||||
// if this parses to a standard FT8 free text message
|
// if this parses to a standard FT8 free text message
|
||||||
// but it can be parsed as a directed message, then we
|
// but it can be parsed as a directed message, then we
|
||||||
// should send the directed version. if we've already sent
|
// should send the directed version. if we've already sent
|
||||||
// a directed message, we won't send any more but instead
|
// a directed message or a data frame, we will only follow it
|
||||||
// send it as a data message
|
// with more data frames.
|
||||||
|
|
||||||
if(isFree && !hasDirected && l > 0){
|
if(isFree && !hasDirected && !hasData && l > 0){
|
||||||
useBcn = true;
|
useBcn = true;
|
||||||
hasDirected = false;
|
hasDirected = false;
|
||||||
frame = bcnFrame;
|
frame = bcnFrame;
|
||||||
}
|
}
|
||||||
else if(isFree && !hasDirected && n > 0){
|
else if(isFree && !hasDirected && !hasData && n > 0){
|
||||||
useDir = true;
|
useDir = true;
|
||||||
hasDirected = true;
|
hasDirected = true;
|
||||||
frame = dirFrame;
|
frame = dirFrame;
|
||||||
}
|
}
|
||||||
else if ((isFree || hasDirected) && m > 0) {
|
else if ((isFree || hasDirected) && m > 0) {
|
||||||
useDat = true;
|
useDat = true;
|
||||||
|
hasData = true;
|
||||||
frame = datFrame;
|
frame = datFrame;
|
||||||
if(!datLineOut.isEmpty()){
|
if(!datLineOut.isEmpty()){
|
||||||
line = datLineOut;
|
line = datLineOut;
|
||||||
@ -7363,7 +7373,7 @@ void MainWindow::buildQueryMenu(QMenu * menu){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAllCall = call == "ALLCALL";
|
bool isAllCall = isAllCallIncluded(call);
|
||||||
|
|
||||||
auto sendReplyAction = menu->addAction("CALL - Send a message to selected callsign");
|
auto sendReplyAction = menu->addAction("CALL - Send a message to selected callsign");
|
||||||
|
|
||||||
@ -8690,185 +8700,38 @@ bool MainWindow::isMyCallIncluded(const QString &text){
|
|||||||
return text.contains(myCall);
|
return text.contains(myCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MainWindow::isAllCallIncluded(const QString &text){
|
bool MainWindow::isAllCallIncluded(const QString &text){
|
||||||
return text.contains("ALLCALL");
|
return text.contains("ALLCALL");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::displayActivity(bool force){
|
void MainWindow::processActivity(bool force) {
|
||||||
if (!m_rxDirty && !force) {
|
if (!m_rxDirty && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it ok to post spots to PSKReporter?
|
// Recent Rx Activity
|
||||||
int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged;
|
processRxActivity();
|
||||||
bool okToPost=(nsec>(4*m_TRperiod)/5);
|
|
||||||
|
|
||||||
// Selected Rows
|
// Grouped Compound Activity
|
||||||
int selectedOffset = -1;
|
processCompoundActivity();
|
||||||
auto selectedItems = ui->tableWidgetRXAll->selectedItems();
|
|
||||||
if(!selectedItems.isEmpty()){
|
// Buffered Activity
|
||||||
selectedOffset = selectedItems.first()->text().toInt();
|
processBufferedActivity();
|
||||||
|
|
||||||
|
// Command Activity
|
||||||
|
processCommandActivity();
|
||||||
|
|
||||||
|
// Process PSKReporter Spots
|
||||||
|
processSpots();
|
||||||
|
|
||||||
|
m_rxDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selected callsign
|
void MainWindow::processRxActivity() {
|
||||||
QString selectedCall = callsignSelected();
|
if(m_rxFrameQueue.isEmpty()){
|
||||||
|
return;
|
||||||
// Band Activity
|
|
||||||
auto now = QDateTime::currentDateTimeUtc();
|
|
||||||
clearTableWidget(ui->tableWidgetRXAll);
|
|
||||||
QList<int> keys = m_bandActivity.keys();
|
|
||||||
|
|
||||||
// sort directed & recent messages first
|
|
||||||
qSort(keys.begin(), keys.end(), [this](const int left, int right){
|
|
||||||
if(m_rxDirectedCache.contains(left/10*10)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(m_rxDirectedCache.contains(right/10*10)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(m_rxRecentCache.contains(left/10*10)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(m_rxRecentCache.contains(right/10*10)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return left < right;
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (int offset, keys) {
|
|
||||||
QList<ActivityDetail> items = m_bandActivity[offset];
|
|
||||||
if(items.length() > 0){
|
|
||||||
QStringList text;
|
|
||||||
QString age;
|
|
||||||
int snr = 0;
|
|
||||||
int activityAging = m_config.activity_aging();
|
|
||||||
foreach(ActivityDetail item, items){
|
|
||||||
if(activityAging && item.utcTimestamp.secsTo(now)/60 >= activityAging){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(item.text.isEmpty()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(item.isLowConfidence){
|
|
||||||
item.text = QString("[%1]").arg(item.text);
|
|
||||||
}
|
|
||||||
if(item.bits == Varicode::FT8CallLast){
|
|
||||||
// can also use \u0004 \u2666 \u2404
|
|
||||||
item.text = QString("%1 \u2301 ").arg(item.text);
|
|
||||||
}
|
|
||||||
text.append(item.text);
|
|
||||||
snr = item.snr;
|
|
||||||
age = since(item.utcTimestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto joined = text.join(" ");
|
|
||||||
if(joined.isEmpty()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->tableWidgetRXAll->insertRow(ui->tableWidgetRXAll->rowCount());
|
|
||||||
|
|
||||||
auto offsetItem = new QTableWidgetItem(QString("%1").arg(offset));
|
|
||||||
offsetItem->setData(Qt::UserRole, QVariant(offset));
|
|
||||||
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 0, offsetItem);
|
|
||||||
|
|
||||||
auto ageItem = new QTableWidgetItem(QString("(%1)").arg(age));
|
|
||||||
ageItem->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
|
|
||||||
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 1, ageItem);
|
|
||||||
|
|
||||||
auto snrItem = new QTableWidgetItem(QString("%1").arg(Varicode::formatSNR(snr)));
|
|
||||||
snrItem->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
|
|
||||||
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 2, snrItem);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// align right if eliding...
|
|
||||||
int colWidth = ui->tableWidgetRXAll->columnWidth(3);
|
|
||||||
auto textItem = new QTableWidgetItem(joined);
|
|
||||||
QFontMetrics fm(textItem->font());
|
|
||||||
auto elidedText = fm.elidedText(joined, Qt::ElideLeft, colWidth);
|
|
||||||
auto flag = Qt::AlignLeft|Qt::AlignVCenter;
|
|
||||||
if(elidedText != joined){
|
|
||||||
flag = Qt::AlignRight|Qt::AlignVCenter;
|
|
||||||
textItem->setText(joined);
|
|
||||||
}
|
|
||||||
textItem->setTextAlignment(flag);
|
|
||||||
|
|
||||||
if (text.last().contains(QRegularExpression {"^(CQ|QRZ|DE)\\s"})){
|
|
||||||
offsetItem->setBackground(QBrush(m_config.color_CQ()));
|
|
||||||
ageItem->setBackground(QBrush(m_config.color_CQ()));
|
|
||||||
snrItem->setBackground(QBrush(m_config.color_CQ()));
|
|
||||||
textItem->setBackground(QBrush(m_config.color_CQ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_rxDirectedCache.contains(offset/10*10)){
|
|
||||||
offsetItem->setBackground(QBrush(m_config.color_MyCall()));
|
|
||||||
ageItem->setBackground(QBrush(m_config.color_MyCall()));
|
|
||||||
snrItem->setBackground(QBrush(m_config.color_MyCall()));
|
|
||||||
textItem->setBackground(QBrush(m_config.color_MyCall()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 3, textItem);
|
|
||||||
|
|
||||||
if(offset == selectedOffset){
|
|
||||||
ui->tableWidgetRXAll->selectRow(ui->tableWidgetRXAll->rowCount() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui->tableWidgetRXAll->resizeColumnToContents(0);
|
|
||||||
ui->tableWidgetRXAll->resizeColumnToContents(1);
|
|
||||||
ui->tableWidgetRXAll->resizeColumnToContents(2);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Call Activity
|
|
||||||
|
|
||||||
clearTableWidget(ui->tableWidgetCalls);
|
|
||||||
|
|
||||||
ui->tableWidgetCalls->insertRow(ui->tableWidgetCalls->rowCount());
|
|
||||||
auto item = new QTableWidgetItem("ALLCALL");
|
|
||||||
item->setData(Qt::UserRole, QVariant("ALLCALL"));
|
|
||||||
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 0, item);
|
|
||||||
ui->tableWidgetCalls->setSpan(ui->tableWidgetCalls->rowCount() - 1, 0, 1, ui->tableWidgetCalls->columnCount());
|
|
||||||
if(selectedCall == "ALLCALL"){
|
|
||||||
ui->tableWidgetCalls->selectRow(ui->tableWidgetCalls->rowCount() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QString> calls = m_callActivity.keys();
|
|
||||||
qSort(calls.begin(), calls.end());
|
|
||||||
int callsignAging = m_config.callsign_aging();
|
|
||||||
foreach(QString call, calls){
|
|
||||||
CallDetail d = m_callActivity[call];
|
|
||||||
|
|
||||||
if(callsignAging && d.utcTimestamp.secsTo(now)/60 >= callsignAging){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->tableWidgetCalls->insertRow(ui->tableWidgetCalls->rowCount());
|
|
||||||
|
|
||||||
QString displayCall = d.through.isEmpty() ? d.call : QString("%1 | %2").arg(d.through).arg(d.call);
|
|
||||||
auto displayItem = new QTableWidgetItem(displayCall);
|
|
||||||
displayItem->setData(Qt::UserRole, QVariant((d.call)));
|
|
||||||
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 0, displayItem);
|
|
||||||
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 1, new QTableWidgetItem(QString("(%1)").arg(since(d.utcTimestamp))));
|
|
||||||
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 2, new QTableWidgetItem(QString("%1").arg(Varicode::formatSNR(d.snr))));
|
|
||||||
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 3, new QTableWidgetItem(QString("%1").arg(d.grid)));
|
|
||||||
|
|
||||||
auto distanceItem = new QTableWidgetItem(calculateDistance(d.grid));
|
|
||||||
distanceItem->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
|
||||||
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 4, distanceItem);
|
|
||||||
|
|
||||||
if(call == selectedCall){
|
|
||||||
ui->tableWidgetCalls->selectRow(ui->tableWidgetCalls->rowCount() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui->tableWidgetCalls->resizeColumnToContents(0);
|
|
||||||
ui->tableWidgetCalls->resizeColumnToContents(1);
|
|
||||||
ui->tableWidgetCalls->resizeColumnToContents(2);
|
|
||||||
ui->tableWidgetCalls->resizeColumnToContents(3);
|
|
||||||
|
|
||||||
// Recently Directed Activity
|
|
||||||
while (!m_rxFrameQueue.isEmpty()) {
|
while (!m_rxFrameQueue.isEmpty()) {
|
||||||
ActivityDetail d = m_rxFrameQueue.dequeue();
|
ActivityDetail d = m_rxFrameQueue.dequeue();
|
||||||
|
|
||||||
@ -8893,9 +8756,14 @@ void MainWindow::displayActivity(bool force){
|
|||||||
m_rxFrameBlockNumbers.remove(freq);
|
m_rxFrameBlockNumbers.remove(freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Grouped Compound Activity
|
void MainWindow::processCompoundActivity() {
|
||||||
// TODO: jsherer - group compound callsign and directed commands together.
|
if(m_messageBuffer.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// group compound callsign and directed commands together.
|
||||||
foreach(auto freq, m_messageBuffer.keys()) {
|
foreach(auto freq, m_messageBuffer.keys()) {
|
||||||
QMap < int, MessageBuffer > ::iterator i = m_messageBuffer.find(freq);
|
QMap < int, MessageBuffer > ::iterator i = m_messageBuffer.find(freq);
|
||||||
|
|
||||||
@ -8954,8 +8822,13 @@ void MainWindow::displayActivity(bool force){
|
|||||||
m_rxCommandQueue.append(buffer.cmd);
|
m_rxCommandQueue.append(buffer.cmd);
|
||||||
m_messageBuffer.remove(freq);
|
m_messageBuffer.remove(freq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::processBufferedActivity() {
|
||||||
|
if(m_messageBuffer.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Buffered Activity
|
|
||||||
foreach(auto freq, m_messageBuffer.keys()) {
|
foreach(auto freq, m_messageBuffer.keys()) {
|
||||||
auto buffer = m_messageBuffer[freq];
|
auto buffer = m_messageBuffer[freq];
|
||||||
|
|
||||||
@ -8988,24 +8861,34 @@ void MainWindow::displayActivity(bool force){
|
|||||||
// regardless of valid or not, remove the "complete" buffered message from the buffer cache
|
// regardless of valid or not, remove the "complete" buffered message from the buffer cache
|
||||||
m_messageBuffer.remove(freq);
|
m_messageBuffer.remove(freq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Command Activity
|
void MainWindow::processCommandActivity() {
|
||||||
if(m_txFrameQueue.isEmpty() && !m_rxCommandQueue.isEmpty()){
|
#if 0
|
||||||
int f = currentFreq();
|
if (!m_txFrameQueue.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (m_rxCommandQueue.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
|
|
||||||
// TODO: jsherer - should we if we have _any_ directed messages, pause the beacon??
|
int f = currentFreq();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO: jsherer - should we, if we have _any_ directed messages, pause the beacon??
|
||||||
// pauseBacon();
|
// pauseBacon();
|
||||||
|
|
||||||
while (!m_rxCommandQueue.isEmpty()) {
|
while (!m_rxCommandQueue.isEmpty()) {
|
||||||
auto d = m_rxCommandQueue.dequeue();
|
auto d = m_rxCommandQueue.dequeue();
|
||||||
|
|
||||||
bool isAllCall = d.to == "ALLCALL";
|
bool isAllCall = isAllCallIncluded(d.to);
|
||||||
|
|
||||||
#if 1
|
qDebug() << "try processing command" << d.from << d.to << d.cmd << d.freq;
|
||||||
qDebug() << "processing command" << d.from << d.to << d.cmd << d.freq;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// if we need a compound callsign but never got one...skip
|
// if we need a compound callsign but never got one...skip
|
||||||
if (d.from == "<....>" || d.to == "<....>") {
|
if (d.from == "<....>" || d.to == "<....>") {
|
||||||
@ -9022,16 +8905,19 @@ void MainWindow::displayActivity(bool force){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// TODO: jsherer - check to make sure we haven't replied to their allcall recently (in the past beacon interval)
|
// TODO: jsherer - check to make sure we haven't replied to their allcall recently (in the past beacon interval)
|
||||||
if (isAllCall && m_txAllcallCommandCache.contains(Radio::base_callsign(d.from)) && m_txAllcallCommandCache[Radio::base_callsign(d.from)]->secsTo(QDateTime::currentDateTimeUtc()) / 60 < m_config.beacon()) {
|
if (isAllCall && m_txAllcallCommandCache.contains(Radio::base_callsign(d.from)) && m_txAllcallCommandCache[Radio::base_callsign(d.from)]->secsTo(QDateTime::currentDateTimeUtc()) / 60 < m_config.beacon()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: jsherer - we need to queue these for later processing
|
||||||
// record the spot to PSKReporter
|
// record the spot to PSKReporter
|
||||||
if (okToPost) {
|
if (okToPost) {
|
||||||
pskSetLocal();
|
pskSetLocal();
|
||||||
pskLogReport("FT8Call", d.freq, d.snr, d.from, "");
|
pskLogReport("FT8Call", d.freq, d.snr, d.from, "");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// construct a reply
|
// construct a reply
|
||||||
QString reply;
|
QString reply;
|
||||||
@ -9070,7 +8956,9 @@ void MainWindow::displayActivity(bool force){
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int maxStations = 4;
|
int maxStations = 4;
|
||||||
auto calls = m_callActivity.keys();
|
auto calls = m_callActivity.keys();
|
||||||
qSort(calls.begin(), calls.end(), [this](QString const &a, QString const &b){
|
qSort(calls.begin(), calls.end(), [this](QString
|
||||||
|
const & a, QString
|
||||||
|
const & b) {
|
||||||
auto left = m_callActivity[a];
|
auto left = m_callActivity[a];
|
||||||
auto right = m_callActivity[b];
|
auto right = m_callActivity[b];
|
||||||
return right.snr < left.snr;
|
return right.snr < left.snr;
|
||||||
@ -9106,7 +8994,6 @@ void MainWindow::displayActivity(bool force){
|
|||||||
msgBox->setText(header);
|
msgBox->setText(header);
|
||||||
msgBox->setInformativeText(d.text);
|
msgBox->setInformativeText(d.text);
|
||||||
|
|
||||||
|
|
||||||
auto ab = msgBox->addButton("ACK", QMessageBox::AcceptRole);
|
auto ab = msgBox->addButton("ACK", QMessageBox::AcceptRole);
|
||||||
auto db = msgBox->addButton("Discard", QMessageBox::NoRole);
|
auto db = msgBox->addButton("Discard", QMessageBox::NoRole);
|
||||||
|
|
||||||
@ -9114,8 +9001,11 @@ void MainWindow::displayActivity(bool force){
|
|||||||
if (btn != ab) {
|
if (btn != ab) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
addMessageText(QString("%1 ACK").arg(d.from));
|
addMessageText(QString("%1 ACK").arg(d.from));
|
||||||
toggleTx(true);
|
toggleTx(true);
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
msgBox->show();
|
msgBox->show();
|
||||||
@ -9129,27 +9019,227 @@ void MainWindow::displayActivity(bool force){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
addMessageText(reply);
|
addMessageText(reply);
|
||||||
|
|
||||||
// use the last frequency
|
// use the last frequency
|
||||||
f = d.freq;
|
f = d.freq;
|
||||||
|
|
||||||
// if we're responding via allcall, pick a different frequency and mark it in the cache.
|
// if we're responding via allcall, pick a different frequency and mark it in the cache.
|
||||||
if(d.to == "ALLCALL"){
|
if (isAllCallIncluded(d.to)) {
|
||||||
f = findFreeFreqOffset(qMax(0, f - 100), qMin(f + 100, 2500), 50);
|
f = findFreeFreqOffset(qMax(0, f - 100), qMin(f + 100, 2500), 50);
|
||||||
m_txAllcallCommandCache.insert(Radio::base_callsign(d.from), new QDateTime(QDateTime::currentDateTimeUtc()), 25);
|
m_txAllcallCommandCache.insert(Radio::base_callsign(d.from), new QDateTime(QDateTime::currentDateTimeUtc()), 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
processed = true;
|
processed = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO: jsherer - queue the reply here to be sent when a free interval is available
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (processed && ui->autoReplyButton->isChecked()) {
|
if (processed && ui->autoReplyButton->isChecked()) {
|
||||||
toggleTx(true);
|
toggleTx(true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::processSpots() {
|
||||||
|
// Is it ok to post spots to PSKReporter?
|
||||||
|
int nsec = QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged;
|
||||||
|
bool okToPost = (nsec > (4 * m_TRperiod) / 5);
|
||||||
|
if (!okToPost) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_rxDirty = false;
|
// Process spots to be sent...
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::displayActivity(bool force) {
|
||||||
|
if (!m_rxDirty && !force) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Band Activity
|
||||||
|
displayBandActivity();
|
||||||
|
|
||||||
|
// Call Activity
|
||||||
|
displayCallActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::displayBandActivity() {
|
||||||
|
auto now = QDateTime::currentDateTimeUtc();
|
||||||
|
|
||||||
|
// Selected Offset
|
||||||
|
int selectedOffset = -1;
|
||||||
|
auto selectedItems = ui->tableWidgetRXAll->selectedItems();
|
||||||
|
if (!selectedItems.isEmpty()) {
|
||||||
|
selectedOffset = selectedItems.first()->text().toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the table
|
||||||
|
clearTableWidget(ui->tableWidgetRXAll);
|
||||||
|
|
||||||
|
// Sort directed & recent messages first
|
||||||
|
QList < int > keys = m_bandActivity.keys();
|
||||||
|
qSort(keys.begin(), keys.end(), [this](const int left, int right) {
|
||||||
|
if (m_rxDirectedCache.contains(left / 10 * 10)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (m_rxDirectedCache.contains(right / 10 * 10)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (m_rxRecentCache.contains(left / 10 * 10)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (m_rxRecentCache.contains(right / 10 * 10)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return left < right;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Build the table
|
||||||
|
foreach(int offset, keys) {
|
||||||
|
QList < ActivityDetail > items = m_bandActivity[offset];
|
||||||
|
if (items.length() > 0) {
|
||||||
|
QStringList text;
|
||||||
|
QString age;
|
||||||
|
int snr = 0;
|
||||||
|
int activityAging = m_config.activity_aging();
|
||||||
|
foreach(ActivityDetail item, items) {
|
||||||
|
if (activityAging && item.utcTimestamp.secsTo(now) / 60 >= activityAging) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.text.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.isLowConfidence) {
|
||||||
|
item.text = QString("[%1]").arg(item.text);
|
||||||
|
}
|
||||||
|
if (item.bits == Varicode::FT8CallLast) {
|
||||||
|
// can also use \u0004 \u2666 \u2404
|
||||||
|
item.text = QString("%1 \u2301 ").arg(item.text);
|
||||||
|
}
|
||||||
|
text.append(item.text);
|
||||||
|
snr = item.snr;
|
||||||
|
age = since(item.utcTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto joined = text.join(" ");
|
||||||
|
if (joined.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidgetRXAll->insertRow(ui->tableWidgetRXAll->rowCount());
|
||||||
|
|
||||||
|
auto offsetItem = new QTableWidgetItem(QString("%1").arg(offset));
|
||||||
|
offsetItem->setData(Qt::UserRole, QVariant(offset));
|
||||||
|
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 0, offsetItem);
|
||||||
|
|
||||||
|
auto ageItem = new QTableWidgetItem(QString("(%1)").arg(age));
|
||||||
|
ageItem->setTextAlignment(Qt::AlignCenter | Qt::AlignVCenter);
|
||||||
|
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 1, ageItem);
|
||||||
|
|
||||||
|
auto snrItem = new QTableWidgetItem(QString("%1").arg(Varicode::formatSNR(snr)));
|
||||||
|
snrItem->setTextAlignment(Qt::AlignCenter | Qt::AlignVCenter);
|
||||||
|
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 2, snrItem);
|
||||||
|
|
||||||
|
// align right if eliding...
|
||||||
|
int colWidth = ui->tableWidgetRXAll->columnWidth(3);
|
||||||
|
auto textItem = new QTableWidgetItem(joined);
|
||||||
|
QFontMetrics fm(textItem->font());
|
||||||
|
auto elidedText = fm.elidedText(joined, Qt::ElideLeft, colWidth);
|
||||||
|
auto flag = Qt::AlignLeft | Qt::AlignVCenter;
|
||||||
|
if (elidedText != joined) {
|
||||||
|
flag = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
|
textItem->setText(joined);
|
||||||
|
}
|
||||||
|
textItem->setTextAlignment(flag);
|
||||||
|
|
||||||
|
if (text.last().contains(QRegularExpression {
|
||||||
|
"^(CQ|QRZ|DE)\\s"
|
||||||
|
})) {
|
||||||
|
offsetItem->setBackground(QBrush(m_config.color_CQ()));
|
||||||
|
ageItem->setBackground(QBrush(m_config.color_CQ()));
|
||||||
|
snrItem->setBackground(QBrush(m_config.color_CQ()));
|
||||||
|
textItem->setBackground(QBrush(m_config.color_CQ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_rxDirectedCache.contains(offset / 10 * 10)) {
|
||||||
|
offsetItem->setBackground(QBrush(m_config.color_MyCall()));
|
||||||
|
ageItem->setBackground(QBrush(m_config.color_MyCall()));
|
||||||
|
snrItem->setBackground(QBrush(m_config.color_MyCall()));
|
||||||
|
textItem->setBackground(QBrush(m_config.color_MyCall()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 3, textItem);
|
||||||
|
|
||||||
|
if (offset == selectedOffset) {
|
||||||
|
ui->tableWidgetRXAll->selectRow(ui->tableWidgetRXAll->rowCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resize the table columns
|
||||||
|
ui->tableWidgetRXAll->resizeColumnToContents(0);
|
||||||
|
ui->tableWidgetRXAll->resizeColumnToContents(1);
|
||||||
|
ui->tableWidgetRXAll->resizeColumnToContents(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::displayCallActivity() {
|
||||||
|
auto now = QDateTime::currentDateTimeUtc();
|
||||||
|
|
||||||
|
// Selected callsign
|
||||||
|
QString selectedCall = callsignSelected();
|
||||||
|
|
||||||
|
// Clear the table
|
||||||
|
clearTableWidget(ui->tableWidgetCalls);
|
||||||
|
|
||||||
|
// Create the ALLCALL item
|
||||||
|
auto item = new QTableWidgetItem("ALLCALL");
|
||||||
|
ui->tableWidgetCalls->insertRow(ui->tableWidgetCalls->rowCount());
|
||||||
|
item->setData(Qt::UserRole, QVariant("ALLCALL"));
|
||||||
|
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 0, item);
|
||||||
|
ui->tableWidgetCalls->setSpan(ui->tableWidgetCalls->rowCount() - 1, 0, 1, ui->tableWidgetCalls->columnCount());
|
||||||
|
if (isAllCallIncluded(selectedCall)) {
|
||||||
|
ui->tableWidgetCalls->selectRow(ui->tableWidgetCalls->rowCount() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the table
|
||||||
|
QList < QString > calls = m_callActivity.keys();
|
||||||
|
qSort(calls.begin(), calls.end());
|
||||||
|
int callsignAging = m_config.callsign_aging();
|
||||||
|
foreach(QString call, calls) {
|
||||||
|
CallDetail d = m_callActivity[call];
|
||||||
|
|
||||||
|
if (callsignAging && d.utcTimestamp.secsTo(now) / 60 >= callsignAging) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidgetCalls->insertRow(ui->tableWidgetCalls->rowCount());
|
||||||
|
|
||||||
|
QString displayCall = d.through.isEmpty() ? d.call : QString("%1 | %2").arg(d.through).arg(d.call);
|
||||||
|
auto displayItem = new QTableWidgetItem(displayCall);
|
||||||
|
displayItem->setData(Qt::UserRole, QVariant((d.call)));
|
||||||
|
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 0, displayItem);
|
||||||
|
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 1, new QTableWidgetItem(QString("(%1)").arg(since(d.utcTimestamp))));
|
||||||
|
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 2, new QTableWidgetItem(QString("%1").arg(Varicode::formatSNR(d.snr))));
|
||||||
|
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 3, new QTableWidgetItem(QString("%1").arg(d.grid)));
|
||||||
|
|
||||||
|
auto distanceItem = new QTableWidgetItem(calculateDistance(d.grid));
|
||||||
|
distanceItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 4, distanceItem);
|
||||||
|
|
||||||
|
if (call == selectedCall) {
|
||||||
|
ui->tableWidgetCalls->selectRow(ui->tableWidgetCalls->rowCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resize the table columns
|
||||||
|
ui->tableWidgetCalls->resizeColumnToContents(0);
|
||||||
|
ui->tableWidgetCalls->resizeColumnToContents(1);
|
||||||
|
ui->tableWidgetCalls->resizeColumnToContents(2);
|
||||||
|
ui->tableWidgetCalls->resizeColumnToContents(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::postWSPRDecode (bool is_new, QStringList parts)
|
void MainWindow::postWSPRDecode (bool is_new, QStringList parts)
|
||||||
|
@ -795,7 +795,15 @@ private:
|
|||||||
QString callsignSelected();
|
QString callsignSelected();
|
||||||
bool isRecentOffset(int offset);
|
bool isRecentOffset(int offset);
|
||||||
bool isDirectedOffset(int offset);
|
bool isDirectedOffset(int offset);
|
||||||
|
void processActivity(bool force=false);
|
||||||
|
void processRxActivity();
|
||||||
|
void processCompoundActivity();
|
||||||
|
void processBufferedActivity();
|
||||||
|
void processCommandActivity();
|
||||||
|
void processSpots();
|
||||||
void displayActivity(bool force=false);
|
void displayActivity(bool force=false);
|
||||||
|
void displayBandActivity();
|
||||||
|
void displayCallActivity();
|
||||||
void postWSPRDecode (bool is_new, QStringList message_parts);
|
void postWSPRDecode (bool is_new, QStringList message_parts);
|
||||||
void enable_DXCC_entity (bool on);
|
void enable_DXCC_entity (bool on);
|
||||||
void switch_mode (Mode);
|
void switch_mode (Mode);
|
||||||
|
Loading…
Reference in New Issue
Block a user