-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
82 lines (60 loc) · 1.89 KB
/
mainwindow.cpp
File metadata and controls
82 lines (60 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QThread>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_start_clicked()
{
sensitive = new sensitive_data();
all = new all_data();
worker = new SerialWorker(ui->portAddress->text(), ui->baudRate->text(), ui->parity->text(), ui->stopBit->text(), "saved_data.csv");
worker->start();
connect(worker, &SerialWorker::messageReceived, sensitive, &sensitive_data::handleMessage);
connect(worker, &SerialWorker::messageReceived, all, &all_data::handleMessage);
connect(sensitive, &sensitive_data::stop, this, &MainWindow::stop_serial);
connect(all, &all_data::stop, this, &MainWindow::stop_serial);
connect(sensitive, &sensitive_data::closed, this, &MainWindow::back);
connect(all, &all_data::closed, this, &MainWindow::back);
connect(sensitive, &sensitive_data::change, this, &MainWindow::show_all);
connect(all, &all_data::change, this, &MainWindow::show_sensitive);
connect(this, &MainWindow::stopSignal, worker, &SerialWorker::stopLoop);
connect(this, &MainWindow::stopSignal, sensitive, &sensitive_data::stopSlot);
connect(this, &MainWindow::stopSignal, all, &all_data::stopSlot);
sensitive->resize(800, 600);
all->resize(800, 600);
all->show();
all->hide();
sensitive->show();
this->hide();
}
void MainWindow::show_sensitive()
{
sensitive->show();
all->hide();
}
void MainWindow::show_all()
{
all->show();
sensitive->hide();
}
void MainWindow::stop_serial()
{
emit stopSignal();
}
void MainWindow::back()
{
all->close();
delete all;
sensitive->close();
delete sensitive;
delete worker;
this->show();
}