kopia lustrzana https://gitlab.com/eliggett/wfview
Add get/set command types and make dial change current receiver.
rodzic
0d9bbaedf7
commit
19da8863f0
|
@ -216,7 +216,7 @@ void rigCommander::commonSetup()
|
|||
// Add the below commands so we can get a response until we have received rigCaps
|
||||
rigCaps.commands.clear();
|
||||
rigCaps.commandsReverse.clear();
|
||||
rigCaps.commands.insert(funcTransceiverId,funcType(funcTransceiverId, QString("Transceiver ID"),QByteArrayLiteral("\x19\x00"),0,0,false));
|
||||
rigCaps.commands.insert(funcTransceiverId,funcType(funcTransceiverId, QString("Transceiver ID"),QByteArrayLiteral("\x19\x00"),0,0,false,true,false));
|
||||
rigCaps.commandsReverse.insert(QByteArrayLiteral("\x19\x00"),funcTransceiverId);
|
||||
|
||||
this->setObjectName("Rig Commander");
|
||||
|
@ -1338,7 +1338,9 @@ void rigCommander::determineRigCaps()
|
|||
rigCaps.commands.insert(func, funcType(func, funcString[int(func)],
|
||||
QByteArray::fromHex(settings->value("String", "").toString().toUtf8()),
|
||||
settings->value("Min", 0).toInt(NULL), settings->value("Max", 0).toInt(NULL),
|
||||
settings->value("Command29",false).toBool()));
|
||||
settings->value("Command29",false).toBool(),
|
||||
settings->value("GetCommand",true).toBool(),
|
||||
settings->value("SetCommand",true).toBool()));
|
||||
|
||||
rigCaps.commandsReverse.insert(QByteArray::fromHex(settings->value("String", "").toString().toUtf8()),func);
|
||||
} else {
|
||||
|
@ -2485,10 +2487,27 @@ void rigCommander::receiveCommand(funcs func, QVariant value, uchar receiver)
|
|||
}
|
||||
|
||||
QByteArray payload;
|
||||
auto cmd = rigCaps.commands.find(func);
|
||||
if (cmd == rigCaps.commands.end())
|
||||
{
|
||||
// Command not found, remove from queue
|
||||
qDebug(logRig()) << "Removing unsupported command from queue" << funcString[func] << "VFO" << receiver;
|
||||
queue->del(func,receiver);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getCommand(func,payload,val,receiver))
|
||||
{
|
||||
if (value.isValid())
|
||||
{
|
||||
if (!cmd->setCmd) {
|
||||
qDebug(logRig()) << "Removing unsupported set command from queue" << funcString[func] << "VFO" << receiver;
|
||||
queue->del(func,receiver);
|
||||
return;
|
||||
} else if (cmd->getCmd && func != funcScopeFixedEdgeFreq && func != funcSpeech && func != funcBandStackReg && func != funcMemoryContents && func != funcSendCW) {
|
||||
queue->addUnique(priorityImmediate,func,false,receiver);
|
||||
}
|
||||
|
||||
if (!strcmp(value.typeName(),"bool"))
|
||||
{
|
||||
payload.append(value.value<bool>());
|
||||
|
@ -2855,10 +2874,15 @@ void rigCommander::receiveCommand(funcs func, QVariant value, uchar receiver)
|
|||
return;
|
||||
}
|
||||
// This was a set command, so queue a get straight after to retrieve the updated value
|
||||
// will fail on some commands so they would need to be added here:
|
||||
if (func != funcScopeFixedEdgeFreq && func != funcSpeech && func != funcBandStackReg && func != funcMemoryContents && func != funcSendCW)
|
||||
// will fail on some commands so they would need to be added here:
|
||||
} else {
|
||||
// This is a get command
|
||||
if (!cmd->getCmd)
|
||||
{
|
||||
queue->addUnique(priorityImmediate,func,false,receiver);
|
||||
// Get command not supported
|
||||
qDebug(logRig()) << "Removing unsupported get command from queue" << funcString[func] << "VFO" << receiver;
|
||||
queue->del(func,receiver);
|
||||
return;
|
||||
}
|
||||
}
|
||||
prepDataAndSend(payload);
|
||||
|
|
|
@ -55,6 +55,21 @@ void rigCreator::commandRowAdded(int row)
|
|||
layoutCheckBox->setAlignment(Qt::AlignCenter); // Center the checkbox
|
||||
layoutCheckBox->setContentsMargins(0,0,0,0); // Set the zero padding
|
||||
ui->commands->setCellWidget(row,4, checkBoxWidget);
|
||||
|
||||
QWidget *getSetWidget = new QWidget();
|
||||
QCheckBox *get = new QCheckBox(); // We declare and initialize the checkbox
|
||||
QCheckBox *set = new QCheckBox(); // We declare and initialize the checkbox
|
||||
get->setChecked(true);
|
||||
set->setChecked(true);
|
||||
get->setObjectName("get");
|
||||
set->setObjectName("set");
|
||||
QHBoxLayout *layoutGetSet = new QHBoxLayout(getSetWidget); // create a layer with reference to the widget
|
||||
layoutGetSet->addWidget(get); // Set the checkbox in the layer
|
||||
layoutGetSet->addWidget(set); // Set the checkbox in the layer
|
||||
layoutGetSet->setAlignment(Qt::AlignCenter); // Center the checkbox
|
||||
layoutGetSet->setContentsMargins(0,0,0,0); // Set the zero padding
|
||||
ui->commands->setCellWidget(row,5, getSetWidget);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,6 +209,27 @@ void rigCreator::loadRigFile(QString file)
|
|||
ui->commands->model()->setData(ui->commands->model()->index(c,3),QString::number(settings->value("Max", 0).toInt()));
|
||||
ui->commands->setCellWidget(c,4, checkBoxWidget);
|
||||
|
||||
QWidget *getSetWidget = new QWidget();
|
||||
QCheckBox *get = new QCheckBox(); // We declare and initialize the checkbox
|
||||
QCheckBox *set = new QCheckBox(); // We declare and initialize the checkbox
|
||||
if (settings->value("GetCommand",true).toBool()) {
|
||||
get->setChecked(true);
|
||||
} else {
|
||||
get->setChecked(false);
|
||||
}
|
||||
if (settings->value("SetCommand",true).toBool()) {
|
||||
set->setChecked(true);
|
||||
} else {
|
||||
set->setChecked(false);
|
||||
}
|
||||
get->setObjectName("get");
|
||||
set->setObjectName("set");
|
||||
QHBoxLayout *layoutGetSet = new QHBoxLayout(getSetWidget); // create a layer with reference to the widget
|
||||
layoutGetSet->addWidget(get); // Set the checkbox in the layer
|
||||
layoutGetSet->addWidget(set); // Set the checkbox in the layer
|
||||
layoutGetSet->setAlignment(Qt::AlignCenter); // Center the checkbox
|
||||
layoutGetSet->setContentsMargins(0,0,0,0); // Set the zero padding
|
||||
ui->commands->setCellWidget(c,5, getSetWidget);
|
||||
}
|
||||
settings->endArray();
|
||||
}
|
||||
|
@ -513,6 +549,15 @@ void rigCreator::saveRigFile(QString file)
|
|||
settings->setValue("Command29", chk->isChecked());
|
||||
}
|
||||
|
||||
QList<QCheckBox*> getSet =ui->commands->cellWidget(n,5)->findChildren<QCheckBox*>(QString(), Qt::FindChildrenRecursively);
|
||||
qDebug() << "size = "<<getSet.size();
|
||||
foreach (auto c, getSet)
|
||||
{
|
||||
if (c->objectName() == "get")
|
||||
settings->setValue("GetCommand", c->isChecked());
|
||||
else if (c->objectName() == "set")
|
||||
settings->setValue("SetCommand", c->isChecked());
|
||||
}
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>5</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>false</bool>
|
||||
|
@ -253,6 +253,11 @@
|
|||
<string>29</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>G/S</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -1804,11 +1804,11 @@ void spectrumScope::newFrequency(qint64 freq,uchar vfo)
|
|||
{
|
||||
if (vfo > 0)
|
||||
{
|
||||
queue->add(priorityImmediate,queueItem((funcUnselectedFreq),QVariant::fromValue<freqt>(f),false,receiver));
|
||||
queue->addUnique(priorityImmediate,queueItem((funcUnselectedFreq),QVariant::fromValue<freqt>(f),false,receiver));
|
||||
}
|
||||
else
|
||||
{
|
||||
queue->add(priorityImmediate,queueItem((receiver?funcSubFreq:funcMainFreq),QVariant::fromValue<freqt>(f),false,receiver));
|
||||
queue->addUnique(priorityImmediate,queueItem((receiver?funcSubFreq:funcMainFreq),QVariant::fromValue<freqt>(f),false,receiver));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
29
wfmain.cpp
29
wfmain.cpp
|
@ -3989,19 +3989,24 @@ void wfmain::on_freqDial_valueChanged(int value)
|
|||
|
||||
// With the number of steps and direction of steps established,
|
||||
// we can now adjust the frequency:
|
||||
if (receivers.size()) {
|
||||
f.Hz = roundFrequencyWithStep(receivers[0]->getFrequency().Hz, delta, tsKnobHz);
|
||||
f.MHzDouble = f.Hz / (double)1E6;
|
||||
if (f.Hz > 0)
|
||||
|
||||
for (uchar i=0;i<rigCaps->numReceiver;i++)
|
||||
{
|
||||
if (receivers[i]->isSelected())
|
||||
{
|
||||
oldFreqDialVal = value;
|
||||
receivers[0]->setFrequency(f);
|
||||
queue->add(priorityImmediate,queueItem(funcMainFreq,QVariant::fromValue<freqt>(f),false));
|
||||
} else {
|
||||
ui->freqDial->blockSignals(true);
|
||||
ui->freqDial->setValue(oldFreqDialVal);
|
||||
ui->freqDial->blockSignals(false);
|
||||
return;
|
||||
f.Hz = roundFrequencyWithStep(receivers[i]->getFrequency().Hz, delta, tsKnobHz);
|
||||
f.MHzDouble = f.Hz / (double)1E6;
|
||||
if (f.Hz > 0)
|
||||
{
|
||||
oldFreqDialVal = value;
|
||||
receivers[i]->setFrequency(f);
|
||||
queue->addUnique(priorityImmediate,queueItem((i==0)?funcMainFreq:funcSubFreq,QVariant::fromValue<freqt>(f),false,i));
|
||||
} else {
|
||||
ui->freqDial->blockSignals(true);
|
||||
ui->freqDial->setValue(oldFreqDialVal);
|
||||
ui->freqDial->blockSignals(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -323,13 +323,15 @@ struct spanType {
|
|||
|
||||
struct funcType {
|
||||
funcType() {}
|
||||
funcType(funcs cmd, QString name, QByteArray data, int minVal, int maxVal, bool cmd29) : cmd(cmd), name(name), data(data), minVal(minVal), maxVal(maxVal), cmd29(cmd29) {}
|
||||
funcType(funcs cmd, QString name, QByteArray data, int minVal, int maxVal, bool cmd29, bool getCmd, bool setCmd) : cmd(cmd), name(name), data(data), minVal(minVal), maxVal(maxVal), cmd29(cmd29), getCmd(getCmd), setCmd(setCmd) {}
|
||||
funcs cmd;
|
||||
QString name;
|
||||
QByteArray data;
|
||||
int minVal;
|
||||
int maxVal;
|
||||
bool cmd29;
|
||||
bool getCmd;
|
||||
bool setCmd;
|
||||
};
|
||||
|
||||
//struct commandtype {
|
||||
|
|
Ładowanie…
Reference in New Issue