added dialogs for hardware version 0xFE

This commit is contained in:
Jan Käberich 2023-11-07 14:26:31 +01:00
parent 772ef44d49
commit 11612e44d5
12 changed files with 1694 additions and 8 deletions

View File

@ -0,0 +1,60 @@
#include "deviceconfigurationdialogvfe.h"
#include "ui_deviceconfigurationdialogvfe.h"
#include <QtEndian>
DeviceConfigurationDialogVFE::DeviceConfigurationDialogVFE(LibreVNADriver &dev, QWidget *parent) :
QDialog(parent),
ui(new Ui::DeviceConfigurationDialogVFE),
dev(dev)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
emit dev.acquireControl();
connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p) {
if(p.type == Protocol::PacketType::DeviceConfiguration) {
updateGUI(p.deviceConfig);
}
});
connect(ui->autogain, &QCheckBox::toggled, this, [=](){
ui->portgain->setEnabled(!ui->autogain->isChecked());
ui->refgain->setEnabled(!ui->autogain->isChecked());
});
dev.sendWithoutPayload(Protocol::PacketType::RequestDeviceConfiguration);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [=](){
updateDevice();
accept();
});
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=](){
reject();
});
}
DeviceConfigurationDialogVFE::~DeviceConfigurationDialogVFE()
{
dev.releaseControl();
delete ui;
}
void DeviceConfigurationDialogVFE::updateGUI(const Protocol::DeviceConfig &c)
{
ui->autogain->setChecked(c.VFE.autogain);
ui->portgain->setCurrentIndex(c.VFE.portGain);
ui->refgain->setCurrentIndex(c.VFE.refGain);
}
void DeviceConfigurationDialogVFE::updateDevice()
{
Protocol::PacketInfo p;
p.type = Protocol::PacketType::DeviceConfiguration;
p.deviceConfig.VFE.autogain = ui->autogain->isChecked() ? 1 : 0;
p.deviceConfig.VFE.portGain = ui->portgain->currentIndex();
p.deviceConfig.VFE.refGain = ui->refgain->currentIndex();
dev.SendPacket(p);
}

View File

@ -0,0 +1,31 @@
#ifndef DEVICECONFIGURATIONDIALOGVFE_H
#define DEVICECONFIGURATIONDIALOGVFE_H
#include "librevnadriver.h"
#include <QDialog>
#include <QHostAddress>
namespace Ui {
class DeviceConfigurationDialogVFE;
}
class DeviceConfigurationDialogVFE : public QDialog
{
Q_OBJECT
public:
explicit DeviceConfigurationDialogVFE(LibreVNADriver &dev, QWidget *parent = nullptr);
~DeviceConfigurationDialogVFE();
private:
void updateGUI(const Protocol::DeviceConfig &c);
void updateDevice();
Ui::DeviceConfigurationDialogVFE *ui;
LibreVNADriver &dev;
QHostAddress ip, mask, gateway;
};
#endif // DEVICECONFIGURATIONDIALOGVFE_H

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DeviceConfigurationDialogVFE</class>
<widget class="QWidget" name="DeviceConfigurationDialogVFE">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>307</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>PGA configuration (reset after reboot)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="autogain">
<property name="text">
<string>Autogain</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Port gain:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="portgain">
<item>
<property name="text">
<string>1V/V</string>
</property>
</item>
<item>
<property name="text">
<string>10V/V</string>
</property>
</item>
<item>
<property name="text">
<string>20V/V</string>
</property>
</item>
<item>
<property name="text">
<string>30V/V</string>
</property>
</item>
<item>
<property name="text">
<string>40V/V</string>
</property>
</item>
<item>
<property name="text">
<string>60V/V</string>
</property>
</item>
<item>
<property name="text">
<string>80V/V</string>
</property>
</item>
<item>
<property name="text">
<string>120V/V</string>
</property>
</item>
<item>
<property name="text">
<string>157V/V</string>
</property>
</item>
<item>
<property name="text">
<string>0.25V/V</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Reference gain:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="refgain">
<item>
<property name="text">
<string>1V/V</string>
</property>
</item>
<item>
<property name="text">
<string>10V/V</string>
</property>
</item>
<item>
<property name="text">
<string>20V/V</string>
</property>
</item>
<item>
<property name="text">
<string>30V/V</string>
</property>
</item>
<item>
<property name="text">
<string>40V/V</string>
</property>
</item>
<item>
<property name="text">
<string>60V/V</string>
</property>
</item>
<item>
<property name="text">
<string>80V/V</string>
</property>
</item>
<item>
<property name="text">
<string>120V/V</string>
</property>
</item>
<item>
<property name="text">
<string>157V/V</string>
</property>
</item>
<item>
<property name="text">
<string>0.25V/V</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -204,6 +204,18 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e)
addBool(VFF, "ADC overload", sFF.ADC_overload); addBool(VFF, "ADC overload", sFF.ADC_overload);
addBool(VFF, "Unlevel", sFF.unlevel); addBool(VFF, "Unlevel", sFF.unlevel);
addInteger(VFF, "MCU temperature", sFF.temp_MCU); addInteger(VFF, "MCU temperature", sFF.temp_MCU);
auto sFE = e.p->status.VFE;
auto VFE = new QTreeWidgetItem();
VFE->setData(2, Qt::DisplayRole, "VFE");
item->addChild(VFE);
addBool(VFE, "Source locked", sFE.source_locked);
addBool(VFE, "LO locked", sFE.LO_locked);
addBool(VFE, "ADC overload", sFE.ADC_overload);
addBool(VFE, "Unlevel", sFE.unlevel);
addInteger(VFE, "MCU temperature", sFE.temp_MCU);
addDouble(VFE, "eCal temperature", (double) sFE.temp_eCal / 100.0);
addDouble(VFE, "eCal heater power", (double) sFE.power_heater / 1000.0);
} }
break; break;
case Protocol::PacketType::DeviceInfo: { case Protocol::PacketType::DeviceInfo: {
@ -227,9 +239,129 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e)
addDouble(item, "Maximum harmonic frequency", s.limits_maxFreqHarmonic, "Hz"); addDouble(item, "Maximum harmonic frequency", s.limits_maxFreqHarmonic, "Hz");
} }
break; break;
case Protocol::PacketType::ManualControl: case Protocol::PacketType::ManualControl: {
case Protocol::PacketType::ManualStatus: Protocol::ManualControl s = e.p->manual;
// TODO auto V1 = new QTreeWidgetItem();
V1->setData(2, Qt::DisplayRole, "V1");
item->addChild(V1);
addBool(V1, "High Source chip enable", s.V1.SourceHighCE);
addBool(V1, "High Source RF enable", s.V1.SourceHighRFEN);
addEnum(V1, "High Source power", s.V1.SourceHighPower, {"-4 dBm", "-1 dBm", "2 dBm", "5 dBm"});
addEnum(V1, "High Source lowpass", s.V1.SourceHighLowpass, {"947 MHz", "1880 MHz", "3550 MHz", "None"});
addDouble(V1, "High Source frequency", s.V1.SourceHighFrequency);
addBool(V1, "Low Source enable", s.V1.SourceLowEN);
addEnum(V1, "Low Source power", s.V1.SourceLowPower, {"2 mA", "4 mA", "6 mA", "8 mA"});
addDouble(V1, "Low Source frequency", s.V1.SourceLowFrequency);
addDouble(V1, "Attenuator", s.V1.attenuator * 0.25);
addEnum(V1, "Source band selection", s.V1.SourceHighband, {"Low Source", "High Source"});
addBool(V1, "Amplifier enable", s.V1.AmplifierEN);
addEnum(V1, "Port switch", s.V1.PortSwitch, {"Port 1", "Port 2"});
addBool(V1, "LO1 chip enable", s.V1.LO1CE);
addBool(V1, "LO1 RF enable", s.V1.LO1RFEN);
addDouble(V1, "LO1 frequency", s.V1.LO1Frequency);
addBool(V1, "LO2 enable", s.V1.LO2EN);
addDouble(V1, "LO2 frequency", s.V1.LO2Frequency);
addBool(V1, "Port 1 receiver enable", s.V1.Port1EN);
addBool(V1, "Port 2 receiver enable", s.V1.Port2EN);
addBool(V1, "Reference receiver enable", s.V1.RefEN);
addInteger(V1, "Samples", s.V1.Samples);
addEnum(V1, "Window type", s.V1.WindowType, {"None", "Kaiser", "Hann", "Flattop"});
auto VFF = new QTreeWidgetItem();
VFF->setData(2, Qt::DisplayRole, "VFF");
item->addChild(VFF);
addBool(VFF, "Source chip enable", s.VFF.SourceCE);
addBool(VFF, "Source RF enable", s.VFF.SourceRFEN);
addEnum(VFF, "Source power", s.VFF.SourcePower, {"-1 dBm", "1 dBm", "2.5 dBm", "3.5 dBm", "4.5 dBm", "5.5 dBm", "6.5 dBm", "7 dBm"});
addDouble(VFF, "Source frequency", s.VFF.SourceFrequency);
addDouble(VFF, "Attenuator", s.VFF.attenuator * 0.25);
addBool(VFF, "Source amplifier enable", s.VFF.SourceAmplifierEN);
addBool(VFF, "LO chip enable", s.VFF.LOCE);
addBool(VFF, "LO RF enable", s.VFF.LORFEN);
addBool(VFF, "LO amplifier enable", s.VFF.LOAmplifierEN);
addEnum(VFF, "LO selection", s.VFF.LOexternal, {"Internal", "External"});
addDouble(VFF, "LO frequency", s.VFF.LOFrequency);
addBool(VFF, "Port receiver enable", s.VFF.PortEN);
addBool(VFF, "Reference receiver enable", s.VFF.RefEN);
addInteger(VFF, "Samples", s.VFF.Samples);
addEnum(VFF, "Window type", s.VFF.WindowType, {"None", "Kaiser", "Hann", "Flattop"});
addEnum(VFF, "Port gain", s.VFF.PortGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"});
addEnum(VFF, "Reference gain", s.VFF.RefGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"});
auto VFE = new QTreeWidgetItem();
VFE->setData(2, Qt::DisplayRole, "VFE");
item->addChild(VFE);
addBool(VFE, "Source chip enable", s.VFE.SourceCE);
addBool(VFE, "Source RF enable", s.VFE.SourceRFEN);
addDouble(VFE, "Source frequency", s.VFE.SourceFrequency);
addDouble(VFE, "Attenuator", s.VFE.attenuator * 0.25);
addBool(VFE, "Source amplifier 1 enable", s.VFE.SourceAmplifier1EN);
addBool(VFE, "Source amplifier 2 enable", s.VFE.SourceAmplifier2EN);
addBool(VFE, "LO chip enable", s.VFE.LOCE);
addBool(VFE, "LO RF enable", s.VFE.LORFEN);
addDouble(VFE, "LO frequency", s.VFE.LOFrequency);
addBool(VFE, "Port receiver enable", s.VFE.PortEN);
addBool(VFE, "Reference receiver enable", s.VFE.RefEN);
addInteger(VFE, "Samples", s.VFE.Samples);
addEnum(VFE, "Window type", s.VFE.WindowType, {"None", "Kaiser", "Hann", "Flattop"});
addEnum(VFE, "Port gain", s.VFE.PortGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"});
addEnum(VFE, "Reference gain", s.VFE.RefGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"});
addEnum(VFE, "eCal state", s.VFE.eCal_state, {"Port", "Open", "Short", "Load"});
addDouble(VFE, "eCal target temperature", (double) s.VFE.eCal_target / 100.0);
}
break;
case Protocol::PacketType::ManualStatus: {
Protocol::ManualStatus s = e.p->manualStatus;
auto V1 = new QTreeWidgetItem();
V1->setData(2, Qt::DisplayRole, "V1");
item->addChild(V1);
addInteger(V1, "ADC port 1 minimum", s.V1.port1min);
addInteger(V1, "ADC port 1 maximum", s.V1.port1max);
addInteger(V1, "ADC port 2 minimum", s.V1.port2min);
addInteger(V1, "ADC port 2 maximum", s.V1.port2max);
addInteger(V1, "ADC reference minimum", s.V1.refmin);
addInteger(V1, "ADC reference maximum", s.V1.refmax);
addDouble(V1, "Port 1 real", s.V1.port1real);
addDouble(V1, "Port 1 imaginary", s.V1.port1imag);
addDouble(V1, "Port 2 real", s.V1.port2real);
addDouble(V1, "Port 2 imaginary", s.V1.port2imag);
addDouble(V1, "Reference real", s.V1.refreal);
addDouble(V1, "Reference imaginary", s.V1.refimag);
addInteger(V1, "Source temperature", s.V1.temp_source);
addInteger(V1, "LO1 temperature", s.V1.temp_LO);
addBool(V1, "Source locked", s.V1.source_locked);
addBool(V1, "LO1 locked", s.V1.LO_locked);
auto VFF = new QTreeWidgetItem();
VFF->setData(2, Qt::DisplayRole, "VFF");
item->addChild(VFF);
addInteger(VFF, "ADC port minimum", s.VFF.portmin);
addInteger(VFF, "ADC port maximum", s.VFF.portmax);
addInteger(VFF, "ADC reference minimum", s.VFF.refmin);
addInteger(VFF, "ADC reference maximum", s.VFF.refmax);
addDouble(VFF, "Port real", s.VFF.portreal);
addDouble(VFF, "Port imaginary", s.VFF.portimag);
addDouble(VFF, "Reference real", s.VFF.refreal);
addDouble(VFF, "Reference imaginary", s.VFF.refimag);
addBool(VFF, "Source locked", s.VFF.source_locked);
addBool(VFF, "LO locked", s.VFF.LO_locked);
auto VFE = new QTreeWidgetItem();
VFE->setData(2, Qt::DisplayRole, "VFE");
item->addChild(VFE);
addInteger(VFE, "ADC port minimum", s.VFE.portmin);
addInteger(VFE, "ADC port maximum", s.VFE.portmax);
addInteger(VFE, "ADC reference minimum", s.VFE.refmin);
addInteger(VFE, "ADC reference maximum", s.VFE.refmax);
addDouble(VFE, "Port real", s.VFE.portreal);
addDouble(VFE, "Port imaginary", s.VFE.portimag);
addDouble(VFE, "Reference real", s.VFE.refreal);
addDouble(VFE, "Reference imaginary", s.VFE.refimag);
addBool(VFE, "Source locked", s.VFE.source_locked);
addBool(VFE, "LO locked", s.VFE.LO_locked);
addDouble(VFE, "eCal temperature", (double) s.VFE.temp_eCal / 100.0);
addDouble(VFE, "eCal heater power", (double) s.VFE.power_heater / 1000.0);
}
break; break;
case Protocol::PacketType::SpectrumAnalyzerSettings: { case Protocol::PacketType::SpectrumAnalyzerSettings: {
Protocol::SpectrumAnalyzerSettings s = e.p->spectrumSettings; Protocol::SpectrumAnalyzerSettings s = e.p->spectrumSettings;
@ -330,6 +462,14 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e)
addBool(VFF, "PGA autogain", sFF.autogain); addBool(VFF, "PGA autogain", sFF.autogain);
addInteger(VFF, "Port gain", sFF.portGain); addInteger(VFF, "Port gain", sFF.portGain);
addInteger(VFF, "Reference gain", sFF.refGain); addInteger(VFF, "Reference gain", sFF.refGain);
auto sFE = e.p->deviceConfig.VFE;
auto VFE = new QTreeWidgetItem();
VFE->setData(2, Qt::DisplayRole, "VFE");
item->addChild(VFE);
addBool(VFE, "PGA autogain", sFE.autogain);
addInteger(VFE, "Port gain", sFE.portGain);
addInteger(VFE, "Reference gain", sFE.refGain);
} }
break; break;
default: default:

View File

@ -2,8 +2,10 @@
#include "manualcontroldialogV1.h" #include "manualcontroldialogV1.h"
#include "manualcontroldialogvff.h" #include "manualcontroldialogvff.h"
#include "manualcontroldialogvfe.h"
#include "deviceconfigurationdialogv1.h" #include "deviceconfigurationdialogv1.h"
#include "deviceconfigurationdialogvff.h" #include "deviceconfigurationdialogvff.h"
#include "deviceconfigurationdialogvfe.h"
#include "firmwareupdatedialog.h" #include "firmwareupdatedialog.h"
#include "frequencycaldialog.h" #include "frequencycaldialog.h"
#include "sourcecaldialog.h" #include "sourcecaldialog.h"
@ -121,6 +123,9 @@ LibreVNADriver::LibreVNADriver()
case 1: case 1:
d = new ManualControlDialogV1(*this); d = new ManualControlDialogV1(*this);
break; break;
case 0xFE:
d = new ManualControlDialogVFE(*this);
break;
case 0xFF: case 0xFF:
d = new ManualControlDialogVFF(*this); d = new ManualControlDialogVFF(*this);
break; break;
@ -138,6 +143,9 @@ LibreVNADriver::LibreVNADriver()
case 1: case 1:
d = new DeviceConfigurationDialogV1(*this); d = new DeviceConfigurationDialogV1(*this);
break; break;
case 0xFE:
d = new DeviceConfigurationDialogVFE(*this);
break;
case 0xFF: case 0xFF:
d = new DeviceConfigurationDialogVFF(*this); d = new DeviceConfigurationDialogVFF(*this);
break; break;
@ -210,6 +218,17 @@ std::set<DeviceDriver::Flag> LibreVNADriver::getFlags()
ret.insert(Flag::Overload); ret.insert(Flag::Overload);
} }
break; break;
case 0xFE:
if(!lastStatus.VFE.source_locked || !lastStatus.VFE.LO_locked) {
ret.insert(Flag::Unlocked);
}
if(lastStatus.VFE.unlevel) {
ret.insert(Flag::Unlevel);
}
if(lastStatus.VFE.ADC_overload) {
ret.insert(Flag::Overload);
}
break;
case 0xFF: case 0xFF:
if(!lastStatus.VFF.source_locked || !lastStatus.VFF.LO_locked) { if(!lastStatus.VFF.source_locked || !lastStatus.VFF.LO_locked) {
ret.insert(Flag::Unlocked); ret.insert(Flag::Unlocked);
@ -244,6 +263,11 @@ QString LibreVNADriver::getStatus()
} }
} }
break; break;
case 0xFE:
ret.append(" MCU Temp: "+QString::number(lastStatus.VFE.temp_MCU)+"°C");
ret.append(" eCal Temp: "+QString::number(lastStatus.VFE.temp_eCal / 100.0)+"°C");
ret.append(" eCal Power: "+QString::number(lastStatus.VFE.power_heater / 1000.0)+"W");
break;
case 0xFF: case 0xFF:
ret.append(" MCU Temp: "+QString::number(lastStatus.VFF.temp_MCU)+"°C"); ret.append(" MCU Temp: "+QString::number(lastStatus.VFF.temp_MCU)+"°C");
break; break;
@ -672,8 +696,9 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet)
QString LibreVNADriver::hardwareVersionToString(uint8_t version) QString LibreVNADriver::hardwareVersionToString(uint8_t version)
{ {
switch(version) { switch(version) {
case 1: return "1"; case 0x01: return "1";
case 255: return "PT"; case 0xFE: return "P2";
case 0xFF: return "PT";
default: return "Unknown"; default: return "Unknown";
} }
} }
@ -686,8 +711,9 @@ unsigned int LibreVNADriver::getMaxAmplitudePoints() const
QString LibreVNADriver::getFirmwareMagicString() QString LibreVNADriver::getFirmwareMagicString()
{ {
switch(hardwareVersion) { switch(hardwareVersion) {
case 1: return "VNA!"; case 0x01: return "VNA!";
case 255: return "VNPT"; case 0xFE: return "VNP2";
case 0xFF: return "VNPT";
default: return "XXXX"; default: return "XXXX";
} }
} }

View File

@ -0,0 +1,419 @@
#include "manualcontroldialogvfe.h"
#include "ui_manualcontroldialogvfe.h"
#include "Util/util.h"
#include <QComboBox>
#include <QDebug>
#include <QButtonGroup>
#include <complex>
using namespace std;
ManualControlDialogVFE::ManualControlDialogVFE(LibreVNADriver &dev, QWidget *parent) :
QDialog(parent),
ui(new Ui::ManualControlDialogVFE),
dev(dev)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
emit dev.acquireControl();
ui->SourceFrequency->setUnit("Hz");
ui->SourceFrequency->setPrefixes(" kMG");
ui->SourceFrequency->setPrecision(6);
ui->SourceFrequency->setValueQuiet(1000000000);
ui->IF->setUnit("Hz");
ui->IF->setPrefixes(" kM");
ui->IF->setPrecision(6);
ui->LOFrequency->setUnit("Hz");
ui->LOFrequency->setPrefixes(" kMG");
ui->LOFrequency->setPrecision(6);
ui->eCalTarget->setUnit("°");
ui->eCalTarget->setPrecision(4);
ui->eCalTarget->setValue(0);
ui->eCalTemp->setUnit("°");
ui->eCalTemp->setPrecision(4);
ui->eCalPower->setUnit("W");
ui->eCalPower->setPrefixes("m ");
ui->eCalPower->setPrecision(3);
auto UpdateLO = [=]() {
double sourceFreq = ui->SourceFrequency->value();
if (ui->LOFreqType->currentIndex() == 0) {
// fixed IF mode
ui->LOFrequency->setValueQuiet(sourceFreq + ui->IF->value());
} else {
// Manual Frequency mode
ui->IF->setValueQuiet(ui->LOFrequency->value() - sourceFreq);
}
};
connect(ui->IF, &SIUnitEdit::valueChanged, [=](double) {
UpdateLO();
});
connect(ui->LOFrequency, &SIUnitEdit::valueChanged, [=](double) {
UpdateLO();
});
connect(ui->SourceFrequency, &SIUnitEdit::valueChanged, [=](double) {
UpdateLO();
});
ui->IF->setValue(100000);
// LO mode switch connections
connect(ui->LOFreqType, qOverload<int>(&QComboBox::activated), [=](int index) {
switch(index) {
case 0:
ui->LOFrequency->setEnabled(false);
ui->IF->setEnabled(true);
break;
case 1:
ui->LOFrequency->setEnabled(true);
ui->IF->setEnabled(false);
break;
}
});
// Readonly widgets
auto MakeReadOnly = [](QWidget* w) {
w->setAttribute(Qt::WA_TransparentForMouseEvents);
w->setFocusPolicy(Qt::NoFocus);
};
MakeReadOnly(ui->SourceLocked);
MakeReadOnly(ui->LOlocked);
MakeReadOnly(ui->portmin);
MakeReadOnly(ui->portmax);
MakeReadOnly(ui->portmag);
MakeReadOnly(ui->portphase);
MakeReadOnly(ui->portreferenced);
MakeReadOnly(ui->refmin);
MakeReadOnly(ui->refmax);
MakeReadOnly(ui->refmag);
MakeReadOnly(ui->refphase);
MakeReadOnly(ui->eCalPower);
MakeReadOnly(ui->eCalTemp);
connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p){
if(p.type == Protocol::PacketType::ManualStatus) {
NewStatus(p.manualStatus);
}
}, Qt::QueuedConnection);
connect(ui->SourceCE, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->SourceRFEN, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->LOCE, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->LORFEN, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->SourceAmplifier1Enable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->SourceAmplifier2Enable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->Port1Enable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->RefEnable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); });
connect(ui->portgain, qOverload<int>(&QComboBox::currentIndexChanged), [=](int) { UpdateDevice(); });
connect(ui->refgain, qOverload<int>(&QComboBox::currentIndexChanged), [=](int) { UpdateDevice(); });
connect(ui->SourceFrequency, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); });
connect(ui->LOFrequency, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); });
connect(ui->IF, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); });
connect(ui->Attenuator, qOverload<double>(&QDoubleSpinBox::valueChanged), [=](double) { UpdateDevice(); });
connect(ui->Samples, qOverload<int>(&QSpinBox::valueChanged), [=](double) { UpdateDevice(); });
connect(ui->cbWindow, qOverload<int>(&QComboBox::activated), [=](int) { UpdateDevice(); });
connect(ui->eCalState, qOverload<int>(&QComboBox::currentIndexChanged), [=](int) { UpdateDevice(); });
connect(ui->eCalTarget, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); });
UpdateDevice();
}
ManualControlDialogVFE::~ManualControlDialogVFE()
{
emit dev.releaseControl();
delete ui;
}
void ManualControlDialogVFE::setSourceChipEnable(bool enable)
{
ui->SourceCE->setChecked(enable);
}
bool ManualControlDialogVFE::getSourceChipEnable()
{
return ui->SourceCE->isChecked();
}
void ManualControlDialogVFE::setSourceRFEnable(bool enable)
{
ui->SourceRFEN->setChecked(enable);
}
bool ManualControlDialogVFE::getSourceRFEnable()
{
return ui->SourceRFEN->isChecked();
}
bool ManualControlDialogVFE::getSourceLocked()
{
return ui->SourceLocked->isChecked();
}
void ManualControlDialogVFE::setSourceFrequency(double f)
{
ui->SourceFrequency->setValue(f);
}
double ManualControlDialogVFE::getSourceFrequency()
{
return ui->SourceFrequency->value();
}
void ManualControlDialogVFE::setAttenuator(double att)
{
ui->Attenuator->setValue(att);
}
double ManualControlDialogVFE::getAttenuator()
{
return ui->Attenuator->value();
}
void ManualControlDialogVFE::setSourceAmplifier1Enable(bool enable)
{
ui->SourceAmplifier1Enable->setChecked(enable);
}
bool ManualControlDialogVFE::getSourceAmplifier1Enable()
{
return ui->SourceAmplifier1Enable->isChecked();
}
void ManualControlDialogVFE::setSourceAmplifier2Enable(bool enable)
{
ui->SourceAmplifier2Enable->setChecked(enable);
}
bool ManualControlDialogVFE::getSourceAmplifier2Enable()
{
return ui->SourceAmplifier2Enable->isChecked();
}
void ManualControlDialogVFE::setLOChipEnable(bool enable)
{
ui->LOCE->setChecked(enable);
}
bool ManualControlDialogVFE::getLOChipEnable()
{
return ui->LOCE->isChecked();
}
void ManualControlDialogVFE::setLORFEnable(bool enable)
{
ui->LORFEN->setChecked(enable);
}
bool ManualControlDialogVFE::getLORFEnable()
{
return ui->LORFEN->isChecked();
}
bool ManualControlDialogVFE::getLOLocked()
{
return ui->LOlocked->isChecked();
}
void ManualControlDialogVFE::setLOFrequency(double f)
{
ui->LOFreqType->setCurrentIndex(1);
ui->LOFrequency->setValue(f);
}
double ManualControlDialogVFE::getLOFrequency()
{
return ui->LOFrequency->value();
}
void ManualControlDialogVFE::setIFFrequency(double f)
{
ui->LOFreqType->setCurrentIndex(0);
ui->IF->setValue(f);
}
double ManualControlDialogVFE::getIFFrequency()
{
return ui->IF->value();
}
void ManualControlDialogVFE::setPortEnable(bool enable)
{
ui->Port1Enable->setChecked(enable);
}
bool ManualControlDialogVFE::getPortEnable()
{
return ui->Port1Enable->isChecked();
}
void ManualControlDialogVFE::setRefEnable(bool enable)
{
ui->RefEnable->setChecked(enable);
}
bool ManualControlDialogVFE::getRefEnable()
{
return ui->RefEnable->isChecked();
}
void ManualControlDialogVFE::setPortGain(Gain g)
{
ui->portgain->setCurrentIndex((int) g);
}
ManualControlDialogVFE::Gain ManualControlDialogVFE::getPortGain()
{
return (Gain) ui->portgain->currentIndex();
}
void ManualControlDialogVFE::setRefGain(Gain g)
{
ui->refgain->setCurrentIndex((int) g);
}
ManualControlDialogVFE::Gain ManualControlDialogVFE::getRefGain()
{
return (Gain) ui->refgain->currentIndex();
}
void ManualControlDialogVFE::setNumSamples(int samples)
{
ui->Samples->setValue(samples);
}
int ManualControlDialogVFE::getNumSamples()
{
return ui->Samples->value();
}
void ManualControlDialogVFE::setWindow(ManualControlDialogVFE::Window w)
{
ui->cbWindow->setCurrentIndex((int) w);
}
ManualControlDialogVFE::Window ManualControlDialogVFE::getWindow()
{
return (Window) ui->cbWindow->currentIndex();
}
int ManualControlDialogVFE::getPortMinADC()
{
return ui->portmin->text().toInt();
}
int ManualControlDialogVFE::getPortMaxADC()
{
return ui->portmax->text().toInt();
}
double ManualControlDialogVFE::getPortMagnitude()
{
return ui->portmag->text().toDouble();
}
double ManualControlDialogVFE::getPortPhase()
{
return ui->portphase->text().toDouble();
}
std::complex<double> ManualControlDialogVFE::getPortReferenced()
{
return portreferenced;
}
int ManualControlDialogVFE::getRefMinADC()
{
return ui->refmin->text().toInt();
}
int ManualControlDialogVFE::getRefMaxADC()
{
return ui->refmax->text().toInt();
}
double ManualControlDialogVFE::getRefMagnitude()
{
return ui->refmag->text().toDouble();
}
double ManualControlDialogVFE::getRefPhase()
{
return ui->refphase->text().toDouble();
}
void ManualControlDialogVFE::NewStatus(Protocol::ManualStatus status)
{
// ADC values
ui->portmin->setText(QString::number(status.VFE.portmin));
ui->portmax->setText(QString::number(status.VFE.portmax));
auto port = complex<double>(status.VFE.portreal, status.VFE.portimag);
ui->portmag->setText(QString::number(abs(port)));
ui->portphase->setText(QString::number(arg(port)*180/M_PI));
ui->refmin->setText(QString::number(status.VFE.refmin));
ui->refmax->setText(QString::number(status.VFE.refmax));
auto ref = complex<double>(status.VFE.refreal, status.VFE.refimag);
ui->refmag->setText(QString::number(abs(ref)));
ui->refphase->setText(QString::number(arg(ref)*180/M_PI));
portreferenced = port / ref;
auto portdb = Util::SparamTodB(portreferenced);
ui->portreferenced->setText(QString::number(portdb, 'f', 1) + "db@" + QString::number(arg(portreferenced)*180/M_PI, 'f', 0) + "°");
// PLL state
ui->SourceLocked->setChecked(status.VFE.source_locked);
ui->LOlocked->setChecked(status.VFE.LO_locked);
// eCal
ui->eCalTemp->setValue((double) status.VFE.temp_eCal / 100.0);
ui->eCalPower->setValue((double) status.VFE.power_heater / 1000.0);
}
void ManualControlDialogVFE::UpdateDevice()
{
Protocol::PacketInfo p;
p.type = Protocol::PacketType::ManualControl;
auto &m = p.manual.VFE;
// Source highband
m.SourceCE = ui->SourceCE->isChecked();
m.SourceRFEN = ui->SourceRFEN->isChecked();
m.SourceFrequency = ui->SourceFrequency->value();
m.SourceAmplifier1EN = ui->SourceAmplifier1Enable->isChecked();
m.SourceAmplifier2EN = ui->SourceAmplifier2Enable->isChecked();
m.attenuator = -ui->Attenuator->value() / 0.25;
// LO
m.LOCE = ui->LOCE->isChecked();
m.LORFEN = ui->LORFEN->isChecked();
m.LOFrequency = ui->LOFrequency->value();
// Acquisition
m.PortEN = ui->Port1Enable->isChecked();
m.PortGain = ui->portgain->currentIndex();
m.RefEN = ui->RefEnable->isChecked();
m.RefGain = ui->refgain->currentIndex();
m.Samples = ui->Samples->value();
m.WindowType = ui->cbWindow->currentIndex();
// eCal
m.eCal_state = ui->eCalState->currentIndex();
m.eCal_target = ui->eCalTarget->value() * 100;
qDebug() << "Updating manual control state";
dev.SendPacket(p);
}

