#include "devicedriver.h" #include "LibreVNA/librevnatcpdriver.h" #include "LibreVNA/librevnausbdriver.h" #include "LibreVNA/Compound/compounddriver.h" #include "SSA3000X/ssa3000xdriver.h" #include "SNA5000A/sna5000adriver.h" #include "Harogic/harogicb60.h" DeviceDriver *DeviceDriver::activeDriver = nullptr; DeviceDriver::~DeviceDriver() { for(auto a : specificActions) { delete a; } } std::vector DeviceDriver::getDrivers() { static std::vector ret; if (ret.size() == 0) { // first function call ret.push_back(new LibreVNAUSBDriver); ret.push_back(new LibreVNATCPDriver); ret.push_back(new CompoundDriver); ret.push_back(new SSA3000XDriver); ret.push_back(new SNA5000ADriver); ret.push_back(new HarogicB60); } return ret; } bool DeviceDriver::connectDevice(QString serial, bool isIndepedentDriver) { if(!isIndepedentDriver) { if(activeDriver && activeDriver != this) { activeDriver->disconnect(); } } if(connectTo(serial)) { if(!isIndepedentDriver) { activeDriver = this; } return true; } else { return false; } } void DeviceDriver::disconnectDevice() { disconnect(); activeDriver = nullptr; } unsigned int DeviceDriver::SApoints() { if(activeDriver) { return activeDriver->getSApoints(); } else { // return default value instead return 1001; } } Sparam DeviceDriver::VNAMeasurement::toSparam(int ports) const { if(ports == 0) { // determine number of ports by highest available S parameter for(const auto &m : measurements) { if(!m.first.startsWith("S")) { // something else we can not handle continue; } int to = m.first.mid(1,1).toUInt(); int from = m.first.mid(2,1).toUInt(); if(to > ports) { ports = to; } if(from > ports) { ports = from; } } } // create S paramters auto S = Sparam(ports); // fill data for(const auto &m : measurements) { if(!m.first.startsWith("S")) { // something else we can not handle continue; } int to = m.first.mid(1,1).toUInt(); int from = m.first.mid(2,1).toUInt(); S.set(to, from, m.second); } return S; } void DeviceDriver::VNAMeasurement::fromSparam(Sparam S, std::vector portMapping) { if(portMapping.size() == 0) { // set up default port mapping for(unsigned int i=1;i<=S.ports();i++) { portMapping.push_back(i); } } for(unsigned int i=0;i intersectFeatures; std::set_intersection(supportedFeatures.begin(), supportedFeatures.end(), info.supportedFeatures.begin(), info.supportedFeatures.end(), std::inserter(intersectFeatures, intersectFeatures.begin())); supportedFeatures = intersectFeatures; }