inial commit
This commit is contained in:
commit
e87470d14e
50
CMakeLists.txt
Normal file
50
CMakeLists.txt
Normal file
|
@ -0,0 +1,50 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(eismuliplexer-qt)
|
||||
|
||||
set(CMAKE_PROJECT_VERSION_MAJOR 0)
|
||||
set(CMAKE_PROJECT_VERSION_MINOR 9)
|
||||
set(CMAKE_PROJECT_VERSION_PATCH 0)
|
||||
|
||||
add_compile_definitions(VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR})
|
||||
add_compile_definitions(VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR})
|
||||
add_compile_definitions(VERSION_PATCH=${CMAKE_PROJECT_VERSION_PATCH})
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
|
||||
message(FATAL_ERROR "Windows builds have to be cross compiled on UNIX")
|
||||
endif()
|
||||
|
||||
message("Platform " ${CMAKE_SYSTEM_NAME})
|
||||
if(WIN32)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/release-win.sh ${CMAKE_CURRENT_BINARY_DIR}/release.sh @ONLY)
|
||||
add_custom_target(package
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/release.sh
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Createing release archive"
|
||||
VERBATIM)
|
||||
endif(WIN32)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(EISMULIPLEXER REQUIRED eismuliplexer)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.cpp
|
||||
channelwidget.cpp
|
||||
channelwidget.h
|
||||
mainwindow.h
|
||||
mainwindow.cpp
|
||||
mainwindow.ui
|
||||
multiplexer.h
|
||||
multiplexer.cpp
|
||||
)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC "-Wall")
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::Core ${EISMULIPLEXER_LIBRARIES})
|
||||
#target_include_directories(${PROJECT_NAME} PUBLIC ${EISMULIPLEXER_INCLUDE_DIRS})
|
97
channelwidget.cpp
Normal file
97
channelwidget.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "channelwidget.h"
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
ChannelWidget::ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber,
|
||||
std::shared_ptr<struct eismultiplexer> multiplexer,
|
||||
QWidget *parent)
|
||||
:
|
||||
QWidget(parent),
|
||||
deviceSerial(deviceSerial),
|
||||
channelNumber(channelNumber),
|
||||
multiplexer(multiplexer),
|
||||
checkbox("Enable"),
|
||||
devicelabel(QString::asprintf("Device %04u", deviceSerial)),
|
||||
channellabel(QString::asprintf("Channel %u", channelNumber)),
|
||||
ganglabel("Ganged:")
|
||||
{
|
||||
hlayout.addLayout(&labellayout);
|
||||
vlayout.addLayout(&hlayout);
|
||||
|
||||
labellayout.addWidget(&devicelabel);
|
||||
labellayout.addWidget(&channellabel);
|
||||
|
||||
line.setGeometry(QRect(320, 150, 118, 3));
|
||||
line.setFrameShape(QFrame::HLine);
|
||||
line.setFrameShadow(QFrame::Sunken);
|
||||
vlayout.addWidget(&line);
|
||||
|
||||
gangcombo.addItem("Unganged");
|
||||
|
||||
hlayout.addStretch();
|
||||
hlayout.addWidget(&ganglabel);
|
||||
hlayout.addWidget(&gangcombo);
|
||||
hlayout.addWidget(&checkbox);
|
||||
connect(&checkbox, &QCheckBox::toggled, this, &ChannelWidget::onChannelToggled);
|
||||
|
||||
setFixedHeight(96);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
setLayout(&vlayout);
|
||||
}
|
||||
|
||||
ChannelWidget::~ChannelWidget()
|
||||
{
|
||||
// Nothing to clean up
|
||||
}
|
||||
|
||||
uint16_t ChannelWidget::getDeviceSerial() const
|
||||
{
|
||||
return deviceSerial;
|
||||
}
|
||||
|
||||
uint16_t ChannelWidget::getChannelNumber() const
|
||||
{
|
||||
return channelNumber;
|
||||
}
|
||||
|
||||
bool ChannelWidget::isChecked() const
|
||||
{
|
||||
return checkbox.isChecked();
|
||||
}
|
||||
|
||||
void ChannelWidget::onChannelToggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
// Emit signal before actually turning on the channel
|
||||
emit channelAboutToBeTurnedOn(deviceSerial, channelNumber);
|
||||
}
|
||||
|
||||
channel_t channelFlag = static_cast<channel_t>(1 << channelNumber);
|
||||
if (checked)
|
||||
{
|
||||
if (eismultiplexer_connect_channel(multiplexer.get(), channelFlag) < 0)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Connection Failed"),
|
||||
tr("Failed to connect channel %1 on device %2").arg(channelNumber).arg(deviceSerial));
|
||||
qWarning() << "Failed to connect channel" << channelNumber << "on device" << deviceSerial;
|
||||
checkbox.blockSignals(true);
|
||||
checkbox.setChecked(false);
|
||||
setEnabled(false); // Gray out the widget
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (eismultiplexer_disconnect_channel(multiplexer.get(), channelFlag) < 0)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Disconnection Failed"),
|
||||
tr("Failed to disconnect channel %1 on device %2").arg(channelNumber).arg(deviceSerial));
|
||||
qWarning() << "Failed to disconnect channel" << channelNumber << "on device" << deviceSerial;
|
||||
checkbox.blockSignals(true);
|
||||
checkbox.setChecked(true);
|
||||
setEnabled(false); // Gray out the widget
|
||||
}
|
||||
}
|
||||
}
|
||||
|
49
channelwidget.h
Normal file
49
channelwidget.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef CHANNELWIDGET_H
|
||||
#define CHANNELWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <eismultiplexer.h>
|
||||
#include <memory>
|
||||
|
||||
class ChannelWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChannelWidget(uint16_t deviceSerial, uint16_t channelNumber,
|
||||
std::shared_ptr<struct eismultiplexer> multiplexer,
|
||||
QWidget *parent = nullptr);
|
||||
~ChannelWidget() override;
|
||||
|
||||
uint16_t getDeviceSerial() const;
|
||||
uint16_t getChannelNumber() const;
|
||||
bool isChecked() const;
|
||||
|
||||
signals:
|
||||
void channelAboutToBeTurnedOn(uint16_t deviceSerial, uint16_t channelNumber);
|
||||
|
||||
private slots:
|
||||
void onChannelToggled(bool checked);
|
||||
|
||||
private:
|
||||
uint16_t deviceSerial;
|
||||
uint16_t channelNumber;
|
||||
std::shared_ptr<struct eismultiplexer> multiplexer;
|
||||
QCheckBox checkbox;
|
||||
QLabel devicelabel;
|
||||
QLabel channellabel;
|
||||
QLabel ganglabel;
|
||||
QComboBox gangcombo;
|
||||
QFrame line;
|
||||
QVBoxLayout vlayout;
|
||||
QHBoxLayout hlayout;
|
||||
QVBoxLayout labellayout;
|
||||
};
|
||||
|
||||
#endif // CHANNELWIDGET_H
|
||||
|
||||
|
10
main.cpp
Normal file
10
main.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
MainWindow window;
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
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);
|
||||
}
|
31
mainwindow.h
Normal file
31
mainwindow.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <memory>
|
||||
|
||||
#include "channelwidget.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
std::vector<std::shared_ptr<ChannelWidget>> channels;
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
signals:
|
||||
void channelStateChanged(uint16_t device, uint16_t channel);
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
void enumerateDevices();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
68
mainwindow.ui
Normal file
68
mainwindow.ui
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>EisMultiplexer-Qt</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>788</width>
|
||||
<height>537</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="channelLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
16
multiplexer.cpp
Normal file
16
multiplexer.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include "multiplexer.h"
|
||||
|
||||
Multiplexer::Multiplexer(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
Multiplexer::~Multiplexer()
|
||||
{
|
||||
for(auto& multiplexer : multiplexers)
|
||||
eismultiplexer_disconnect(multiplexer.get());
|
||||
}
|
||||
|
||||
void Multiplexer::probe()
|
||||
{
|
||||
|
||||
}
|
22
multiplexer.h
Normal file
22
multiplexer.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef MULTIPLEXER_H
|
||||
#define MULTIPLEXER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "eismultiplexer.h"
|
||||
|
||||
class Multiplexer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
std::vector<std::shared_ptr<struct eismultiplexer>> multiplexers;
|
||||
std::vector<channel_t> channelStates;
|
||||
|
||||
public:
|
||||
explicit Multiplexer(QObject *parent = nullptr);
|
||||
~Multiplexer();
|
||||
void probe();
|
||||
|
||||
signals:
|
||||
void foundDevice(std::shared_ptr<struct eismultiplexer>);
|
||||
};
|
||||
|
||||
#endif // MULTIPLEXER_H
|
61
scripts/release-win.sh
Executable file
61
scripts/release-win.sh
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/bin/bash -e
|
||||
#
|
||||
# libkissinference - an inference libary for kiss networks
|
||||
# Copyright (C) 2024 Carl Philipp Klemm <carl@uvos.xyz>
|
||||
#
|
||||
# This file is part of libkissinference.
|
||||
#
|
||||
# libkissinference is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# libkissinference is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with libkissinference. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
PROJECTNAME=@PROJECT_NAME@
|
||||
SYSTEMPROC=@CMAKE_SYSTEM_PROCESSOR@
|
||||
ROOTPATH=@CMAKE_FIND_ROOT_PATH@
|
||||
VERSION="@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@"
|
||||
BINARYDIR="@CMAKE_CURRENT_BINARY_DIR@"
|
||||
SRCDIR="@CMAKE_CURRENT_SOURCE_DIR@"
|
||||
RELDIRECTORY="$BINARYDIR/packaged/$VERSION/release"
|
||||
ZIPNAME=$PROJECTNAME-$SYSTEMPROC-$VERSION
|
||||
|
||||
rm $BINARYDIR/packaged/$ZIPNAME.zip || true
|
||||
cd $BINARYDIR
|
||||
install -d $RELDIRECTORY
|
||||
cp eismuliplexer-qt.exe $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libwinpthread-1.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libusb-1.0.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libssp-0.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libgcc_s_seh-1.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libstdc++-6.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/Qt6Core.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/Qt6Gui.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/Qt6Widgets.dll $RELDIRECTORY
|
||||
cp -r $ROOTPATH/lib/qt6/plugins/platforms $RELDIRECTORY
|
||||
cp $ROOTPATH/lib/libeismultiplexer.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libpcre2-*-0.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/zlib1.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libfreetype-6.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libpng16-16.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libzstd.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libharfbuzz-0.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libintl-8.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libgraphite2.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libglib-2.0-0.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libbz2-1.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libbrotlidec.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libbrotlicommon.dll $RELDIRECTORY
|
||||
cp $ROOTPATH/bin/libiconv-2.dll $RELDIRECTORY
|
||||
#cp $SRCDIR/README.md $RELDIRECTORY
|
||||
cd $RELDIRECTORY/..
|
||||
rm $BINARYDIR/packaged/$ZIPNAME.zip || true
|
||||
zip -r $BINARYDIR/packaged/$ZIPNAME.zip release
|
Loading…
Reference in a new issue