/** * Jungfraujoch * API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates. * * The version of the OpenAPI document: 1.0.0-rc.25 * Contact: filip.leonarski@psi.ch * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ #include "Detector.h" #include "Helpers.h" #include namespace org::openapitools::server::model { Detector::Detector() { m_Description = ""; m_Serial_number = ""; m_TypeIsSet = false; m_High_voltage_V = 0L; m_High_voltage_VIsSet = false; m_Udp_interface_count = 1L; m_Udp_interface_countIsSet = false; m_Module_sync = true; m_Module_syncIsSet = false; m_Sensor_thickness_um = 320.0f; m_Sensor_thickness_umIsSet = false; m_Calibration_fileIsSet = false; m_HostnameIsSet = false; m_Sensor_material = "Si"; m_Sensor_materialIsSet = false; m_Tx_delayIsSet = false; m_Base_data_ipv4_address = ""; m_Base_data_ipv4_addressIsSet = false; m_Standard_geometryIsSet = false; m_Custom_geometryIsSet = false; m_Mirror_y = true; m_Mirror_yIsSet = false; } void Detector::validate() const { std::stringstream msg; if (!validate(msg)) { throw org::openapitools::server::helpers::ValidationException(msg.str()); } } bool Detector::validate(std::stringstream& msg) const { return validate(msg, ""); } bool Detector::validate(std::stringstream& msg, const std::string& pathPrefix) const { bool success = true; const std::string _pathPrefix = pathPrefix.empty() ? "Detector" : pathPrefix; /* Description */ { const std::string& value = m_Description; const std::string currentValuePath = _pathPrefix + ".description"; if (value.length() < 1) { success = false; msg << currentValuePath << ": must be at least 1 characters long;"; } } /* Serial_number */ { const std::string& value = m_Serial_number; const std::string currentValuePath = _pathPrefix + ".serialNumber"; if (value.length() < 1) { success = false; msg << currentValuePath << ": must be at least 1 characters long;"; } } if (highVoltageVIsSet()) { const int64_t& value = m_High_voltage_V; const std::string currentValuePath = _pathPrefix + ".highVoltageV"; if (value < 0ll) { success = false; msg << currentValuePath << ": must be greater than or equal to 0;"; } if (value > 200ll) { success = false; msg << currentValuePath << ": must be less than or equal to 200;"; } } if (udpInterfaceCountIsSet()) { const int64_t& value = m_Udp_interface_count; const std::string currentValuePath = _pathPrefix + ".udpInterfaceCount"; if (value < 1ll) { success = false; msg << currentValuePath << ": must be greater than or equal to 1;"; } if (value > 2ll) { success = false; msg << currentValuePath << ": must be less than or equal to 2;"; } } if (sensorThicknessUmIsSet()) { const float& value = m_Sensor_thickness_um; const std::string currentValuePath = _pathPrefix + ".sensorThicknessUm"; if (value < static_cast(0)) { success = false; msg << currentValuePath << ": must be greater than or equal to 0;"; } } if (calibrationFileIsSet()) { const std::vector& value = m_Calibration_file; const std::string currentValuePath = _pathPrefix + ".calibrationFile"; { // Recursive validation of array elements const std::string oldValuePath = currentValuePath; int i = 0; for (const std::string& value : value) { const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; i++; } } } if (hostnameIsSet()) { const std::vector& value = m_Hostname; const std::string currentValuePath = _pathPrefix + ".hostname"; { // Recursive validation of array elements const std::string oldValuePath = currentValuePath; int i = 0; for (const std::string& value : value) { const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; i++; } } } if (txDelayIsSet()) { const std::vector& value = m_Tx_delay; const std::string currentValuePath = _pathPrefix + ".txDelay"; { // Recursive validation of array elements const std::string oldValuePath = currentValuePath; int i = 0; for (const int64_t& value : value) { const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; i++; } } } if (customGeometryIsSet()) { const std::vector& value = m_Custom_geometry; const std::string currentValuePath = _pathPrefix + ".customGeometry"; { // Recursive validation of array elements const std::string oldValuePath = currentValuePath; int i = 0; for (const org::openapitools::server::model::Detector_module& value : value) { const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; success = value.validate(msg, currentValuePath + ".customGeometry") && success; i++; } } } return success; } bool Detector::operator==(const Detector& rhs) const { return (getDescription() == rhs.getDescription()) && (getSerialNumber() == rhs.getSerialNumber()) && ((!typeIsSet() && !rhs.typeIsSet()) || (typeIsSet() && rhs.typeIsSet() && getType() == rhs.getType())) && ((!highVoltageVIsSet() && !rhs.highVoltageVIsSet()) || (highVoltageVIsSet() && rhs.highVoltageVIsSet() && getHighVoltageV() == rhs.getHighVoltageV())) && ((!udpInterfaceCountIsSet() && !rhs.udpInterfaceCountIsSet()) || (udpInterfaceCountIsSet() && rhs.udpInterfaceCountIsSet() && getUdpInterfaceCount() == rhs.getUdpInterfaceCount())) && ((!moduleSyncIsSet() && !rhs.moduleSyncIsSet()) || (moduleSyncIsSet() && rhs.moduleSyncIsSet() && isModuleSync() == rhs.isModuleSync())) && ((!sensorThicknessUmIsSet() && !rhs.sensorThicknessUmIsSet()) || (sensorThicknessUmIsSet() && rhs.sensorThicknessUmIsSet() && getSensorThicknessUm() == rhs.getSensorThicknessUm())) && ((!calibrationFileIsSet() && !rhs.calibrationFileIsSet()) || (calibrationFileIsSet() && rhs.calibrationFileIsSet() && getCalibrationFile() == rhs.getCalibrationFile())) && ((!hostnameIsSet() && !rhs.hostnameIsSet()) || (hostnameIsSet() && rhs.hostnameIsSet() && getHostname() == rhs.getHostname())) && ((!sensorMaterialIsSet() && !rhs.sensorMaterialIsSet()) || (sensorMaterialIsSet() && rhs.sensorMaterialIsSet() && getSensorMaterial() == rhs.getSensorMaterial())) && ((!txDelayIsSet() && !rhs.txDelayIsSet()) || (txDelayIsSet() && rhs.txDelayIsSet() && getTxDelay() == rhs.getTxDelay())) && ((!baseDataIpv4AddressIsSet() && !rhs.baseDataIpv4AddressIsSet()) || (baseDataIpv4AddressIsSet() && rhs.baseDataIpv4AddressIsSet() && getBaseDataIpv4Address() == rhs.getBaseDataIpv4Address())) && ((!standardGeometryIsSet() && !rhs.standardGeometryIsSet()) || (standardGeometryIsSet() && rhs.standardGeometryIsSet() && getStandardGeometry() == rhs.getStandardGeometry())) && ((!customGeometryIsSet() && !rhs.customGeometryIsSet()) || (customGeometryIsSet() && rhs.customGeometryIsSet() && getCustomGeometry() == rhs.getCustomGeometry())) && ((!mirrorYIsSet() && !rhs.mirrorYIsSet()) || (mirrorYIsSet() && rhs.mirrorYIsSet() && isMirrorY() == rhs.isMirrorY())) ; } bool Detector::operator!=(const Detector& rhs) const { return !(*this == rhs); } void to_json(nlohmann::json& j, const Detector& o) { j = nlohmann::json::object(); j["description"] = o.m_Description; j["serial_number"] = o.m_Serial_number; if(o.typeIsSet()) j["type"] = o.m_Type; if(o.highVoltageVIsSet()) j["high_voltage_V"] = o.m_High_voltage_V; if(o.udpInterfaceCountIsSet()) j["udp_interface_count"] = o.m_Udp_interface_count; if(o.moduleSyncIsSet()) j["module_sync"] = o.m_Module_sync; if(o.sensorThicknessUmIsSet()) j["sensor_thickness_um"] = o.m_Sensor_thickness_um; if(o.calibrationFileIsSet() || !o.m_Calibration_file.empty()) j["calibration_file"] = o.m_Calibration_file; if(o.hostnameIsSet() || !o.m_Hostname.empty()) j["hostname"] = o.m_Hostname; if(o.sensorMaterialIsSet()) j["sensor_material"] = o.m_Sensor_material; if(o.txDelayIsSet() || !o.m_Tx_delay.empty()) j["tx_delay"] = o.m_Tx_delay; if(o.baseDataIpv4AddressIsSet()) j["base_data_ipv4_address"] = o.m_Base_data_ipv4_address; if(o.standardGeometryIsSet()) j["standard_geometry"] = o.m_Standard_geometry; if(o.customGeometryIsSet() || !o.m_Custom_geometry.empty()) j["custom_geometry"] = o.m_Custom_geometry; if(o.mirrorYIsSet()) j["mirror_y"] = o.m_Mirror_y; } void from_json(const nlohmann::json& j, Detector& o) { j.at("description").get_to(o.m_Description); j.at("serial_number").get_to(o.m_Serial_number); if(j.find("type") != j.end()) { j.at("type").get_to(o.m_Type); o.m_TypeIsSet = true; } if(j.find("high_voltage_V") != j.end()) { j.at("high_voltage_V").get_to(o.m_High_voltage_V); o.m_High_voltage_VIsSet = true; } if(j.find("udp_interface_count") != j.end()) { j.at("udp_interface_count").get_to(o.m_Udp_interface_count); o.m_Udp_interface_countIsSet = true; } if(j.find("module_sync") != j.end()) { j.at("module_sync").get_to(o.m_Module_sync); o.m_Module_syncIsSet = true; } if(j.find("sensor_thickness_um") != j.end()) { j.at("sensor_thickness_um").get_to(o.m_Sensor_thickness_um); o.m_Sensor_thickness_umIsSet = true; } if(j.find("calibration_file") != j.end()) { j.at("calibration_file").get_to(o.m_Calibration_file); o.m_Calibration_fileIsSet = true; } if(j.find("hostname") != j.end()) { j.at("hostname").get_to(o.m_Hostname); o.m_HostnameIsSet = true; } if(j.find("sensor_material") != j.end()) { j.at("sensor_material").get_to(o.m_Sensor_material); o.m_Sensor_materialIsSet = true; } if(j.find("tx_delay") != j.end()) { j.at("tx_delay").get_to(o.m_Tx_delay); o.m_Tx_delayIsSet = true; } if(j.find("base_data_ipv4_address") != j.end()) { j.at("base_data_ipv4_address").get_to(o.m_Base_data_ipv4_address); o.m_Base_data_ipv4_addressIsSet = true; } if(j.find("standard_geometry") != j.end()) { j.at("standard_geometry").get_to(o.m_Standard_geometry); o.m_Standard_geometryIsSet = true; } if(j.find("custom_geometry") != j.end()) { j.at("custom_geometry").get_to(o.m_Custom_geometry); o.m_Custom_geometryIsSet = true; } if(j.find("mirror_y") != j.end()) { j.at("mirror_y").get_to(o.m_Mirror_y); o.m_Mirror_yIsSet = true; } } std::string Detector::getDescription() const { return m_Description; } void Detector::setDescription(std::string const& value) { m_Description = value; } std::string Detector::getSerialNumber() const { return m_Serial_number; } void Detector::setSerialNumber(std::string const& value) { m_Serial_number = value; } org::openapitools::server::model::Detector_type Detector::getType() const { return m_Type; } void Detector::setType(org::openapitools::server::model::Detector_type const& value) { m_Type = value; m_TypeIsSet = true; } bool Detector::typeIsSet() const { return m_TypeIsSet; } void Detector::unsetType() { m_TypeIsSet = false; } int64_t Detector::getHighVoltageV() const { return m_High_voltage_V; } void Detector::setHighVoltageV(int64_t const value) { m_High_voltage_V = value; m_High_voltage_VIsSet = true; } bool Detector::highVoltageVIsSet() const { return m_High_voltage_VIsSet; } void Detector::unsetHigh_voltage_V() { m_High_voltage_VIsSet = false; } int64_t Detector::getUdpInterfaceCount() const { return m_Udp_interface_count; } void Detector::setUdpInterfaceCount(int64_t const value) { m_Udp_interface_count = value; m_Udp_interface_countIsSet = true; } bool Detector::udpInterfaceCountIsSet() const { return m_Udp_interface_countIsSet; } void Detector::unsetUdp_interface_count() { m_Udp_interface_countIsSet = false; } bool Detector::isModuleSync() const { return m_Module_sync; } void Detector::setModuleSync(bool const value) { m_Module_sync = value; m_Module_syncIsSet = true; } bool Detector::moduleSyncIsSet() const { return m_Module_syncIsSet; } void Detector::unsetModule_sync() { m_Module_syncIsSet = false; } float Detector::getSensorThicknessUm() const { return m_Sensor_thickness_um; } void Detector::setSensorThicknessUm(float const value) { m_Sensor_thickness_um = value; m_Sensor_thickness_umIsSet = true; } bool Detector::sensorThicknessUmIsSet() const { return m_Sensor_thickness_umIsSet; } void Detector::unsetSensor_thickness_um() { m_Sensor_thickness_umIsSet = false; } std::vector Detector::getCalibrationFile() const { return m_Calibration_file; } void Detector::setCalibrationFile(std::vector const& value) { m_Calibration_file = value; m_Calibration_fileIsSet = true; } bool Detector::calibrationFileIsSet() const { return m_Calibration_fileIsSet; } void Detector::unsetCalibration_file() { m_Calibration_fileIsSet = false; } std::vector Detector::getHostname() const { return m_Hostname; } void Detector::setHostname(std::vector const& value) { m_Hostname = value; m_HostnameIsSet = true; } bool Detector::hostnameIsSet() const { return m_HostnameIsSet; } void Detector::unsetHostname() { m_HostnameIsSet = false; } std::string Detector::getSensorMaterial() const { return m_Sensor_material; } void Detector::setSensorMaterial(std::string const& value) { m_Sensor_material = value; m_Sensor_materialIsSet = true; } bool Detector::sensorMaterialIsSet() const { return m_Sensor_materialIsSet; } void Detector::unsetSensor_material() { m_Sensor_materialIsSet = false; } std::vector Detector::getTxDelay() const { return m_Tx_delay; } void Detector::setTxDelay(std::vector const value) { m_Tx_delay = value; m_Tx_delayIsSet = true; } bool Detector::txDelayIsSet() const { return m_Tx_delayIsSet; } void Detector::unsetTx_delay() { m_Tx_delayIsSet = false; } std::string Detector::getBaseDataIpv4Address() const { return m_Base_data_ipv4_address; } void Detector::setBaseDataIpv4Address(std::string const& value) { m_Base_data_ipv4_address = value; m_Base_data_ipv4_addressIsSet = true; } bool Detector::baseDataIpv4AddressIsSet() const { return m_Base_data_ipv4_addressIsSet; } void Detector::unsetBase_data_ipv4_address() { m_Base_data_ipv4_addressIsSet = false; } org::openapitools::server::model::Standard_detector_geometry Detector::getStandardGeometry() const { return m_Standard_geometry; } void Detector::setStandardGeometry(org::openapitools::server::model::Standard_detector_geometry const& value) { m_Standard_geometry = value; m_Standard_geometryIsSet = true; } bool Detector::standardGeometryIsSet() const { return m_Standard_geometryIsSet; } void Detector::unsetStandard_geometry() { m_Standard_geometryIsSet = false; } std::vector Detector::getCustomGeometry() const { return m_Custom_geometry; } void Detector::setCustomGeometry(std::vector const& value) { m_Custom_geometry = value; m_Custom_geometryIsSet = true; } bool Detector::customGeometryIsSet() const { return m_Custom_geometryIsSet; } void Detector::unsetCustom_geometry() { m_Custom_geometryIsSet = false; } bool Detector::isMirrorY() const { return m_Mirror_y; } void Detector::setMirrorY(bool const value) { m_Mirror_y = value; m_Mirror_yIsSet = true; } bool Detector::mirrorYIsSet() const { return m_Mirror_yIsSet; } void Detector::unsetMirror_y() { m_Mirror_yIsSet = false; } } // namespace org::openapitools::server::model