Added polling preferences and changed UI elements to radio buttons with

spin box.
half-duplex
Elliott Liggett 2022-11-26 21:43:47 -08:00
rodzic 39caf41905
commit 4f6da00206
4 zmienionych plików z 129 dodań i 34 usunięć

Wyświetl plik

@ -20,6 +20,7 @@ struct preferences {
bool forceRTSasPTT;
QString serialPortRadio;
quint32 serialPortBaud;
int polling_ms;
bool enablePTT;
bool niceTS;
bool enableLAN;

Wyświetl plik

@ -1420,6 +1420,7 @@ void wfmain::setDefPrefs()
defPrefs.forceRTSasPTT = false;
defPrefs.serialPortRadio = QString("auto");
defPrefs.serialPortBaud = 115200;
defPrefs.polling_ms = 0; // 0 = Automatic
defPrefs.enablePTT = false;
defPrefs.niceTS = true;
defPrefs.enableRigCtlD = false;
@ -1568,6 +1569,27 @@ void wfmain::loadSettings()
serverConfig.baudRate = prefs.serialPortBaud;
}
prefs.polling_ms = settings->value("polling_ms", defPrefs.polling_ms).toInt();
if(prefs.polling_ms == 0)
{
// Automatic
ui->pollingButtonGroup->blockSignals(true);
ui->autoPollBtn->setChecked(true);
ui->manualPollBtn->setChecked(false);
ui->pollingButtonGroup->blockSignals(false);
ui->pollTimeMsSpin->setEnabled(false);
} else {
// Manual
ui->pollingButtonGroup->blockSignals(true);
ui->autoPollBtn->setChecked(false);
ui->manualPollBtn->setChecked(true);
ui->pollingButtonGroup->blockSignals(false);
ui->pollTimeMsSpin->blockSignals(true);
ui->pollTimeMsSpin->setValue(prefs.polling_ms);
ui->pollTimeMsSpin->blockSignals(false);
ui->pollTimeMsSpin->setEnabled(true);
}
prefs.virtualSerialPort = settings->value("VirtualSerialPort", defPrefs.virtualSerialPort).toString();
int vspIndex = ui->vspCombo->findText(prefs.virtualSerialPort);
if (vspIndex != -1) {
@ -2131,6 +2153,7 @@ void wfmain::saveSettings()
settings->setValue("RigCIVuInt", prefs.radioCIVAddr);
settings->setValue("CIVisRadioModel", prefs.CIVisRadioModel);
settings->setValue("ForceRTSasPTT", prefs.forceRTSasPTT);
settings->setValue("polling_ms", prefs.polling_ms); // 0 = automatic
settings->setValue("SerialPortRadio", prefs.serialPortRadio);
settings->setValue("SerialPortBaud", prefs.serialPortBaud);
settings->setValue("VirtualSerialPort", prefs.virtualSerialPort);
@ -3713,7 +3736,12 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
issueDelayedCommand(cmdGetFreq);
issueDelayedCommand(cmdGetMode);
// recalculate command timing now that we know the rig better:
calculateTimingParameters();
if(prefs.polling_ms != 0)
{
changePollTiming(prefs.polling_ms, true);
} else {
calculateTimingParameters();
}
initPeriodicCommands();
// Set the second meter here as I suspect we need to be connected for it to work?
@ -5885,6 +5913,10 @@ void wfmain::calculateTimingParameters()
qInfo(logSystem()) << "Delay command interval timing: " << delayedCommand->interval() << "ms";
ui->pollTimeMsSpin->blockSignals(true);
ui->pollTimeMsSpin->setValue(delayedCommand->interval());
ui->pollTimeMsSpin->blockSignals(false);
// Normal:
delayedCmdIntervalLAN_ms = delayedCommand->interval();
delayedCmdIntervalSerial_ms = delayedCommand->interval();
@ -6166,20 +6198,6 @@ void wfmain::on_wfLengthSlider_valueChanged(int value)
prepareWf(value);
}
void wfmain::on_pollingBtn_clicked()
{
bool ok;
int timing = 0;
timing = QInputDialog::getInt(this, "wfview Radio Polling Setup", "Poll Timing Interval (ms)", delayedCommand->interval(), 1, 200, 1, &ok );
if(ok && timing)
{
delayedCommand->setInterval( timing );
qInfo(logSystem()) << "User changed radio polling interval to " << timing << "ms.";
showStatusBarText("User changed radio polling interval to " + QString("%1").arg(timing) + "ms.");
}
}
void wfmain::on_wfAntiAliasChk_clicked(bool checked)
{
colorMap->setAntialiased(checked);
@ -7836,3 +7854,46 @@ void wfmain::on_clickDragTuningEnableChk_clicked(bool checked)
}
void wfmain::on_autoPollBtn_clicked(bool checked)
{
ui->pollTimeMsSpin->setEnabled(!checked);
if(checked)
{
prefs.polling_ms = 0;
qInfo(logSystem()) << "User set radio polling interval to automatic.";
calculateTimingParameters();
}
}
void wfmain::on_manualPollBtn_clicked(bool checked)
{
ui->pollTimeMsSpin->setEnabled(checked);
if(checked)
{
prefs.polling_ms = ui->pollTimeMsSpin->value();
changePollTiming(prefs.polling_ms);
}
}
void wfmain::on_pollTimeMsSpin_valueChanged(int timing_ms)
{
if(ui->manualPollBtn->isChecked())
{
changePollTiming(timing_ms);
}
}
void wfmain::changePollTiming(int timing_ms, bool setUI)
{
delayedCommand->setInterval(timing_ms);
qInfo(logSystem()) << "User changed radio polling interval to " << timing_ms << "ms.";
showStatusBarText("User changed radio polling interval to " + QString("%1").arg(timing_ms) + "ms.");
prefs.polling_ms = timing_ms;
if(setUI)
{
ui->pollTimeMsSpin->blockSignals(true);
ui->pollTimeMsSpin->setValue(timing_ms);
ui->pollTimeMsSpin->blockSignals(false);
}
}

Wyświetl plik

@ -512,8 +512,6 @@ private slots:
void on_wfLengthSlider_valueChanged(int value);
void on_pollingBtn_clicked();
void on_wfAntiAliasChk_clicked(bool checked);
void on_wfInterpolateChk_clicked(bool checked);
@ -684,6 +682,12 @@ private slots:
void receiveClusterOutput(QString text);
void receiveSpots(QList<spotData> spots);
void on_autoPollBtn_clicked(bool checked);
void on_manualPollBtn_clicked(bool checked);
void on_pollTimeMsSpin_valueChanged(int arg1);
private:
Ui::wfmain *ui;
void closeEvent(QCloseEvent *event);
@ -972,6 +976,7 @@ private:
void insertSlowPeriodicCommand(cmds cmd, unsigned char priority);
void calculateTimingParameters();
void changePollTiming(int timing_ms, bool setUI=false);
void changeMode(mode_kind mode);
void changeMode(mode_kind mode, bool dataOn);

Wyświetl plik

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1023</width>
<width>1082</width>
<height>660</height>
</rect>
</property>
@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<widget class="QWidget" name="mainTab">
<attribute name="title">
@ -3147,18 +3147,45 @@
<widget class="QComboBox" name="meter2selectionCombo"/>
</item>
<item>
<widget class="QPushButton" name="pollingBtn">
<property name="toolTip">
<string>Set up radio polling. The radio's meter is polled every-other interval.</string>
</property>
<property name="accessibleName">
<string>Polling</string>
</property>
<property name="accessibleDescription">
<string/>
</property>
<widget class="QRadioButton" name="autoPollBtn">
<property name="text">
<string>Polling</string>
<string>AutoPolling</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">pollingButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="manualPollBtn">
<property name="text">
<string>Manual Polling Inteval:</string>
</property>
<attribute name="buttonGroup">
<string notr="true">pollingButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pollTimeMsSpin">
<property name="toolTip">
<string>Sets the polling interval, in ms.</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>250</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_50">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
@ -3350,8 +3377,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>799</width>
<height>269</height>
<width>858</width>
<height>287</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -5262,8 +5289,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1023</width>
<height>23</height>
<width>1082</width>
<height>21</height>
</rect>
</property>
</widget>
@ -5291,6 +5318,7 @@
<connections/>
<buttongroups>
<buttongroup name="underlayButtonGroup"/>
<buttongroup name="pollingButtonGroup"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>