oven.h
5.42 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#ifndef OVEN_H
#define OVEN_H
#include <QObject>
#include <QTimer>
#include <QTime>
class OvenInterface : public QObject
{
Q_OBJECT
public:
OvenInterface(QObject *parent = 0) : QObject(parent) {}
virtual ~OvenInterface(){}
virtual int currentTemp() = 0;
virtual int currentHumidity() = 0;
virtual int currentInterTemp() = 0;
virtual bool door() = 0;
signals:
void doorOpened();
void doorClosed();
public slots:
// virtual void setMode(Oven::Mode mode) = 0;
virtual void setHumidity(int percentage) = 0;
virtual void setTemp(int celsius) = 0;
virtual void setTime(int secs) = 0;
virtual void setInterTemp(int celsius) = 0;
virtual void setFan(int rpm) = 0;
virtual void startCooking() = 0;
virtual void stopCooking() = 0;
virtual void startPreheating() = 0;
virtual void stopPreheating() = 0;
virtual void startCooldown() = 0;
virtual void stopCooldown() = 0;
virtual void startHumidification() = 0;
virtual void stopHumidification() = 0;
virtual void startWashing() = 0;
virtual void stopWashing() = 0;
virtual void openDamper() = 0;
virtual void closeDamper() = 0;
};
Q_DECLARE_INTERFACE(OvenInterface, "OvenInterface")
class Oven : public QObject
{
Q_OBJECT
public:
enum Mode { HeatMode, SteamMode, CombinationMode };
private:
Mode mode_;
int humidity_;
int temp_;
int time_;
bool interTempEnabled_ = false;
int interTemp_;
int fan_; // 1 ~ 5
bool cooking_ = false;
bool preheating_ = false;
bool cooldown_ = false;
bool damper_ = false; // true: open, false: close
bool humidification_ = false;
bool door_ = false; // true: open, false: close
int currentHumidity_;
int currentTemp_;
int currentInterTemp_;
bool isInterTempValid_;
QTime interTempValidTime;
bool damperRepeat;
bool damperRepeatInfinitely;
int damperRepeatRuntime;
int damperRepeatDelay;
int damperRepeatCount;
QTimer damperRepeatRuntimeTimer;
QTimer damperRepeatDelayTimer;
bool damperRepeatPaused;
bool damperRepeatPausedOnRuntime;
int damperRepeatRemainingTime;
bool humidificationRepeat;
bool humidificationRepeatInfinitely;
int humidificationRepeatRuntime;
int humidificationRepeatDelay;
int humidificationRepeatCount;
QTimer humidificationRepeatRuntimeTimer;
QTimer humidificationRepeatDelayTimer;
bool humidificationRepeatPaused;
bool humidificationRepeatPausedOnRuntime;
int humidificationRepeatRemainingTime;
bool paused_;
QTimer cookingTimer;
QTimer damperTimer;
QTimer humidificationTimer;
QTimer interTempTimer;
OvenInterface *interface;
static Oven *instance;
public:
explicit Oven(QObject *parent = 0);
static Oven *getInstance() {
if (instance == 0)
instance = new Oven();
return instance;
}
Mode mode() { return mode_; }
int humidity() { return humidity_; }
int temp() { return temp_; }
int time();
bool interTempEnabled() { return interTempEnabled_; }
int interTemp() { return interTemp_; }
int fan() { return fan_; }
bool cooking() { return cooking_; }
bool preheating() { return preheating_; }
bool cooldown() { return cooldown_; }
bool damper() { return damper_; }
bool humidification() { return humidification_; }
bool door() { return door_; }
bool paused() { return paused_; }
int currentTemp() { return currentTemp_; }
int currentHumidity() { return currentHumidity_; }
int currentInterTemp() { return currentInterTemp_; }
bool isInterTempValid();
bool cookingStartable();
bool preheatingStartable();
bool cooldownStartable();
bool humidificationStartable();
bool damperOpenable();
int maxTemp();
int minTemp();
int maxInterTemp();
int minInterTemp();
int maxFan();
int minFan();
signals:
void changed(Oven *);
void doorOpened();
public slots:
void setMode(Mode mode);
void setDefault(Mode mode);
void setHumidity(int percentage);
void setTemp(int celsius);
void setTime(int secs);
void setInterTempEnabled(bool enabled);
void setInterTemp(int celsius);
void setFan(int speed);
void stop();
void startCooking();
void stopCooking();
void startPreheating();
void stopPreheating();
void startCooldown();
void stopCooldown();
void startHumidification(int secs = 600);
void stopHumidification();
void openDamper(int secs = 300);
void closeDamper();
void repeatHumidification(int runtime, int delay, int count = 0);
void stopRepeatHumidification();
void pauseRepeatHumidification();
void resumeRepeatHumidification();
void repeatDamper(int runtime, int delay, int count = 0);
void stopRepeatDamper();
void pauseRepeatDamper();
void resumeRepeatDamper();
void setCurrentHumidity(int percentage);
void setCurrentTemp(int celsius);
void setCurrentInterTemp(int celsius);
void setInterface(OvenInterface *interface);
private slots:
bool setMode_(Mode mode);
bool setHumidity_(int percentage);
bool setTemp_(int celsius);
bool setInterTempEnabled_(bool enabled);
bool setInterTemp_(int celsius);
bool setFan_(int speed);
void runRepeatHumidification();
void idleRepeatHumidification();
void runRepeatDamper();
void idleRepeatDamper();
void onDoorOpened();
void onDoorClosed();
};
#endif // OVEN_H