View File

@ -0,0 +1,102 @@
#ifndef MANUALCONTROLDIALOGVFE_H
#define MANUALCONTROLDIALOGVFE_H
#include "librevnadriver.h"
#include <QDialog>
#include <complex>
namespace Ui {
class ManualControlDialogVFE;
}
class ManualControlDialogVFE : public QDialog
{
Q_OBJECT
public:
explicit ManualControlDialogVFE(LibreVNADriver &dev, QWidget *parent = nullptr);
~ManualControlDialogVFE();
void setSourceChipEnable(bool enable);
bool getSourceChipEnable();
void setSourceRFEnable(bool enable);
bool getSourceRFEnable();
bool getSourceLocked();
void setSourceFrequency(double f);
double getSourceFrequency();
void setAttenuator(double att);
double getAttenuator();
void setSourceAmplifier1Enable(bool enable);
bool getSourceAmplifier1Enable();
void setSourceAmplifier2Enable(bool enable);
bool getSourceAmplifier2Enable();
void setLOChipEnable(bool enable);
bool getLOChipEnable();
void setLORFEnable(bool enable);
bool getLORFEnable();
bool getLOLocked();
void setLOFrequency(double f);
double getLOFrequency();
void setIFFrequency(double f);
double getIFFrequency();
void setPortEnable(bool enable);
bool getPortEnable();
void setRefEnable(bool enable);
bool getRefEnable();
enum class Gain {
G1 = 0,
G10 = 1,
G20 = 2,
G30 = 3,
G40 = 4,
G60 = 5,
G80 = 6,
G120 = 7,
G157 = 8,
G0_25 = 9,
};
void setPortGain(Gain g);
Gain getPortGain();
void setRefGain(Gain g);
Gain getRefGain();
void setNumSamples(int samples);
int getNumSamples();
enum class Window {
None = 0,
Kaiser = 1,
Hann = 2,
FlatTop = 3
};
void setWindow(Window w);
Window getWindow();
int getPortMinADC();
int getPortMaxADC();
double getPortMagnitude();
double getPortPhase();
std::complex<double> getPortReferenced();
int getRefMinADC();
int getRefMaxADC();
double getRefMagnitude();
double getRefPhase();
public slots:
void NewStatus(Protocol::ManualStatus status);
private:
void UpdateDevice();
Ui::ManualControlDialogVFE *ui;
LibreVNADriver &dev;
std::complex<double> portreferenced;
};
#endif // MANUALCONTROLDIALOGVFE_H

