#include "ovenstatics.h" #include #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; } }