Move the LAN connection and the read device settings part into separate threads

in order to keep the gui responsive.
merge-requests/1/head
Teuniz 2016-10-02 20:22:48 +02:00
rodzic f970045457
commit acf53c833f
11 zmienionych plików z 1921 dodań i 1484 usunięć

Wyświetl plik

@ -53,6 +53,8 @@ HEADERS += edflib.h
HEADERS += signalcurve.h HEADERS += signalcurve.h
HEADERS += settings_dialog.h HEADERS += settings_dialog.h
HEADERS += screen_thread.h HEADERS += screen_thread.h
HEADERS += lan_connect_thread.h
HEADERS += read_settings_thread.h
HEADERS += third_party/kiss_fft/kiss_fft.h HEADERS += third_party/kiss_fft/kiss_fft.h
HEADERS += third_party/kiss_fft/_kiss_fft_guts.h HEADERS += third_party/kiss_fft/_kiss_fft_guts.h
@ -74,6 +76,8 @@ SOURCES += edflib.c
SOURCES += signalcurve.cpp SOURCES += signalcurve.cpp
SOURCES += settings_dialog.cpp SOURCES += settings_dialog.cpp
SOURCES += screen_thread.cpp SOURCES += screen_thread.cpp
SOURCES += lan_connect_thread.cpp
SOURCES += read_settings_thread.cpp
SOURCES += third_party/kiss_fft/kiss_fft.c SOURCES += third_party/kiss_fft/kiss_fft.c
SOURCES += third_party/kiss_fft/kiss_fftr.c SOURCES += third_party/kiss_fft/kiss_fftr.c

Wyświetl plik

@ -35,7 +35,7 @@
#define PROGRAM_NAME "DSRemote" #define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.32_1609200823" #define PROGRAM_VERSION "0.32_1610022021"
#define MAX_PATHLEN 4096 #define MAX_PATHLEN 4096

Wyświetl plik

@ -0,0 +1,72 @@
/*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************
*/
#include "lan_connect_thread.h"
lan_connect_thread::lan_connect_thread()
{
device = NULL;
dev_str[0] = 0;
}
void lan_connect_thread::run()
{
if(dev_str[0] == 0) return;
device = tmc_open_lan(dev_str);
}
struct tmcdev * lan_connect_thread::get_device(void)
{
return device;
}
void lan_connect_thread::set_device_address(const char *addr)
{
strncpy(dev_str, addr, 16);
dev_str[15] = 0;
}

Wyświetl plik

@ -0,0 +1,92 @@
/*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************
*/
#ifndef DEF_LAN_CONNECT_THREAD_H
#define DEF_LAN_CONNECT_THREAD_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <QObject>
#include <QThread>
#include "global.h"
#include "utils.h"
#include "connection.h"
#include "tmc_dev.h"
class lan_connect_thread : public QThread
{
Q_OBJECT
public:
lan_connect_thread();
void set_device_address(const char *);
struct tmcdev * get_device(void);
private:
char dev_str[256];
struct tmcdev *device;
void run();
};
#endif

Plik diff jest za duży Load Diff

Wyświetl plik

@ -84,6 +84,8 @@
#include "signalcurve.h" #include "signalcurve.h"
#include "settings_dialog.h" #include "settings_dialog.h"
#include "screen_thread.h" #include "screen_thread.h"
#include "lan_connect_thread.h"
#include "read_settings_thread.h"
#include "third_party/kiss_fft/kiss_fftr.h" #include "third_party/kiss_fft/kiss_fftr.h"
@ -120,7 +122,7 @@ public:
QTimer *scrn_timer, QTimer *scrn_timer,
*label_timer; *label_timer;
screenThread *scrn_thread; screen_thread *scrn_thread;
private: private:

Wyświetl plik

@ -136,7 +136,7 @@ UI_Mainwindow::UI_Mainwindow()
devparms.mutexx = new QMutex(); devparms.mutexx = new QMutex();
scrn_thread = new screenThread; scrn_thread = new screen_thread;
scrn_thread->set_device(NULL); scrn_thread->set_device(NULL);
menubar = menuBar(); menubar = menuBar();

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,97 @@
/*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************
*/
#ifndef DEF_READ_SETTINGS_THREAD_H
#define DEF_READ_SETTINGS_THREAD_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <QObject>
#include <QThread>
#include "global.h"
#include "utils.h"
#include "connection.h"
#include "tmc_dev.h"
class read_settings_thread : public QThread
{
Q_OBJECT
public:
read_settings_thread();
void set_device(struct tmcdev *);
void set_devparm_ptr(struct device_settings *);
int get_error_num(void);
void get_error_str(char *);
private:
struct tmcdev *device;
struct device_settings *devparms;
char err_str[4096];
int err_num;
void run();
};
#endif

Wyświetl plik

@ -33,7 +33,7 @@
#define SPECT_LOG_MINIMUM_LOG (-80) #define SPECT_LOG_MINIMUM_LOG (-80)
void screenThread::set_device(struct tmcdev *tmdev) void screen_thread::set_device(struct tmcdev *tmdev)
{ {
params.cmd_cue_idx_in = 0; params.cmd_cue_idx_in = 0;
params.cmd_cue_idx_out = 0; params.cmd_cue_idx_out = 0;
@ -43,7 +43,7 @@ void screenThread::set_device(struct tmcdev *tmdev)
} }
screenThread::screenThread() screen_thread::screen_thread()
{ {
int i; int i;
@ -62,7 +62,7 @@ screenThread::screenThread()
} }
screenThread::~screenThread() screen_thread::~screen_thread()
{ {
int i; int i;
@ -73,7 +73,7 @@ screenThread::~screenThread()
} }
void screenThread::set_params(struct device_settings *dev_parms) void screen_thread::set_params(struct device_settings *dev_parms)
{ {
deviceparms = dev_parms; deviceparms = dev_parms;
params.connected = deviceparms->connected; params.connected = deviceparms->connected;
@ -101,7 +101,7 @@ void screenThread::set_params(struct device_settings *dev_parms)
} }
void screenThread::get_params(struct device_settings *dev_parms) void screen_thread::get_params(struct device_settings *dev_parms)
{ {
int i; int i;
@ -147,7 +147,7 @@ void screenThread::get_params(struct device_settings *dev_parms)
} }
int screenThread::get_devicestatus() int screen_thread::get_devicestatus()
{ {
int line; int line;
@ -293,7 +293,7 @@ OUT_ERROR:
} }
void screenThread::run() void screen_thread::run()
{ {
int i, j, k, n=0, chns=0, line, cmd_sent=0; int i, j, k, n=0, chns=0, line, cmd_sent=0;

Wyświetl plik

@ -48,14 +48,14 @@
class screenThread : public QThread class screen_thread : public QThread
{ {
Q_OBJECT Q_OBJECT
public: public:
screenThread(); screen_thread();
~screenThread(); ~screen_thread();
int h_busy; int h_busy;