inial commit
This commit is contained in:
commit
e87470d14e
10 changed files with 472 additions and 0 deletions
68
mainwindow.cpp
Normal file
68
mainwindow.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#include <eismultiplexer.h>
|
||||
#include <QMessageBox>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
enumerateDevices();
|
||||
|
||||
connect(ui->actionQuit, &QAction::triggered, this, [this]()
|
||||
{
|
||||
close();
|
||||
});
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::enumerateDevices()
|
||||
{
|
||||
size_t count = 0;
|
||||
uint16_t* serials = eismultiplexer_list_available_devices(&count);
|
||||
|
||||
if (!serials || count == 0)
|
||||
{
|
||||
QMessageBox::warning(nullptr, tr("No Devices Found"),
|
||||
tr("No EIS multiplexer devices were found. Please connect a device and try again."));
|
||||
qWarning() << "No EIS multiplexer devices found";
|
||||
exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
uint16_t serial = serials[i];
|
||||
std::shared_ptr<struct eismultiplexer> multiplexer(new struct eismultiplexer);
|
||||
if (eismultiplexer_connect(multiplexer.get(), serial) >= 0)
|
||||
{
|
||||
uint16_t channelCount = 0;
|
||||
qDebug()<<"Adding channels from device "<<serial;
|
||||
if (eismultiplexer_get_channel_count(multiplexer.get(), &channelCount) >= 0)
|
||||
{
|
||||
for (uint16_t channel = 0; channel < channelCount; channel++)
|
||||
{
|
||||
std::shared_ptr<ChannelWidget> widget(new ChannelWidget(serial, channel, multiplexer));
|
||||
qDebug()<<"Added widget from device "<<serial<<" channel "<<channel;
|
||||
channels.push_back(widget);
|
||||
ui->channelLayout->addWidget(widget.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, tr("Connection Failed"),
|
||||
tr("Failed to connect to device with serial %1").arg(serial));
|
||||
qWarning() << "Failed to connect to device with serial" << serial;
|
||||
}
|
||||
ui->channelLayout->addStretch();
|
||||
}
|
||||
ui->statusbar->showMessage("Ready");
|
||||
|
||||
free(serials);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue