Sweep function added
This commit is contained in:
parent
631b7e6d40
commit
cfde664b6c
@ -223,8 +223,6 @@ SOURCES += \
|
||||
unit.cpp
|
||||
|
||||
LIBS += -lusb-1.0
|
||||
unix:LIBS += -L/usr/lib/
|
||||
win32:LIBS += -L"$$_PRO_FILE_PWD_" # Github actions placed libusb here
|
||||
|
||||
QT += widgets
|
||||
|
||||
|
@ -14,8 +14,10 @@ public:
|
||||
// Nothing to do for now
|
||||
virtual nlohmann::json toJSON() override {return nlohmann::json();};
|
||||
virtual void fromJSON(nlohmann::json j) override {Q_UNUSED(j)};
|
||||
|
||||
private slots:
|
||||
void updateDevice();
|
||||
|
||||
private:
|
||||
SignalgeneratorWidget *central;
|
||||
};
|
||||
|
@ -10,6 +10,24 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
|
||||
ui->frequency->setPrefixes(" kMG");
|
||||
ui->frequency->setPrecision(6); // show enough digits
|
||||
|
||||
ui->span->setUnit("Hz");
|
||||
ui->span->setPrefixes(" kMG");
|
||||
ui->span->setPrecision(6); // show enough digits
|
||||
|
||||
ui->current->setUnit("Hz");
|
||||
ui->current->setPrefixes(" kMG");
|
||||
ui->current->setPrecision(6); // show enough digits
|
||||
|
||||
ui->dwell->setUnit("s");
|
||||
ui->dwell->setPrefixes(" m");
|
||||
ui->dwell->setPrecision(6); // show enough digits
|
||||
ui->dwell->setValueQuiet(1);
|
||||
m_timerId = startTimer(1000);
|
||||
|
||||
ui->steps->setValueQuiet(100);
|
||||
ui->steps->setPrefixes(" k");
|
||||
ui->steps->setPrecision(0);
|
||||
|
||||
connect(ui->frequency, &SIUnitEdit::valueChanged, [=](double newval) {
|
||||
if(newval < Device::Info().limits_minFreq) {
|
||||
newval = Device::Info().limits_minFreq;
|
||||
@ -19,6 +37,44 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
|
||||
ui->frequency->setValueQuiet(newval);
|
||||
emit SettingsChanged();
|
||||
});
|
||||
|
||||
connect(ui->span, &SIUnitEdit::valueChanged, [=](double newval) {
|
||||
if(newval < 0 ) {
|
||||
newval = 0;
|
||||
} else if (newval > Device::Info().limits_maxFreq - Device::Info().limits_minFreq) {
|
||||
newval = Device::Info().limits_maxFreq - Device::Info().limits_minFreq;
|
||||
}
|
||||
ui->span->setValueQuiet(newval);
|
||||
|
||||
double newF = ui->frequency->value() - ui->span->value()/2;
|
||||
if (newF < 0) {
|
||||
ui->frequency->setValueQuiet(ui->frequency->value() - newF);
|
||||
}
|
||||
|
||||
emit SettingsChanged();
|
||||
});
|
||||
|
||||
connect(ui->current, &SIUnitEdit::valueChanged, [=](double newval) {
|
||||
if(newval < 0 ) {
|
||||
newval = 0;
|
||||
} else if (newval > Device::Info().limits_maxFreq - Device::Info().limits_minFreq) {
|
||||
newval = Device::Info().limits_maxFreq - Device::Info().limits_minFreq;
|
||||
}
|
||||
ui->current->setValueQuiet(newval);
|
||||
emit SettingsChanged();
|
||||
});
|
||||
|
||||
connect(ui->dwell, &SIUnitEdit::valueChanged, [=](double newval) {
|
||||
if(newval < 0 ) {
|
||||
newval = 0;
|
||||
} else if (newval > 60) {
|
||||
newval = 60;
|
||||
}
|
||||
ui->dwell->setValueQuiet(newval);
|
||||
m_timerId = startTimer(newval*1000);
|
||||
emit SettingsChanged();
|
||||
});
|
||||
|
||||
connect(ui->levelSpin, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &SignalgeneratorWidget::setLevel);
|
||||
connect(ui->levelSlider, &QSlider::valueChanged, [=](int value) {
|
||||
setLevel((double) value / 100.0);
|
||||
@ -35,17 +91,46 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
|
||||
}
|
||||
emit SettingsChanged();
|
||||
});
|
||||
connect(ui->EnabledSweep, &QCheckBox::clicked, [=](){
|
||||
if(ui->EnabledSweep->isChecked()) {
|
||||
double newF = ui->frequency->value() - ui->span->value()/2;
|
||||
if (newF < 0) {
|
||||
ui->frequency->setValueQuiet(ui->frequency->value() - newF);
|
||||
newF = 0;
|
||||
}
|
||||
ui->current->setValueQuiet(newF);
|
||||
} else {
|
||||
}
|
||||
emit SettingsChanged();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
SignalgeneratorWidget::~SignalgeneratorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SignalgeneratorWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == m_timerId) {
|
||||
if (ui->EnabledSweep->isChecked()) {
|
||||
double newF = ui->current->value() + ui->span->value()/ui->steps->value();
|
||||
if (newF > ui->frequency->value() + ui->span->value()/2)
|
||||
newF = ui->frequency->value() - ui->span->value()/2;
|
||||
ui->current->setValueQuiet(newF);
|
||||
SettingsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Protocol::GeneratorSettings SignalgeneratorWidget::getDeviceStatus()
|
||||
{
|
||||
Protocol::GeneratorSettings s = {};
|
||||
s.frequency = ui->frequency->value();
|
||||
if (ui->EnabledSweep->isChecked())
|
||||
s.frequency = ui->current->value();
|
||||
else
|
||||
s.frequency = ui->frequency->value();
|
||||
s.cdbm_level = ui->levelSpin->value() * 100.0;
|
||||
if(ui->EnablePort1->isChecked()) {
|
||||
s.activePort = 1;
|
||||
|
@ -24,8 +24,13 @@ signals:
|
||||
public slots:
|
||||
void setLevel(double level);
|
||||
void setFrequency(double frequency);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
|
||||
private:
|
||||
Ui::SignalgeneratorWidget *ui;
|
||||
int m_timerId;
|
||||
};
|
||||
|
||||
#endif // SIGNALGENERATOR_H
|
||||
|
@ -30,7 +30,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>197</width>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -38,19 +38,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
@ -157,17 +144,128 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Sweep</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="SIUnitEdit" name="span">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>40</y>
|
||||
<width>133</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0MHz</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>47</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Span:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SIUnitEdit" name="steps">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>70</y>
|
||||
<width>133</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>100</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>47</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Steps:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>47</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dwell:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SIUnitEdit" name="dwell">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>100</y>
|
||||
<width>133</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>100ms</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="EnabledSweep">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>10</y>
|
||||
<width>101</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>47</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Current:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SIUnitEdit" name="current">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>130</y>
|
||||
<width>133</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0MHz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -178,7 +276,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>196</width>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
|
Loading…
Reference in New Issue
Block a user