kopia lustrzana https://gitlab.com/eliggett/wfview
Added a fix to keep the local frequency in-sync with any recent commands
sent to the radio.merge-requests/5/head
rodzic
b6cac33ee9
commit
2e9c734b64
75
wfmain.cpp
75
wfmain.cpp
|
@ -846,6 +846,7 @@ void wfmain::setInitialTiming()
|
||||||
timeSync = new QTimer(this);
|
timeSync = new QTimer(this);
|
||||||
connect(timeSync, SIGNAL(timeout()), this, SLOT(setRadioTimeDateSend()));
|
connect(timeSync, SIGNAL(timeout()), this, SLOT(setRadioTimeDateSend()));
|
||||||
waitingToSetTimeDate = false;
|
waitingToSetTimeDate = false;
|
||||||
|
lastFreqCmdTime_ms = QDateTime::currentMSecsSinceEpoch() - 5000; // 5 seconds ago
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::setServerToPrefs()
|
void wfmain::setServerToPrefs()
|
||||||
|
@ -2264,6 +2265,7 @@ void wfmain::doCmd(commandtype cmddata)
|
||||||
{
|
{
|
||||||
case cmdSetFreq:
|
case cmdSetFreq:
|
||||||
{
|
{
|
||||||
|
lastFreqCmdTime_ms = QDateTime::currentMSecsSinceEpoch();
|
||||||
freqt f = (*std::static_pointer_cast<freqt>(data));
|
freqt f = (*std::static_pointer_cast<freqt>(data));
|
||||||
emit setFrequency(f);
|
emit setFrequency(f);
|
||||||
break;
|
break;
|
||||||
|
@ -2954,10 +2956,15 @@ void wfmain::insertSlowPeriodicCommand(cmds cmd, unsigned char priority)
|
||||||
void wfmain::receiveFreq(freqt freqStruct)
|
void wfmain::receiveFreq(freqt freqStruct)
|
||||||
{
|
{
|
||||||
|
|
||||||
//qInfo(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz;
|
qint64 tnow_ms = QDateTime::currentMSecsSinceEpoch();
|
||||||
ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f'));
|
if(tnow_ms - lastFreqCmdTime_ms > delayedCommand->interval() * 2)
|
||||||
freq = freqStruct;
|
{
|
||||||
//showStatusBarText(QString("Frequency: %1").arg(freqMhz));
|
ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f'));
|
||||||
|
freq = freqStruct;
|
||||||
|
} else {
|
||||||
|
qDebug(logSystem()) << "Rejecting stale frequency: " << freqStruct.Hz << " Hz, delta time ms = " << tnow_ms - lastFreqCmdTime_ms\
|
||||||
|
<< ", tnow_ms " << tnow_ms << ", last: " << lastFreqCmdTime_ms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::receivePTTstatus(bool pttOn)
|
void wfmain::receivePTTstatus(bool pttOn)
|
||||||
|
@ -3101,20 +3108,23 @@ void wfmain::receiveSpectrumMode(spectrumMode spectMode)
|
||||||
void wfmain::handlePlotDoubleClick(QMouseEvent *me)
|
void wfmain::handlePlotDoubleClick(QMouseEvent *me)
|
||||||
{
|
{
|
||||||
double x;
|
double x;
|
||||||
freqt freq;
|
freqt freqGo;
|
||||||
//double y;
|
//double y;
|
||||||
//double px;
|
//double px;
|
||||||
if(!freqLock)
|
if(!freqLock)
|
||||||
{
|
{
|
||||||
//y = plot->yAxis->pixelToCoord(me->pos().y());
|
//y = plot->yAxis->pixelToCoord(me->pos().y());
|
||||||
x = plot->xAxis->pixelToCoord(me->pos().x());
|
x = plot->xAxis->pixelToCoord(me->pos().x());
|
||||||
freq.Hz = x*1E6;
|
freqGo.Hz = x*1E6;
|
||||||
|
|
||||||
freq.Hz = roundFrequency(freq.Hz, tsWfScrollHz);
|
freqGo.Hz = roundFrequency(freqGo.Hz, tsWfScrollHz);
|
||||||
|
freqGo.MHzDouble = (float)freqGo.Hz / 1E6;
|
||||||
|
|
||||||
//emit setFrequency(freq);
|
//emit setFrequency(freq);
|
||||||
issueCmd(cmdSetFreq, freq);
|
issueCmd(cmdSetFreq, freqGo);
|
||||||
issueDelayedCommand(cmdGetFreq);
|
freq = freqGo;
|
||||||
|
setUIFreq();
|
||||||
|
//issueDelayedCommand(cmdGetFreq);
|
||||||
showStatusBarText(QString("Going to %1 MHz").arg(x));
|
showStatusBarText(QString("Going to %1 MHz").arg(x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3122,7 +3132,7 @@ void wfmain::handlePlotDoubleClick(QMouseEvent *me)
|
||||||
void wfmain::handleWFDoubleClick(QMouseEvent *me)
|
void wfmain::handleWFDoubleClick(QMouseEvent *me)
|
||||||
{
|
{
|
||||||
double x;
|
double x;
|
||||||
freqt freq;
|
freqt freqGo;
|
||||||
//double y;
|
//double y;
|
||||||
//x = wf->xAxis->pixelToCoord(me->pos().x());
|
//x = wf->xAxis->pixelToCoord(me->pos().x());
|
||||||
//y = wf->yAxis->pixelToCoord(me->pos().y());
|
//y = wf->yAxis->pixelToCoord(me->pos().y());
|
||||||
|
@ -3130,13 +3140,15 @@ void wfmain::handleWFDoubleClick(QMouseEvent *me)
|
||||||
if(!freqLock)
|
if(!freqLock)
|
||||||
{
|
{
|
||||||
x = plot->xAxis->pixelToCoord(me->pos().x());
|
x = plot->xAxis->pixelToCoord(me->pos().x());
|
||||||
freq.Hz = x*1E6;
|
freqGo.Hz = x*1E6;
|
||||||
|
|
||||||
freq.Hz = roundFrequency(freq.Hz, tsWfScrollHz);
|
freqGo.Hz = roundFrequency(freqGo.Hz, tsWfScrollHz);
|
||||||
|
freqGo.MHzDouble = (float)freqGo.Hz / 1E6;
|
||||||
|
|
||||||
//emit setFrequency(freq);
|
//emit setFrequency(freq);
|
||||||
issueCmd(cmdSetFreq, freq);
|
issueCmd(cmdSetFreq, freqGo);
|
||||||
issueDelayedCommand(cmdGetFreq);
|
freq = freqGo;
|
||||||
|
setUIFreq();
|
||||||
showStatusBarText(QString("Going to %1 MHz").arg(x));
|
showStatusBarText(QString("Going to %1 MHz").arg(x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3191,7 +3203,7 @@ void wfmain::handleWFScroll(QWheelEvent *we)
|
||||||
//emit setFrequency(f);
|
//emit setFrequency(f);
|
||||||
issueCmdUniquePriority(cmdSetFreq, f);
|
issueCmdUniquePriority(cmdSetFreq, f);
|
||||||
ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f'));
|
ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f'));
|
||||||
issueDelayedCommandUnique(cmdGetFreq);
|
//issueDelayedCommandUnique(cmdGetFreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::handlePlotScroll(QWheelEvent *we)
|
void wfmain::handlePlotScroll(QWheelEvent *we)
|
||||||
|
@ -3310,32 +3322,32 @@ void wfmain::on_goFreqBtn_clicked()
|
||||||
{
|
{
|
||||||
freqt f;
|
freqt f;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
double freq = 0;
|
double freqDbl = 0;
|
||||||
int KHz = 0;
|
int KHz = 0;
|
||||||
|
|
||||||
if(ui->freqMhzLineEdit->text().contains("."))
|
if(ui->freqMhzLineEdit->text().contains("."))
|
||||||
{
|
{
|
||||||
|
|
||||||
freq = ui->freqMhzLineEdit->text().toDouble(&ok);
|
freqDbl = ui->freqMhzLineEdit->text().toDouble(&ok);
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
f.Hz = freq*1E6;
|
f.Hz = freqDbl*1E6;
|
||||||
//emit setFrequency(f);
|
issueCmd(cmdSetFreq, f);
|
||||||
issueCmd(cmdSetFreq, f);
|
|
||||||
//issueCmdSetFreq(f);
|
|
||||||
issueDelayedCommand(cmdGetFreq);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
KHz = ui->freqMhzLineEdit->text().toInt(&ok);
|
KHz = ui->freqMhzLineEdit->text().toInt(&ok);
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
f.Hz = KHz*1E3;
|
f.Hz = KHz*1E3;
|
||||||
//issueCmdSetFreq(f);
|
|
||||||
//emit setFrequency(f);
|
|
||||||
issueCmd(cmdSetFreq, f);
|
issueCmd(cmdSetFreq, f);
|
||||||
issueDelayedCommand(cmdGetFreq);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
f.MHzDouble = (float)f.Hz / 1E6;
|
||||||
|
freq = f;
|
||||||
|
setUIFreq();
|
||||||
|
}
|
||||||
|
|
||||||
ui->freqMhzLineEdit->selectAll();
|
ui->freqMhzLineEdit->selectAll();
|
||||||
freqTextSelected = true;
|
freqTextSelected = true;
|
||||||
|
@ -3615,17 +3627,19 @@ void wfmain::on_freqDial_valueChanged(int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::receiveBandStackReg(freqt freq, char mode, char filter, bool dataOn)
|
void wfmain::receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn)
|
||||||
{
|
{
|
||||||
// read the band stack and apply by sending out commands
|
// read the band stack and apply by sending out commands
|
||||||
|
|
||||||
qInfo(logSystem()) << __func__ << "BSR received into main: Freq: " << freq.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << ", data mode: " << dataOn;
|
qInfo(logSystem()) << __func__ << "BSR received into main: Freq: " << freqGo.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << ", data mode: " << dataOn;
|
||||||
//emit setFrequency(freq);
|
//emit setFrequency(freq);
|
||||||
issueCmd(cmdSetFreq, freq);
|
issueCmd(cmdSetFreq, freqGo);
|
||||||
setModeVal = (unsigned char) mode;
|
setModeVal = (unsigned char) mode;
|
||||||
setFilterVal = (unsigned char) filter;
|
setFilterVal = (unsigned char) filter;
|
||||||
|
|
||||||
issueDelayedCommand(cmdSetModeFilter);
|
issueDelayedCommand(cmdSetModeFilter);
|
||||||
|
freq = freqGo;
|
||||||
|
setUIFreq();
|
||||||
|
|
||||||
if(dataOn)
|
if(dataOn)
|
||||||
{
|
{
|
||||||
|
@ -3633,8 +3647,8 @@ void wfmain::receiveBandStackReg(freqt freq, char mode, char filter, bool dataOn
|
||||||
} else {
|
} else {
|
||||||
issueDelayedCommand(cmdSetDataModeOff);
|
issueDelayedCommand(cmdSetDataModeOff);
|
||||||
}
|
}
|
||||||
issueDelayedCommand(cmdGetFreq);
|
//issueDelayedCommand(cmdGetFreq);
|
||||||
issueDelayedCommand(cmdGetMode);
|
//issueDelayedCommand(cmdGetMode);
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
receiveMode((unsigned char) mode, (unsigned char) filter); // update UI
|
receiveMode((unsigned char) mode, (unsigned char) filter); // update UI
|
||||||
|
@ -3856,7 +3870,6 @@ void wfmain::on_fRclBtn_clicked()
|
||||||
setModeVal = temp.mode;
|
setModeVal = temp.mode;
|
||||||
setFilterVal = ui->modeFilterCombo->currentIndex()+1; // TODO, add to memory
|
setFilterVal = ui->modeFilterCombo->currentIndex()+1; // TODO, add to memory
|
||||||
issueDelayedCommand(cmdSetModeFilter);
|
issueDelayedCommand(cmdSetModeFilter);
|
||||||
issueDelayedCommand(cmdGetFreq);
|
|
||||||
issueDelayedCommand(cmdGetMode);
|
issueDelayedCommand(cmdGetMode);
|
||||||
} else {
|
} else {
|
||||||
qInfo(logSystem()) << "Could not recall preset. Valid presets are 0 through 99.";
|
qInfo(logSystem()) << "Could not recall preset. Valid presets are 0 through 99.";
|
||||||
|
|
3
wfmain.h
3
wfmain.h
|
@ -630,6 +630,8 @@ private:
|
||||||
|
|
||||||
void removeSimilarCommand(cmds cmd);
|
void removeSimilarCommand(cmds cmd);
|
||||||
|
|
||||||
|
qint64 lastFreqCmdTime_ms;
|
||||||
|
|
||||||
int pCmdNum = 0;
|
int pCmdNum = 0;
|
||||||
int delayedCmdIntervalLAN_ms = 100;
|
int delayedCmdIntervalLAN_ms = 100;
|
||||||
int delayedCmdIntervalSerial_ms = 100;
|
int delayedCmdIntervalSerial_ms = 100;
|
||||||
|
@ -637,6 +639,7 @@ private:
|
||||||
bool runPeriodicCommands;
|
bool runPeriodicCommands;
|
||||||
bool usingLAN = false;
|
bool usingLAN = false;
|
||||||
|
|
||||||
|
// Radio time sync:
|
||||||
QTimer *timeSync;
|
QTimer *timeSync;
|
||||||
bool waitingToSetTimeDate;
|
bool waitingToSetTimeDate;
|
||||||
void setRadioTimeDatePrep();
|
void setRadioTimeDatePrep();
|
||||||
|
|
Ładowanie…
Reference in New Issue