Lots of fixes for PBT and command handling - experimental

half-duplex
Phil Taylor 2023-01-27 01:41:35 +00:00
rodzic 49501273d0
commit 5128ea0e69
4 zmienionych plików z 257 dodań i 192 usunięć

Wyświetl plik

@ -35,6 +35,7 @@ struct udpPreferences {
QString password;
QString clientName;
quint8 waterfallFormat;
bool halfDuplex;
};
struct networkAudioLevels {

Wyświetl plik

@ -2040,6 +2040,8 @@ void wfmain::loadSettings()
udpPrefs.clientName = settings->value("ClientName", udpDefPrefs.clientName).toString();
udpPrefs.halfDuplex = settings->value("HalfDuplex", udpDefPrefs.halfDuplex).toBool();
settings->endGroup();
settings->beginGroup("Server");
@ -2700,6 +2702,7 @@ void wfmain::saveSettings()
settings->setValue("ResampleQuality", rxSetup.resampleQuality);
settings->setValue("ClientName", udpPrefs.clientName);
settings->setValue("WaterfallFormat", prefs.waterfallFormat);
settings->setValue("HalfDuplex", udpPrefs.halfDuplex);
settings->endGroup();
@ -4055,9 +4058,15 @@ void wfmain::issueDelayedCommandUnique(cmds cmd)
cmddata.cmd = cmd;
cmddata.data = NULL;
delayedCmdQue.push_front(cmddata);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
// The following is both expensive and not that great,
// since it does not check if the arguments are the same.
bool found = false;
// since it does not check if the arguments are the same.
/* bool found = false;
for(unsigned int i=0; i < delayedCmdQue.size(); i++)
{
if(delayedCmdQue.at(i).cmd == cmd)
@ -4076,7 +4085,9 @@ void wfmain::issueDelayedCommandUnique(cmds cmd)
// {
// delayedCmdQue.push_front(cmddata);
// }
*/
// delayedCmdQue.push_front(cmddata);
}
void wfmain::issueCmd(cmds cmd, mode_info m)
@ -4175,7 +4186,9 @@ void wfmain::issueCmdUniquePriority(cmds cmd, bool b)
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<bool>(new bool(b));
delayedCmdQue.push_front(cmddata);
removeSimilarCommand(cmd);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
//removeSimilarCommand(cmd);
}
void wfmain::issueCmdUniquePriority(cmds cmd, unsigned char c)
@ -4184,7 +4197,9 @@ void wfmain::issueCmdUniquePriority(cmds cmd, unsigned char c)
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<unsigned char>(new unsigned char(c));
delayedCmdQue.push_front(cmddata);
removeSimilarCommand(cmd);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
//removeSimilarCommand(cmd);
}
void wfmain::issueCmdUniquePriority(cmds cmd, char c)
@ -4193,7 +4208,8 @@ void wfmain::issueCmdUniquePriority(cmds cmd, char c)
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<char>(new char(c));
delayedCmdQue.push_front(cmddata);
removeSimilarCommand(cmd);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
//removeSimilarCommand(cmd);
}
void wfmain::issueCmdUniquePriority(cmds cmd, freqt f)
@ -4202,7 +4218,8 @@ void wfmain::issueCmdUniquePriority(cmds cmd, freqt f)
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<freqt>(new freqt(f));
delayedCmdQue.push_front(cmddata);
removeSimilarCommand(cmd);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
//removeSimilarCommand(cmd);
}
void wfmain::issueCmdUniquePriority(cmds cmd, quint16 c)
@ -4211,7 +4228,8 @@ void wfmain::issueCmdUniquePriority(cmds cmd, quint16 c)
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<quint16>(new quint16(c));
delayedCmdQue.push_front(cmddata);
removeSimilarCommand(cmd);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
//removeSimilarCommand(cmd);
}
void wfmain::issueCmdUniquePriority(cmds cmd, qint16 c)
@ -4220,7 +4238,8 @@ void wfmain::issueCmdUniquePriority(cmds cmd, qint16 c)
cmddata.cmd = cmd;
cmddata.data = std::shared_ptr<qint16>(new qint16(c));
delayedCmdQue.push_front(cmddata);
removeSimilarCommand(cmd);
delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }), delayedCmdQue.end());
//removeSimilarCommand(cmd);
}
void wfmain::removeSimilarCommand(cmds cmd)
@ -4507,9 +4526,13 @@ void wfmain::initPeriodicCommands()
rapidPollCmdQueue.clear();
if (rigCaps.hasSpectrum) {
// Get passband
insertPeriodicRapidCmd(cmdGetPassband);
insertPeriodicRapidCmd(cmdGetTPBFInner);
insertPeriodicRapidCmd(cmdGetTPBFOuter);
//insertPeriodicRapidCmd(cmdGetPassband);
//insertPeriodicRapidCmd(cmdGetTPBFInner);
//insertPeriodicRapidCmd(cmdGetTPBFOuter);
insertSlowPeriodicCommand(cmdGetPassband, 128);
insertSlowPeriodicCommand(cmdGetTPBFInner, 128);
insertSlowPeriodicCommand(cmdGetTPBFOuter, 128);
}
rapidPollCmdQueueEnabled = true;
}
@ -5110,31 +5133,36 @@ void wfmain::handlePlotMouseMove(QMouseEvent* me)
}
else if (passbandAction == passbandResizing)
{
// We are currently resizing the passband.
double pb = 0.0;
double origin = 0.0;
switch (currentModeInfo.mk)
{
case modeCW:
case modeCW_R:
origin = 0.0;
break;
case modeLSB:
origin = -passbandCenterFrequency;
break;
default:
origin = passbandCenterFrequency;
break;
}
static double lastFreq = movedFrequency;
if (lastFreq - movedFrequency > 0.000049 || movedFrequency - lastFreq > 0.000049) {
if (plot->xAxis->pixelToCoord(cursor) >= freq.MHzDouble + origin) {
pb = plot->xAxis->pixelToCoord(cursor) - passbandIndicator->topLeft->coords().x();
}
else {
pb = passbandIndicator->bottomRight->coords().x() - plot->xAxis->pixelToCoord(cursor);
}
// We are currently resizing the passband.
double pb = 0.0;
double origin = 0.0;
switch (currentModeInfo.mk)
{
case modeCW:
case modeCW_R:
origin = 0.0;
break;
case modeLSB:
origin = -passbandCenterFrequency;
break;
default:
origin = passbandCenterFrequency;
break;
}
issueCmdUniquePriority(cmdSetPassband, (quint16)(pb * 1000000));
if (plot->xAxis->pixelToCoord(cursor) >= freq.MHzDouble + origin) {
pb = plot->xAxis->pixelToCoord(cursor) - passbandIndicator->topLeft->coords().x();
}
else {
pb = passbandIndicator->bottomRight->coords().x() - plot->xAxis->pixelToCoord(cursor);
}
issueCmdUniquePriority(cmdSetPassband, (quint16)(pb * 1000000));
issueDelayedCommandUnique(cmdGetPassband);
lastFreq = movedFrequency;
}
}
else if (passbandAction == pbtMoving) {
@ -5154,25 +5182,36 @@ void wfmain::handlePlotMouseMove(QMouseEvent* me)
qDebug() << QString("Moving passband by %1 Hz (Inner %2) (Outer %3) Mode:%4").arg((qint16)(movedFrequency * 1000000))
.arg(newInFreq).arg(newOutFreq).arg(currentModeInfo.mk);
issueCmd(cmdSetTPBFInner, (unsigned char)newInFreq);
issueCmd(cmdSetTPBFOuter, (unsigned char)newOutFreq);
issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newInFreq);
issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newOutFreq);
issueDelayedCommandUnique(cmdGetTPBFInner);
issueDelayedCommandUnique(cmdGetTPBFOuter);
}
lastFreq = movedFrequency;
}
}
else if (passbandAction == pbtInnerMove) {
double pbFreq = ((double)(TPBFInner + movedFrequency) / passbandWidth) * 127.0;
qint16 newFreq = pbFreq + 128;
if (newFreq >= 0 && newFreq <= 255) {
issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newFreq);
static double lastFreq = movedFrequency;
if (lastFreq - movedFrequency > 0.000049 || movedFrequency - lastFreq > 0.000049) {
double pbFreq = ((double)(TPBFInner + movedFrequency) / passbandWidth) * 127.0;
qint16 newFreq = pbFreq + 128;
if (newFreq >= 0 && newFreq <= 255) {
issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newFreq);
issueDelayedCommandUnique(cmdGetTPBFInner);
}
lastFreq = movedFrequency;
}
}
else if (passbandAction == pbtOuterMove) {
double pbFreq = ((double)(TPBFOuter + movedFrequency) / passbandWidth) * 127.0;
qint16 newFreq = pbFreq + 128;
if (newFreq >= 0 && newFreq <= 255) {
issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newFreq);
static double lastFreq = movedFrequency;
if (lastFreq - movedFrequency > 0.000049 || movedFrequency - lastFreq > 0.000049) {
double pbFreq = ((double)(TPBFOuter + movedFrequency) / passbandWidth) * 127.0;
qint16 newFreq = pbFreq + 128;
if (newFreq >= 0 && newFreq <= 255) {
issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newFreq);
issueDelayedCommandUnique(cmdGetTPBFOuter);
}
lastFreq = movedFrequency;
}
}
else if (passbandAction == passbandStatic && me->buttons() == Qt::LeftButton && textItem == nullptr && prefs.clickDragTuningEnable)
@ -5266,106 +5305,101 @@ void wfmain::receiveMode(unsigned char mode, unsigned char filter)
if(mode < 0x23)
{
for(int i=0; i < ui->modeSelectCombo->count(); i++)
// Update mode information if mode/filter has changed
if (currentModeInfo.mk != (mode_kind)mode || currentModeInfo.filter != filter)
{
if(ui->modeSelectCombo->itemData(i).toInt() == mode)
{
ui->modeSelectCombo->blockSignals(true);
ui->modeSelectCombo->setCurrentIndex(i);
ui->modeSelectCombo->blockSignals(false);
found = true;
removePeriodicRapidCmd(cmdGetCwPitch);
quint16 maxPassbandHz = 0;
switch ((mode_kind)mode) {
case modeFM:
if (filter == 1)
passbandWidth = 0.015;
else if (filter == 2)
passbandWidth = 0.010;
else
passbandWidth = 0.007;
passbandCenterFrequency = 0.0;
maxPassbandHz = 10E3;
break;
case modeCW:
case modeCW_R:
insertPeriodicRapidCmdUnique(cmdGetCwPitch);
maxPassbandHz = 3600;
break;
case modeAM:
passbandCenterFrequency = 0.0;
maxPassbandHz = 10E3;
break;
case modeLSB:
case modeUSB:
passbandCenterFrequency = 0.0015;
maxPassbandHz = 3600;
break;
default:
passbandCenterFrequency = 0.0;
maxPassbandHz = 3600;
break;
}
}
currentModeIndex = mode;
currentModeInfo.mk = (mode_kind)mode;
cw->handleCurrentModeUpdate((mode_kind)mode);
currentModeInfo.filter = filter;
switch (currentModeInfo.mk) {
case modeFM:
if (currentModeInfo.filter == 1)
passbandWidth = 0.015;
else if (currentModeInfo.filter == 2)
passbandWidth = 0.010;
else
passbandWidth = 0.007;
passbandCenterFrequency = 0.0;
break;
case modeLSB:
case modeUSB:
removePeriodicCommand(cmdGetCwPitch);
removePeriodicCommand(cmdGetPskTone);
removePeriodicCommand(cmdGetRttyMark);
passbandCenterFrequency = 0.0015;
break;
case modeCW:
case modeCW_R:
insertPeriodicCommandUnique(cmdGetCwPitch);
removePeriodicCommand(cmdGetPskTone);
removePeriodicCommand(cmdGetRttyMark);
break;
default:
removePeriodicCommand(cmdGetCwPitch);
removePeriodicCommand(cmdGetPskTone);
removePeriodicCommand(cmdGetRttyMark);
passbandCenterFrequency = 0.0;
break;
}
for (int i = 0; i < ui->modeSelectCombo->count(); i++)
{
if (ui->modeSelectCombo->itemData(i).toInt() == mode)
{
ui->modeSelectCombo->blockSignals(true);
ui->modeSelectCombo->setCurrentIndex(i);
ui->modeSelectCombo->blockSignals(false);
found = true;
}
}
} else {
qCritical(logSystem()) << __func__ << "Invalid mode " << mode << " received. ";
}
if ((filter) && (filter < 4)) {
ui->modeFilterCombo->blockSignals(true);
ui->modeFilterCombo->setCurrentIndex(filter - 1);
ui->modeFilterCombo->blockSignals(false);
}
if(!found)
{
qWarning(logSystem()) << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. ";
return;
}
currentModeIndex = mode;
currentModeInfo.mk = (mode_kind)mode;
currentMode = (mode_kind)mode;
currentModeInfo.filter = filter;
currentModeInfo.reg = mode;
rpt->handleUpdateCurrentMainMode(currentModeInfo);
<<<<<<< Updated upstream
currentModeIndex = mode;
currentModeInfo.mk = (mode_kind)mode;
currentMode = (mode_kind)mode;
currentModeInfo.filter = filter;
=======
if (!found)
{
qWarning(logSystem()) << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. ";
return;
}
>>>>>>> Stashed changes
if( (filter) && (filter < 4)){
ui->modeFilterCombo->blockSignals(true);
ui->modeFilterCombo->setCurrentIndex(filter-1);
ui->modeFilterCombo->blockSignals(false);
}
if (maxPassbandHz != 0)
{
trxadj->setMaxPassband(maxPassbandHz);
}
quint16 maxPassbandHz = 0;
switch(currentMode)
{
case modeUSB:
case modeLSB:
case modeCW:
case modeCW_R:
case modePSK:
case modePSK_R:
maxPassbandHz = 3600;
break;
case modeRTTY:
case modeRTTY_R:
maxPassbandHz = 2700;
break;
case modeAM:
maxPassbandHz = 10E3;
break;
case modeFM:
maxPassbandHz = 10E3;
break;
default:
break;
}
if(maxPassbandHz != 0)
{
trxadj->setMaxPassband(maxPassbandHz);
}
// Note: we need to know if the DATA mode is active to reach mode-D
// some kind of queued query:
if (rigCaps.hasDataModes && rigCaps.hasTransmit)
{
issueDelayedCommand(cmdGetDataMode);
issueDelayedCommandUnique(cmdGetPassband);
issueDelayedCommandUnique(cmdGetCwPitch);
issueDelayedCommandUnique(cmdGetTPBFInner);
issueDelayedCommandUnique(cmdGetTPBFOuter);
// Note: we need to know if the DATA mode is active to reach mode-D
// some kind of queued query:
if (rigCaps.hasDataModes && rigCaps.hasTransmit)
{
issueDelayedCommand(cmdGetDataMode);
}
}
} else {
qCritical(logSystem()) << __func__ << "Invalid mode " << mode << " received. ";
}
}
@ -5649,7 +5683,9 @@ void wfmain::on_modeSelectCombo_activated(int index)
}
issueCmd(cmdSetMode, mode);
currentModeInfo = mode;
issueDelayedCommand(cmdGetMode);
//currentModeInfo = mode;
}
}
@ -6191,6 +6227,11 @@ void wfmain::on_passwordTxt_textChanged(QString text)
udpPrefs.password = text;
}
void wfmain::on_audioDuplexCombo_currentIndexChanged(int value)
{
udpPrefs.halfDuplex = (bool)value;
}
void wfmain::on_audioOutputCombo_currentIndexChanged(int value)
{
@ -6344,6 +6385,7 @@ void wfmain::on_modeFilterCombo_activated(int index)
m.mk = (mode_kind)newMode;
m.reg = newMode;
issueCmd(cmdSetMode, m);
//emit setMode(newMode, (unsigned char)filterSelection);
}
}

Wyświetl plik

@ -451,6 +451,8 @@ private slots:
void on_passwordTxt_textChanged(QString text);
void on_audioDuplexCombo_currentIndexChanged(int value);
void on_audioOutputCombo_currentIndexChanged(int value);
void on_audioInputCombo_currentIndexChanged(int value);

136
wfmain.ui
Wyświetl plik

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1082</width>
<width>1063</width>
<height>660</height>
</rect>
</property>
@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="mainTab">
<attribute name="title">
@ -1808,7 +1808,6 @@
<font>
<family>DejaVu Sans Mono</family>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -2233,7 +2232,7 @@
<item>
<widget class="QStackedWidget" name="settingsStack">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="radioAccess">
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -2775,61 +2774,26 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_15">
<widget class="QLabel" name="label_51">
<property name="text">
<string>Audio Output </string>
<string>Duplex</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="audioOutputCombo">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="accessibleName">
<string>Audio Output Selector</string>
</property>
<widget class="QComboBox" name="audioDuplexCombo">
<item>
<property name="text">
<string>Full Duplex</string>
</property>
</item>
<item>
<property name="text">
<string>Half Duplex</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Audio Input</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="audioInputCombo">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="accessibleName">
<string>Audio Input Selector</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>15</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_40">
<property name="text">
@ -2871,6 +2835,63 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_47">
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Audio Output </string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="audioOutputCombo">
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="accessibleName">
<string>Audio Output Selector</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Audio Input</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="audioInputCombo">
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="accessibleName">
<string>Audio Input Selector</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_37">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -3409,8 +3430,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>858</width>
<height>287</height>
<width>579</width>
<height>224</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -5359,7 +5380,6 @@
<widget class="QPushButton" name="exitBtn">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
@ -5378,8 +5398,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1082</width>
<height>21</height>
<width>1063</width>
<height>22</height>
</rect>
</property>
</widget>
@ -5407,7 +5427,7 @@
<connections/>
<buttongroups>
<buttongroup name="pollingButtonGroup"/>
<buttongroup name="underlayButtonGroup"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="underlayButtonGroup"/>
</buttongroups>
</ui>