mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 14:07:30 +00:00
Include mode/sweep/acquisition settings in setup files
This commit is contained in:
parent
cf22f40630
commit
68dc9842e9
13 changed files with 316 additions and 19 deletions
|
|
@ -40,6 +40,19 @@ void Generator::initializeDevice()
|
|||
updateDevice();
|
||||
}
|
||||
|
||||
nlohmann::json Generator::toJSON()
|
||||
{
|
||||
return central->toJSON();
|
||||
}
|
||||
|
||||
void Generator::fromJSON(nlohmann::json j)
|
||||
{
|
||||
if(j.is_null()) {
|
||||
return;
|
||||
}
|
||||
central->fromJSON(j);
|
||||
}
|
||||
|
||||
void Generator::updateDevice()
|
||||
{
|
||||
if(!window->getDevice() || Mode::getActiveMode() != this) {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ public:
|
|||
void initializeDevice() override;
|
||||
|
||||
// Nothing to do for now
|
||||
virtual nlohmann::json toJSON() override {return nlohmann::json();};
|
||||
virtual void fromJSON(nlohmann::json j) override {Q_UNUSED(j)};
|
||||
virtual nlohmann::json toJSON() override;
|
||||
virtual void fromJSON(nlohmann::json j) override;
|
||||
|
||||
private slots:
|
||||
void updateDevice();
|
||||
|
|
|
|||
|
|
@ -157,6 +157,44 @@ Protocol::GeneratorSettings SignalgeneratorWidget::getDeviceStatus()
|
|||
return s;
|
||||
}
|
||||
|
||||
nlohmann::json SignalgeneratorWidget::toJSON()
|
||||
{
|
||||
nlohmann::json j;
|
||||
j["frequency"] = ui->frequency->value();
|
||||
j["power"] = ui->levelSpin->value();
|
||||
if(ui->EnablePort1->isChecked()) {
|
||||
j["port"] = 1;
|
||||
} else if(ui->EnablePort2->isChecked()) {
|
||||
j["port"] = 2;
|
||||
} else {
|
||||
j["port"] = 0;
|
||||
}
|
||||
nlohmann::json sweep;
|
||||
sweep["span"] = ui->span->value();
|
||||
sweep["steps"] = ui->steps->value();
|
||||
sweep["dwell"] = ui->dwell->value();
|
||||
sweep["enabled"] = ui->EnabledSweep->isChecked();
|
||||
j["sweep"] = sweep;
|
||||
return j;
|
||||
}
|
||||
|
||||
void SignalgeneratorWidget::fromJSON(nlohmann::json j)
|
||||
{
|
||||
setFrequency(j.value("frequency", ui->frequency->value()));
|
||||
setLevel(j.value("power", ui->levelSpin->value()));
|
||||
setPort(j.value("port", 0));
|
||||
if(j.contains("sweep")) {
|
||||
auto sweep = j["sweep"];
|
||||
// extract sweep settings, keeping current values as default
|
||||
ui->span->setValue(sweep.value("span", ui->span->value()));
|
||||
ui->steps->setValue(sweep.value("steps", ui->steps->value()));
|
||||
ui->dwell->setValue(sweep.value("dwell", ui->dwell->value()));
|
||||
ui->EnabledSweep->setChecked(sweep.value("enabled", false));
|
||||
} else {
|
||||
ui->EnabledSweep->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SignalgeneratorWidget::setLevel(double level)
|
||||
{
|
||||
// TODO constrain to frequency dependent levels
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include "Device/device.h"
|
||||
#include "savable.h"
|
||||
|
||||
namespace Ui {
|
||||
class SignalgeneratorWidget;
|
||||
}
|
||||
|
||||
class SignalgeneratorWidget : public QWidget
|
||||
class SignalgeneratorWidget : public QWidget, public Savable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -17,6 +18,8 @@ public:
|
|||
~SignalgeneratorWidget();
|
||||
|
||||
Protocol::GeneratorSettings getDeviceStatus();
|
||||
virtual nlohmann::json toJSON() override;
|
||||
virtual void fromJSON(nlohmann::json j) override;
|
||||
|
||||
signals:
|
||||
void SettingsChanged();
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="SIUnitEdit" name="span">
|
||||
<property name="text">
|
||||
<string>0MHz</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -195,7 +195,7 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="SIUnitEdit" name="steps">
|
||||
<property name="text">
|
||||
<string>100</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -209,7 +209,7 @@
|
|||
<item row="2" column="1">
|
||||
<widget class="SIUnitEdit" name="dwell">
|
||||
<property name="text">
|
||||
<string>100ms</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -226,7 +226,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0MHz</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue