-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
118 lines (97 loc) · 2.43 KB
/
mainwindow.h
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* qCommTest - Serial Communication Test Tool
* Version : 1.0
* Date : 20.11.2017
* Author : Eray Ozturk | github.com/diffstorm
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "tcp_server.h"
#include "serial_port.h"
namespace Ui
{
class MainWindow;
}
enum class Channel_t
{
TCP,
Serial
};
enum class Test_Step_t
{
step_Idle, // Wait for first packet from device
step_Test, // Test
};
enum class Icon_t
{
Disconnected,
Connecting,
Testing,
TestSuccess,
TestFailed
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Test_Step_t m_testStep;
qint32 m_testIndex;
QPoint m_dragPosition;
bool m_testStarted;
qint64 m_data_size = 0;
qint64 m_testStartAt;
qint64 m_testFinishAt;
qint64 m_testElapsedTime;
Ui::MainWindow *ui;
TcpServer *m_tcpServer;
serial_port *m_serialPort;
QAction *usageAction;
QAction *aboutAction;
QAction *quitAction;
QMovie *movie = nullptr;
QTimer m_timer_test;
void Form_Init();
void Log(const QString &);
void TcpServer_Init();
bool TcpServer_Start(int);
void TcpServer_Stop();
void SerialPort_Init();
void SerialPort_Refresh();
bool SerialPort_Start();
void SerialPort_Stop();
void SerialPort_SetEnabled(bool);
void Clean_Counters();
void Inc_RX();
void Inc_TX();
void Inc_Error();
void SetTestStarted(bool);
bool Send(Channel_t, QByteArray);
qint64 PacketTimeout(Channel_t);
qint64 ElapsedTime(Channel_t);
QByteArray Protocol_Wrap(QByteArray);
QByteArray Protocol_Unwrap(QByteArray);
void Test(Channel_t, QByteArray);
quint32 crc32(const char *, quint16);
void SetMoodIcon(Icon_t);
void PrintResults();
private slots:
void About();
void Usage();
void onLogMessage(const QString &log);
void onTcpClientDisconnected();
void onTcpClientConnected();
void onTcpDataReceivedFromClient();
void onSerialDataReceived();
void onTimeoutTest();
void on_tabWidget_currentChanged(int);
void on_serial_open_clicked();
void on_tcp_listen_clicked();
protected:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
};
#endif // MAINWINDOW_H