LibreVNA/Software/PC_Application/VNA/vna.h

115 lines
3.1 KiB
C
Raw Normal View History

#ifndef VNA_H
#define VNA_H
#include <QObject>
#include <QWidget>
#include "appwindow.h"
#include "mode.h"
#include "CustomWidgets/tilewidget.h"
#include "Device/device.h"
#include <functional>
#include "Deembedding/deembedding.h"
#include "scpi.h"
class VNA : public Mode, public SCPINode
{
Q_OBJECT
public:
VNA(AppWindow *window);
void deactivate() override;
void initializeDevice() override;
2020-09-14 00:01:32 +08:00
void deviceDisconnected() override;
void shutdown() override;
2020-12-05 06:49:52 +08:00
// Only save/load user changeable stuff, no need to save the widgets/mode name etc.
virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override;
private slots:
void NewDatapoint(Protocol::Datapoint d);
void StartImpedanceMatching();
// Sweep control
void SetStartFreq(double freq);
void SetStopFreq(double freq);
void SetCenterFreq(double freq);
void SetSpan(double span);
void SetFullSpan();
void SpanZoomIn();
void SpanZoomOut();
// Acquisition control
void SetSourceLevel(double level);
void SetPoints(unsigned int points);
void SetIFBandwidth(double bandwidth);
void SetAveraging(unsigned int averages);
void ExcitationRequired(bool port1, bool port2);
// Calibration
void DisableCalibration(bool force = false);
void ApplyCalibration(Calibration::Type type);
void StartCalibrationMeasurement(Calibration::Measurement m);
signals:
void CalibrationMeasurementComplete(Calibration::Measurement m);
private:
void SetupSCPI();
2020-10-23 17:39:07 +08:00
void UpdateAverageCount();
void SettingsChanged(std::function<void (Device::TransmissionResult)> cb = nullptr);
void ConstrainAndUpdateFrequencies();
void LoadSweepSettings();
void StoreSweepSettings();
void StopSweep();
void StartCalibrationDialog(Calibration::Type type = Calibration::Type::None);
void UpdateCalWidget();
private slots:
void EnableDeembedding(bool enable);
private:
Protocol::SweepSettings settings;
unsigned int averages;
TraceModel traceModel;
TraceMarkerModel *markerModel;
Averaging average;
// Calibration
Calibration cal;
bool calValid;
bool calEdited;
Calibration::Measurement calMeasurement;
bool calMeasuring;
bool calWaitFirst;
QProgressDialog calDialog;
2020-12-07 23:04:59 +08:00
QString getCalStyle();
QString getCalToolTip();
2020-09-14 00:01:32 +08:00
QMenu *defaultCalMenu;
QAction *assignDefaultCal, *removeDefaultCal;
QAction *saveCal;
2020-09-14 00:01:32 +08:00
Deembedding deembedding;
QAction *enableDeembeddingAction;
bool deembedding_active;
2020-10-31 23:52:59 +08:00
// Status Labels
QLabel *lAverages;
QLabel *calLabel;
TileWidget *central;
signals:
void dataChanged();
void startFreqChanged(double freq);
void stopFreqChanged(double freq);
void centerFreqChanged(double freq);
void spanChanged(double span);
void sourceLevelChanged(double level);
void pointsChanged(unsigned int points);
void IFBandwidthChanged(double bandwidth);
void averagingChanged(unsigned int averages);
void CalibrationDisabled();
void CalibrationApplied(Calibration::Type type);
};
#endif // VNA_H