Skip to content

Commit

Permalink
Add input field for eego-SDK DLL, display error message if it doesn't…
Browse files Browse the repository at this point in the history
… exist
  • Loading branch information
tstenner committed Aug 26, 2019
1 parent be60676 commit bac9a50
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 127 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ include(Findliblsl.cmake)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5 REQUIRED COMPONENTS Widgets)
find_package(Boost 1.69 REQUIRED)
find_package(Boost 1.65 REQUIRED)

add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
reader.h
reader.cpp
eemagine/sdk/wrapper.cc
Expand Down
9 changes: 8 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ MainWindow::MainWindow(QWidget *parent, const std::string &config_file, const bo
save_config(QFileDialog::getSaveFileName(
this, "Save Configuration File", "", "Configuration Files (*.cfg)"));
});
connect(ui->btn_dll, &QPushButton::clicked, [this]() {
auto dllpath = QFileDialog::getOpenFileName(this, "Select eego-SDK.dll",
QCoreApplication::applicationDirPath(), "SDK dll (eego-SDK.dll)");
this->ui->input_dll->setText(dllpath);
});
connect(ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
connect(ui->linkButton, &QPushButton::clicked, this, &MainWindow::link);
if(!config_file.empty()) load_config(QString::fromStdString(config_file));
Expand Down Expand Up @@ -88,8 +93,10 @@ void MainWindow::link() {
QString sr = ui->samplingRate->currentText();
int samplingRate = sr.toInt();// boost::lexical_cast<int>(sr);

auto dllpath = ui->input_dll->text();
if(!QFile::exists(dllpath)) throw std::runtime_error("eego-SDK.dll wasn't found.");
thread = new QThread;
reader = new Reader();
reader = new Reader(dllpath.toStdString());

reader->setParams(samplingRate);

Expand Down
220 changes: 98 additions & 122 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,135 +2,105 @@
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>203</width>
<height>166</height>
</rect>
</property>
<property name="windowTitle">
<string>eegApp</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_sr">
<property name="text">
<string>Sampling Rate</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="samplingRate">
<property name="toolTip">
<string>Sampling rate to use.</string>
</property>
<item>
<property name="text">
<string>500</string>
</property>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Device Settings</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Sampling Rate</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="samplingRate">
<property name="toolTip">
<string>Sampling rate to use.</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>500</string>
</property>
</item>
<item>
<property name="text">
<string>512</string>
</property>
</item>
<item>
<property name="text">
<string>1000</string>
</property>
</item>
<item>
<property name="text">
<string>1024</string>
</property>
</item>
<item>
<property name="text">
<string>2000</string>
</property>
</item>
<item>
<property name="text">
<string>2048</string>
</property>
</item>
<item>
<property name="text">
<string>4000</string>
</property>
</item>
<item>
<property name="text">
<string>4960</string>
</property>
</item>
<item>
<property name="text">
<string>8000</string>
</property>
</item>
<item>
<property name="text">
<string>8192</string>
</property>
</item>
<item>
<property name="text">
<string>16000</string>
</property>
</item>
<item>
<property name="text">
<string>16384</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<property name="text">
<string>512</string>
</property>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="linkButton">
<property name="text">
<string>Link</string>
</property>
</widget>
</item>
</layout>
<property name="text">
<string>1000</string>
</property>
</item>
</layout>
<item>
<property name="text">
<string>1024</string>
</property>
</item>
<item>
<property name="text">
<string>2000</string>
</property>
</item>
<item>
<property name="text">
<string>2048</string>
</property>
</item>
<item>
<property name="text">
<string>4000</string>
</property>
</item>
<item>
<property name="text">
<string>4960</string>
</property>
</item>
<item>
<property name="text">
<string>8000</string>
</property>
</item>
<item>
<property name="text">
<string>8192</string>
</property>
</item>
<item>
<property name="text">
<string>16000</string>
</property>
</item>
<item>
<property name="text">
<string>16384</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="linkButton">
<property name="text">
<string>Link</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="input_dll">
<property name="text">
<string>./eego-SDK.dll</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="btn_dll">
<property name="text">
<string>Select SDK dll</string>
</property>
</widget>
</item>
</layout>
</widget>
Expand All @@ -139,7 +109,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>203</width>
<width>244</width>
<height>23</height>
</rect>
</property>
Expand Down Expand Up @@ -186,6 +156,12 @@
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>btn_dll</tabstop>
<tabstop>input_dll</tabstop>
<tabstop>samplingRate</tabstop>
<tabstop>linkButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
2 changes: 1 addition & 1 deletion reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Reader::setParams(int sampling_rate) {
void Reader::read() {
bool ampFound = true;
try {
factory fact("eego-SDK.dll");
factory fact(dllpath);
amp = fact.getAmplifier();
eegStream = amp->OpenEegStream(samplingRate);

Expand Down
6 changes: 4 additions & 2 deletions reader.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once
#include <QObject>
#include <string>

namespace eemagine { namespace sdk { class amplifier; class stream; }}

class Reader : public QObject {
Q_OBJECT
public:
Reader(): stop(false) {}
Reader(std::string dllpath): dllpath(std::move(dllpath)) {}
virtual ~Reader() override;

public slots:
Expand All @@ -25,6 +26,7 @@ class Reader : public QObject {
private:
eemagine::sdk::amplifier* amp;
eemagine::sdk::stream* eegStream;
std::string dllpath;
unsigned int samplingRate;
bool stop;
bool stop{false};
};

0 comments on commit bac9a50

Please sign in to comment.