various minor improvements
This commit is contained in:
parent
e58a76c488
commit
6500f67b5e
@ -1316,7 +1316,7 @@ void Calibration::fromJSON(nlohmann::json j)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: {
|
case 2: {
|
||||||
// TODO load associated calkit
|
// associated calkit should already be loaded
|
||||||
if(j.contains("measurements")) {
|
if(j.contains("measurements")) {
|
||||||
// grab measurements
|
// grab measurements
|
||||||
for(auto j_m : j["measurements"]) {
|
for(auto j_m : j["measurements"]) {
|
||||||
|
@ -25,6 +25,7 @@ USBInBuffer::USBInBuffer(libusb_device_handle *handle, unsigned char endpoint, i
|
|||||||
inCallback(false)
|
inCallback(false)
|
||||||
{
|
{
|
||||||
buffer = new unsigned char[buffer_size];
|
buffer = new unsigned char[buffer_size];
|
||||||
|
memset(buffer, 0, buffer_size);
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = libusb_alloc_transfer(0);
|
||||||
libusb_fill_bulk_transfer(transfer, handle, endpoint, buffer, buffer_size, CallbackTrampoline, this, 0);
|
libusb_fill_bulk_transfer(transfer, handle, endpoint, buffer, buffer_size, CallbackTrampoline, this, 0);
|
||||||
libusb_submit_transfer(transfer);
|
libusb_submit_transfer(transfer);
|
||||||
@ -229,9 +230,6 @@ Device::Device(QString serial)
|
|||||||
connect(this, &Device::receivedAnswer, this, &Device::transmissionFinished, Qt::QueuedConnection);
|
connect(this, &Device::receivedAnswer, this, &Device::transmissionFinished, Qt::QueuedConnection);
|
||||||
transmissionTimer.setSingleShot(true);
|
transmissionTimer.setSingleShot(true);
|
||||||
transmissionActive = false;
|
transmissionActive = false;
|
||||||
// got a new connection, request info
|
|
||||||
SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceInfo);
|
|
||||||
SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::~Device()
|
Device::~Device()
|
||||||
|
@ -178,6 +178,14 @@ void VirtualDevice::RegisterTypes()
|
|||||||
qRegisterMetaType<VirtualDevice::SAMeasurement>("SAMeasurement");
|
qRegisterMetaType<VirtualDevice::SAMeasurement>("SAMeasurement");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VirtualDevice::initialize()
|
||||||
|
{
|
||||||
|
for(auto dev : devices) {
|
||||||
|
dev->SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceInfo);
|
||||||
|
dev->SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool VirtualDevice::isCompoundDevice() const
|
bool VirtualDevice::isCompoundDevice() const
|
||||||
{
|
{
|
||||||
return cdev != nullptr;
|
return cdev != nullptr;
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
|
|
||||||
static void RegisterTypes();
|
static void RegisterTypes();
|
||||||
|
|
||||||
|
void initialize(); // call this after creating the virtual device and all connections to signals have been made
|
||||||
|
|
||||||
bool isCompoundDevice() const;
|
bool isCompoundDevice() const;
|
||||||
Device *getDevice();
|
Device *getDevice();
|
||||||
CompoundDevice *getCompoundDevice();
|
CompoundDevice *getCompoundDevice();
|
||||||
|
@ -339,12 +339,13 @@ void TracePlot::finishContextMenu()
|
|||||||
void TracePlot::mousePressEvent(QMouseEvent *event)
|
void TracePlot::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
auto &pref = Preferences::getInstance();
|
auto &pref = Preferences::getInstance();
|
||||||
|
auto position = event->pos() - QPoint(marginLeft, marginTop);
|
||||||
if(event->buttons() == Qt::LeftButton) {
|
if(event->buttons() == Qt::LeftButton) {
|
||||||
selectedMarker = markerAtPosition(event->pos(), true);
|
selectedMarker = markerAtPosition(position, true);
|
||||||
if(!selectedMarker && pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) {
|
if(!selectedMarker && pref.Graphs.enablePanAndZoom && positionWithinGraphArea(position)) {
|
||||||
// no marker at the position, enter trace moving mode
|
// no marker at the position, enter trace moving mode
|
||||||
movingGraph = true;
|
movingGraph = true;
|
||||||
lastMousePoint = event->pos();
|
lastMousePoint = position;
|
||||||
cursorLabel->hide();
|
cursorLabel->hide();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -374,8 +375,8 @@ void TracePlot::mouseMoveEvent(QMouseEvent *event)
|
|||||||
selectedMarker->setPosition(nearestTracePoint(trace, clickPoint));
|
selectedMarker->setPosition(nearestTracePoint(trace, clickPoint));
|
||||||
cursorLabel->hide();
|
cursorLabel->hide();
|
||||||
} else if(movingGraph) {
|
} else if(movingGraph) {
|
||||||
move(event->pos() - lastMousePoint);
|
move(clickPoint - lastMousePoint);
|
||||||
lastMousePoint = event->pos();
|
lastMousePoint = clickPoint;
|
||||||
} else {
|
} else {
|
||||||
auto text = mouseText(clickPoint);
|
auto text = mouseText(clickPoint);
|
||||||
if(!text.isEmpty()) {
|
if(!text.isEmpty()) {
|
||||||
|
@ -118,7 +118,12 @@ void TracePolar::setAuto(bool horizontally, bool vertically)
|
|||||||
bool TracePolar::positionWithinGraphArea(const QPoint &p)
|
bool TracePolar::positionWithinGraphArea(const QPoint &p)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
auto coord = pixelToData(p);
|
||||||
|
if(abs(coord) <= edgeReflection) {
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint TracePolar::dataToPixel(std::complex<double> d)
|
QPoint TracePolar::dataToPixel(std::complex<double> d)
|
||||||
|
@ -345,8 +345,6 @@ bool AppWindow::ConnectToDevice(QString serial)
|
|||||||
}
|
}
|
||||||
ui->actionPreset->setEnabled(true);
|
ui->actionPreset->setEnabled(true);
|
||||||
|
|
||||||
UpdateAcquisitionFrequencies();
|
|
||||||
|
|
||||||
for(auto d : deviceActionGroup->actions()) {
|
for(auto d : deviceActionGroup->actions()) {
|
||||||
if(d->text() == vdevice->serial()) {
|
if(d->text() == vdevice->serial()) {
|
||||||
d->blockSignals(true);
|
d->blockSignals(true);
|
||||||
@ -359,6 +357,9 @@ bool AppWindow::ConnectToDevice(QString serial)
|
|||||||
connect(vdevice, &VirtualDevice::InfoUpdated, m, &Mode::deviceInfoUpdated);
|
connect(vdevice, &VirtualDevice::InfoUpdated, m, &Mode::deviceInfoUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vdevice->initialize();
|
||||||
|
|
||||||
|
UpdateAcquisitionFrequencies();
|
||||||
if (modeHandler->getActiveMode()) {
|
if (modeHandler->getActiveMode()) {
|
||||||
modeHandler->getActiveMode()->initializeDevice();
|
modeHandler->getActiveMode()->initializeDevice();
|
||||||
}
|
}
|
||||||
@ -1276,18 +1277,11 @@ void AppWindow::UpdateStatusBar(DeviceStatusBar status)
|
|||||||
case DeviceStatusBar::Connected:
|
case DeviceStatusBar::Connected:
|
||||||
lConnectionStatus.setText("Connected to " + vdevice->serial());
|
lConnectionStatus.setText("Connected to " + vdevice->serial());
|
||||||
qInfo() << "Connected to" << vdevice->serial();
|
qInfo() << "Connected to" << vdevice->serial();
|
||||||
// lDeviceInfo.setText(vdevice->getLastDeviceInfoString());
|
|
||||||
break;
|
break;
|
||||||
case DeviceStatusBar::Disconnected:
|
case DeviceStatusBar::Disconnected:
|
||||||
lConnectionStatus.setText("No device connected");
|
lConnectionStatus.setText("No device connected");
|
||||||
lDeviceInfo.setText("No device information available yet");
|
lDeviceInfo.setText("No device information available yet");
|
||||||
break;
|
break;
|
||||||
case DeviceStatusBar::Updated:
|
|
||||||
// lDeviceInfo.setText(vdevice->getLastDeviceInfoString());
|
|
||||||
// lADCOverload.setVisible(vdevice->StatusV1().ADC_overload);
|
|
||||||
// lUnlevel.setVisible(vdevice->StatusV1().unlevel);
|
|
||||||
// lUnlock.setVisible(!vdevice->StatusV1().LO1_locked || !vdevice->StatusV1().source_locked);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// invalid status
|
// invalid status
|
||||||
break;
|
break;
|
||||||
|
@ -79,7 +79,6 @@ private:
|
|||||||
|
|
||||||
enum class DeviceStatusBar {
|
enum class DeviceStatusBar {
|
||||||
Connected,
|
Connected,
|
||||||
Updated,
|
|
||||||
Disconnected,
|
Disconnected,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user