OmronPID
Loading...
Searching...
No Matches
mainwindow.h
Go to the documentation of this file.
1
6#ifndef MAINWINDOW_H
7#define MAINWINDOW_H
8
9#include <QMainWindow>
10#include <QtSerialPort>
11#include <QModbusClient>
12#include <QModbusDataUnit>
13#include <QModbusRtuSerialMaster> //Qt5
14//#include <QModbusRtuSerialClient> //Qt6
15#include <QScrollBar>
16#include <QMutex>
17#include <QMutexLocker>
18#include <QImage>
19#include <qcustomplot.h>
20#include <QElapsedTimer>
21#include <QApplication>
22#include <QCoreApplication>
23#include <QVBoxLayout>
24#include <QHBoxLayout>
25#include <QFile>
26#include <QGraphicsView>
27#include <QTextStream>
28#include <QSslSocket>
29#include "configuredialog.h"
30#include "plotdialog.h"
31#include "tempdropdialog.h"
32#include "helpdialog.h"
33#include "joinlinedialog.h"
34#include "notify.h"
35#include "datasummary.h"
36
40namespace Ui {
41 class MainWindow;
42}
43
44class Communication;
45class Safety;
46class DataSummary;
47
51class MainWindow : public QMainWindow
52{
53 Q_OBJECT
54
55public:
60 explicit MainWindow(QWidget *parent = 0);
61
66
72 void LogMsg(QString str, bool newLine = true);
73
78
79signals:
80
81public slots:
85 void makePlot();
86
91 void updateTemperature(double temperature);
92
97 void updateMV(double MV);
98
103 void updateSV(double SV);
104
109 void updateMVupper(double MVupper);
110
115 void updateMVlower(double MVlower);
116
121 void updatePID_P(double PID_P);
122
127 void updatePID_I(double PID_I);
128
133 void updatePID_D(double PID_D);
134
138 void updateStatus();
139
144 void finishSendAT(int atFlag);
145
150 void finishSendSV(double SV);
151
156 void catchLogMsg(const QString& msg);
157
163 void catchLogMsgWithColor(const QString& msg, QColor color);
164
168 void connectDevice();
169
173 void connectFailed();
174
179 void catchDanger(int type);
180
185 void updateCheckNumber(int checkNumber);
186
191 void cathcEscapeTempCheckChange(int sign);
192
197 void catchStartTempChangeCheck(int checknumber);
198
199
200private slots:
205 void keyPressEvent(QKeyEvent *key);
206
211 void keyReleaseEvent(QKeyEvent *key);
212
217 void waitForMSec(int msec);
218
224 void panalOnOff(bool IO);
225
230 void showTime();
231
235 void getSetting();
236
241 void setTextTempDrop(bool);
242
243 void on_pushButton_Connect_clicked();
244 void on_pushButton_AskStatus_clicked();
245 void on_pushButton_SetSV_clicked();
246 void on_pushButton_GetPID_clicked();
247 void on_pushButton_Control_clicked();
248 void on_comboBox_AT_currentIndexChanged(int index);
249 void on_comboBox_Mode_currentIndexChanged(int index);
250 void on_comboBox_MemAddress_currentTextChanged(const QString &arg1);
251 void on_doubleSpinBox_MVlower_valueChanged(double arg1);
252 void on_doubleSpinBox_MVupper_valueChanged(double arg1);
253 void on_checkBox_dataSave_toggled(bool checked);
254 void on_pushButton_Log_toggled(bool checked);
255 void on_pushButton_RunStop_toggled(bool checked);
256 void on_actionOpen_File_triggered();
257 void on_action_Setting_parameters_for_TempCheck_triggered();
258 void on_action_Setting_plot_triggered();
259 void on_actionHelp_Page_triggered();
260 void on_action_JoinLINE_triggered();
261 void fillDataAndPlot(const QDateTime date, const double PV, const double SV, const double MV);
262 void Run();
263 void Stop();
264 void Quit();
265 void setIntervalAskMV();
266 void setIntervalAskTemp();
267 void setIntervalPlot(int interval);
268 void setSafeLimit();
269 void setNumbers();
270 void setIgnoreRange();
271 void setParametersTempCheckChange(bool mute = true);
272 void setIgnoreEnable();
273 double fillDifference(bool mute = true);
274
275
280 void setColor(int colorindex = 0);
281
286 void sendLINE(const QString& message);
287private:
288 Ui::MainWindow *ui;
289 QCustomPlot *plot{nullptr};
290 Communication *com_{nullptr};
291 Safety *safety_{nullptr};
292 Notify *notify_{nullptr};
293 DataSummary *data_{nullptr};
294 HelpDialog *helpDialog_{nullptr};
295 QGraphicsScene *scene_{nullptr};
296 QGraphicsView *view{nullptr};
297 PlotDialog *plotDialog_{nullptr};
298 ConfigureDialog *configureDialog_{nullptr};
299 TempDropDialog *tempDropDialog_{nullptr};
300 JoinLINEDialog *joinDialog_{nullptr};
301 QString omronPortName{};
302 int msgCount{0};
303 int timing_{0};
304 int intervalPlot_{5000};
305 bool tempControlOnOff{false};
306 bool tempRecordOnOff{false};
307 bool comboxEnable{false};
308 bool spinBoxEnable{false};
309 bool muteLog{false};
310 QDateTime dateStart_{};
311 QString filePath_{};
312 QVector<QCPGraphData> pvData{};
313 QVector<QCPGraphData> svData{};
314 QVector<QCPGraphData> mvData{};
315 QVector<double> vtemp_{};
316 QVector<double> valltemp_{};
317 QVector<double> vdifftemp_{};
318 QTimer *clock{nullptr};
319 QTimer *waitTimer{nullptr};
320 QTimer *plotTimer_{nullptr};
321
322 QString LINEToken_{};
323 QUrl LINEurl_{};
324 QElapsedTimer totalElapse{};
325 bool checkDay{false};
326 int dayCounter{};
327 bool bkgColorChangeable_{true};
328 bool isQuit_{false};
329
330 // Private functions
331 void addPortName(QList<QSerialPortInfo> info);
332 void setupPlot();
333
337 void setupCombBox();
338
342 void setEnabledFalse();
343
347 void setupDialog();
348
352 void initializeVariables();
353
357 void updateStatusBoxes();
358
365 void controlStableMode(double targetValue, double tempTorr, double tempStepSize);
366
373 void controlFixedTimeMode(double targetValue, double tempTorr, double tempStepSize);
374
381 void controlFixedRateMode(double targetValue, double tempTorr, double tempStepSize);
382
389 void controlNormalAndFixedRateMode(double targetValue, double tempTorr, double tempStepSize);
390
398 double calcRate(double temp, double aftertemp, int min);
399
400};
401
402#endif // MAINWINDOW_H
The Communication class provides an interface for communicating with he E5CC temperature controller v...
Definition: communication.h:19
Dialog for configuring parameters of the Omron_PID application.
Definition: configuredialog.h:23
Class representing summary information of data.
Definition: datasummary.h:17
The HelpDialog class displays a dialog with help information.
Definition: helpdialog.h:17
The JoinLINEGroup class displays a dialog for joining a LINE group.
Definition: joinlinedialog.h:17
The MainWindow class represents the main window of the application.
Definition: mainwindow.h:52
void updatePID_D(double PID_D)
updatePID_D Slot function to update the PID controller's derivative (D) gain value display
Definition: mainwindow.cpp:1243
void updateTemperature(double temperature)
updateTemperature Slot function to update the temperature display
Definition: mainwindow.cpp:1157
void catchLogMsg(const QString &msg)
catchLogMsg Slot function to catch a log message emitted by a thread and add it to the application lo...
Definition: mainwindow.cpp:1286
void findSeriesPortDevices()
Finds all available serial port devices.
void LogMsg(QString str, bool newLine=true)
Logs a message to the GUI log.
Definition: mainwindow.cpp:124
void updateSV(double SV)
updateSV Slot function to update the set value (SV) display
Definition: mainwindow.cpp:1181
void catchLogMsgWithColor(const QString &msg, QColor color)
catchLogMsg Slot function to catch a log message emitted by a thread and add it to the application lo...
Definition: mainwindow.cpp:1297
void makePlot()
makePlot Slot function to generate plot
Definition: mainwindow.cpp:1039
void catchStartTempChangeCheck(int checknumber)
catchStartTempChangeCheck Slot function to handle the start of a temperature change check
Definition: mainwindow.cpp:1463
void updatePID_I(double PID_I)
updatePID_I Slot function to update the PID controller's integral (I) gain value display
Definition: mainwindow.cpp:1231
void finishSendSV(double SV)
finishSendSV Slot function to handle the completion of sending the set value (SV) to the device
Definition: mainwindow.cpp:1380
void updateMVupper(double MVupper)
updateMVupper Slot function to update the upper limit of the MV display
Definition: mainwindow.cpp:1193
void updateStatus()
updateStatus Slot function to update the status display
Definition: mainwindow.cpp:1270
void catchDanger(int type)
catchDanger Slot function to handle a dangerous situation detected by the Safety class
Definition: mainwindow.cpp:1400
void connectFailed()
connectFailed Slot function to handle device connection failure
Definition: mainwindow.cpp:1335
void updatePID_P(double PID_P)
updatePID_I Slot function to update the PID controller's integral (I) gain value display
Definition: mainwindow.cpp:1219
void finishSendAT(int atFlag)
finishSendAT Slot function to handle the completion of sending AT command to device
Definition: mainwindow.cpp:1355
void updateMVlower(double MVlower)
updateMVlower Slot function to update the lower limit of MV display
Definition: mainwindow.cpp:1207
void updateCheckNumber(int checkNumber)
updateCheckNumber Slot function to update the number of temperature checks that have been performed
Definition: mainwindow.cpp:1255
void connectDevice()
connectDevice Slot function to handle device connection
Definition: mainwindow.cpp:1309
void cathcEscapeTempCheckChange(int sign)
cathcEscapeTempCheckChange Slot function to handle changes in the escape temperature check checkbox
Definition: mainwindow.cpp:1439
void updateMV(double MV)
updateMV Slot function to update the MV display (MV means output power)
Definition: mainwindow.cpp:1169
~MainWindow()
Destructor for MainWindow class.
Definition: mainwindow.cpp:105
The Notify class provides a way to send notifications to different services.
Definition: notify.h:12
The PlotDialog class.
Definition: plotdialog.h:23
The central class of the library.
Definition: qcustomplot.h:3583
The Safety class ensures the safe operation of the system. This class monitors the temperature and ot...
Definition: safety.h:22
Definition: tempdropdialog.h:22
Definition: ui_mainwindow.h:957
Header file for the ConfigureDialog class.
Header file for the DataSummary class.
Header file for the HelpDialog class.
The MainWindow class represents the main window of the application.
Definition: joindialog.h:12
The dialog to set parameters of qcustomplot.
The dialog to set parameters of TempDrop.