hide device specific actions based on the hardware version
Some checks are pending
Build / PC_Application_Ubuntu (push) Waiting to run
Build / PC_Application_RPi5 (push) Waiting to run
Build / PC_Application_Windows (push) Waiting to run
Build / PC_Application_OSX (push) Waiting to run
Build / PC_Application_OSX_13 (push) Waiting to run
Build / Embedded_Firmware (push) Waiting to run
HIL_Tests / Get_Repository (push) Waiting to run
HIL_Tests / PC_Application_RPi5 (push) Blocked by required conditions
HIL_Tests / Embedded_Firmware (push) Blocked by required conditions
HIL_Tests / HIL (push) Blocked by required conditions
Unit_Tests / Tests (push) Waiting to run

This commit is contained in:
Jan Käberich 2025-10-23 10:16:33 +02:00
parent f51c6a0bce
commit ed699cfd6a
5 changed files with 50 additions and 7 deletions

View file

@ -206,9 +206,9 @@ LibreVNADriver::LibreVNADriver()
});
specificActions.push_back(freqcal);
sep = new QAction();
sep->setSeparator(true);
specificActions.push_back(sep);
auto sep2 = new QAction();
sep2->setSeparator(true);
specificActions.push_back(sep2);
auto log = new QAction("View Packet Log");
connect(log, &QAction::triggered, this, [=](){
@ -217,6 +217,14 @@ LibreVNADriver::LibreVNADriver()
});
specificActions.push_back(log);
// set available actions for each hardware version
availableActions[0x01] = {manual, config, update, sep, srccal, recvcal, freqcal, sep2, log};
availableActions[0xD0] = {manual, update, sep, srccal, recvcal, freqcal, sep2, log};
availableActions[0xE0] = {manual, update, sep, srccal, recvcal, freqcal, sep2, log};
availableActions[0xFD] = {manual, update, sep, srccal, recvcal, freqcal, sep2, log};
availableActions[0xFE] = {manual, config, update, sep, srccal, recvcal, freqcal, sep2, log};
availableActions[0xFF] = {manual, config, update, sep, srccal, recvcal, freqcal, sep2, log};
// Create driver specific commands
specificSCPIcommands.push_back(new SCPICommand("DEVice:INFo:TEMPeratures", nullptr, [=](QStringList) -> QString {
if(!connected) {
@ -713,6 +721,8 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet)
info.Limits.SA.maxdBm = (double) packet.info.limits_cdbm_max / 100;
limits_maxAmplitudePoints = packet.info.limits_maxAmplitudePoints;
updateActionVisibility(hardwareVersion);
emit InfoUpdated();
}
break;
@ -784,6 +794,27 @@ QString LibreVNADriver::hardwareVersionToString(uint8_t version)
}
}
void LibreVNADriver::updateActionVisibility(uint8_t hardwareVersion)
{
// only show actions for the correct hardware version
if(availableActions.contains(hardwareVersion)) {
// hide all actions
for(auto a : specificActions) {
a->setVisible(false);
}
// show the relevant actions
for(auto a : availableActions[hardwareVersion]) {
a->setVisible(true);
}
} else {
// the hardware version is unknown. This should not happen but just in case
// we set all actions to visible
for(auto a : specificActions) {
a->setVisible(true);
}
}
}
unsigned int LibreVNADriver::getProtocolVersion() const
{
return protocolVersion;

View file

@ -197,6 +197,7 @@ protected slots:
void handleReceivedPacket(const Protocol::PacketInfo& packet);
protected:
QString hardwareVersionToString(uint8_t version);
void updateActionVisibility(uint8_t hardwareVersion);
bool connected;
unsigned int protocolVersion;
@ -228,6 +229,9 @@ protected:
bool VNASuppressInvalidPeaks;
bool VNAAdjustPowerLevel;
// available actions per hardware version
QMap<uint8_t, QList<QAction*>> availableActions;
QDialog *manualControlDialog;
};

View file

@ -1,10 +1,10 @@
@echo off
SetLocal EnableDelayedExpansion
(set PATH=C:\Qt\6.2.4\mingw_64\bin;!PATH!)
(set PATH=C:\Qt\6.8.0\mingw_64\bin;!PATH!)
if defined QT_PLUGIN_PATH (
set QT_PLUGIN_PATH=C:\Qt\6.2.4\mingw_64\plugins;!QT_PLUGIN_PATH!
set QT_PLUGIN_PATH=C:\Qt\6.8.0\mingw_64\plugins;!QT_PLUGIN_PATH!
) else (
set QT_PLUGIN_PATH=C:\Qt\6.2.4\mingw_64\plugins
set QT_PLUGIN_PATH=C:\Qt\6.8.0\mingw_64\plugins
)
%*
EndLocal

View file

@ -110,6 +110,7 @@ uint16_t Protocol::EncodePacket(const PacketInfo &packet, uint8_t *dest, uint16_
case PacketType::ReceiverCalPoint: payload_size = sizeof(packet.amplitudePoint); break;
case PacketType::FrequencyCorrection: payload_size = sizeof(packet.frequencyCorrection); break;
case PacketType::DeviceConfiguration: payload_size = sizeof(packet.deviceConfig); break;
case PacketType::PerformAction: payload_size = sizeof(packet.performAction); break;
case PacketType::Ack:
case PacketType::PerformFirmwareUpdate:
case PacketType::ClearFlash:

View file

@ -544,6 +544,11 @@ using DeviceConfig = struct _deviceconfig {
};
};
using PerformAction = struct _performaction {
uint16_t action;
uint8_t additional_information[128];
};
enum class PacketType : uint8_t {
None = 0,
//Datapoint = 1, // Deprecated, replaced by VNADatapoint
@ -577,7 +582,8 @@ enum class PacketType : uint8_t {
ClearTrigger = 29,
StopStatusUpdates = 30,
StartStatusUpdates = 31,
InitiateSweep = 32
InitiateSweep = 32,
PerformAction = 33,
};
using PacketInfo = struct _packetinfo {
@ -597,6 +603,7 @@ using PacketInfo = struct _packetinfo {
AmplitudeCorrectionPoint amplitudePoint;
FrequencyCorrection frequencyCorrection;
DeviceConfig deviceConfig;
PerformAction performAction;
/*
* When encoding: Pointer may go invalid after call to EncodePacket
* When decoding: VNADatapoint is created on heap by DecodeBuffer, freeing is up to the caller