ovenstatics.cpp
14.9 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
#include "ovenstatics.h"
#include <QtDebug>
#include <QApplication>
#include <QTimer>
#include "mainwindow.h"
#include "ovencontroller.h"
#include "popupwindow.h"
#include "engineermenuwindow.h"
#include "errorpopupdlg.h"
OvenStatics* OvenStatics::p_singtonInstance=NULL;
OvenStatics* OvenStatics::getInstance(QObject *parent, UdpHandler* udp, Oven* oven){
if(!p_singtonInstance){
if(udp==NULL) return NULL;
p_singtonInstance = new OvenStatics(parent);
p_singtonInstance->udp = udp;
p_singtonInstance->oven = oven;
//for singletone event debug
MainWindow* mw = (MainWindow*)parent;
connect(mw->pcombiButton, SIGNAL(clicked()),p_singtonInstance, SLOT(onDataChanged()));
connect(p_singtonInstance->udp , SIGNAL(changed()), p_singtonInstance, SLOT(onDataChanged()));
QTimer *timer = new QTimer(p_singtonInstance);
connect(timer, SIGNAL(timeout()),p_singtonInstance,SLOT(oneSecTimerFired()));
timer->start(1000); //1000ms fired
}
return p_singtonInstance;
}
void OvenStatics::destroy(){
if(!p_singtonInstance)
delete p_singtonInstance;
}
OvenStatics::OvenStatics(QObject* parent) :QObject(parent)
{
curdoorstate = false;
curSysErrorState = 0;
curCommErrorState = 0;
curSensorErrorState = 0;
bDataRefreshed = false;
srvdatas = new servicedatas();
srvdatas->loadServiceDatas();
}
OvenStatics::~OvenStatics(){
delete srvdatas;
}
void OvenStatics::onDataChanged()
{
error_item *item;
time_t ltime=0;
uint16_t errstatetemp;
qDebug() << "statics event fired";
return;
udp->fillControl(control);
udp->fillData(state);
bDataRefreshed = true;
time(<ime);
if(oven->cooking() && control.system){
if(state.door_state ==1 && curdoorstate==0){
//door error
item = &(srvdatas->err_log.items.door);
item->fired_cnt+=1;
if(item->first_fired==0)item->first_fired = ltime;
item->last_fried = ltime;
}
curdoorstate = state.door_state;
}
if(state.system_error!=0 && state.system_error != curSysErrorState){
processSystemError( state.system_error,ltime);
}
curSysErrorState = state.system_error;
errstatetemp = state.reserved2f;
if(errstatetemp!=0 && errstatetemp != curCommErrorState ){
processCommError( errstatetemp,ltime );
}
curCommErrorState = errstatetemp;
errstatetemp = state.reserved30;
if(errstatetemp!=0 && errstatetemp != curSensorErrorState ){
processCommError( errstatetemp,ltime );
}
curSensorErrorState = errstatetemp;
}
void OvenStatics::processSensorError(uint16_t errflag, time_t ltime){
error_item *item;
QString strMsg = "";
uint8_t state;
if( control.system==0 && !oven->cooking()) state = SYS_OFF_COOK_OFF;
else if(control.system != 0 && !oven->cooking()) state = SYS_ON_COOK_OFF;
else if(control.system !=0 && oven->cooking()) state = SYS_ON_COOK_ON;
else state = SYS_ON_COOK_OFF;
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_1)){
item = &(srvdatas->err_log.items.inner_temp_fail);
strMsg = tr("내부 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_1],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_2)){
item = &(srvdatas->err_log.items.qunching_temp_fail);
strMsg = tr("퀀칭 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_2],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_3)){
//Reserved allerrornoe 설정
item = &(srvdatas->err_log.items.qunching_temp_fail);
strMsg = tr("퀀칭 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_3],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_4)){
item = &(srvdatas->err_log.items.wall_temp1_fail);
strMsg = tr("벽면 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_4],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_5)){
item = &(srvdatas->err_log.items.steam_gen_temp_fail);
strMsg = tr("스팀제네레이터 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_5],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_6)){
item = &(srvdatas->err_log.items.meatprove_temp1_fail);
strMsg = tr("미트프로브 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_6],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_7)){
//Reseved
item = &(srvdatas->err_log.items.meatprove_temp2_fail);
strMsg = tr("미트프로브2 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_7],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_8)){
//Reserved
item = &(srvdatas->err_log.items.meatprove_temp3_fail);
strMsg = tr("미트프로브3 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_8],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_9)){
//Reserved
item = &(srvdatas->err_log.items.meatprove_temp4_fail);
strMsg = tr("미트프로브4 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_9],strMsg,ltime);
}
if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_10)){
item = &(srvdatas->err_log.items.pcb_temp_fail);
strMsg = tr("PCB 온도 이상 발생");
processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_10],strMsg,ltime);
}
}
void OvenStatics::processCommError(uint16_t errflag, time_t ltime){
error_item *item;
QString strMsg = "";
uint8_t state;
if( control.system==0 && !oven->cooking()) state = SYS_OFF_COOK_OFF;
else if(control.system != 0 && !oven->cooking()) state = SYS_ON_COOK_OFF;
else if(control.system !=0 && oven->cooking()) state = SYS_ON_COOK_ON;
else state = SYS_ON_COOK_OFF;
if(errflag & MAKE_MASK(COMM_ERR_BUNNER1)){
item = &(srvdatas->err_log.items.upper_pan_fail);
strMsg = tr("상부 송풍기 이상 발생");
processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER1],strMsg,ltime);
}
if(errflag & MAKE_MASK(COMM_ERR_BUNNER2)){
item = &(srvdatas->err_log.items.lower_pan_fail);
strMsg = tr("하부 송풍기 이상 발생");
processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER2],strMsg,ltime);
}
if(errflag & MAKE_MASK(COMM_ERR_BUNNER3)){
item = &(srvdatas->err_log.items.steam_pan_fail);
strMsg = tr("스팀 송풍기 이상 발생");
processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER3],strMsg,ltime);
}
if(errflag & MAKE_MASK(COMM_ERR_LOWERPAN)){
item = &(srvdatas->err_log.items.lower_motor_fail);
strMsg = tr("상부 모터 컨트롤러 이상 발생");
processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER2],strMsg,ltime);
}
if(errflag & MAKE_MASK(COMM_ERR_UPPERFAN)){
item = &(srvdatas->err_log.items.upper_motor_fail);
strMsg = tr("상부 모터 컨트롤러 이상 발생");
processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER2],strMsg,ltime);
}
}
void OvenStatics::processSystemError(uint16_t errflag,time_t ltime){
error_item *item;
QString strMsg = "";
uint8_t state;
if( control.system==0 && !oven->cooking()) state = SYS_OFF_COOK_OFF;
else if(control.system != 0 && !oven->cooking()) state = SYS_ON_COOK_OFF;
else if(control.system !=0 && oven->cooking()) state = SYS_ON_COOK_ON;
else state = SYS_ON_COOK_OFF;
if( errflag & MAKE_MASK(SYS_ERR_FIRE_TRIGGER1)){
//버너 컨트롤러 1 착화 이상
item = &(srvdatas->err_log.items.upper_fire_fail);
strMsg = tr("상부 버너 착하가 되지 않습니다.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_FIRE_TRIGGER1],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_FIRE_TRIGGER2)){
//버너 컨트롤러 2 착화 이상
item = &(srvdatas->err_log.items.lower_fire_fail);
strMsg = tr("하부 버너 착하가 되지 않습니다.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_FIRE_TRIGGER2],strMsg,ltime);
}
if(errflag & SYS_ERR_FIRE_TRIGGER3){
item = &(srvdatas->err_log.items.steam_fire_fail);
strMsg = tr("스팀 버너 착하가 되지 않습니다.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_FIRE_TRIGGER3],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_OVNE_TEMP_ALARM)){
item = &(srvdatas->err_log.items.inner_temp_high_alarm);
strMsg = tr("내부 온도 과열 발생.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_OVNE_TEMP_ALARM],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_QUN_TEMP_ALARM)){
//퀀칭 온도 센서 과열
item = &(srvdatas->err_log.items.qunching_temp_high_alarm);
strMsg = tr("퀀칭 온도 센서 이상 발생.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_QUN_TEMP_ALARM],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_CENTER_TEMP_ALARM)){
//중심 온도 과열
item = &(srvdatas->err_log.items.meatprove_temp1_high_alarm);
strMsg = tr("미트프로브 온도 센서 이상 발생.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_CENTER_TEMP_ALARM],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_WALL_TEMP_ALARM)){
item = &(srvdatas->err_log.items.wall_temp1_high_alarm);
strMsg = tr("벽면 온도 센서 이상 발생.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_WALL_TEMP_ALARM],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_WATER_SPLY_FAIL)){
//급수 이상 -> 유량 센서 이상
item = &(srvdatas->err_log.items.water_level_sensor_fail);
strMsg = tr("급수가 되지 않습니다.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_WATER_SPLY_FAIL],strMsg,ltime);
}
if(errflag & MAKE_MASK(SYS_ERR_WATER_LEVEL_FAIL)){
//급수 이상 -> 수위 센서 이상
item = &(srvdatas->err_log.items.water_level_sensor_fail);
strMsg = tr("급수가 되지 않습니다.");
processErrorItems(item, sys_err_type_def[state][SYS_ERR_WATER_LEVEL_FAIL],strMsg,ltime);
}
}
bool OvenStatics::getNeedErrorClear(){
return bNeedErrorClear;
}
void OvenStatics::clearNeedErrorClear(){
//에러클리어 송신 후 flag clear
bNeedErrorClear = false;
}
void OvenStatics::oneSecTimerFired(void){
if(bDataRefreshed) bDataRefreshed= false;
else{
udp->fillControl(control);
udp->fillData(state);
}
//가열부 시간 측정
if( (state.onoff_state1 & LOAD_STATE1_STEAM_BUNNER) !=0){
srvdatas->use_log.items.steam_heat +=1;
}
if( (state.onoff_state1 & (LOAD_STATE1_UPPER_BUNNER | LOAD_STATE1_LOWER_FAN))!=0){
srvdatas->use_log.items.dry_heat+=1;
if(state.onoff_state1 & (LOAD_STATE1_UPPER_BUNNER)){
srvdatas->use_log.items.upper_heat +=1;
}
if((state.onoff_state2 & LOAD_STATE1_LOWER_BUNNER)!=0){
srvdatas->use_log.items.lower_heat +=1;
}
}
//모드 시간 계산
if(state.cooking_mode !=0){
if(state.cooking_humidity==0){
//건열 모드
srvdatas->use_log.items.cook_dry_mode+=1;
}
else if(state.cooking_humidity ==100){
//스팀모드
srvdatas->use_log.items.cook_steam_mode+=1;
}
else srvdatas->use_log.items.cook_combi_mode+=1;
}
if(state.cleaning_mode !=0){
switch (state.cleaning_mode) {
case (uint16_t)wash_mode_nocleanser:
srvdatas->use_log.items.wash_mode_nocleanser+=1;
break;
case (uint16_t)wash_mode_simple:
srvdatas->use_log.items.wash_mode_simple+=1;
break;
case (uint16_t)wash_mode_standard:
srvdatas->use_log.items.wash_mode_standard+=1;
break;
case (uint16_t)wash_mode_strong:
srvdatas->use_log.items.wash_mode_strong+=1;
break;
case (uint16_t)wash_mode_highspeed:
srvdatas->use_log.items.wash_mode_speed+=1;
break;
default:
break;
}
}
if(control.cooldown ==1){
srvdatas->use_log.items.cooldown_mode+=1;
}
//부품
if(state.door_state ==1){
srvdatas->use_log.items.door_open+=1;
}
if(state.onoff_state2 !=0){
if( (state.onoff_state2 & LOAD_STATE2_DV)!=0){
srvdatas->use_log.items.dv_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_SSV)!=0){
srvdatas->use_log.items.ssv_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_QNV)!=0){
srvdatas->use_log.items.qnv_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_SNV)!=0){
srvdatas->use_log.items.snv_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_SSP)!=0){
srvdatas->use_log.items.ssp_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_HDM)!=0){
srvdatas->use_log.items.hdm_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_DP)!=0){
srvdatas->use_log.items.dp_open+=1;
}
if((state.onoff_state2 & LOAD_STATE2_UNP) !=0){
srvdatas->use_log.items.unp_open+=1;
}
}
}
void OvenStatics::processErrorItems(error_item *item, error_exe_type errtype, const QString &MsgDesc, time_t ltime){
if(errtype >= error_type_onlychk){
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
switch(errtype){
case error_type_onlypop:
case error_type_popclr:
case error_type_popnonclr:
{
errorPopupDlg *dlg = new errorPopupDlg(QApplication::activeWindow(),MsgDesc);
dlg->exec();
break;
}
case error_type_engclr:
case error_type_engnonclr:
case error_type_onlyeng:
{
engineermenuwindow *w = new engineermenuwindow(QApplication::activeWindow());
w->showFullScreen();
break;
}
default:
break;
}
if(errtype > error_type_clrsplit){
//에러 클리어 명령 송신
qDebug() << "send error clear command";
if(errtype == error_type_engclr){
//확인 후 송신
bNeedErrorClear = true;
}
else{
//에러클리어 메시지 즉시 송신
}
}
}