diff --git a/mainwindow.cpp b/mainwindow.cpp index 51d04110e..f5b30b776 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -286,6 +286,12 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) : } } #endif + +#ifdef unix + psk_Reporter = new PSK_Reporter(this); + psk_Reporter->setLocalStation(m_myCall,m_myGrid, "WSJT-X r" + rev.mid(6,4) ); +#endif + ui->label_9->setStyleSheet("QLabel{background-color: #aabec8}"); ui->label_10->setStyleSheet("QLabel{background-color: #aabec8}"); @@ -649,6 +655,11 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog } } #endif + +#ifdef unix + psk_Reporter->setLocalStation(m_myCall,m_myGrid, "WSJT-X r" + rev.mid(6,4) ); +#endif + m_pskReporter=dlg.m_pskReporter; m_After73=dlg.m_After73; @@ -1331,6 +1342,22 @@ void MainWindow::readFromStdout() //readFromStdout } } #endif + +#ifdef unix + if(b and !m_diskData) { + int i1=msg.indexOf(" "); + QString c2=msg.mid(i1+1); + int i2=c2.indexOf(" "); + QString g2=c2.mid(i2+1,4); + c2=c2.mid(0,i2); + QString grid; + if(gridOK(g2)) grid = g2; + int nHz=t.mid(22,4).toInt(); + QString freq = QString::number(1000000.0*m_dialFreq + nHz + 0.5); + QString snr= QString::number(t.mid(10,3).toInt()); + psk_Reporter->addRemoteStation(c2,grid,freq,"JT9",snr,QString::number(QDateTime::currentDateTime().toTime_t())); + } +#endif } } } diff --git a/mainwindow.h b/mainwindow.h index 89b9b471a..a9cc74ca8 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -6,6 +6,7 @@ #include "soundin.h" #include "soundout.h" #include "commons.h" +#include "psk_reporter.h" #ifdef WIN32 #include "PSKReporter.h" @@ -315,6 +316,8 @@ private: QSharedMemory *mem_jt9; + PSK_Reporter *psk_Reporter; + //---------------------------------------------------- private functions void readSettings(); void writeSettings(); diff --git a/psk_reporter.cpp b/psk_reporter.cpp index 7287f4088..522714da7 100644 --- a/psk_reporter.cpp +++ b/psk_reporter.cpp @@ -2,7 +2,6 @@ // Implemented by Edson Pereira PY2SDR // // Reports will be sent in batch mode every 5 minutes. -// If there are no spots to be sent, a report will be sent with only the receiver station info. #include "psk_reporter.h" @@ -37,7 +36,6 @@ PSK_Reporter::PSK_Reporter(QObject *parent) : reportTimer = new QTimer(this); connect(reportTimer, SIGNAL(timeout()), this, SLOT(sendReport())); - reportTimer->start(5*60*1000); // 5 minutes; } void PSK_Reporter::setLocalStation(QString call, QString gridSquare, QString programInfo) @@ -45,6 +43,7 @@ void PSK_Reporter::setLocalStation(QString call, QString gridSquare, QString pro m_rxCall = call; m_rxGrid = gridSquare; m_progId = programInfo; + reportTimer->start(5*60*1000); // 5 minutes; } void PSK_Reporter::addRemoteStation(QString call, QString grid, QString freq, QString mode, QString snr, QString time ) @@ -61,6 +60,9 @@ void PSK_Reporter::addRemoteStation(QString call, QString grid, QString freq, QS void PSK_Reporter::sendReport() { + if (m_spotQueue.isEmpty()) + return; + // Header QString header_h = m_header_h; header_h.replace("tttttttt", QString("%1").arg(QDateTime::currentDateTime().toTime_t(),8,16,QChar('0'))); @@ -75,24 +77,21 @@ void PSK_Reporter::sendReport() rxInfoData_h += "0000"; rxInfoData_h.replace("50E2llll", "50E2" + QString("%1").arg(rxInfoData_h.length()/2,4,16,QChar('0'))); - // Sender information - QString txInfoData_h; - if (!m_spotQueue.isEmpty()) { - txInfoData_h = "50E3llll"; - while (!m_spotQueue.isEmpty()) { - QHash spot = m_spotQueue.dequeue(); - qDebug() << spot; - txInfoData_h += QString("%1").arg(spot["call"].length(),2,16,QChar('0')) + spot["call"].toUtf8().toHex(); - txInfoData_h += QString("%1").arg(spot["freq"].toLongLong(),8,16,QChar('0')); - txInfoData_h += QString("%1").arg(spot["snr"].toInt(),1,16,QChar('0')).mid(14,2); - txInfoData_h += QString("%1").arg(spot["mode"].length(),2,16,QChar('0')) + spot["mode"].toUtf8().toHex(); - txInfoData_h += QString("%1").arg(spot["grid"].length(),2,16,QChar('0')) + spot["grid"].toUtf8().toHex(); - txInfoData_h += QString("%1").arg(1,2,16,QChar('0'));; - txInfoData_h += QString("%1").arg(spot["time"].toInt(),8,16,QChar('0')); - } - txInfoData_h += "0000"; - txInfoData_h.replace("50E3llll", "50E3" + QString("%1").arg(txInfoData_h.length()/2,4,16,QChar('0'))); + // Sender information + QString txInfoData_h = "50E3llll"; + while (!m_spotQueue.isEmpty()) { + QHash spot = m_spotQueue.dequeue(); + qDebug() << spot; + txInfoData_h += QString("%1").arg(spot["call"].length(),2,16,QChar('0')) + spot["call"].toUtf8().toHex(); + txInfoData_h += QString("%1").arg(spot["freq"].toLongLong(),8,16,QChar('0')); + txInfoData_h += QString("%1").arg(spot["snr"].toInt(),1,16,QChar('0')).mid(14,2); + txInfoData_h += QString("%1").arg(spot["mode"].length(),2,16,QChar('0')) + spot["mode"].toUtf8().toHex(); + txInfoData_h += QString("%1").arg(spot["grid"].length(),2,16,QChar('0')) + spot["grid"].toUtf8().toHex(); + txInfoData_h += QString("%1").arg(1,2,16,QChar('0'));; + txInfoData_h += QString("%1").arg(spot["time"].toInt(),8,16,QChar('0')); } + txInfoData_h += "0000"; + txInfoData_h.replace("50E3llll", "50E3" + QString("%1").arg(txInfoData_h.length()/2,4,16,QChar('0'))); // Build report QString report_h = header_h + m_rxInfoDescriptor_h + m_txInfoDescriptor_h + rxInfoData_h + txInfoData_h;