ovenstatics.cpp
4.11 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
#include "ovenstatics.h"
#include <QtDebug>
#include "mainwindow.h"
#include "ovencontroller.h"
#include "popupwindow.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()));
}
return p_singtonInstance;
}
void OvenStatics::destroy(){
if(!p_singtonInstance)
delete p_singtonInstance;
}
OvenStatics::OvenStatics(QObject* parent) :QObject(parent)
{
curdoorstate = false;
curSysErrorState = 0;
srvdatas = new servicedatas();
srvdatas->loadServiceDatas();
}
OvenStatics::~OvenStatics(){
delete srvdatas;
}
void OvenStatics::onDataChanged()
{
error_item *item;
time_t ltime=0;
qDebug() << "statics event fired";
popupWindow *w = new popupWindow((QWidget*) parent());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
return;
udp->fillControl(control);
udp->fillData(state);
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;
}
}
void OvenStatics::processSystemError(uint16_t errflag,time_t ltime){
error_item *item;
if( errflag & SYS_ERR_FIRE_TRIGGER1){
//버너 컨트롤러 1 착화 이상
item = &(srvdatas->err_log.items.upper_fire_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_FIRE_TRIGGER2){
//버너 컨트롤러 2 착화 이상
item = &(srvdatas->err_log.items.lower_fire_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_FIRE_TRIGGER3){
item = &(srvdatas->err_log.items.steam_fire_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_OVNE_TEMP_ALARM){
item = &(srvdatas->err_log.items.inner_temp_high_alarm);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_QUN_TEMP_ALARM){
//퀀칭 온도 센서 과열 -> 에러 항목 없으며 통신이상과 동일 처리
item = &(srvdatas->err_log.items.qunching_temp_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_CENTER_TEMP_ALARM){
item = &(srvdatas->err_log.items.meat_prove_temp1_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_WALL_TEMP_ALARM){
item = &(srvdatas->err_log.items.wall_temp1_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
if(errflag & SYS_ERR_WATER_SPLY_FAIL){
//급수 이상 -> 수위 센서 이상으로 통일
item = &(srvdatas->err_log.items.water_level_sensor_fail);
item->fired_cnt+=1;
if(item->first_fired == 0) item->first_fired = ltime;
item->last_fried = ltime;
}
}