LibreVNA/Software/PC_Application/Calibration/calkit.h
2022-08-28 22:06:16 +02:00

73 lines
2.0 KiB
C++

#ifndef CALKIT_H
#define CALKIT_H
#include "touchstone.h"
#include "Util/qpointervariant.h"
#include "calstandard.h"
#include "savable.h"
#include <string>
#include <complex>
#include <QDir>
class Calkit : public Savable
{
friend class CalkitDialog;
public:
Calkit();
Calkit(const Calkit&) = default;
Calkit& operator=(const Calkit& other)
{
this->manufacturer = other.manufacturer;
this->serialnumber = other.serialnumber;
this->description = other.description;
this->standards = other.standards;
return *this;
}
class SOLT {
public:
std::complex<double> Open;
std::complex<double> Short;
std::complex<double> Load;
std::complex<double> ThroughS11, ThroughS12, ThroughS21, ThroughS22;
};
class TRL {
public:
bool reflectionIsNegative;
std::complex<double> ThroughS11, ThroughS12, ThroughS21, ThroughS22;
};
void toFile(QString filename);
static Calkit fromFile(QString filename);
void edit(std::function<void(void)> updateCal = nullptr);
bool hasSeparateMaleFemaleStandards();
SOLT toSOLT(double frequency, bool male_standards = true);
TRL toTRL(double frequency);
double minFreqTRL();
double maxFreqTRL();
double minFreqSOLT(bool male_standards = true);
double maxFreqSOLT(bool male_standards = true);
bool checkIfValid(double min_freq, double max_freq, bool isTRL, bool include_male, bool include_female);
bool isTRLReflectionShort() const;
std::vector<CalStandard::Virtual *> getStandards() const;
virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override;
private:
void clearStandards();
QString manufacturer, serialnumber, description;
std::vector<CalStandard::Virtual*> standards;
const std::vector<Savable::SettingDescription> descr = {{
{&manufacturer, "Manufacturer", ""},
{&serialnumber, "Serialnumber", ""},
{&description, "Description", ""},
}};
};
#endif // CALKIT_H