View File

@ -0,0 +1,661 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ManualControlDialogVFE</class>
<widget class="QWidget" name="ManualControlDialogVFE">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>816</width>
<height>588</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
<string>Signal Generation</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Source</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QCheckBox" name="SourceCE">
<property name="text">
<string>Chip Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="SourceRFEN">
<property name="text">
<string>RF Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="SourceLocked">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Locked</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Frequency:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SIUnitEdit" name="SourceFrequency"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Attenuator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QDoubleSpinBox" name="Attenuator">
<property name="suffix">
<string>db</string>
</property>
<property name="minimum">
<double>-31.750000000000000</double>
</property>
<property name="maximum">
<double>0.000000000000000</double>
</property>
<property name="singleStep">
<double>0.250000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Amplifier</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QCheckBox" name="SourceAmplifier1Enable">
<property name="text">
<string>Enable Amp1</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="SourceAmplifier2Enable">
<property name="text">
<string>Enable Amp2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Signal Analysis</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>LO</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="LOCE">
<property name="text">
<string>Chip Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="LORFEN">
<property name="text">
<string>RF Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="LOlocked">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Locked</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Freq. Type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="LOFreqType">
<item>
<property name="text">
<string>IF</string>
</property>
</item>
<item>
<property name="text">
<string>Absolute</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Frequency:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SIUnitEdit" name="LOFrequency">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>IF1:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SIUnitEdit" name="IF"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Aquisition</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="Port1Enable">
<property name="text">
<string>Port Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="RefEnable">
<property name="text">
<string>Reference Enable</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="1">
<widget class="QComboBox" name="portgain">
<item>
<property name="text">
<string>1V/V</string>
</property>
</item>
<item>
<property name="text">
<string>10V/V</string>
</property>
</item>
<item>
<property name="text">
<string>20V/V</string>
</property>
</item>
<item>
<property name="text">
<string>30V/V</string>
</property>
</item>
<item>
<property name="text">
<string>40V/V</string>
</property>
</item>
<item>
<property name="text">
<string>60V/V</string>
</property>
</item>
<item>
<property name="text">
<string>80V/V</string>
</property>
</item>
<item>
<property name="text">
<string>120V/V</string>
</property>
</item>
<item>
<property name="text">
<string>157V/V</string>
</property>
</item>
<item>
<property name="text">
<string>0.25V/V</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="refgain">
<item>
<property name="text">
<string>1V/V</string>
</property>
</item>
<item>
<property name="text">
<string>10V/V</string>
</property>
</item>
<item>
<property name="text">
<string>20V/V</string>
</property>
</item>
<item>
<property name="text">
<string>30V/V</string>
</property>
</item>
<item>
<property name="text">
<string>40V/V</string>
</property>
</item>
<item>
<property name="text">
<string>60V/V</string>
</property>
</item>
<item>
<property name="text">
<string>80V/V</string>
</property>
</item>
<item>
<property name="text">
<string>120V/V</string>
</property>
</item>
<item>
<property name="text">
<string>157V/V</string>
</property>
</item>
<item>
<property name="text">
<string>0.25V/V</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Samples:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="Samples">
<property name="minimum">
<number>96</number>
</property>
<property name="maximum">
<number>16384</number>
</property>
<property name="singleStep">
<number>16</number>
</property>
<property name="value">
<number>16384</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Window:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="cbWindow">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Kaiser</string>
</property>
</item>
<item>
<property name="text">
<string>Hann</string>
</property>
</item>
<item>
<property name="text">
<string>Flat Top</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Reference PGA gain:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Port PGA gain:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>eCal</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Target temperature:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SIUnitEdit" name="eCalTarget"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>State:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="eCalState">
<item>
<property name="text">
<string>Port</string>
</property>
</item>
<item>
<property name="text">
<string>Open</string>
</property>
</item>
<item>
<property name="text">
<string>Short</string>
</property>
</item>
<item>
<property name="text">
<string>Load</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_12">
<property name="title">
<string>Measurements</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QGroupBox" name="groupBox_16">
<property name="title">
<string>Port</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<layout class="QFormLayout" name="formLayout_9">
<item row="0" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>ADC min:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="portmin"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>ADC max:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="portmax"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Magnitude:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="portmag"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>Phase:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="portphase"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Referenced:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="portreferenced"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_15">
<property name="title">
<string>Reference</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<layout class="QFormLayout" name="formLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>ADC min:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="refmin"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>ADC max:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="refmax"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Magnitude:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="refmag"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Phase:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="refphase"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>eCal</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Temperature:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SIUnitEdit" name="eCalTemp">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Heater Power:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SIUnitEdit" name="eCalPower">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SIUnitEdit</class>
<extends>QLineEdit</extends>
<header>CustomWidgets/siunitedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -207,6 +207,10 @@ void SignalgeneratorWidget::deviceInfoUpdated()
emit SettingsChanged(); emit SettingsChanged();
}); });
} }
setFrequency(ui->frequency->value());
setLevel(ui->levelSpin->value());
setPort(port); setPort(port);
ui->levelSlider->setMaximum(info.Limits.Generator.maxdBm * 100); ui->levelSlider->setMaximum(info.Limits.Generator.maxdBm * 100);
@ -217,7 +221,13 @@ void SignalgeneratorWidget::deviceInfoUpdated()
void SignalgeneratorWidget::setLevel(double level) void SignalgeneratorWidget::setLevel(double level)
{ {
// TODO constrain to frequency dependent levels auto info = DeviceDriver::getInfo(window->getDevice());
if(level < info.Limits.Generator.mindBm) {
level = info.Limits.Generator.mindBm;
}
if(level > info.Limits.Generator.maxdBm) {
level = info.Limits.Generator.maxdBm;
}
ui->levelSpin->blockSignals(true); ui->levelSpin->blockSignals(true);
ui->levelSlider->blockSignals(true); ui->levelSlider->blockSignals(true);
ui->levelSpin->setValue(level); ui->levelSpin->setValue(level);
@ -229,6 +239,13 @@ void SignalgeneratorWidget::setLevel(double level)
void SignalgeneratorWidget::setFrequency(double frequency) void SignalgeneratorWidget::setFrequency(double frequency)
{ {
auto info = DeviceDriver::getInfo(window->getDevice());
if(frequency < info.Limits.Generator.minFreq) {
frequency = info.Limits.Generator.minFreq;
}
if(frequency > info.Limits.Generator.maxFreq) {
frequency = info.Limits.Generator.maxFreq;
}
ui->frequency->setValue(frequency); ui->frequency->setValue(frequency);
} }

View File

@ -24,6 +24,7 @@ HEADERS += \
Device/LibreVNA/Compound/compounddriver.h \ Device/LibreVNA/Compound/compounddriver.h \
Device/LibreVNA/amplitudecaldialog.h \ Device/LibreVNA/amplitudecaldialog.h \
Device/LibreVNA/deviceconfigurationdialogv1.h \ Device/LibreVNA/deviceconfigurationdialogv1.h \
Device/LibreVNA/deviceconfigurationdialogvfe.h \
Device/LibreVNA/deviceconfigurationdialogvff.h \ Device/LibreVNA/deviceconfigurationdialogvff.h \
Device/LibreVNA/devicepacketlog.h \ Device/LibreVNA/devicepacketlog.h \
Device/LibreVNA/devicepacketlogview.h \ Device/LibreVNA/devicepacketlogview.h \
@ -33,6 +34,7 @@ HEADERS += \
Device/LibreVNA/librevnatcpdriver.h \ Device/LibreVNA/librevnatcpdriver.h \
Device/LibreVNA/librevnausbdriver.h \ Device/LibreVNA/librevnausbdriver.h \
Device/LibreVNA/manualcontroldialogV1.h \ Device/LibreVNA/manualcontroldialogV1.h \
Device/LibreVNA/manualcontroldialogvfe.h \
Device/LibreVNA/manualcontroldialogvff.h \ Device/LibreVNA/manualcontroldialogvff.h \
Device/LibreVNA/receivercaldialog.h \ Device/LibreVNA/receivercaldialog.h \
Device/LibreVNA/sourcecaldialog.h \ Device/LibreVNA/sourcecaldialog.h \
@ -182,6 +184,7 @@ SOURCES += \
Device/LibreVNA/Compound/compounddriver.cpp \ Device/LibreVNA/Compound/compounddriver.cpp \
Device/LibreVNA/amplitudecaldialog.cpp \ Device/LibreVNA/amplitudecaldialog.cpp \
Device/LibreVNA/deviceconfigurationdialogv1.cpp \ Device/LibreVNA/deviceconfigurationdialogv1.cpp \
Device/LibreVNA/deviceconfigurationdialogvfe.cpp \
Device/LibreVNA/deviceconfigurationdialogvff.cpp \ Device/LibreVNA/deviceconfigurationdialogvff.cpp \
Device/LibreVNA/devicepacketlog.cpp \ Device/LibreVNA/devicepacketlog.cpp \
Device/LibreVNA/devicepacketlogview.cpp \ Device/LibreVNA/devicepacketlogview.cpp \
@ -191,6 +194,7 @@ SOURCES += \
Device/LibreVNA/librevnatcpdriver.cpp \ Device/LibreVNA/librevnatcpdriver.cpp \
Device/LibreVNA/librevnausbdriver.cpp \ Device/LibreVNA/librevnausbdriver.cpp \
Device/LibreVNA/manualcontroldialogV1.cpp \ Device/LibreVNA/manualcontroldialogV1.cpp \
Device/LibreVNA/manualcontroldialogvfe.cpp \
Device/LibreVNA/manualcontroldialogvff.cpp \ Device/LibreVNA/manualcontroldialogvff.cpp \
Device/LibreVNA/receivercaldialog.cpp \ Device/LibreVNA/receivercaldialog.cpp \
Device/LibreVNA/sourcecaldialog.cpp \ Device/LibreVNA/sourcecaldialog.cpp \
@ -330,12 +334,14 @@ FORMS += \
Device/LibreVNA/amplitudecaldialog.ui \ Device/LibreVNA/amplitudecaldialog.ui \
Device/LibreVNA/automaticamplitudedialog.ui \ Device/LibreVNA/automaticamplitudedialog.ui \
Device/LibreVNA/deviceconfigurationdialogv1.ui \ Device/LibreVNA/deviceconfigurationdialogv1.ui \
Device/LibreVNA/deviceconfigurationdialogvfe.ui \
Device/LibreVNA/deviceconfigurationdialogvff.ui \ Device/LibreVNA/deviceconfigurationdialogvff.ui \
Device/LibreVNA/devicepacketlogview.ui \ Device/LibreVNA/devicepacketlogview.ui \
Device/LibreVNA/firmwareupdatedialog.ui \ Device/LibreVNA/firmwareupdatedialog.ui \
Device/LibreVNA/frequencycaldialog.ui \ Device/LibreVNA/frequencycaldialog.ui \
Device/LibreVNA/librevnadriversettingswidget.ui \ Device/LibreVNA/librevnadriversettingswidget.ui \
Device/LibreVNA/manualcontroldialogV1.ui \ Device/LibreVNA/manualcontroldialogV1.ui \
Device/LibreVNA/manualcontroldialogvfe.ui \
Device/LibreVNA/manualcontroldialogvff.ui \ Device/LibreVNA/manualcontroldialogvff.ui \
Device/devicelog.ui \ Device/devicelog.ui \
Device/devicetcpdriversettings.ui \ Device/devicetcpdriversettings.ui \

View File

@ -27,6 +27,7 @@ SOURCES += \
../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \
../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.cpp \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.cpp \
../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp \
../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp \
@ -34,6 +35,7 @@ SOURCES += \
../LibreVNA-GUI/Device/LibreVNA/librevnatcpdriver.cpp \ ../LibreVNA-GUI/Device/LibreVNA/librevnatcpdriver.cpp \
../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp \ ../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.cpp \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.cpp \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.cpp \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.cpp \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.cpp \
../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp \
../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp \
@ -203,6 +205,7 @@ HEADERS += \
../LibreVNA-GUI/CustomWidgets/tracesetselector.h \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.h \
../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.h \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.h \
../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h \
../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h \
@ -210,6 +213,7 @@ HEADERS += \
../LibreVNA-GUI/Device/LibreVNA/librevnatcpdriver.h \ ../LibreVNA-GUI/Device/LibreVNA/librevnatcpdriver.h \
../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h \ ../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.h \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.h \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.h \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.h \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.h \
../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h \
../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h \
@ -364,12 +368,14 @@ FORMS += \
../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui \
../LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.ui \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui \
../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.ui \
../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui \
../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.ui \
../LibreVNA-GUI/Device/LibreVNA/librevnadriversettingswidget.ui \ ../LibreVNA-GUI/Device/LibreVNA/librevnadriversettingswidget.ui \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.ui \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.ui \
../LibreVNA-GUI/Device/LibreVNA/Compound/compounddeviceeditdialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/Compound/compounddeviceeditdialog.ui \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.ui \
../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.ui \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.ui \
../LibreVNA-GUI/Device/devicelog.ui \ ../LibreVNA-GUI/Device/devicelog.ui \
../LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.ui \ ../LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.ui \

View File

@ -238,6 +238,15 @@ using DeviceStatus = struct _deviceStatus {
uint8_t unlevel:1; uint8_t unlevel:1;
uint8_t temp_MCU; uint8_t temp_MCU;
} VFF; } VFF;
struct {
uint8_t source_locked:1;
uint8_t LO_locked:1;
uint8_t ADC_overload:1;
uint8_t unlevel:1;
uint8_t temp_MCU;
uint16_t temp_eCal; // in 1/100 °C
uint16_t power_heater; // in mW
} VFE;
}; };
}; };
@ -264,6 +273,16 @@ using ManualStatus = struct _manualstatus {
uint8_t source_locked :1; uint8_t source_locked :1;
uint8_t LO_locked :1; uint8_t LO_locked :1;
} VFF; } VFF;
struct {
int16_t portmin, portmax;
int16_t refmin, refmax;
float portreal, portimag;
float refreal, refimag;
uint8_t source_locked :1;
uint8_t LO_locked :1;
uint16_t temp_eCal; // in 1/100 °C
uint16_t power_heater; // in mW
} VFE;
}; };
}; };
@ -322,6 +341,30 @@ using ManualControl = struct _manualControl {
uint16_t RefGain :4; uint16_t RefGain :4;
uint16_t Samples; uint16_t Samples;
} VFF; } VFF;
struct {
// Source
uint8_t SourceCE :1;
uint8_t SourceRFEN :1;
uint64_t SourceFrequency;
// Source signal path
uint8_t attenuator :7;
uint8_t SourceAmplifier1EN :1;
uint8_t SourceAmplifier2EN :1;
// LO
uint8_t LOCE :1;
uint8_t LORFEN :1;
uint64_t LOFrequency;
// Acquisition
uint16_t PortEN :1;
uint16_t RefEN :1;
uint16_t WindowType :2;
uint16_t PortGain :4;
uint16_t RefGain :4;
uint16_t Samples;
// other settings
uint8_t eCal_state :2;
uint16_t eCal_target; // in 1/100 °C
} VFE;
}; };
}; };
@ -405,6 +448,11 @@ using DeviceConfig = struct _deviceconfig {
uint16_t portGain :4; uint16_t portGain :4;
uint16_t refGain :4; uint16_t refGain :4;
} VFF; } VFF;
struct {
uint16_t autogain :1;
uint16_t portGain :4;
uint16_t refGain :4;
} VFE;
}; };
}; };