2012-10-29 17:10:03 -04:00
|
|
|
//--------------------------------------------------------------- MainWindow
|
2012-05-22 13:09:48 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include "devsetup.h"
|
|
|
|
#include "plotter.h"
|
|
|
|
#include "about.h"
|
|
|
|
#include "widegraph.h"
|
|
|
|
#include "sleep.h"
|
2012-10-28 11:47:43 -04:00
|
|
|
#include "getfile.h"
|
2012-05-22 13:09:48 -04:00
|
|
|
#include <portaudio.h>
|
|
|
|
|
2012-10-05 13:13:21 -04:00
|
|
|
int itone[85]; //Tx audio tones for 85 symbols
|
2012-05-22 13:09:48 -04:00
|
|
|
bool btxok; //True if OK to transmit
|
|
|
|
double outputLatency; //Latency in seconds
|
2012-10-16 19:32:15 -04:00
|
|
|
float c0[2*1800*1500];
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
WideGraph* g_pWideGraph = NULL;
|
|
|
|
|
|
|
|
QString rev="$Rev$";
|
2012-10-29 14:00:49 -04:00
|
|
|
QString Program_Title_Version=" WSJT-X v0.2, r" + rev.mid(6,4) +
|
2012-05-22 13:09:48 -04:00
|
|
|
" by K1JT";
|
|
|
|
|
|
|
|
//-------------------------------------------------- MainWindow constructor
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
on_EraseButton_clicked();
|
|
|
|
ui->labUTC->setStyleSheet( \
|
|
|
|
"QLabel { background-color : black; color : yellow; }");
|
|
|
|
ui->labTol1->setStyleSheet( \
|
|
|
|
"QLabel { background-color : white; color : black; }");
|
|
|
|
ui->labTol1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
|
|
ui->dxStationGroupBox->setStyleSheet("QFrame{border: 5px groove red}");
|
|
|
|
|
|
|
|
QActionGroup* paletteGroup = new QActionGroup(this);
|
|
|
|
ui->actionCuteSDR->setActionGroup(paletteGroup);
|
|
|
|
ui->actionLinrad->setActionGroup(paletteGroup);
|
|
|
|
ui->actionAFMHot->setActionGroup(paletteGroup);
|
|
|
|
ui->actionBlue->setActionGroup(paletteGroup);
|
|
|
|
|
|
|
|
QActionGroup* modeGroup = new QActionGroup(this);
|
2012-10-04 17:39:48 -04:00
|
|
|
ui->actionJT9_1->setActionGroup(modeGroup);
|
|
|
|
ui->actionJT9_2->setActionGroup(modeGroup);
|
|
|
|
ui->actionJT9_5->setActionGroup(modeGroup);
|
|
|
|
ui->actionJT9_10->setActionGroup(modeGroup);
|
|
|
|
ui->actionJT9_30->setActionGroup(modeGroup);
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
QActionGroup* saveGroup = new QActionGroup(this);
|
|
|
|
ui->actionSave_all->setActionGroup(saveGroup);
|
|
|
|
ui->actionNone->setActionGroup(saveGroup);
|
|
|
|
|
|
|
|
QActionGroup* DepthGroup = new QActionGroup(this);
|
|
|
|
ui->actionNo_Deep_Search->setActionGroup(DepthGroup);
|
|
|
|
ui->actionNormal_Deep_Search->setActionGroup(DepthGroup);
|
|
|
|
ui->actionAggressive_Deep_Search->setActionGroup(DepthGroup);
|
|
|
|
|
|
|
|
QButtonGroup* txMsgButtonGroup = new QButtonGroup;
|
|
|
|
txMsgButtonGroup->addButton(ui->txrb1,1);
|
|
|
|
txMsgButtonGroup->addButton(ui->txrb2,2);
|
|
|
|
txMsgButtonGroup->addButton(ui->txrb3,3);
|
|
|
|
txMsgButtonGroup->addButton(ui->txrb4,4);
|
|
|
|
txMsgButtonGroup->addButton(ui->txrb5,5);
|
|
|
|
txMsgButtonGroup->addButton(ui->txrb6,6);
|
|
|
|
connect(txMsgButtonGroup,SIGNAL(buttonClicked(int)),SLOT(set_ntx(int)));
|
|
|
|
connect(ui->decodedTextBrowser,SIGNAL(selectCallsign(bool)),this,
|
|
|
|
SLOT(selectCall2(bool)));
|
|
|
|
|
|
|
|
setWindowTitle(Program_Title_Version);
|
|
|
|
|
|
|
|
connect(&soundInThread, SIGNAL(readyForFFT(int)),
|
|
|
|
this, SLOT(dataSink(int)));
|
|
|
|
connect(&soundInThread, SIGNAL(error(QString)), this,
|
|
|
|
SLOT(showSoundInError(QString)));
|
|
|
|
connect(&soundInThread, SIGNAL(status(QString)), this,
|
|
|
|
SLOT(showStatusMessage(QString)));
|
|
|
|
createStatusBar();
|
|
|
|
|
|
|
|
QTimer *guiTimer = new QTimer(this);
|
|
|
|
connect(guiTimer, SIGNAL(timeout()), this, SLOT(guiUpdate()));
|
|
|
|
guiTimer->start(100); //Don't change the 100 ms!
|
|
|
|
|
|
|
|
m_auto=false;
|
|
|
|
m_waterfallAvg = 1;
|
|
|
|
m_network = true;
|
|
|
|
m_txFirst=false;
|
|
|
|
m_txMute=false;
|
|
|
|
btxok=false;
|
|
|
|
m_restart=false;
|
|
|
|
m_transmitting=false;
|
|
|
|
m_killAll=false;
|
|
|
|
m_widebandDecode=false;
|
|
|
|
m_ntx=1;
|
|
|
|
m_myCall="K1JT";
|
|
|
|
m_myGrid="FN20qi";
|
|
|
|
m_appDir = QApplication::applicationDirPath();
|
2012-09-24 15:11:31 -04:00
|
|
|
m_saveDir="/users/joe/wsjtx/install/save";
|
2012-10-15 13:43:49 -04:00
|
|
|
m_txFreq=1500;
|
2012-05-22 13:09:48 -04:00
|
|
|
m_setftx=0;
|
|
|
|
m_loopall=false;
|
|
|
|
m_startAnother=false;
|
|
|
|
m_saveAll=false;
|
|
|
|
m_sec0=-1;
|
|
|
|
m_palette="CuteSDR";
|
2012-09-24 11:20:48 -04:00
|
|
|
m_RxLog=1; //Write Date and Time to RxLog
|
2012-05-22 13:09:48 -04:00
|
|
|
m_nutc0=9999;
|
|
|
|
m_NB=false;
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode="JT9-1";
|
2012-09-24 15:11:31 -04:00
|
|
|
m_TRperiod=60;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
ui->xThermo->setFillBrush(Qt::green);
|
|
|
|
|
|
|
|
PaError paerr=Pa_Initialize(); //Initialize Portaudio
|
|
|
|
if(paerr!=paNoError) {
|
|
|
|
msgBox("Unable to initialize PortAudio.");
|
|
|
|
}
|
|
|
|
readSettings(); //Restore user's setup params
|
|
|
|
m_pbdecoding_style1="QPushButton{background-color: cyan; \
|
|
|
|
border-style: outset; border-width: 1px; border-radius: 5px; \
|
|
|
|
border-color: black; min-width: 5em; padding: 3px;}";
|
|
|
|
m_pbmonitor_style="QPushButton{background-color: #00ff00; \
|
|
|
|
border-style: outset; border-width: 1px; border-radius: 5px; \
|
|
|
|
border-color: black; min-width: 5em; padding: 3px;}";
|
|
|
|
m_pbAutoOn_style="QPushButton{background-color: red; \
|
|
|
|
border-style: outset; border-width: 1px; border-radius: 5px; \
|
|
|
|
border-color: black; min-width: 5em; padding: 3px;}";
|
|
|
|
|
2012-09-24 15:11:31 -04:00
|
|
|
genStdMsgs("-30");
|
2012-07-02 16:52:56 -04:00
|
|
|
on_actionWide_Waterfall_triggered(); //###
|
2012-10-04 17:39:48 -04:00
|
|
|
if(m_mode=="JT9-1") on_actionJT9_1_triggered();
|
|
|
|
if(m_mode=="JT9-2") on_actionJT9_2_triggered();
|
|
|
|
if(m_mode=="JT9-5") on_actionJT9_5_triggered();
|
|
|
|
if(m_mode=="JT9-10") on_actionJT9_10_triggered();
|
|
|
|
if(m_mode=="JT9-30") on_actionJT9_30_triggered();
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
future1 = new QFuture<void>;
|
|
|
|
watcher1 = new QFutureWatcher<void>;
|
|
|
|
connect(watcher1, SIGNAL(finished()),this,SLOT(diskDat()));
|
|
|
|
|
|
|
|
future2 = new QFuture<void>;
|
|
|
|
watcher2 = new QFutureWatcher<void>;
|
|
|
|
connect(watcher2, SIGNAL(finished()),this,SLOT(diskWriteFinished()));
|
|
|
|
|
2012-10-15 15:18:45 -04:00
|
|
|
future3 = new QFuture<void>;
|
|
|
|
watcher3 = new QFutureWatcher<void>;
|
|
|
|
connect(watcher3, SIGNAL(finished()),this,SLOT(decoderFinished()));
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
soundInThread.setInputDevice(m_paInDevice);
|
|
|
|
soundInThread.start(QThread::HighestPriority);
|
2012-07-05 12:16:03 -04:00
|
|
|
soundOutThread.setOutputDevice(m_paOutDevice);
|
2012-10-17 15:58:35 -04:00
|
|
|
soundOutThread.setTxFreq(m_txFreq);
|
2012-09-29 13:23:02 -04:00
|
|
|
m_monitoring=true; // Start with Monitoring ON
|
2012-05-22 13:09:48 -04:00
|
|
|
soundInThread.setMonitoring(m_monitoring);
|
|
|
|
m_diskData=false;
|
2012-10-15 13:43:49 -04:00
|
|
|
m_tol=50;
|
2012-05-22 13:09:48 -04:00
|
|
|
g_pWideGraph->setTol(m_tol);
|
|
|
|
|
|
|
|
// Create "m_worked", a dictionary of all calls in wsjt.log
|
|
|
|
QFile f("wsjt.log");
|
|
|
|
f.open(QIODevice::ReadOnly);
|
|
|
|
QTextStream in(&f);
|
|
|
|
QString line,t,callsign;
|
|
|
|
for(int i=0; i<99999; i++) {
|
|
|
|
line=in.readLine();
|
|
|
|
if(line.length()<=0) break;
|
|
|
|
t=line.mid(18,12);
|
|
|
|
callsign=t.mid(0,t.indexOf(","));
|
|
|
|
}
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
if(ui->actionLinrad->isChecked()) on_actionLinrad_triggered();
|
|
|
|
if(ui->actionCuteSDR->isChecked()) on_actionCuteSDR_triggered();
|
|
|
|
if(ui->actionAFMHot->isChecked()) on_actionAFMHot_triggered();
|
|
|
|
if(ui->actionBlue->isChecked()) on_actionBlue_triggered();
|
|
|
|
|
2012-07-18 09:35:54 -04:00
|
|
|
} // End of MainWindow constructor
|
|
|
|
|
|
|
|
//--------------------------------------------------- MainWindow destructor
|
2012-05-22 13:09:48 -04:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
writeSettings();
|
|
|
|
if (soundInThread.isRunning()) {
|
|
|
|
soundInThread.quit();
|
|
|
|
soundInThread.wait(3000);
|
|
|
|
}
|
|
|
|
if (soundOutThread.isRunning()) {
|
|
|
|
soundOutThread.quitExecution=true;
|
|
|
|
soundOutThread.wait(3000);
|
|
|
|
}
|
|
|
|
if(!m_decoderBusy) {
|
|
|
|
QFile lockFile(m_appDir + "/.lock");
|
|
|
|
lockFile.remove();
|
|
|
|
}
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------- writeSettings()
|
|
|
|
void MainWindow::writeSettings()
|
|
|
|
{
|
2012-09-24 15:11:31 -04:00
|
|
|
QString inifile = m_appDir + "/wsjtx.ini";
|
2012-05-22 13:09:48 -04:00
|
|
|
QSettings settings(inifile, QSettings::IniFormat);
|
|
|
|
|
|
|
|
settings.beginGroup("MainWindow");
|
|
|
|
settings.setValue("geometry", saveGeometry());
|
|
|
|
settings.setValue("MRUdir", m_path);
|
|
|
|
settings.setValue("TxFirst",m_txFirst);
|
|
|
|
settings.setValue("DXcall",ui->dxCallEntry->text());
|
|
|
|
settings.setValue("DXgrid",ui->dxGridEntry->text());
|
|
|
|
if(g_pWideGraph->isVisible()) {
|
|
|
|
m_wideGraphGeom = g_pWideGraph->geometry();
|
|
|
|
settings.setValue("WideGraphGeom",m_wideGraphGeom);
|
|
|
|
}
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
settings.beginGroup("Common");
|
|
|
|
settings.setValue("MyCall",m_myCall);
|
|
|
|
settings.setValue("MyGrid",m_myGrid);
|
|
|
|
settings.setValue("IDint",m_idInt);
|
|
|
|
settings.setValue("PTTport",m_pttPort);
|
|
|
|
settings.setValue("SaveDir",m_saveDir);
|
|
|
|
settings.setValue("DXCCpfx",m_dxccPfx);
|
|
|
|
settings.setValue("SoundInIndex",m_nDevIn);
|
|
|
|
settings.setValue("paInDevice",m_paInDevice);
|
|
|
|
settings.setValue("SoundOutIndex",m_nDevOut);
|
|
|
|
settings.setValue("paOutDevice",m_paOutDevice);
|
|
|
|
settings.setValue("PaletteCuteSDR",ui->actionCuteSDR->isChecked());
|
|
|
|
settings.setValue("PaletteLinrad",ui->actionLinrad->isChecked());
|
|
|
|
settings.setValue("PaletteAFMHot",ui->actionAFMHot->isChecked());
|
|
|
|
settings.setValue("PaletteBlue",ui->actionBlue->isChecked());
|
|
|
|
settings.setValue("Mode",m_mode);
|
|
|
|
settings.setValue("SaveNone",ui->actionNone->isChecked());
|
|
|
|
settings.setValue("SaveAll",ui->actionSave_all->isChecked());
|
|
|
|
settings.setValue("NDepth",m_ndepth);
|
|
|
|
settings.setValue("KB8RQ",m_kb8rq);
|
|
|
|
settings.setValue("NB",m_NB);
|
|
|
|
settings.setValue("NBslider",m_NBslider);
|
2012-10-05 15:14:45 -04:00
|
|
|
settings.setValue("TxFreq",m_txFreq);
|
2012-05-22 13:09:48 -04:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------- readSettings()
|
|
|
|
void MainWindow::readSettings()
|
|
|
|
{
|
2012-09-24 15:11:31 -04:00
|
|
|
QString inifile = m_appDir + "/wsjtx.ini";
|
2012-05-22 13:09:48 -04:00
|
|
|
QSettings settings(inifile, QSettings::IniFormat);
|
|
|
|
settings.beginGroup("MainWindow");
|
|
|
|
restoreGeometry(settings.value("geometry").toByteArray());
|
|
|
|
ui->dxCallEntry->setText(settings.value("DXcall","").toString());
|
|
|
|
ui->dxGridEntry->setText(settings.value("DXgrid","").toString());
|
|
|
|
m_wideGraphGeom = settings.value("WideGraphGeom", \
|
2012-07-13 15:08:55 -04:00
|
|
|
QRect(45,30,726,301)).toRect();
|
2012-05-22 13:09:48 -04:00
|
|
|
m_path = settings.value("MRUdir", m_appDir + "/save").toString();
|
|
|
|
m_txFirst = settings.value("TxFirst",false).toBool();
|
|
|
|
ui->txFirstCheckBox->setChecked(m_txFirst);
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
settings.beginGroup("Common");
|
|
|
|
m_myCall=settings.value("MyCall","").toString();
|
|
|
|
m_myGrid=settings.value("MyGrid","").toString();
|
|
|
|
m_idInt=settings.value("IDint",0).toInt();
|
|
|
|
m_pttPort=settings.value("PTTport",0).toInt();
|
|
|
|
m_saveDir=settings.value("SaveDir",m_appDir + "/save").toString();
|
|
|
|
m_dxccPfx=settings.value("DXCCpfx","").toString();
|
|
|
|
m_nDevIn = settings.value("SoundInIndex", 0).toInt();
|
|
|
|
m_paInDevice = settings.value("paInDevice",0).toInt();
|
|
|
|
m_nDevOut = settings.value("SoundOutIndex", 0).toInt();
|
|
|
|
m_paOutDevice = settings.value("paOutDevice",0).toInt();
|
|
|
|
ui->actionCuteSDR->setChecked(settings.value(
|
|
|
|
"PaletteCuteSDR",true).toBool());
|
|
|
|
ui->actionLinrad->setChecked(settings.value(
|
|
|
|
"PaletteLinrad",false).toBool());
|
|
|
|
ui->actionAFMHot->setChecked(settings.value(
|
|
|
|
"PaletteAFMHot",false).toBool());
|
|
|
|
ui->actionBlue->setChecked(settings.value(
|
|
|
|
"PaletteBlue",false).toBool());
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode=settings.value("Mode","JT9-1").toString();
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->actionNone->setChecked(settings.value("SaveNone",true).toBool());
|
|
|
|
ui->actionSave_all->setChecked(settings.value("SaveAll",false).toBool());
|
2012-09-25 16:26:12 -04:00
|
|
|
m_NB=settings.value("NB",false).toBool();
|
|
|
|
ui->NBcheckBox->setChecked(m_NB);
|
|
|
|
m_NBslider=settings.value("NBslider",40).toInt();
|
|
|
|
ui->NBslider->setValue(m_NBslider);
|
2012-10-05 15:14:45 -04:00
|
|
|
m_txFreq=settings.value("TxFreq",1500).toInt();
|
|
|
|
ui->TxFreqSpinBox->setValue(m_txFreq);
|
2012-10-17 15:58:35 -04:00
|
|
|
soundOutThread.setTxFreq(m_txFreq);
|
2012-05-22 13:09:48 -04:00
|
|
|
m_saveAll=ui->actionSave_all->isChecked();
|
|
|
|
m_ndepth=settings.value("NDepth",0).toInt();
|
|
|
|
ui->actionF4_sets_Tx6->setChecked(m_kb8rq);
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
if(!ui->actionLinrad->isChecked() && !ui->actionCuteSDR->isChecked() &&
|
|
|
|
!ui->actionAFMHot->isChecked() && !ui->actionBlue->isChecked()) {
|
|
|
|
on_actionLinrad_triggered();
|
|
|
|
ui->actionLinrad->setChecked(true);
|
|
|
|
}
|
|
|
|
if(m_ndepth==0) ui->actionNo_Deep_Search->setChecked(true);
|
|
|
|
if(m_ndepth==1) ui->actionNormal_Deep_Search->setChecked(true);
|
|
|
|
if(m_ndepth==2) ui->actionAggressive_Deep_Search->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------- dataSink()
|
|
|
|
void MainWindow::dataSink(int k)
|
|
|
|
{
|
2012-10-15 13:43:49 -04:00
|
|
|
static float s[NSMAX],red[NSMAX],splot[NSMAX];
|
2012-09-25 16:26:12 -04:00
|
|
|
static int n=0;
|
|
|
|
static int ihsym=0;
|
|
|
|
static int nzap=0;
|
|
|
|
static int ntr0=0;
|
|
|
|
static int nkhz;
|
2012-05-22 13:09:48 -04:00
|
|
|
static int ndiskdat;
|
2012-09-25 16:26:12 -04:00
|
|
|
static int nadj=0;
|
2012-09-25 20:48:49 -04:00
|
|
|
static int nb;
|
2012-10-03 11:22:49 -04:00
|
|
|
static int trmin;
|
2012-10-16 19:32:15 -04:00
|
|
|
static int npts8;
|
2012-09-25 20:48:49 -04:00
|
|
|
static float px=0.0;
|
2012-10-03 11:22:49 -04:00
|
|
|
static float df3;
|
2012-09-25 16:26:12 -04:00
|
|
|
static uchar lstrong[1024];
|
|
|
|
static float slimit;
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
if(m_diskData) {
|
|
|
|
ndiskdat=1;
|
2012-10-03 11:42:13 -04:00
|
|
|
jt9com_.ndiskdat=1;
|
2012-05-22 13:09:48 -04:00
|
|
|
} else {
|
|
|
|
ndiskdat=0;
|
2012-10-03 11:42:13 -04:00
|
|
|
jt9com_.ndiskdat=0;
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
2012-10-21 15:35:10 -04:00
|
|
|
|
|
|
|
// Get power, spectrum, and ihsym
|
2012-09-25 16:26:12 -04:00
|
|
|
nb=0;
|
|
|
|
if(m_NB) nb=1;
|
2012-10-03 11:22:49 -04:00
|
|
|
trmin=m_TRperiod/60;
|
2012-10-16 19:32:15 -04:00
|
|
|
symspec_(&k, &trmin, &m_nsps, &nb, &m_NBslider, &px, s, red,
|
|
|
|
&df3, &ihsym, &nzap, &slimit, lstrong, c0, &npts8);
|
2012-09-25 20:48:49 -04:00
|
|
|
if(ihsym <=0) return;
|
2012-09-25 16:26:12 -04:00
|
|
|
QString t;
|
|
|
|
m_pctZap=nzap/178.3;
|
|
|
|
t.sprintf(" Rx noise: %5.1f %5.1f %% ",px,m_pctZap);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab3->setText(t);
|
2012-09-25 16:26:12 -04:00
|
|
|
ui->xThermo->setValue((double)px); //Update the thermometer
|
|
|
|
if(m_monitoring || m_diskData) {
|
2012-10-15 13:43:49 -04:00
|
|
|
g_pWideGraph->dataSink2(s,red,df3,ihsym,m_diskData,lstrong);
|
2012-07-12 17:22:55 -04:00
|
|
|
}
|
|
|
|
|
2012-09-25 16:26:12 -04:00
|
|
|
//Average over specified number of spectra
|
|
|
|
if (n==0) {
|
2012-09-29 09:02:19 -04:00
|
|
|
for (int i=0; i<NSMAX; i++)
|
2012-09-25 16:26:12 -04:00
|
|
|
splot[i]=s[i];
|
|
|
|
} else {
|
2012-09-29 09:02:19 -04:00
|
|
|
for (int i=0; i<NSMAX; i++)
|
2012-09-25 16:26:12 -04:00
|
|
|
splot[i] += s[i];
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
2012-09-25 16:26:12 -04:00
|
|
|
n++;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-09-25 16:26:12 -04:00
|
|
|
if (n>=m_waterfallAvg) {
|
2012-09-29 09:02:19 -04:00
|
|
|
for (int i=0; i<NSMAX; i++) {
|
2012-09-25 16:26:12 -04:00
|
|
|
splot[i] /= n; //Normalize the average
|
|
|
|
}
|
2012-07-04 12:27:57 -04:00
|
|
|
|
2012-09-25 16:26:12 -04:00
|
|
|
// Time according to this computer
|
|
|
|
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
|
|
|
int ntr = (ms/1000) % m_TRperiod;
|
|
|
|
if((m_diskData && ihsym <= m_waterfallAvg) || (!m_diskData && ntr<ntr0)) {
|
2012-09-29 09:02:19 -04:00
|
|
|
for (int i=0; i<NSMAX; i++) {
|
2012-09-25 16:26:12 -04:00
|
|
|
splot[i] = 1.e30;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ntr0=ntr;
|
|
|
|
n=0;
|
|
|
|
}
|
2012-10-21 15:35:10 -04:00
|
|
|
// This is a bit strange. Why do we need the "-3" ???
|
2012-10-19 15:26:07 -04:00
|
|
|
if(ihsym == m_hsymStop-3) {
|
|
|
|
jt9com_.npts8=(ihsym*m_nsps)/16;
|
2012-10-26 12:52:04 -04:00
|
|
|
jt9com_.newdat=1;
|
|
|
|
jt9com_.nagain=0;
|
2012-09-25 16:26:12 -04:00
|
|
|
QDateTime t = QDateTime::currentDateTimeUtc();
|
|
|
|
m_dateTime=t.toString("yyyy-MMM-dd hh:mm");
|
|
|
|
decode(); //Start the decoder
|
|
|
|
if(m_saveAll and !m_diskData) {
|
2012-10-26 12:01:57 -04:00
|
|
|
int ihr=t.time().toString("hh").toInt();
|
|
|
|
int imin=t.time().toString("mm").toInt();
|
|
|
|
imin=imin - (imin%(m_TRperiod/60));
|
2012-10-27 09:22:47 -04:00
|
|
|
QString t2;
|
|
|
|
t2.sprintf("%2.2d%2.2d",ihr,imin);
|
2012-09-25 16:26:12 -04:00
|
|
|
QString fname=m_saveDir + "/" + t.date().toString("yyMMdd") + "_" +
|
2012-10-26 12:01:57 -04:00
|
|
|
t2 + ".wav";
|
2012-09-26 11:20:43 -04:00
|
|
|
*future2 = QtConcurrent::run(savewav, fname, m_TRperiod);
|
2012-05-22 13:09:48 -04:00
|
|
|
watcher2->setFuture(*future2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
soundInThread.m_dataSinkBusy=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::showSoundInError(const QString& errorMsg)
|
|
|
|
{QMessageBox::critical(this, tr("Error in SoundIn"), errorMsg);}
|
|
|
|
|
|
|
|
void MainWindow::showStatusMessage(const QString& statusMsg)
|
|
|
|
{statusBar()->showMessage(statusMsg);}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
|
|
|
|
{
|
|
|
|
DevSetup dlg(this);
|
|
|
|
dlg.m_myCall=m_myCall;
|
|
|
|
dlg.m_myGrid=m_myGrid;
|
|
|
|
dlg.m_idInt=m_idInt;
|
|
|
|
dlg.m_pttPort=m_pttPort;
|
|
|
|
dlg.m_saveDir=m_saveDir;
|
|
|
|
dlg.m_dxccPfx=m_dxccPfx;
|
|
|
|
dlg.m_nDevIn=m_nDevIn;
|
|
|
|
dlg.m_nDevOut=m_nDevOut;
|
|
|
|
|
|
|
|
dlg.initDlg();
|
|
|
|
if(dlg.exec() == QDialog::Accepted) {
|
|
|
|
m_myCall=dlg.m_myCall;
|
|
|
|
m_myGrid=dlg.m_myGrid;
|
|
|
|
m_idInt=dlg.m_idInt;
|
2012-07-04 10:40:11 -04:00
|
|
|
m_pttPort=dlg.m_pttPort;
|
2012-05-22 13:09:48 -04:00
|
|
|
m_saveDir=dlg.m_saveDir;
|
|
|
|
m_dxccPfx=dlg.m_dxccPfx;
|
|
|
|
m_nDevIn=dlg.m_nDevIn;
|
|
|
|
m_paInDevice=dlg.m_paInDevice;
|
|
|
|
m_nDevOut=dlg.m_nDevOut;
|
|
|
|
m_paOutDevice=dlg.m_paOutDevice;
|
|
|
|
|
|
|
|
if(dlg.m_restartSoundIn) {
|
|
|
|
soundInThread.quit();
|
|
|
|
soundInThread.wait(1000);
|
|
|
|
soundInThread.setInputDevice(m_paInDevice);
|
|
|
|
soundInThread.start(QThread::HighestPriority);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dlg.m_restartSoundOut) {
|
|
|
|
soundOutThread.quitExecution=true;
|
|
|
|
soundOutThread.wait(1000);
|
|
|
|
soundOutThread.setOutputDevice(m_paOutDevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_monitorButton_clicked() //Monitor
|
|
|
|
{
|
|
|
|
m_monitoring=true;
|
|
|
|
soundInThread.setMonitoring(true);
|
|
|
|
m_diskData=false;
|
|
|
|
}
|
|
|
|
void MainWindow::on_actionLinrad_triggered() //Linrad palette
|
|
|
|
{
|
|
|
|
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("Linrad");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionCuteSDR_triggered() //CuteSDR palette
|
|
|
|
{
|
|
|
|
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("CuteSDR");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAFMHot_triggered()
|
|
|
|
{
|
|
|
|
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("AFMHot");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionBlue_triggered()
|
|
|
|
{
|
|
|
|
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("Blue");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAbout_triggered() //Display "About"
|
|
|
|
{
|
|
|
|
CAboutDlg dlg(this,Program_Title_Version);
|
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_autoButton_clicked() //Auto
|
|
|
|
{
|
|
|
|
m_auto = !m_auto;
|
|
|
|
if(m_auto) {
|
|
|
|
ui->autoButton->setStyleSheet(m_pbAutoOn_style);
|
|
|
|
ui->autoButton->setText("Auto is ON");
|
|
|
|
} else {
|
|
|
|
btxok=false;
|
|
|
|
ui->autoButton->setStyleSheet("");
|
|
|
|
ui->autoButton->setText("Auto is OFF");
|
|
|
|
on_monitorButton_clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_stopTxButton_clicked() //Stop Tx
|
|
|
|
{
|
|
|
|
if(m_auto) on_autoButton_clicked();
|
|
|
|
btxok=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::keyPressEvent( QKeyEvent *e ) //keyPressEvent
|
|
|
|
{
|
|
|
|
switch(e->key())
|
|
|
|
{
|
|
|
|
case Qt::Key_F3:
|
|
|
|
m_txMute=!m_txMute;
|
|
|
|
break;
|
|
|
|
case Qt::Key_F4:
|
|
|
|
ui->dxCallEntry->setText("");
|
|
|
|
ui->dxGridEntry->setText("");
|
|
|
|
if(m_kb8rq) {
|
|
|
|
m_ntx=6;
|
|
|
|
ui->txrb6->setChecked(true);
|
|
|
|
}
|
|
|
|
case Qt::Key_F6:
|
|
|
|
if(e->modifiers() & Qt::ShiftModifier) {
|
|
|
|
on_actionDecode_remaining_files_in_directory_triggered();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Qt::Key_F11:
|
|
|
|
if(e->modifiers() & Qt::ShiftModifier) {
|
|
|
|
} else {
|
2012-10-19 15:26:07 -04:00
|
|
|
int n=g_pWideGraph->QSOfreq();
|
|
|
|
n--;
|
|
|
|
g_pWideGraph->setQSOfreq(n);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Qt::Key_F12:
|
|
|
|
if(e->modifiers() & Qt::ShiftModifier) {
|
|
|
|
} else {
|
2012-10-19 15:26:07 -04:00
|
|
|
int n=g_pWideGraph->QSOfreq();
|
|
|
|
n++;
|
|
|
|
g_pWideGraph->setQSOfreq(n);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Qt::Key_G:
|
|
|
|
if(e->modifiers() & Qt::AltModifier) {
|
2012-09-24 15:11:31 -04:00
|
|
|
genStdMsgs("-30");
|
2012-05-22 13:09:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Qt::Key_L:
|
|
|
|
if(e->modifiers() & Qt::ControlModifier) {
|
|
|
|
lookup();
|
2012-09-24 15:11:31 -04:00
|
|
|
genStdMsgs("-30");
|
2012-05-22 13:09:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::bumpDF(int n) //bumpDF()
|
|
|
|
{
|
|
|
|
if(n==11) {
|
|
|
|
int n0=g_pWideGraph->DF();
|
|
|
|
int n=(n0 + 10000) % 5;
|
|
|
|
if(n==0) n=5;
|
|
|
|
g_pWideGraph->setDF(n0-n);
|
|
|
|
}
|
|
|
|
if(n==12) {
|
|
|
|
int n0=g_pWideGraph->DF();
|
|
|
|
int n=(n0 + 10000) % 5;
|
|
|
|
if(n==0) n=5;
|
|
|
|
g_pWideGraph->setDF(n0+n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWindow::eventFilter(QObject *object, QEvent *event) //eventFilter()
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
|
|
MainWindow::keyPressEvent(keyEvent);
|
|
|
|
return QObject::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
return QObject::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::createStatusBar() //createStatusBar
|
|
|
|
{
|
|
|
|
lab1 = new QLabel("Receiving");
|
|
|
|
lab1->setAlignment(Qt::AlignHCenter);
|
|
|
|
lab1->setMinimumSize(QSize(80,10));
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #00ff00}");
|
|
|
|
lab1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
|
|
statusBar()->addWidget(lab1);
|
|
|
|
|
2012-07-05 15:37:59 -04:00
|
|
|
lab2 = new QLabel("");
|
2012-05-22 13:09:48 -04:00
|
|
|
lab2->setAlignment(Qt::AlignHCenter);
|
|
|
|
lab2->setMinimumSize(QSize(90,10));
|
|
|
|
lab2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
|
|
statusBar()->addWidget(lab2);
|
|
|
|
|
2012-10-20 12:37:01 -04:00
|
|
|
lab3 = new QLabel("");
|
2012-05-22 13:09:48 -04:00
|
|
|
lab3->setAlignment(Qt::AlignHCenter);
|
|
|
|
lab3->setMinimumSize(QSize(80,10));
|
|
|
|
lab3->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
|
|
statusBar()->addWidget(lab3);
|
|
|
|
|
|
|
|
lab4 = new QLabel("");
|
|
|
|
lab4->setAlignment(Qt::AlignHCenter);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab4->setMinimumSize(QSize(50,10));
|
2012-05-22 13:09:48 -04:00
|
|
|
lab4->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
|
|
statusBar()->addWidget(lab4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tolSpinBox_valueChanged(int i) //tolSpinBox
|
|
|
|
{
|
2012-10-15 13:43:49 -04:00
|
|
|
static int ntol[] = {1,2,5,10,20,50,100,200,500,1000};
|
2012-05-22 13:09:48 -04:00
|
|
|
m_tol=ntol[i];
|
|
|
|
g_pWideGraph->setTol(m_tol);
|
|
|
|
ui->labTol1->setText(QString::number(ntol[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionExit_triggered() //Exit()
|
|
|
|
{
|
|
|
|
OnExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent*)
|
|
|
|
{
|
|
|
|
OnExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::OnExit()
|
|
|
|
{
|
|
|
|
g_pWideGraph->saveSettings();
|
|
|
|
m_killAll=true;
|
2012-10-21 15:35:10 -04:00
|
|
|
qApp->exit(0); // Exit the event loop
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_stopButton_clicked() //stopButton
|
|
|
|
{
|
|
|
|
m_monitoring=false;
|
|
|
|
soundInThread.setMonitoring(m_monitoring);
|
|
|
|
m_loopall=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::msgBox(QString t) //msgBox
|
|
|
|
{
|
|
|
|
msgBox0.setText(t);
|
|
|
|
msgBox0.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::stub() //stub()
|
|
|
|
{
|
|
|
|
msgBox("Not yet implemented.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionOnline_Users_Guide_triggered() //Display manual
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(
|
2012-09-24 11:20:48 -04:00
|
|
|
"http://www.physics.princeton.edu/pulsar/K1JT/WSJT-X_Users_Guide.pdf",
|
2012-05-22 13:09:48 -04:00
|
|
|
QUrl::TolerantMode));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls
|
|
|
|
{
|
|
|
|
if(g_pWideGraph==NULL) {
|
|
|
|
g_pWideGraph = new WideGraph(0);
|
|
|
|
g_pWideGraph->setWindowTitle("Wide Graph");
|
|
|
|
g_pWideGraph->setGeometry(m_wideGraphGeom);
|
|
|
|
Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
|
|
|
|
Qt::WindowMinimizeButtonHint;
|
|
|
|
g_pWideGraph->setWindowFlags(flags);
|
|
|
|
connect(g_pWideGraph, SIGNAL(freezeDecode2(int)),this,
|
|
|
|
SLOT(freezeDecode(int)));
|
|
|
|
connect(g_pWideGraph, SIGNAL(f11f12(int)),this,
|
|
|
|
SLOT(bumpDF(int)));
|
|
|
|
}
|
2012-07-06 16:47:07 -04:00
|
|
|
g_pWideGraph->show();
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpen_triggered() //Open File
|
|
|
|
{
|
|
|
|
m_monitoring=false;
|
|
|
|
soundInThread.setMonitoring(m_monitoring);
|
|
|
|
QString fname;
|
2012-07-02 11:33:33 -04:00
|
|
|
fname=QFileDialog::getOpenFileName(this, "Open File", m_path,
|
2012-09-24 11:20:48 -04:00
|
|
|
"WSJT Files (*.wav)");
|
2012-05-22 13:09:48 -04:00
|
|
|
if(fname != "") {
|
|
|
|
m_path=fname;
|
|
|
|
int i;
|
2012-09-26 11:20:43 -04:00
|
|
|
i=fname.indexOf(".wav") - 11;
|
2012-05-22 13:09:48 -04:00
|
|
|
if(i>=0) {
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #66ff66}");
|
|
|
|
lab1->setText(" " + fname.mid(i,15) + " ");
|
|
|
|
}
|
|
|
|
on_stopButton_clicked();
|
|
|
|
m_diskData=true;
|
|
|
|
int dbDgrd=0;
|
2012-09-26 11:20:43 -04:00
|
|
|
*future1 = QtConcurrent::run(getfile, fname, m_TRperiod);
|
2012-10-05 13:13:21 -04:00
|
|
|
watcher1->setFuture(*future1); // call diskDat() when done
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpen_next_in_directory_triggered() //Open Next
|
|
|
|
{
|
|
|
|
int i,len;
|
|
|
|
QFileInfo fi(m_path);
|
|
|
|
QStringList list;
|
2012-07-12 17:22:55 -04:00
|
|
|
list= fi.dir().entryList().filter(".wav");
|
2012-05-22 13:09:48 -04:00
|
|
|
for (i = 0; i < list.size()-1; ++i) {
|
|
|
|
if(i==list.size()-2) m_loopall=false;
|
2012-07-12 17:22:55 -04:00
|
|
|
len=list.at(i).length();
|
2012-05-22 13:09:48 -04:00
|
|
|
if(list.at(i)==m_path.right(len)) {
|
|
|
|
int n=m_path.length();
|
|
|
|
QString fname=m_path.replace(n-len,len,list.at(i+1));
|
|
|
|
m_path=fname;
|
|
|
|
int i;
|
2012-07-12 17:22:55 -04:00
|
|
|
i=fname.indexOf(".wav") - 11;
|
2012-05-22 13:09:48 -04:00
|
|
|
if(i>=0) {
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #66ff66}");
|
|
|
|
lab1->setText(" " + fname.mid(i,len) + " ");
|
|
|
|
}
|
|
|
|
m_diskData=true;
|
|
|
|
int dbDgrd=0;
|
|
|
|
if(m_myCall=="K1JT" and m_idInt<0) dbDgrd=m_idInt;
|
2012-09-26 11:20:43 -04:00
|
|
|
*future1 = QtConcurrent::run(getfile, fname, m_TRperiod);
|
2012-05-22 13:09:48 -04:00
|
|
|
watcher1->setFuture(*future1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Open all remaining files
|
|
|
|
void MainWindow::on_actionDecode_remaining_files_in_directory_triggered()
|
|
|
|
{
|
|
|
|
m_loopall=true;
|
|
|
|
on_actionOpen_next_in_directory_triggered();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::diskDat() //diskDat()
|
|
|
|
{
|
2012-10-19 15:26:07 -04:00
|
|
|
int k;
|
2012-09-26 11:20:43 -04:00
|
|
|
int kstep=m_nsps/2;
|
2012-05-22 13:09:48 -04:00
|
|
|
m_diskData=true;
|
2012-10-11 14:33:50 -04:00
|
|
|
for(int n=1; n<=m_hsymStop; n++) { // Do the half-symbol FFTs
|
2012-10-19 15:26:07 -04:00
|
|
|
k=(n+1)*kstep;
|
|
|
|
jt9com_.npts8=k/8;
|
2012-05-22 13:09:48 -04:00
|
|
|
dataSink(k);
|
2012-10-11 14:33:50 -04:00
|
|
|
if(n%10 == 1 or n == m_hsymStop) qApp->processEvents(); //Keep GUI responsive
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::diskWriteFinished() //diskWriteFinished
|
|
|
|
{
|
2012-10-26 12:01:57 -04:00
|
|
|
// qDebug() << "diskWriteFinished";
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
2012-10-15 15:18:45 -04:00
|
|
|
|
|
|
|
void MainWindow::decoderFinished() //decoderFinished
|
|
|
|
{
|
2012-10-16 19:32:15 -04:00
|
|
|
QFile f("decoded.txt");
|
2012-10-15 17:06:15 -04:00
|
|
|
f.open(QIODevice::ReadOnly);
|
|
|
|
QTextStream in(&f);
|
|
|
|
QString line;
|
|
|
|
for(int i=0; i<99999; i++) {
|
|
|
|
line=in.readLine();
|
|
|
|
if(line.length()<=0) break;
|
2012-10-16 19:32:15 -04:00
|
|
|
ui->decodedTextBrowser->append(line);
|
2012-10-15 17:06:15 -04:00
|
|
|
}
|
|
|
|
f.close();
|
2012-10-21 13:20:09 -04:00
|
|
|
ui->DecodeButton->setStyleSheet("");
|
|
|
|
decodeBusy(false);
|
2012-10-20 12:37:01 -04:00
|
|
|
if(m_loopall) on_actionOpen_next_in_directory_triggered();
|
2012-10-15 15:18:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//Delete ../save/*.wav
|
2012-07-02 12:13:21 -04:00
|
|
|
void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered()
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
QString fname;
|
|
|
|
int ret = QMessageBox::warning(this, "Confirm Delete",
|
2012-07-02 12:13:21 -04:00
|
|
|
"Are you sure you want to delete all *.wav files in\n" +
|
2012-05-22 13:09:48 -04:00
|
|
|
QDir::toNativeSeparators(m_saveDir) + " ?",
|
|
|
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
|
|
if(ret==QMessageBox::Yes) {
|
|
|
|
QDir dir(m_saveDir);
|
|
|
|
QStringList files=dir.entryList(QDir::Files);
|
|
|
|
QList<QString>::iterator f;
|
|
|
|
for(f=files.begin(); f!=files.end(); ++f) {
|
|
|
|
fname=*f;
|
2012-07-05 12:16:03 -04:00
|
|
|
i=(fname.indexOf(".wav"));
|
2012-07-05 15:18:58 -04:00
|
|
|
if(i>10) dir.remove(fname);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionF4_sets_Tx6_triggered() //F4 sets Tx6
|
|
|
|
{
|
|
|
|
m_kb8rq = !m_kb8rq;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNo_shorthands_if_Tx1_triggered()
|
|
|
|
{
|
|
|
|
stub();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNo_Deep_Search_triggered() //No Deep Search
|
|
|
|
{
|
|
|
|
m_ndepth=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNormal_Deep_Search_triggered() //Normal DS
|
|
|
|
{
|
|
|
|
m_ndepth=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAggressive_Deep_Search_triggered() //Aggressive DS
|
|
|
|
{
|
|
|
|
m_ndepth=2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNone_triggered() //Save None
|
|
|
|
{
|
|
|
|
m_saveAll=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSave_all_triggered() //Save All
|
|
|
|
{
|
|
|
|
m_saveAll=true;
|
|
|
|
}
|
2012-07-18 09:35:54 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
void MainWindow::on_actionKeyboard_shortcuts_triggered()
|
|
|
|
{
|
2012-07-18 09:35:54 -04:00
|
|
|
stub(); //Display list of keyboard shortcuts
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
2012-07-18 09:35:54 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
void MainWindow::on_actionSpecial_mouse_commands_triggered()
|
|
|
|
{
|
2012-07-18 09:35:54 -04:00
|
|
|
stub(); //Display list of mouse commands
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
void MainWindow::on_actionAvailable_suffixes_and_add_on_prefixes_triggered()
|
|
|
|
{
|
2012-07-18 09:35:54 -04:00
|
|
|
stub(); //Display list of Add-On pfx/sfx
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_DecodeButton_clicked() //Decode request
|
|
|
|
{
|
2012-10-26 12:52:04 -04:00
|
|
|
if(!m_decoderBusy) {
|
|
|
|
jt9com_.newdat=0;
|
|
|
|
jt9com_.nagain=1;
|
|
|
|
decode();
|
|
|
|
}
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::freezeDecode(int n) //freezeDecode()
|
|
|
|
{
|
2012-10-26 12:52:04 -04:00
|
|
|
if(!m_decoderBusy) {
|
|
|
|
jt9com_.newdat=0;
|
|
|
|
jt9com_.nagain=1;
|
|
|
|
decode();
|
|
|
|
}
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::decode() //decode()
|
|
|
|
{
|
2012-10-21 13:20:09 -04:00
|
|
|
decodeBusy(true);
|
|
|
|
ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
|
2012-10-26 12:52:04 -04:00
|
|
|
|
|
|
|
if(jt9com_.nagain==0 && (!m_diskData)) {
|
|
|
|
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
|
|
|
int imin=ms/60000;
|
|
|
|
int ihr=imin/60;
|
|
|
|
imin=imin%60;
|
|
|
|
if(m_TRperiod>60) imin=imin - imin%(m_TRperiod/60);
|
|
|
|
jt9com_.nutc=100*ihr + imin;
|
|
|
|
}
|
|
|
|
|
|
|
|
// jt9com_.newdat=1;
|
|
|
|
// jt9com_.nagain=0;
|
2012-10-19 15:26:07 -04:00
|
|
|
jt9com_.nfqso=g_pWideGraph->QSOfreq();
|
|
|
|
m_tol=g_pWideGraph->Tol();
|
|
|
|
jt9com_.ntol=m_tol;
|
2012-10-27 10:09:34 -04:00
|
|
|
if(jt9com_.nutc < m_nutc0) m_RxLog |= 1; //Date and Time to wsjtx_rx.log
|
|
|
|
m_nutc0=jt9com_.nutc;
|
|
|
|
*future3 = QtConcurrent::run(decoder_, &m_TRperiod, &m_RxLog, &c0[0]);
|
2012-10-16 19:32:15 -04:00
|
|
|
watcher3->setFuture(*future3);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_EraseButton_clicked() //Erase
|
|
|
|
{
|
|
|
|
ui->decodedTextBrowser->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::decodeBusy(bool b) //decodeBusy()
|
|
|
|
{
|
|
|
|
m_decoderBusy=b;
|
|
|
|
ui->DecodeButton->setEnabled(!b);
|
|
|
|
ui->actionOpen->setEnabled(!b);
|
|
|
|
ui->actionOpen_next_in_directory->setEnabled(!b);
|
|
|
|
ui->actionDecode_remaining_files_in_directory->setEnabled(!b);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------- //guiUpdate()
|
|
|
|
void MainWindow::guiUpdate()
|
|
|
|
{
|
|
|
|
static int iptt0=0;
|
|
|
|
static int iptt=0;
|
|
|
|
static bool btxok0=false;
|
|
|
|
static int nc0=1;
|
|
|
|
static int nc1=1;
|
2012-07-12 15:10:39 -04:00
|
|
|
static char msgsent[29];
|
2012-05-22 13:09:48 -04:00
|
|
|
static int nsendingsh=0;
|
|
|
|
int khsym=0;
|
|
|
|
|
|
|
|
double tx1=0.0;
|
2012-10-05 13:13:21 -04:00
|
|
|
// double tx2=m_TRperiod;
|
|
|
|
double tx2=1.0 + 85.0*m_nsps/12000.0;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
if(!m_txFirst) {
|
2012-09-24 15:11:31 -04:00
|
|
|
tx1 += m_TRperiod;
|
|
|
|
tx2 += m_TRperiod;
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
|
|
|
int nsec=ms/1000;
|
|
|
|
double tsec=0.001*ms;
|
2012-09-24 15:11:31 -04:00
|
|
|
double t2p=fmod(tsec,2*m_TRperiod);
|
2012-07-02 16:52:56 -04:00
|
|
|
bool bTxTime = t2p >= tx1 && t2p < tx2;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
if(m_auto) {
|
2012-10-26 12:01:57 -04:00
|
|
|
|
|
|
|
QFile f("txboth");
|
|
|
|
if(f.exists() and fmod(tsec,m_TRperiod)<1.0 + 85.0*m_nsps/12000.0)
|
|
|
|
bTxTime=true;
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
if(bTxTime and iptt==0 and !m_txMute) {
|
|
|
|
int itx=1;
|
2012-10-28 11:47:43 -04:00
|
|
|
int ierr = ptt(m_pttPort,itx,&iptt); // Raise PTT
|
|
|
|
if(ierr<0) {
|
2012-05-22 13:09:48 -04:00
|
|
|
on_stopTxButton_clicked();
|
|
|
|
char s[18];
|
2012-10-28 11:47:43 -04:00
|
|
|
sprintf(s,"PTT Error %d",ierr);
|
2012-05-22 13:09:48 -04:00
|
|
|
msgBox(s);
|
|
|
|
}
|
|
|
|
if(!soundOutThread.isRunning()) {
|
2012-10-26 10:03:43 -04:00
|
|
|
QString t=ui->tx6->text();
|
|
|
|
double snr=t.mid(1,5).toDouble();
|
|
|
|
if(snr>0.0 or snr < -50.0) snr=99.0;
|
|
|
|
soundOutThread.setTxSNR(snr);
|
2012-05-22 13:09:48 -04:00
|
|
|
soundOutThread.start(QThread::HighPriority);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!bTxTime || m_txMute) {
|
|
|
|
btxok=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate Tx waveform when needed
|
|
|
|
if((iptt==1 && iptt0==0) || m_restart) {
|
2012-07-12 15:10:39 -04:00
|
|
|
char message[29];
|
2012-05-22 13:09:48 -04:00
|
|
|
QByteArray ba;
|
|
|
|
if(m_ntx == 1) ba=ui->tx1->text().toLocal8Bit();
|
|
|
|
if(m_ntx == 2) ba=ui->tx2->text().toLocal8Bit();
|
|
|
|
if(m_ntx == 3) ba=ui->tx3->text().toLocal8Bit();
|
|
|
|
if(m_ntx == 4) ba=ui->tx4->text().toLocal8Bit();
|
|
|
|
if(m_ntx == 5) ba=ui->tx5->text().toLocal8Bit();
|
|
|
|
if(m_ntx == 6) ba=ui->tx6->text().toLocal8Bit();
|
|
|
|
|
|
|
|
ba2msg(ba,message);
|
2012-07-12 15:10:39 -04:00
|
|
|
ba2msg(ba,msgsent);
|
2012-10-05 13:13:21 -04:00
|
|
|
int len1=22;
|
|
|
|
int len2=22;
|
2012-10-16 19:32:15 -04:00
|
|
|
genjt9_(message,msgsent,itone,len1,len2);
|
2012-05-22 13:09:48 -04:00
|
|
|
if(m_restart) {
|
2012-09-24 15:11:31 -04:00
|
|
|
QFile f("wsjtx_tx.log");
|
2012-05-22 13:09:48 -04:00
|
|
|
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
|
|
|
|
QTextStream out(&f);
|
|
|
|
out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
|
|
|
|
<< " Tx message: " << QString::fromAscii(msgsent) << endl;
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_restart=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If PTT was just raised, start a countdown for raising TxOK:
|
|
|
|
if(iptt==1 && iptt0==0) nc1=-9; // TxDelay = 0.8 s
|
|
|
|
if(nc1 <= 0) nc1++;
|
|
|
|
if(nc1 == 0) {
|
|
|
|
ui->xThermo->setValue(0.0); //Set the Thermos to zero
|
|
|
|
m_monitoring=false;
|
|
|
|
soundInThread.setMonitoring(false);
|
|
|
|
btxok=true;
|
|
|
|
m_transmitting=true;
|
|
|
|
|
2012-09-24 15:11:31 -04:00
|
|
|
QFile f("wsjtx_tx.log");
|
2012-05-22 13:09:48 -04:00
|
|
|
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
|
|
|
|
QTextStream out(&f);
|
|
|
|
out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
|
|
|
|
<< " Tx message: " << QString::fromAscii(msgsent) << endl;
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If btxok was just lowered, start a countdown for lowering PTT
|
|
|
|
if(!btxok && btxok0 && iptt==1) nc0=-11; //RxDelay = 1.0 s
|
|
|
|
if(nc0 <= 0) nc0++;
|
|
|
|
if(nc0 == 0) {
|
|
|
|
int itx=0;
|
2012-10-28 11:47:43 -04:00
|
|
|
int ierr=ptt(m_pttPort,itx,&iptt); // Lower PTT
|
|
|
|
if(ierr<0) {
|
|
|
|
char s[18];
|
|
|
|
sprintf(s,"PTT Error %d",ierr);
|
|
|
|
msgBox(s);
|
|
|
|
}
|
2012-05-22 13:09:48 -04:00
|
|
|
if(!m_txMute) soundOutThread.quitExecution=true;
|
|
|
|
m_transmitting=false;
|
|
|
|
if(m_auto) {
|
|
|
|
m_monitoring=true;
|
|
|
|
soundInThread.setMonitoring(m_monitoring);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(iptt == 0 && !btxok) {
|
|
|
|
// sending=""
|
|
|
|
// nsendingsh=0
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_monitoring) {
|
|
|
|
ui->monitorButton->setStyleSheet(m_pbmonitor_style);
|
|
|
|
} else {
|
|
|
|
ui->monitorButton->setStyleSheet("");
|
|
|
|
}
|
|
|
|
|
2012-09-29 13:52:35 -04:00
|
|
|
lab2->setText("QSO Freq: " + QString::number(g_pWideGraph->QSOfreq()));
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
if(m_startAnother) {
|
|
|
|
m_startAnother=false;
|
|
|
|
on_actionOpen_next_in_directory_triggered();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nsec != m_sec0) { //Once per second
|
2012-10-26 12:01:57 -04:00
|
|
|
QDateTime t = QDateTime::currentDateTimeUtc();
|
2012-05-22 13:09:48 -04:00
|
|
|
if(m_transmitting) {
|
|
|
|
if(nsendingsh==1) {
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #66ffff}");
|
|
|
|
} else if(nsendingsh==-1) {
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #ffccff}");
|
|
|
|
} else {
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #ffff33}");
|
|
|
|
}
|
|
|
|
char s[37];
|
|
|
|
sprintf(s,"Tx: %s",msgsent);
|
|
|
|
lab1->setText(s);
|
|
|
|
} else if(m_monitoring) {
|
|
|
|
lab1->setStyleSheet("QLabel{background-color: #00ff00}");
|
2012-09-25 20:48:49 -04:00
|
|
|
lab1->setText("Receiving ");
|
2012-05-22 13:09:48 -04:00
|
|
|
} else if (!m_diskData) {
|
|
|
|
lab1->setStyleSheet("");
|
|
|
|
lab1->setText("");
|
|
|
|
}
|
|
|
|
|
|
|
|
m_setftx=0;
|
|
|
|
QString utc = " " + t.time().toString() + " ";
|
|
|
|
ui->labUTC->setText(utc);
|
2012-09-25 20:48:49 -04:00
|
|
|
if(!m_monitoring and !m_diskData) {
|
2012-10-21 15:35:10 -04:00
|
|
|
ui->xThermo->setValue(0.0);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
m_hsym0=khsym;
|
|
|
|
m_sec0=nsec;
|
|
|
|
}
|
|
|
|
iptt0=iptt;
|
|
|
|
btxok0=btxok;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ba2msg(QByteArray ba, char message[]) //ba2msg()
|
|
|
|
{
|
|
|
|
bool eom;
|
|
|
|
eom=false;
|
2012-07-17 15:31:01 -04:00
|
|
|
for(int i=0;i<28; i++) {
|
2012-05-22 13:09:48 -04:00
|
|
|
if((int)ba[i] == 0) eom=true;
|
|
|
|
if(eom) {
|
|
|
|
message[i]=32;
|
|
|
|
} else {
|
|
|
|
message[i]=ba[i];
|
|
|
|
}
|
|
|
|
}
|
2012-07-17 15:31:01 -04:00
|
|
|
message[28]=0;
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txFirstCheckBox_stateChanged(int nstate) //TxFirst
|
|
|
|
{
|
|
|
|
m_txFirst = (nstate==2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::set_ntx(int n) //set_ntx()
|
|
|
|
{
|
|
|
|
m_ntx=n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txb1_clicked() //txb1
|
|
|
|
{
|
|
|
|
m_ntx=1;
|
|
|
|
ui->txrb1->setChecked(true);
|
|
|
|
m_restart=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txb2_clicked() //txb2
|
|
|
|
{
|
|
|
|
m_ntx=2;
|
|
|
|
ui->txrb2->setChecked(true);
|
|
|
|
m_restart=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txb3_clicked() //txb3
|
|
|
|
{
|
|
|
|
m_ntx=3;
|
|
|
|
ui->txrb3->setChecked(true);
|
|
|
|
m_restart=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txb4_clicked() //txb4
|
|
|
|
{
|
|
|
|
m_ntx=4;
|
|
|
|
ui->txrb4->setChecked(true);
|
|
|
|
m_restart=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txb5_clicked() //txb5
|
|
|
|
{
|
|
|
|
m_ntx=5;
|
|
|
|
ui->txrb5->setChecked(true);
|
|
|
|
m_restart=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_txb6_clicked() //txb6
|
|
|
|
{
|
|
|
|
m_ntx=6;
|
|
|
|
ui->txrb6->setChecked(true);
|
|
|
|
m_restart=true;
|
|
|
|
}
|
|
|
|
|
2012-09-25 20:48:49 -04:00
|
|
|
void MainWindow::selectCall2(bool ctrl) //selectCall2
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
|
|
|
QString t = ui->decodedTextBrowser->toPlainText(); //Full contents
|
|
|
|
int i=ui->decodedTextBrowser->textCursor().position();
|
|
|
|
int i0=t.lastIndexOf(" ",i);
|
|
|
|
int i1=t.indexOf(" ",i);
|
|
|
|
QString hiscall=t.mid(i0+1,i1-i0-1);
|
|
|
|
if(hiscall!="") {
|
|
|
|
if(hiscall.length() < 13) doubleClickOnCall(hiscall, ctrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//doubleClickOnCall
|
|
|
|
void MainWindow::doubleClickOnCall(QString hiscall, bool ctrl)
|
|
|
|
{
|
|
|
|
ui->dxCallEntry->setText(hiscall);
|
|
|
|
QString t = ui->decodedTextBrowser->toPlainText(); //Full contents
|
|
|
|
int i2=ui->decodedTextBrowser->textCursor().position();
|
2012-10-24 15:44:29 -04:00
|
|
|
int i3=t.mid(i2,99).indexOf("\n")-1; //points to last char of line
|
|
|
|
QString t1 = t.mid(0,i3); //contents up to \n on selected line
|
|
|
|
int i1=t1.lastIndexOf("\n") + 1; //points to first char of line
|
|
|
|
QString t2 = t1.mid(i1,i3-i1); //selected line
|
|
|
|
int n = 60*t2.mid(0,2).toInt() + t2.mid(2,2).toInt();
|
|
|
|
int nmod=n%(m_TRperiod/30);
|
|
|
|
m_txFirst=(nmod!=0);
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->txFirstCheckBox->setChecked(m_txFirst);
|
2012-10-24 15:44:29 -04:00
|
|
|
QString rpt=t2.mid(10,3);
|
|
|
|
if(ctrl) {
|
|
|
|
int i4=t.mid(i2,20).indexOf(" ");
|
|
|
|
QString hisgrid=t.mid(i2,20).mid(i4+1,4);
|
|
|
|
ui->dxGridEntry->setText(hisgrid);
|
|
|
|
} else {
|
|
|
|
lookup();
|
|
|
|
}
|
2012-05-22 13:09:48 -04:00
|
|
|
genStdMsgs(rpt);
|
|
|
|
if(t2.indexOf(m_myCall)>0) {
|
|
|
|
m_ntx=2;
|
|
|
|
ui->txrb2->setChecked(true);
|
|
|
|
} else {
|
|
|
|
m_ntx=1;
|
|
|
|
ui->txrb1->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::genStdMsgs(QString rpt) //genStdMsgs()
|
|
|
|
{
|
|
|
|
QString hiscall=ui->dxCallEntry->text().toUpper().trimmed();
|
|
|
|
ui->dxCallEntry->setText(hiscall);
|
|
|
|
QString t0=hiscall + " " + m_myCall + " ";
|
|
|
|
QString t=t0 + m_myGrid.mid(0,4);
|
|
|
|
msgtype(t, ui->tx1);
|
|
|
|
if(rpt == "") {
|
|
|
|
t=t+" OOO";
|
|
|
|
msgtype(t, ui->tx2);
|
|
|
|
msgtype("RO", ui->tx3);
|
|
|
|
msgtype("RRR", ui->tx4);
|
|
|
|
msgtype("73", ui->tx5);
|
|
|
|
} else {
|
|
|
|
t=t0 + rpt;
|
|
|
|
msgtype(t, ui->tx2);
|
|
|
|
t=t0 + "R" + rpt;
|
|
|
|
msgtype(t, ui->tx3);
|
|
|
|
t=t0 + "RRR";
|
|
|
|
msgtype(t, ui->tx4);
|
|
|
|
t=t0 + "73";
|
|
|
|
msgtype(t, ui->tx5);
|
|
|
|
}
|
|
|
|
t="CQ " + m_myCall + " " + m_myGrid.mid(0,4);
|
|
|
|
msgtype(t, ui->tx6);
|
|
|
|
m_ntx=1;
|
|
|
|
ui->txrb1->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::lookup() //lookup()
|
|
|
|
{
|
|
|
|
QString hiscall=ui->dxCallEntry->text().toUpper().trimmed();
|
|
|
|
ui->dxCallEntry->setText(hiscall);
|
|
|
|
QString call3File = m_appDir + "/CALL3.TXT";
|
|
|
|
QFile f(call3File);
|
|
|
|
if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
msgBox("Cannot open " + call3File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
char c[132];
|
|
|
|
qint64 n=0;
|
|
|
|
for(int i=0; i<999999; i++) {
|
|
|
|
n=f.readLine(c,sizeof(c));
|
|
|
|
if(n <= 0) {
|
|
|
|
ui->dxGridEntry->setText("");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QString t=QString(c);
|
|
|
|
if(t.indexOf(hiscall)==0) {
|
|
|
|
int i1=t.indexOf(",");
|
|
|
|
QString hisgrid=t.mid(i1+1,6);
|
|
|
|
i1=hisgrid.indexOf(",");
|
|
|
|
if(i1>0) {
|
|
|
|
hisgrid=hisgrid.mid(0,4);
|
|
|
|
} else {
|
|
|
|
hisgrid=hisgrid.mid(0,4) + hisgrid.mid(4,2).toLower();
|
|
|
|
}
|
|
|
|
ui->dxGridEntry->setText(hisgrid);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_lookupButton_clicked() //Lookup button
|
|
|
|
{
|
|
|
|
lookup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_addButton_clicked() //Add button
|
|
|
|
{
|
2012-10-27 14:06:48 -04:00
|
|
|
if(ui->dxGridEntry->text()=="") {
|
|
|
|
msgBox("Please enter a valid grid locator.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_call3Modified=false;
|
|
|
|
QString hiscall=ui->dxCallEntry->text().toUpper().trimmed();
|
|
|
|
QString hisgrid=ui->dxGridEntry->text().trimmed();
|
|
|
|
QString newEntry=hiscall + "," + hisgrid;
|
|
|
|
|
|
|
|
// int ret = QMessageBox::warning(this, "Add",
|
|
|
|
// newEntry + "\n" + "Is this station known to be active on EME?",
|
|
|
|
// QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
|
|
// if(ret==QMessageBox::Yes) {
|
|
|
|
// newEntry += ",EME,,";
|
|
|
|
// } else {
|
|
|
|
newEntry += ",,,";
|
|
|
|
// }
|
|
|
|
|
|
|
|
QString call3File = m_appDir + "/CALL3.TXT";
|
|
|
|
QFile f1(call3File);
|
|
|
|
if(!f1.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
msgBox("Cannot open " + call3File);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QString tmpFile = m_appDir + "/CALL3.TMP";
|
|
|
|
QFile f2(tmpFile);
|
|
|
|
if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
msgBox("Cannot open " + tmpFile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QTextStream in(&f1);
|
|
|
|
QTextStream out(&f2);
|
|
|
|
QString hc=hiscall;
|
|
|
|
QString hc1="";
|
|
|
|
QString hc2="AAAAAA";
|
|
|
|
QString s;
|
|
|
|
do {
|
|
|
|
s=in.readLine();
|
|
|
|
hc1=hc2;
|
|
|
|
if(s.mid(0,2)=="//") {
|
|
|
|
out << s + "\n";
|
|
|
|
} else {
|
|
|
|
int i1=s.indexOf(",");
|
|
|
|
hc2=s.mid(0,i1);
|
|
|
|
if(hc>hc1 && hc<hc2) {
|
|
|
|
out << newEntry + "\n";
|
|
|
|
if(s.mid(0,6)=="ZZZZZZ") {
|
|
|
|
out << s + "\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
m_call3Modified=true;
|
|
|
|
} else if(hc==hc2) {
|
|
|
|
QString t=s + "\n\n is already in CALL3.TXT\n" +
|
|
|
|
"Do you wish to replace it?";
|
|
|
|
int ret = QMessageBox::warning(this, "Add",t,
|
|
|
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
|
|
if(ret==QMessageBox::Yes) {
|
|
|
|
out << newEntry + "\n";
|
|
|
|
m_call3Modified=true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(s!="") out << s + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while(!s.isNull());
|
|
|
|
|
|
|
|
f1.close();
|
|
|
|
if(hc>hc1 && !m_call3Modified) {
|
|
|
|
out << newEntry + "\n";
|
|
|
|
}
|
|
|
|
if(m_call3Modified) {
|
|
|
|
QFile f0(m_appDir + "/CALL3.OLD");
|
|
|
|
if(f0.exists()) f0.remove();
|
|
|
|
QFile f1(m_appDir + "/CALL3.TXT");
|
|
|
|
f1.rename(m_appDir + "/CALL3.OLD");
|
|
|
|
f2.rename(m_appDir + "/CALL3.TXT");
|
|
|
|
f2.close();
|
|
|
|
}
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype()
|
|
|
|
{
|
|
|
|
char message[23];
|
|
|
|
char msgsent[23];
|
|
|
|
int len1=22;
|
|
|
|
double samfac=1.0;
|
|
|
|
int nsendingsh=0;
|
|
|
|
int mwave;
|
|
|
|
t=t.toUpper();
|
|
|
|
int i1=t.indexOf(" OOO");
|
|
|
|
QByteArray s=t.toUpper().toLocal8Bit();
|
|
|
|
ba2msg(s,message);
|
2012-09-25 16:26:12 -04:00
|
|
|
// gen65_(message,&mode65,&samfac,&nsendingsh,msgsent,iwave,&mwave,len1,len1);
|
2012-07-13 15:30:35 -04:00
|
|
|
nsendingsh=0;
|
2012-05-22 13:09:48 -04:00
|
|
|
QPalette p(tx->palette());
|
|
|
|
if(nsendingsh==1) {
|
|
|
|
p.setColor(QPalette::Base,"#66ffff");
|
|
|
|
} else if(nsendingsh==-1) {
|
|
|
|
p.setColor(QPalette::Base,"#ffccff");
|
|
|
|
} else {
|
|
|
|
p.setColor(QPalette::Base,Qt::white);
|
|
|
|
}
|
|
|
|
tx->setPalette(p);
|
|
|
|
int len=t.length();
|
|
|
|
if(nsendingsh==-1) {
|
|
|
|
len=qMin(len,13);
|
|
|
|
if(i1>10) {
|
|
|
|
tx->setText(t.mid(0,len).toUpper() + " OOO");
|
|
|
|
} else {
|
|
|
|
tx->setText(t.mid(0,len).toUpper());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tx->setText(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tx1_editingFinished() //tx1 edited
|
|
|
|
{
|
|
|
|
QString t=ui->tx1->text();
|
|
|
|
msgtype(t, ui->tx1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tx2_editingFinished() //tx2 edited
|
|
|
|
{
|
|
|
|
QString t=ui->tx2->text();
|
|
|
|
msgtype(t, ui->tx2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tx3_editingFinished() //tx3 edited
|
|
|
|
{
|
|
|
|
QString t=ui->tx3->text();
|
|
|
|
msgtype(t, ui->tx3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tx4_editingFinished() //tx4 edited
|
|
|
|
{
|
|
|
|
QString t=ui->tx4->text();
|
|
|
|
msgtype(t, ui->tx4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tx5_editingFinished() //tx5 edited
|
|
|
|
{
|
|
|
|
QString t=ui->tx5->text();
|
|
|
|
msgtype(t, ui->tx5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tx6_editingFinished() //tx6 edited
|
|
|
|
{
|
|
|
|
QString t=ui->tx6->text();
|
|
|
|
msgtype(t, ui->tx6);
|
2012-10-26 10:03:43 -04:00
|
|
|
double snr=t.mid(1,5).toDouble();
|
|
|
|
if(snr>0.0 or snr < -50.0) snr=99.0;
|
|
|
|
soundOutThread.setTxSNR(snr);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_dxCallEntry_textChanged(const QString &t) //dxCall changed
|
|
|
|
{
|
|
|
|
m_hisCall=t.toUpper().trimmed();
|
|
|
|
ui->dxCallEntry->setText(m_hisCall);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_dxGridEntry_textChanged(const QString &t) //dxGrid changed
|
|
|
|
{
|
|
|
|
int n=t.length();
|
|
|
|
if(n!=4 and n!=6) return;
|
|
|
|
if(!t[0].isLetter() or !t[1].isLetter()) return;
|
|
|
|
if(!t[2].isDigit() or !t[3].isDigit()) return;
|
|
|
|
if(n==4) m_hisGrid=t.mid(0,2).toUpper() + t.mid(2,2);
|
|
|
|
if(n==6) m_hisGrid=t.mid(0,2).toUpper() + t.mid(2,2) +
|
|
|
|
t.mid(4,2).toLower();
|
|
|
|
ui->dxGridEntry->setText(m_hisGrid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_genStdMsgsPushButton_clicked() //genStdMsgs button
|
|
|
|
{
|
2012-09-24 15:11:31 -04:00
|
|
|
genStdMsgs("-30");
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_logQSOButton_clicked() //Log QSO button
|
|
|
|
{
|
2012-07-04 12:27:57 -04:00
|
|
|
int nMHz=144;
|
2012-05-22 13:09:48 -04:00
|
|
|
QDateTime t = QDateTime::currentDateTimeUtc();
|
|
|
|
QString logEntry=t.date().toString("yyyy-MMM-dd,") +
|
|
|
|
t.time().toString("hh:mm,") + m_hisCall + "," + m_hisGrid + "," +
|
2012-07-18 09:25:16 -04:00
|
|
|
QString::number(nMHz) + ",JTMSK\n";
|
2012-05-22 13:09:48 -04:00
|
|
|
QFile f("wsjt.log");
|
|
|
|
if(!f.open(QFile::Append)) {
|
|
|
|
msgBox("Cannot open file \"wsjt.log\".");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QTextStream out(&f);
|
|
|
|
out << logEntry;
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
|
2012-09-24 11:20:48 -04:00
|
|
|
void MainWindow::on_actionErase_wsjtx_rx_log_triggered() //Erase Rx log
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
|
|
|
int ret = QMessageBox::warning(this, "Confirm Erase",
|
2012-09-24 15:11:31 -04:00
|
|
|
"Are you sure you want to erase file wsjtx_rx.log ?",
|
2012-05-22 13:09:48 -04:00
|
|
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
|
|
if(ret==QMessageBox::Yes) {
|
2012-09-24 15:11:31 -04:00
|
|
|
m_RxLog |= 2; // Rewind wsjtx_rx.log
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-24 11:20:48 -04:00
|
|
|
void MainWindow::on_actionErase_wsjtx_tx_log_triggered() //Erase Tx log
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
|
|
|
int ret = QMessageBox::warning(this, "Confirm Erase",
|
2012-09-24 15:11:31 -04:00
|
|
|
"Are you sure you want to erase file wsjtx_tx.log ?",
|
2012-05-22 13:09:48 -04:00
|
|
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
|
|
if(ret==QMessageBox::Yes) {
|
2012-09-24 15:11:31 -04:00
|
|
|
QFile f("wsjtx_tx.log");
|
2012-05-22 13:09:48 -04:00
|
|
|
f.remove();
|
|
|
|
}
|
|
|
|
}
|
2012-09-24 15:11:31 -04:00
|
|
|
|
2012-10-04 17:39:48 -04:00
|
|
|
void MainWindow::on_actionJT9_1_triggered()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode="JT9-1";
|
2012-09-24 15:11:31 -04:00
|
|
|
m_TRperiod=60;
|
2012-09-28 19:59:50 -04:00
|
|
|
m_nsps=6912;
|
2012-10-11 14:33:50 -04:00
|
|
|
m_hsymStop=181;
|
2012-09-25 20:48:49 -04:00
|
|
|
soundInThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
soundOutThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab4->setStyleSheet("QLabel{background-color: #ff6ec7}");
|
|
|
|
lab4->setText(m_mode);
|
2012-10-04 17:39:48 -04:00
|
|
|
ui->actionJT9_1->setChecked(true);
|
2012-09-24 15:11:31 -04:00
|
|
|
}
|
|
|
|
|
2012-10-04 17:39:48 -04:00
|
|
|
void MainWindow::on_actionJT9_2_triggered()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode="JT9-2";
|
2012-09-24 15:11:31 -04:00
|
|
|
m_TRperiod=120;
|
2012-09-28 19:59:50 -04:00
|
|
|
m_nsps=15360;
|
2012-10-11 14:33:50 -04:00
|
|
|
m_hsymStop=178;
|
2012-09-25 20:48:49 -04:00
|
|
|
soundInThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
soundOutThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab4->setStyleSheet("QLabel{background-color: #ffff00}");
|
|
|
|
lab4->setText(m_mode);
|
2012-10-04 17:39:48 -04:00
|
|
|
ui->actionJT9_2->setChecked(true);
|
2012-09-24 15:11:31 -04:00
|
|
|
}
|
|
|
|
|
2012-10-04 17:39:48 -04:00
|
|
|
void MainWindow::on_actionJT9_5_triggered()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode="JT9-5";
|
2012-09-24 15:11:31 -04:00
|
|
|
m_TRperiod=300;
|
2012-09-28 19:59:50 -04:00
|
|
|
m_nsps=40960;
|
2012-10-11 14:33:50 -04:00
|
|
|
m_hsymStop=172;
|
2012-09-25 20:48:49 -04:00
|
|
|
soundInThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
soundOutThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab4->setStyleSheet("QLabel{background-color: #ffa500}");
|
|
|
|
lab4->setText(m_mode);
|
2012-10-04 17:39:48 -04:00
|
|
|
ui->actionJT9_5->setChecked(true);
|
2012-09-24 15:11:31 -04:00
|
|
|
}
|
|
|
|
|
2012-10-04 17:39:48 -04:00
|
|
|
void MainWindow::on_actionJT9_10_triggered()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode="JT9-10";
|
2012-09-24 15:11:31 -04:00
|
|
|
m_TRperiod=600;
|
2012-09-28 19:59:50 -04:00
|
|
|
m_nsps=82944;
|
2012-10-11 14:33:50 -04:00
|
|
|
m_hsymStop=171;
|
2012-09-25 20:48:49 -04:00
|
|
|
soundInThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
soundOutThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab4->setStyleSheet("QLabel{background-color: #7fff00}");
|
|
|
|
lab4->setText(m_mode);
|
2012-10-04 17:39:48 -04:00
|
|
|
ui->actionJT9_10->setChecked(true);
|
2012-09-24 15:11:31 -04:00
|
|
|
}
|
|
|
|
|
2012-10-04 17:39:48 -04:00
|
|
|
void MainWindow::on_actionJT9_30_triggered()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
2012-10-04 17:39:48 -04:00
|
|
|
m_mode="JT9-30";
|
2012-09-24 15:11:31 -04:00
|
|
|
m_TRperiod=1800;
|
2012-10-05 13:13:21 -04:00
|
|
|
m_nsps=252000;
|
2012-10-11 14:33:50 -04:00
|
|
|
m_hsymStop=167;
|
2012-09-25 20:48:49 -04:00
|
|
|
soundInThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
soundOutThread.setPeriod(m_TRperiod,m_nsps);
|
|
|
|
g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
|
2012-10-20 12:37:01 -04:00
|
|
|
lab4->setStyleSheet("QLabel{background-color: #97ffff}");
|
|
|
|
lab4->setText(m_mode);
|
2012-10-04 17:39:48 -04:00
|
|
|
ui->actionJT9_30->setChecked(true);
|
2012-09-24 15:11:31 -04:00
|
|
|
}
|
2012-09-25 16:26:12 -04:00
|
|
|
|
|
|
|
void MainWindow::on_NBcheckBox_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_NB=checked;
|
|
|
|
ui->NBslider->setEnabled(m_NB);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_NBslider_valueChanged(int n)
|
|
|
|
{
|
|
|
|
m_NBslider=n;
|
|
|
|
}
|
2012-10-05 15:14:45 -04:00
|
|
|
|
|
|
|
void MainWindow::on_TxFreqSpinBox_valueChanged(int n)
|
|
|
|
{
|
|
|
|
m_txFreq=n;
|
|
|
|
soundOutThread.setTxFreq(n);
|
|
|
|
}
|
2012-10-20 16:52:29 -04:00
|
|
|
|
|
|
|
void MainWindow::on_pbTxFreq_clicked()
|
|
|
|
{
|
|
|
|
int ntx=g_pWideGraph->QSOfreq();
|
|
|
|
m_txFreq=ntx;
|
|
|
|
ui->TxFreqSpinBox->setValue(ntx);
|
|
|
|
}
|