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++) {
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
auto *model = qobject_cast<QStandardItemModel *>(ui->sync->model());
Q_ASSERT(model != nullptr);
@ -36,6 +38,10 @@ CompoundDeviceEditDialog::CompoundDeviceEditDialog(CompoundDevice *cdev, QWidget
item->setFlags(disabled ? item->flags() & ~Qt::ItemIsEnabled
: item->flags() | Qt::ItemIsEnabled);
}
break;
default:
break;
}
}
connect(ui->sync, &QComboBox::currentTextChanged, [=](){
ldev.sync = CompoundDevice::SyncFromString(ui->sync->currentText());

View File

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

View File

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

View File

@ -153,6 +153,7 @@ void LibreVNATCPDriver::disconnect()
transmissionTimer.stop();
transmissionQueue.clear();
transmissionActive = false;
dataSocket.flush();
dataSocket.close();
logSocket.close();
// 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.
* 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:
void SSDPreceived(QUdpSocket *sock);

View File

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