-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathqpidcontroller.h
105 lines (90 loc) · 2.37 KB
/
qpidcontroller.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
/*
*
* MashBerry Homebrewing-controller
*
* Copyright (C) 2013 Sebastian Duell
* <mail@sebastian-duell.de>
*
* This file is licensed under the terms of the GNU General Public
* License version 3. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#ifndef QPIDCONTROLLER_H
#define QPIDCONTROLLER_H
#include <QThread>
#include <QTimer>
#include <QTime>
#include <QMutex>
#include <QTextStream>
#include "PID/PID_v1.h"
#include "PID/PID_AutoTune_v0.h"
#include "qtempsensor.h"
#include "qpidparameters.h"
#include "qrecipe.h"
#include "qmysettings.h"
#include "qgpio.h"
#define dbgout qDebug
//#define dbgout printf
class QPidController : public QThread
{
Q_OBJECT
public:
explicit QPidController(QMySettings *pSettings, QObject *parent = 0);
~QPidController();
void EndThread();
signals:
void SetAktTemp(double temp);
void SetSetTemp(double temp);
void SetAktPower(int power);
void SetAktAction(QString action);
void SetRemainTime(QString t);
void EnableContinueButton(bool state);
private slots:
public slots:
void ATuneSingle(int Setpoint);
void ATuneRecipe(QRecipe *pRecipe, bool overwrite);
void SetRecipe(QRecipe *pRecipe);
void ContinueClicked();
void FlushCsvFile();
void StopRecipe();
protected:
void run();
void InitTempSensor();
bool ActivateRecipeStep(int idx);
void StartAtune(bool single, double Setpoint = 0);
void LogTemp();
void DoAutotune();
void SkipTunedRecipeSteps();
void Beep(int msec);
void Endbeep();
private:
bool m_bEndThread;
bool m_bAutoTuning;
bool m_bOverwriteATuning;
bool m_bRecipeTuning;
bool m_bAutotuneComplete;
bool m_bRecipeMode;
bool m_bRecipeTempReached;
bool m_bLogTemp;
QTime *m_pATuneTime;
QTime *m_pRecipeTime;
QMutex m_CtrlMutex;
QFile *m_pLogFile;
QTextStream *m_pLogStream;
PID *m_pPID;
PID_ATune *m_pATune;
QTempSensor *m_pTempSensor;
QRecipe *m_pRecipe;
QRecipeEntry *m_pAktRecipeStep;
QGpio m_beeperGpio;
QMySettings *m_pSettings;
double m_AktTemp;
int m_AktPower;
double m_AktSetpoint;
int m_stepTime;
int m_recipeStep;
double m_kp;
double m_ki;
double m_kd;
};
#endif // QPIDCONTROLLER_H