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