Compound device driver improvements

This commit is contained in:
Jan Käberich 2023-03-10 00:08:13 +01:00
parent ce50ddc702
commit d30fa8b2ce
6 changed files with 38 additions and 13 deletions

View File

@ -27,7 +27,9 @@ CompoundDeviceEditDialog::CompoundDeviceEditDialog(CompoundDevice *cdev, QWidget
}); });
for(int i=0;i<(int)LibreVNADriver::Synchronization::Last;i++) { for(int i=0;i<(int)LibreVNADriver::Synchronization::Last;i++) {
ui->sync->addItem(CompoundDevice::SyncToString((LibreVNADriver::Synchronization) i)); ui->sync->addItem(CompoundDevice::SyncToString((LibreVNADriver::Synchronization) i));
if((LibreVNADriver::Synchronization) i == LibreVNADriver::Synchronization::ExternalTrigger) { switch((LibreVNADriver::Synchronization) i) {
case LibreVNADriver::Synchronization::Disabled:
case LibreVNADriver::Synchronization::Reserved: {
// Disable for now // Disable for now
auto *model = qobject_cast<QStandardItemModel *>(ui->sync->model()); auto *model = qobject_cast<QStandardItemModel *>(ui->sync->model());
Q_ASSERT(model != nullptr); Q_ASSERT(model != nullptr);
@ -36,6 +38,10 @@ CompoundDeviceEditDialog::CompoundDeviceEditDialog(CompoundDevice *cdev, QWidget
item->setFlags(disabled ? item->flags() & ~Qt::ItemIsEnabled item->setFlags(disabled ? item->flags() & ~Qt::ItemIsEnabled
: item->flags() | Qt::ItemIsEnabled); : item->flags() | Qt::ItemIsEnabled);
} }
break;
default:
break;
}
} }
connect(ui->sync, &QComboBox::currentTextChanged, [=](){ connect(ui->sync, &QComboBox::currentTextChanged, [=](){
ldev.sync = CompoundDevice::SyncFromString(ui->sync->currentText()); ldev.sync = CompoundDevice::SyncFromString(ui->sync->currentText());

View File

@ -6,6 +6,7 @@
#include "ui_compounddriversettingswidget.h" #include "ui_compounddriversettingswidget.h"
#include "compounddeviceeditdialog.h" #include "compounddeviceeditdialog.h"
#include "preferences.h" #include "preferences.h"
#include "Device/LibreVNA/devicepacketlogview.h"
#include <exception> #include <exception>
@ -16,6 +17,13 @@ CompoundDriver::CompoundDriver()
drivers.push_back(new LibreVNAUSBDriver); drivers.push_back(new LibreVNAUSBDriver);
drivers.push_back(new LibreVNATCPDriver); drivers.push_back(new LibreVNATCPDriver);
auto log = new QAction("View Packet Log");
connect(log, &QAction::triggered, this, [=](){
auto d = new DevicePacketLogView();
d->show();
});
specificActions.push_back(log);
auto &p = Preferences::getInstance(); auto &p = Preferences::getInstance();
for(auto d : drivers) { for(auto d : drivers) {
p.load(d->driverSpecificSettings()); p.load(d->driverSpecificSettings());
@ -91,7 +99,9 @@ bool CompoundDriver::connectTo(QString getSerial)
device = new LibreVNAUSBDriver(); device = new LibreVNAUSBDriver();
break; break;
} else if(i == 1) { } else if(i == 1) {
device = new LibreVNATCPDriver(); auto tcp = new LibreVNATCPDriver();
tcp->copyDetectedDevices(*static_cast<LibreVNATCPDriver*>(drivers[i]));
device = tcp;
break; break;
} }
} }
@ -287,6 +297,7 @@ bool CompoundDriver::setVNA(const DeviceDriver::VNASettings &s, std::function<vo
} }
zerospan = (s.freqStart == s.freqStop) && (s.dBmStart == s.dBmStop); zerospan = (s.freqStart == s.freqStop) && (s.dBmStart == s.dBmStop);
VNApoints = s.points;
// create vector of currently used stimulus ports // create vector of currently used stimulus ports
std::vector<CompoundDevice::PortMapping> activeMapping; std::vector<CompoundDevice::PortMapping> activeMapping;
for(auto p : s.excitedPorts) { for(auto p : s.excitedPorts) {
@ -689,15 +700,17 @@ void CompoundDriver::datapointReceivecd(LibreVNADriver *dev, Protocol::VNADatapo
// Clear this and all (incomplete) older datapoint buffers // Clear this and all (incomplete) older datapoint buffers
int pointNum = data->pointNum; int pointNum = data->pointNum;
auto it = compoundVNABuffer.begin(); while(compoundVNABuffer.count(pointNum)) {
while(it != compoundVNABuffer.end()) { auto &buf = compoundVNABuffer[pointNum];
if(it->first <= pointNum) { for(auto d : buf) {
for(auto d : it->second) { delete d.second;
delete d.second; }
} compoundVNABuffer.erase(pointNum);
it = compoundVNABuffer.erase(it); // move on to previous point
if(pointNum > 0) {
pointNum--;
} else { } else {
it++; pointNum = VNApoints - 1;
} }
} }
} }

View File

@ -198,6 +198,7 @@ private:
bool connected; bool connected;
std::vector<LibreVNADriver*> devices; std::vector<LibreVNADriver*> devices;
bool zerospan; bool zerospan;
unsigned int VNApoints;
unsigned int SApoints; unsigned int SApoints;
// Driver specific settings // Driver specific settings

View File

@ -153,6 +153,7 @@ void LibreVNATCPDriver::disconnect()
transmissionTimer.stop(); transmissionTimer.stop();
transmissionQueue.clear(); transmissionQueue.clear();
transmissionActive = false; transmissionActive = false;
dataSocket.flush();
dataSocket.close(); dataSocket.close();
logSocket.close(); logSocket.close();
// delete dataSocket; // delete dataSocket;

View File

@ -46,7 +46,11 @@ public:
* If the device driver uses a queued signal/slot connection with custom data types, these types must be registered before emitting the signal. * If the device driver uses a queued signal/slot connection with custom data types, these types must be registered before emitting the signal.
* Register them within this function with qRegisterMetaType<Type>("Name"); * Register them within this function with qRegisterMetaType<Type>("Name");
*/ */
virtual void registerTypes(); virtual void registerTypes() override;
void copyDetectedDevices(const LibreVNATCPDriver &other) {
detectedDevices = other.detectedDevices;
}
private slots: private slots:
void SSDPreceived(QUdpSocket *sock); void SSDPreceived(QUdpSocket *sock);

View File

@ -467,13 +467,13 @@
<number>96</number> <number>96</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>32000</number> <number>16384</number>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<number>16</number> <number>16</number>
</property> </property>
<property name="value"> <property name="value">
<number>32000</number> <number>16384</number>
</property> </property>
</widget> </widget>
</item> </item>