kopia lustrzana https://gitlab.com/eliggett/wfview
Merge branch 'sequence'
commit
8a49e0267d
160
rigcommander.cpp
160
rigcommander.cpp
|
@ -2020,6 +2020,143 @@ void rigCommander::setRefAdjustFine(unsigned char level)
|
|||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::setTime(timekind t)
|
||||
{
|
||||
QByteArray payload;
|
||||
|
||||
switch(rigCaps.model)
|
||||
{
|
||||
case model705:
|
||||
payload.setRawData("\x1A\x05\x01\x66", 4);
|
||||
break;
|
||||
case model7300:
|
||||
payload.setRawData("\x1A\x05\x00\x95", 4);
|
||||
break;
|
||||
case model7610:
|
||||
payload.setRawData("\x1A\x05\x01\x59", 4);
|
||||
break;
|
||||
case model7700:
|
||||
payload.setRawData("\x1A\x05\x00\x59", 4);
|
||||
break;
|
||||
case model7850:
|
||||
payload.setRawData("\x1A\x05\x00\x96", 4);
|
||||
break;
|
||||
case model9700:
|
||||
payload.setRawData("\x1A\x05\x01\x80", 4);
|
||||
break;
|
||||
case modelR8600:
|
||||
payload.setRawData("\x1A\x05\x01\x32", 4);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
|
||||
}
|
||||
payload.append(convertNumberToHex(t.hours));
|
||||
payload.append(convertNumberToHex(t.minutes));
|
||||
//qDebug(logRig()) << "Setting time to this: ";
|
||||
//printHex(payload);
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::setDate(datekind d)
|
||||
{
|
||||
QByteArray payload;
|
||||
|
||||
switch(rigCaps.model)
|
||||
{
|
||||
case model705:
|
||||
payload.setRawData("\x1A\x05\x01\x65", 4);
|
||||
break;
|
||||
case model7300:
|
||||
payload.setRawData("\x1A\x05\x00\x94", 4);
|
||||
break;
|
||||
case model7610:
|
||||
payload.setRawData("\x1A\x05\x01\x58", 4);
|
||||
break;
|
||||
case model7700:
|
||||
payload.setRawData("\x1A\x05\x00\x58", 4);
|
||||
break;
|
||||
case model7850:
|
||||
payload.setRawData("\x1A\x05\x00\x95", 4);
|
||||
break;
|
||||
case model9700:
|
||||
payload.setRawData("\x1A\x05\x01\x79", 4);
|
||||
break;
|
||||
case modelR8600:
|
||||
payload.setRawData("\x1A\x05\x01\x31", 4);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
|
||||
}
|
||||
// YYYYMMDD
|
||||
payload.append(convertNumberToHex(d.year/100)); // 20
|
||||
payload.append(convertNumberToHex(d.year - 100*(d.year/100))); // 21
|
||||
payload.append(convertNumberToHex(d.month));
|
||||
payload.append(convertNumberToHex(d.day));
|
||||
//qDebug(logRig()) << "Setting date to this: ";
|
||||
//printHex(payload);
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::setUTCOffset(timekind t)
|
||||
{
|
||||
QByteArray payload;
|
||||
|
||||
switch(rigCaps.model)
|
||||
{
|
||||
case model705:
|
||||
payload.setRawData("\x1A\x05\x01\x70", 4);
|
||||
break;
|
||||
case model7300:
|
||||
payload.setRawData("\x1A\x05\x00\x96", 4);
|
||||
break;
|
||||
case model7610:
|
||||
payload.setRawData("\x1A\x05\x01\x62", 4);
|
||||
break;
|
||||
case model7700:
|
||||
payload.setRawData("\x1A\x05\x00\x61", 4);
|
||||
break;
|
||||
case model7850:
|
||||
// Clock 1:
|
||||
payload.setRawData("\x1A\x05\x00\x99", 4);
|
||||
break;
|
||||
case model9700:
|
||||
payload.setRawData("\x1A\x05\x01\x84", 4);
|
||||
break;
|
||||
case modelR8600:
|
||||
payload.setRawData("\x1A\x05\x01\x35", 4);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
|
||||
}
|
||||
payload.append(convertNumberToHex(t.hours));
|
||||
payload.append(convertNumberToHex(t.minutes));
|
||||
payload.append((unsigned char)t.isMinus);
|
||||
//qDebug(logRig()) << "Setting UTC Offset to this: ";
|
||||
//printHex(payload);
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
unsigned char rigCommander::convertNumberToHex(unsigned char num)
|
||||
{
|
||||
// Two digit only
|
||||
if(num > 99)
|
||||
{
|
||||
qInfo(logRig()) << "Invalid numeric conversion from num " << num << " to hex.";
|
||||
return 0xFA;
|
||||
}
|
||||
unsigned char result = 0;
|
||||
result = (num/10) << 4;
|
||||
result |= (num - 10*(num/10));
|
||||
qDebug(logRig()) << "Converting number: " << num << " to hex: " + QString("0x%1").arg(result, 2, 16, QChar('0'));
|
||||
return result;
|
||||
}
|
||||
|
||||
void rigCommander::sendLevelCmd(unsigned char levAddr, unsigned char level)
|
||||
{
|
||||
QByteArray payload("\x14");
|
||||
|
@ -2800,6 +2937,29 @@ void rigCommander::determineRigCaps()
|
|||
rigCaps.bsr[band2m] = 0x01;
|
||||
rigCaps.modes = commonModes;
|
||||
break;
|
||||
case model7600:
|
||||
rigCaps.modelName = QString("IC-7600");
|
||||
rigCaps.hasSpectrum = false;
|
||||
rigCaps.inputs.append(inputACC);
|
||||
rigCaps.inputs.append(inputUSB);
|
||||
rigCaps.hasLan = false;
|
||||
rigCaps.hasEthernet = false;
|
||||
rigCaps.hasWiFi = false;
|
||||
rigCaps.hasFDcomms = false;
|
||||
rigCaps.hasATU = true;
|
||||
rigCaps.hasCTCSS = false;
|
||||
rigCaps.hasDTCS = false;
|
||||
rigCaps.attenuators.insert(rigCaps.attenuators.end(), {0x00, 0x06, 0x12, 0x18});
|
||||
rigCaps.preamps.push_back('\x01');
|
||||
rigCaps.preamps.push_back('\x02');
|
||||
rigCaps.antennas = {0x00, 0x01};
|
||||
rigCaps.bands = standardHF;
|
||||
rigCaps.bands.push_back(bandGen);
|
||||
rigCaps.bsr[bandGen] = 0x11;
|
||||
rigCaps.modes = commonModes;
|
||||
rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modePSK, 0x12, "PSK"),
|
||||
createMode(modePSK_R, 0x13, "PSK-R")});
|
||||
break;
|
||||
case model7610:
|
||||
rigCaps.modelName = QString("IC-7610");
|
||||
rigCaps.hasSpectrum = true;
|
||||
|
|
|
@ -41,6 +41,18 @@ struct freqt {
|
|||
double MHzDouble;
|
||||
};
|
||||
|
||||
struct datekind {
|
||||
uint16_t year;
|
||||
unsigned char month;
|
||||
unsigned char day;
|
||||
};
|
||||
|
||||
struct timekind {
|
||||
unsigned char hours;
|
||||
unsigned char minutes;
|
||||
bool isMinus;
|
||||
};
|
||||
|
||||
struct rigStateStruct {
|
||||
freqt vfoAFreq;
|
||||
freqt vfoBFreq;
|
||||
|
@ -226,6 +238,12 @@ public slots:
|
|||
void setRefAdjustCourse(unsigned char level);
|
||||
void setRefAdjustFine(unsigned char level);
|
||||
|
||||
// Time and Date:
|
||||
void setTime(timekind t);
|
||||
void setDate(datekind d);
|
||||
void setUTCOffset(timekind t);
|
||||
|
||||
|
||||
// Satellite:
|
||||
void setSatelliteMode(bool enabled);
|
||||
void getSatelliteMode();
|
||||
|
@ -350,6 +368,7 @@ private:
|
|||
QByteArray makeFreqPayload(freqt freq);
|
||||
QByteArray encodeTone(quint16 tone, bool tinv, bool rinv);
|
||||
QByteArray encodeTone(quint16 tone);
|
||||
unsigned char convertNumberToHex(unsigned char num);
|
||||
quint16 decodeTone(QByteArray eTone);
|
||||
quint16 decodeTone(QByteArray eTone, bool &tinv, bool &rinv);
|
||||
|
||||
|
|
184
wfmain.cpp
184
wfmain.cpp
|
@ -44,6 +44,9 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s
|
|||
qRegisterMetaType<mode_info>();
|
||||
qRegisterMetaType<audioPacket>();
|
||||
qRegisterMetaType <audioSetup>();
|
||||
qRegisterMetaType <timekind>();
|
||||
qRegisterMetaType <datekind>();
|
||||
|
||||
|
||||
haveRigCaps = false;
|
||||
|
||||
|
@ -358,6 +361,11 @@ void wfmain::rigConnections()
|
|||
connect(cal, SIGNAL(setRefAdjustCourse(unsigned char)), rig, SLOT(setRefAdjustCourse(unsigned char)));
|
||||
connect(cal, SIGNAL(setRefAdjustFine(unsigned char)), rig, SLOT(setRefAdjustFine(unsigned char)));
|
||||
|
||||
// Date and Time:
|
||||
connect(this, SIGNAL(setTime(timekind)), rig, SLOT(setTime(timekind)));
|
||||
connect(this, SIGNAL(setDate(datekind)), rig, SLOT(setDate(datekind)));
|
||||
connect(this, SIGNAL(setUTCOffset(timekind)), rig, SLOT(setUTCOffset(timekind)));
|
||||
|
||||
}
|
||||
|
||||
//void wfmain::removeRigConnections()
|
||||
|
@ -856,6 +864,11 @@ void wfmain::setInitialTiming()
|
|||
pttTimer->setInterval(180*1000); // 3 minute max transmit time in ms
|
||||
pttTimer->setSingleShot(true);
|
||||
connect(pttTimer, SIGNAL(timeout()), this, SLOT(handlePttLimit()));
|
||||
|
||||
timeSync = new QTimer(this);
|
||||
connect(timeSync, SIGNAL(timeout()), this, SLOT(setRadioTimeDateSend()));
|
||||
waitingToSetTimeDate = false;
|
||||
lastFreqCmdTime_ms = QDateTime::currentMSecsSinceEpoch() - 5000; // 5 seconds ago
|
||||
}
|
||||
|
||||
void wfmain::setServerToPrefs()
|
||||
|
@ -1821,7 +1834,7 @@ void wfmain::shortcutF10()
|
|||
|
||||
void wfmain::shortcutF12()
|
||||
{
|
||||
// Speak current frequency and mode via IC-7300
|
||||
// Speak current frequency and mode from the radio
|
||||
showStatusBarText("Sending speech command to radio.");
|
||||
emit sayAll();
|
||||
}
|
||||
|
@ -1837,8 +1850,8 @@ void wfmain::shortcutControlT()
|
|||
void wfmain::shortcutControlR()
|
||||
{
|
||||
// Receive
|
||||
emit setPTT(false);
|
||||
issueDelayedCommand(cmdGetPTT);
|
||||
issueCmdUniquePriority(cmdSetPTT, false);
|
||||
pttTimer->stop();
|
||||
}
|
||||
|
||||
void wfmain::shortcutControlI()
|
||||
|
@ -2278,6 +2291,7 @@ void wfmain::doCmd(commandtype cmddata)
|
|||
{
|
||||
case cmdSetFreq:
|
||||
{
|
||||
lastFreqCmdTime_ms = QDateTime::currentMSecsSinceEpoch();
|
||||
freqt f = (*std::static_pointer_cast<freqt>(data));
|
||||
emit setFrequency(f);
|
||||
break;
|
||||
|
@ -2343,6 +2357,24 @@ void wfmain::doCmd(commandtype cmddata)
|
|||
emit setATU(atuOn);
|
||||
break;
|
||||
}
|
||||
case cmdSetUTCOffset:
|
||||
{
|
||||
timekind u = (*std::static_pointer_cast<timekind>(data));
|
||||
emit setUTCOffset(u);
|
||||
break;
|
||||
}
|
||||
case cmdSetTime:
|
||||
{
|
||||
timekind t = (*std::static_pointer_cast<timekind>(data));
|
||||
emit setTime(t);
|
||||
break;
|
||||
}
|
||||
case cmdSetDate:
|
||||
{
|
||||
datekind d = (*std::static_pointer_cast<datekind>(data));
|
||||
emit setDate(d);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
doCmd(cmd);
|
||||
break;
|
||||
|
@ -2634,10 +2666,27 @@ void wfmain::issueCmd(cmds cmd, freqt f)
|
|||
commandtype cmddata;
|
||||
cmddata.cmd = cmd;
|
||||
cmddata.data = std::shared_ptr<freqt>(new freqt(f));
|
||||
//*static_cast<freqt*>(cmddata.data.get()) = f;
|
||||
delayedCmdQue.push_back(cmddata);
|
||||
}
|
||||
|
||||
void wfmain::issueCmd(cmds cmd, timekind t)
|
||||
{
|
||||
qDebug(logSystem()) << "Issuing timekind command with data: " << t.hours << " hours, " << t.minutes << " minutes, " << t.isMinus << " isMinus";
|
||||
commandtype cmddata;
|
||||
cmddata.cmd = cmd;
|
||||
cmddata.data = std::shared_ptr<timekind>(new timekind(t));
|
||||
delayedCmdQue.push_front(cmddata);
|
||||
}
|
||||
|
||||
void wfmain::issueCmd(cmds cmd, datekind d)
|
||||
{
|
||||
qDebug(logSystem()) << "Issuing datekind command with data: " << d.day << " day, " << d.month << " month, " << d.year << " year.";
|
||||
commandtype cmddata;
|
||||
cmddata.cmd = cmd;
|
||||
cmddata.data = std::shared_ptr<datekind>(new datekind(d));
|
||||
delayedCmdQue.push_front(cmddata);
|
||||
}
|
||||
|
||||
void wfmain::issueCmd(cmds cmd, int i)
|
||||
{
|
||||
commandtype cmddata;
|
||||
|
@ -2933,10 +2982,15 @@ void wfmain::insertSlowPeriodicCommand(cmds cmd, unsigned char priority)
|
|||
void wfmain::receiveFreq(freqt freqStruct)
|
||||
{
|
||||
|
||||
//qInfo(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz;
|
||||
ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f'));
|
||||
freq = freqStruct;
|
||||
//showStatusBarText(QString("Frequency: %1").arg(freqMhz));
|
||||
qint64 tnow_ms = QDateTime::currentMSecsSinceEpoch();
|
||||
if(tnow_ms - lastFreqCmdTime_ms > delayedCommand->interval() * 2)
|
||||
{
|
||||
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)
|
||||
|
@ -3080,20 +3134,23 @@ void wfmain::receiveSpectrumMode(spectrumMode spectMode)
|
|||
void wfmain::handlePlotDoubleClick(QMouseEvent *me)
|
||||
{
|
||||
double x;
|
||||
freqt freq;
|
||||
freqt freqGo;
|
||||
//double y;
|
||||
//double px;
|
||||
if(!freqLock)
|
||||
{
|
||||
//y = plot->yAxis->pixelToCoord(me->pos().y());
|
||||
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);
|
||||
issueCmd(cmdSetFreq, freq);
|
||||
issueDelayedCommand(cmdGetFreq);
|
||||
issueCmd(cmdSetFreq, freqGo);
|
||||
freq = freqGo;
|
||||
setUIFreq();
|
||||
//issueDelayedCommand(cmdGetFreq);
|
||||
showStatusBarText(QString("Going to %1 MHz").arg(x));
|
||||
}
|
||||
}
|
||||
|
@ -3101,7 +3158,7 @@ void wfmain::handlePlotDoubleClick(QMouseEvent *me)
|
|||
void wfmain::handleWFDoubleClick(QMouseEvent *me)
|
||||
{
|
||||
double x;
|
||||
freqt freq;
|
||||
freqt freqGo;
|
||||
//double y;
|
||||
//x = wf->xAxis->pixelToCoord(me->pos().x());
|
||||
//y = wf->yAxis->pixelToCoord(me->pos().y());
|
||||
|
@ -3109,13 +3166,15 @@ void wfmain::handleWFDoubleClick(QMouseEvent *me)
|
|||
if(!freqLock)
|
||||
{
|
||||
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);
|
||||
issueCmd(cmdSetFreq, freq);
|
||||
issueDelayedCommand(cmdGetFreq);
|
||||
issueCmd(cmdSetFreq, freqGo);
|
||||
freq = freqGo;
|
||||
setUIFreq();
|
||||
showStatusBarText(QString("Going to %1 MHz").arg(x));
|
||||
}
|
||||
}
|
||||
|
@ -3170,7 +3229,7 @@ void wfmain::handleWFScroll(QWheelEvent *we)
|
|||
//emit setFrequency(f);
|
||||
issueCmdUniquePriority(cmdSetFreq, f);
|
||||
ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f'));
|
||||
issueDelayedCommandUnique(cmdGetFreq);
|
||||
//issueDelayedCommandUnique(cmdGetFreq);
|
||||
}
|
||||
|
||||
void wfmain::handlePlotScroll(QWheelEvent *we)
|
||||
|
@ -3289,32 +3348,32 @@ void wfmain::on_goFreqBtn_clicked()
|
|||
{
|
||||
freqt f;
|
||||
bool ok = false;
|
||||
double freq = 0;
|
||||
double freqDbl = 0;
|
||||
int KHz = 0;
|
||||
|
||||
if(ui->freqMhzLineEdit->text().contains("."))
|
||||
{
|
||||
|
||||
freq = ui->freqMhzLineEdit->text().toDouble(&ok);
|
||||
freqDbl = ui->freqMhzLineEdit->text().toDouble(&ok);
|
||||
if(ok)
|
||||
{
|
||||
f.Hz = freq*1E6;
|
||||
//emit setFrequency(f);
|
||||
issueCmd(cmdSetFreq, f);
|
||||
//issueCmdSetFreq(f);
|
||||
issueDelayedCommand(cmdGetFreq);
|
||||
f.Hz = freqDbl*1E6;
|
||||
issueCmd(cmdSetFreq, f);
|
||||
}
|
||||
} else {
|
||||
KHz = ui->freqMhzLineEdit->text().toInt(&ok);
|
||||
if(ok)
|
||||
{
|
||||
f.Hz = KHz*1E3;
|
||||
//issueCmdSetFreq(f);
|
||||
//emit setFrequency(f);
|
||||
issueCmd(cmdSetFreq, f);
|
||||
issueDelayedCommand(cmdGetFreq);
|
||||
}
|
||||
}
|
||||
if(ok)
|
||||
{
|
||||
f.MHzDouble = (float)f.Hz / 1E6;
|
||||
freq = f;
|
||||
setUIFreq();
|
||||
}
|
||||
|
||||
ui->freqMhzLineEdit->selectAll();
|
||||
freqTextSelected = true;
|
||||
|
@ -3594,17 +3653,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
|
||||
|
||||
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);
|
||||
issueCmd(cmdSetFreq, freq);
|
||||
issueCmd(cmdSetFreq, freqGo);
|
||||
setModeVal = (unsigned char) mode;
|
||||
setFilterVal = (unsigned char) filter;
|
||||
|
||||
issueDelayedCommand(cmdSetModeFilter);
|
||||
freq = freqGo;
|
||||
setUIFreq();
|
||||
|
||||
if(dataOn)
|
||||
{
|
||||
|
@ -3612,8 +3673,8 @@ void wfmain::receiveBandStackReg(freqt freq, char mode, char filter, bool dataOn
|
|||
} else {
|
||||
issueDelayedCommand(cmdSetDataModeOff);
|
||||
}
|
||||
issueDelayedCommand(cmdGetFreq);
|
||||
issueDelayedCommand(cmdGetMode);
|
||||
//issueDelayedCommand(cmdGetFreq);
|
||||
//issueDelayedCommand(cmdGetMode);
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
||||
receiveMode((unsigned char) mode, (unsigned char) filter); // update UI
|
||||
|
@ -3835,7 +3896,6 @@ void wfmain::on_fRclBtn_clicked()
|
|||
setModeVal = temp.mode;
|
||||
setFilterVal = ui->modeFilterCombo->currentIndex()+1; // TODO, add to memory
|
||||
issueDelayedCommand(cmdSetModeFilter);
|
||||
issueDelayedCommand(cmdGetFreq);
|
||||
issueDelayedCommand(cmdGetMode);
|
||||
} else {
|
||||
qInfo(logSystem()) << "Could not recall preset. Valid presets are 0 through 99.";
|
||||
|
@ -4216,6 +4276,57 @@ void wfmain::on_satOpsBtn_clicked()
|
|||
sat->show();
|
||||
}
|
||||
|
||||
void wfmain::setRadioTimeDatePrep()
|
||||
{
|
||||
if(!waitingToSetTimeDate)
|
||||
{
|
||||
// 1: Find the current time and date
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
now.setTime(QTime::currentTime());
|
||||
|
||||
int second = now.time().second();
|
||||
|
||||
// 2: Find how many mseconds until next minute
|
||||
int msecdelay = QTime::currentTime().msecsTo( QTime::currentTime().addSecs(60-second) );
|
||||
|
||||
// 3: Compute time and date at one minute later
|
||||
QDateTime setpoint = now.addMSecs(msecdelay); // at HMS or posibly HMS + some ms. Never under though.
|
||||
|
||||
// 4: Prepare data structs for the time at one minute later
|
||||
timesetpoint.hours = (unsigned char)setpoint.time().hour();
|
||||
timesetpoint.minutes = (unsigned char)setpoint.time().minute();
|
||||
datesetpoint.day = (unsigned char)setpoint.date().day();
|
||||
datesetpoint.month = (unsigned char)setpoint.date().month();
|
||||
datesetpoint.year = (uint16_t)setpoint.date().year();
|
||||
unsigned int utcOffsetSeconds = (unsigned int)abs(setpoint.offsetFromUtc());
|
||||
bool isMinus = setpoint.offsetFromUtc() < 0;
|
||||
utcsetting.hours = utcOffsetSeconds / 60 / 60;
|
||||
utcsetting.minutes = (utcOffsetSeconds - (utcsetting.hours*60*60) ) / 60;
|
||||
utcsetting.isMinus = isMinus;
|
||||
|
||||
timeSync->setInterval(msecdelay);
|
||||
timeSync->setSingleShot(true);
|
||||
|
||||
// 5: start one-shot timer for the delta computed in #2.
|
||||
timeSync->start();
|
||||
waitingToSetTimeDate = true;
|
||||
showStatusBarText(QString("Setting time, date, and UTC offset for radio in %1 seconds.").arg(msecdelay/1000));
|
||||
}
|
||||
}
|
||||
|
||||
void wfmain::setRadioTimeDateSend()
|
||||
{
|
||||
// Issue priority commands for UTC offset, date, and time
|
||||
// UTC offset must come first, otherwise the radio may "help" and correct for any changes.
|
||||
|
||||
showStatusBarText(QString("Setting time, date, and UTC offset for radio now."));
|
||||
|
||||
issueCmd(cmdSetTime, timesetpoint);
|
||||
issueCmd(cmdSetDate, datesetpoint);
|
||||
issueCmd(cmdSetUTCOffset, utcsetting);
|
||||
waitingToSetTimeDate = false;
|
||||
}
|
||||
|
||||
void wfmain::changeSliderQuietly(QSlider *slider, int value)
|
||||
{
|
||||
slider->blockSignals(true);
|
||||
|
@ -4972,6 +5083,7 @@ void wfmain::on_pollingBtn_clicked()
|
|||
void wfmain::on_debugBtn_clicked()
|
||||
{
|
||||
qInfo(logSystem()) << "Debug button pressed.";
|
||||
trxadj->show();
|
||||
//trxadj->show();
|
||||
setRadioTimeDatePrep();
|
||||
}
|
||||
|
||||
|
|
25
wfmain.h
25
wfmain.h
|
@ -125,6 +125,11 @@ signals:
|
|||
void setATU(bool atuEnabled);
|
||||
void getATUStatus();
|
||||
|
||||
// Time and date:
|
||||
void setTime(timekind t);
|
||||
void setDate(datekind d);
|
||||
void setUTCOffset(timekind t);
|
||||
|
||||
void getRigID(); // this is the model of the rig
|
||||
void getRigCIV(); // get the rig's CIV addr
|
||||
void spectOutputEnable();
|
||||
|
@ -245,6 +250,9 @@ private slots:
|
|||
void serverConfigRequested(SERVERCONFIG conf, bool store);
|
||||
void receiveBaudRate(quint32 baudrate);
|
||||
|
||||
void setRadioTimeDateSend();
|
||||
|
||||
|
||||
// void on_getFreqBtn_clicked();
|
||||
|
||||
// void on_getModeBtn_clicked();
|
||||
|
@ -591,7 +599,8 @@ private:
|
|||
cmdGetTxPower, cmdSetTxPower, cmdGetMicGain, cmdSetMicGain, cmdSetModLevel, cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput,
|
||||
cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdQueNormalSpeed,
|
||||
cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetPowerMeter, cmdGetALCMeter, cmdGetCompMeter, cmdGetTxRxMeter,
|
||||
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna};
|
||||
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna,
|
||||
cmdSetTime, cmdSetDate, cmdSetUTCOffset};
|
||||
|
||||
struct commandtype {
|
||||
cmds cmd;
|
||||
|
@ -606,6 +615,8 @@ private:
|
|||
|
||||
void issueCmd(cmds cmd, freqt f);
|
||||
void issueCmd(cmds cmd, mode_info m);
|
||||
void issueCmd(cmds cmd, timekind t);
|
||||
void issueCmd(cmds cmd, datekind d);
|
||||
void issueCmd(cmds cmd, int i);
|
||||
void issueCmd(cmds cmd, unsigned char c);
|
||||
void issueCmd(cmds cmd, char c);
|
||||
|
@ -619,6 +630,8 @@ private:
|
|||
|
||||
void removeSimilarCommand(cmds cmd);
|
||||
|
||||
qint64 lastFreqCmdTime_ms;
|
||||
|
||||
int pCmdNum = 0;
|
||||
int delayedCmdIntervalLAN_ms = 100;
|
||||
int delayedCmdIntervalSerial_ms = 100;
|
||||
|
@ -626,6 +639,14 @@ private:
|
|||
bool runPeriodicCommands;
|
||||
bool usingLAN = false;
|
||||
|
||||
// Radio time sync:
|
||||
QTimer *timeSync;
|
||||
bool waitingToSetTimeDate;
|
||||
void setRadioTimeDatePrep();
|
||||
timekind timesetpoint;
|
||||
timekind utcsetting;
|
||||
datekind datesetpoint;
|
||||
|
||||
freqMemory mem;
|
||||
struct colors {
|
||||
QColor Dark_PlotBackground;
|
||||
|
@ -786,6 +807,8 @@ Q_DECLARE_METATYPE(struct udpPreferences)
|
|||
Q_DECLARE_METATYPE(struct rigStateStruct)
|
||||
Q_DECLARE_METATYPE(struct audioPacket)
|
||||
Q_DECLARE_METATYPE(struct audioSetup)
|
||||
Q_DECLARE_METATYPE(struct timekind)
|
||||
Q_DECLARE_METATYPE(struct datekind)
|
||||
Q_DECLARE_METATYPE(enum rigInput)
|
||||
Q_DECLARE_METATYPE(enum meterKind)
|
||||
Q_DECLARE_METATYPE(enum spectrumMode)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mainTab">
|
||||
<attribute name="title">
|
||||
|
@ -2678,7 +2678,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="text">
|
||||
<string>Please note: Changing CI-V Address, Serial Device, and Baud rate requires pressing "Save Settings", closing wfview, and re-opening. </string>
|
||||
<string>Please note: Changing the built-in network server requires pressing "Save Settings", closing wfview, and re-opening. </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Ładowanie…
Reference in New Issue