#include "ovenstatics.h" #include #include #include #include "mainwindow.h" #include "ovencontroller.h" #include "popupwindow.h" #include "engineermenuwindow.h" #include "errorpopupdlg.h" #include "historylistwindow.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) { int i = 0; curdoorstate = false; curSysErrorState = 0; curCommErrorState = 0; curSensorErrorState = 0; bDataRefreshed = false; realdata.d32 = 0; for(i=0;iloadServiceDatas(); } OvenStatics::~OvenStatics(){ delete srvdatas; } void OvenStatics::onDataChanged() { error_item *item; time_t ltime=0; uint16_t errstatetemp; qDebug() << "statics event fired"; 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.communication_error; if(errstatetemp!=0 && errstatetemp != curCommErrorState ){ processCommError( errstatetemp,ltime ); } curCommErrorState = errstatetemp; errstatetemp = state.sensor_error; if(errstatetemp!=0 && errstatetemp != curSensorErrorState ){ processSensorError(errstatetemp,ltime ); } curSensorErrorState = errstatetemp; } void OvenStatics::processSensorError(uint16_t errflag, time_t ltime){ error_item *item; QString strMsg = "",strTitle=""; 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); strTitle = tr("내부 온도 이상 발생"); strMsg = tr("내부 온도 센서에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_1],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_2)){ item = &(srvdatas->err_log.items.qunching_temp_fail); strTitle = tr("퀀칭 온도 이상 발생"); strMsg = tr("퀀칭 온도에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_2],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_3)){ //Reserved allerrornoe 설정 item = &(srvdatas->err_log.items.qunching_temp_fail); strTitle = tr("퀀칭 온도 이상 발생"); strMsg = tr("퀀칭 온도 센서에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_3],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_4)){ item = &(srvdatas->err_log.items.wall_temp1_fail); strTitle = tr("벽면 온도 이상 발생"); strMsg = tr("벽면 온도 센서에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_4],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_5)){ item = &(srvdatas->err_log.items.steam_gen_temp_fail); strTitle = tr("스팀제네레이터 온도 이상 발생"); strMsg = tr("스팀제네레이터 온도 센서에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_5],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_6)){ item = &(srvdatas->err_log.items.meatprove_temp1_fail); strTitle = tr("미트프로브 온도 이상 발생"); strMsg = tr("미트프로브 온도 센서에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_6],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_7)){ //Reseved item = &(srvdatas->err_log.items.meatprove_temp2_fail); strTitle = tr("미트프로브2 온도 이상 발생"); strMsg = tr("미트프로브2 온도 센서에 이상이 발생하였습니다."); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_7],strMsg , strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_8)){ //Reserved item = &(srvdatas->err_log.items.meatprove_temp3_fail); strMsg = tr("미트프로브3 온도 센서에 이상이 발생하였습니다."); strTitle = tr("미트프로브3 온도 이상 발생"); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_8],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_9)){ //Reserved item = &(srvdatas->err_log.items.meatprove_temp4_fail); strMsg = tr("미트프로브4 온도 센서에 이상이 발생하였습니다."); strTitle = tr("미트프로브4 온도 이상 발생"); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_9],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(SENSOR_ERR_SENSOR_10)){ item = &(srvdatas->err_log.items.pcb_temp_fail); strMsg = tr("PCB 온도 센서에 이상이 발생하였습니다."); strTitle = tr("PCB 온도 이상 발생"); processErrorItems(item,sensor_err_type_def[state][SENSOR_ERR_SENSOR_10],strMsg,strTitle, ltime); } } void OvenStatics::processCommError(uint16_t errflag, time_t ltime){ error_item *item; QString strMsg = "",strTitle=""; 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("상부 송풍기 이상 발생"); strTitle = tr("상부 송풍기 이상 발생"); processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER1],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(COMM_ERR_BUNNER2)){ item = &(srvdatas->err_log.items.lower_pan_fail); strMsg = tr("하부 송풍기 이상 발생"); strTitle = tr("하부 송풍기 이상 발생"); processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER2],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(COMM_ERR_BUNNER3)){ item = &(srvdatas->err_log.items.steam_pan_fail); strMsg = tr("스팀 송풍기 이상 발생"); strTitle = tr("스팀 송풍기 이상 발생"); processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER3],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(COMM_ERR_LOWERFAN)){ item = &(srvdatas->err_log.items.lower_motor_fail); strMsg = tr("하부 모터 컨트롤러 이상 발생"); strTitle = tr("하부 모터 컨트롤러 이상 발생"); processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER2],strMsg,strTitle, ltime); } if(errflag & MAKE_MASK(COMM_ERR_UPPERFAN)){ item = &(srvdatas->err_log.items.upper_motor_fail); strMsg = tr("상부 모터 컨트롤러 이상 발생"); strTitle = tr("상부 모터 컨트롤러 이상 발생"); processErrorItems(item,comm_err_type_def[state][COMM_ERR_BUNNER2],strMsg,strTitle, ltime); } } void OvenStatics::processSystemError(uint16_t errflag,time_t ltime){ error_item *item; QString strMsg = "",strTitle = ""; 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("상부 버너 착하가 되지 않습니다."); strTitle = tr("상부 버너 착하 이상 발생"); processErrorItems(item, sys_err_type_def[state][SYS_ERR_FIRE_TRIGGER1],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_FIRE_TRIGGER2)){ //버너 컨트롤러 2 착화 이상 item = &(srvdatas->err_log.items.lower_fire_fail); strMsg = tr("하부 버너 착하가 되지 않습니다."); strTitle = tr("하부 버너 착하 이상 발생"); processErrorItems(item, sys_err_type_def[state][SYS_ERR_FIRE_TRIGGER2],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_FIRE_TRIGGER3)){ item = &(srvdatas->err_log.items.steam_fire_fail); strMsg = tr("스팀 버너 착하가 되지 않습니다."); strMsg = tr("스팀 버너 착하 이상 발생"); processErrorItems(item, sys_err_type_def[state][SYS_ERR_FIRE_TRIGGER3],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_OVNE_TEMP_ALARM)){ item = &(srvdatas->err_log.items.inner_temp_high_alarm); strMsg = tr("내부 온도가 과열되었습니다."); strTitle = tr("내부 온도 과열 발생"); processErrorItems(item, sys_err_type_def[state][SYS_ERR_OVNE_TEMP_ALARM],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_QUN_TEMP_ALARM)){ //퀀칭 온도 센서 과열 item = &(srvdatas->err_log.items.qunching_temp_high_alarm); strTitle = tr("퀀칭 온도 센서 이상 발생"); strMsg = tr("퀀칭 온도 센서가 과열되었습니다"); processErrorItems(item, sys_err_type_def[state][SYS_ERR_QUN_TEMP_ALARM],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_CENTER_TEMP_ALARM)){ //중심 온도 과열 item = &(srvdatas->err_log.items.meatprove_temp1_high_alarm); strTitle = tr("미트프로브 온도 센서 이상 발생."); strMsg = tr("미트프로브 온도 센서 과열되었습니다."); processErrorItems(item, sys_err_type_def[state][SYS_ERR_CENTER_TEMP_ALARM],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_WALL_TEMP_ALARM)){ item = &(srvdatas->err_log.items.wall_temp1_high_alarm); strTitle = tr("벽면 온도 센서 이상 발생."); strMsg = tr("벽면 온도 센서가 과열 되었습니다."); processErrorItems(item, sys_err_type_def[state][SYS_ERR_WALL_TEMP_ALARM],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_STAM_TEMP_ALARM)){ item = &(srvdatas->err_log.items.steam_gen_temp_high_alram); strTitle = tr("스팀제네레이터 온도 과열 발생."); strMsg = tr("스팀제네레이터 온도 센서 과열이 발생되었습니다."); processErrorItems(item, sys_err_type_def[state][SYS_ERR_STAM_TEMP_ALARM],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_WATER_SPLY_FAIL)){ //급수 이상 -> 유량 센서 이상 item = &(srvdatas->err_log.items.water_level_sensor_fail); strTitle = tr("급수 이상 발생"); strMsg = tr("급수가 되지 않습니다."); processErrorItems(item, sys_err_type_def[state][SYS_ERR_WATER_SPLY_FAIL],strMsg,strTitle,ltime); } if(errflag & MAKE_MASK(SYS_ERR_WATER_LEVEL_FAIL)){ //급수 이상 -> 수위 센서 이상 item = &(srvdatas->err_log.items.water_level_sensor_fail); strTitle = tr("급수 이상 발생"); strMsg = tr("급수가 되지 않습니다."); processErrorItems(item, sys_err_type_def[state][SYS_ERR_WATER_LEVEL_FAIL],strMsg,strTitle,ltime); } } bool OvenStatics::getNeedErrorClear(){ return bNeedErrorClear; } void OvenStatics::clearNeedErrorClear(){ //에러클리어 송신 후 flag clear bNeedErrorClear = false; } void OvenStatics::oneSecTimerFired(void){ static int nOneSecCnt=1; time_t ltime; ltime = time(NULL); nOneSecCnt++; if( (nOneSecCnt % 10) ==0 ) { srvdatas->saveServiceDatas(); qDebug()<<"statics data saved"; } 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 && state.cleaning_sate !=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 !=0){ srvdatas->use_log.items.door_open+=1; realdata.b.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; } } //Real time Data Refresh realdata.b.door_open = state.door_state==0?0:1; realdata.b.dv_open = (state.onoff_state2&LOAD_STATE2_DV)==0?0:1; realdata.b.qnv_open = (state.onoff_state2&LOAD_STATE2_QNV)==0?0:1; realdata.b.sgnv_open = (state.onoff_state2&LOAD_STATE2_SGNV)==0?0:1; realdata.b.snv_open = (state.onoff_state2&LOAD_STATE2_SNV)==0?0:1; realdata.b.wsv_open = (state.onoff_state2&LOAD_STATE2_WSV)==0?0:1; realdata.b.ssv_open = (state.onoff_state2&LOAD_STATE2_SSV)==0?0:1; realdata.b.water_level = 0; if(srvdatas->sensor_log.items.B1.high_temp.itemp < state.sensor1 ){ srvdatas->sensor_log.items.B1.high_temp.itemp = state.sensor1; srvdatas->sensor_log.items.B1.last_high_time = ltime; } curSensorValue[0].itemp = state.sensor1; if(srvdatas->sensor_log.items.B2.high_temp.itemp < state.sensor2 ){ srvdatas->sensor_log.items.B2.high_temp.itemp = state.sensor2; srvdatas->sensor_log.items.B2.last_high_time = ltime; } curSensorValue[1].itemp = state.sensor2; if(srvdatas->sensor_log.items.B3_1.high_temp.itemp < state.sensor6 ){ srvdatas->sensor_log.items.B3_1.high_temp.itemp = state.sensor6; srvdatas->sensor_log.items.B3_1.last_high_time = ltime; } curSensorValue[5].itemp = state.sensor6; if(srvdatas->sensor_log.items.B4.high_temp.itemp < state.sensor4 ){ srvdatas->sensor_log.items.B4.high_temp.itemp = state.sensor4; srvdatas->sensor_log.items.B4.last_high_time = ltime; } curSensorValue[3].itemp = state.sensor4; if(srvdatas->sensor_log.items.B5.high_temp.itemp < state.sensor5 ){ srvdatas->sensor_log.items.B5.high_temp.itemp = state.sensor5; srvdatas->sensor_log.items.B5.last_high_time = ltime; } curSensorValue[4].itemp = state.sensor5; if(srvdatas->sensor_log.items.B3_2.high_temp.itemp < state.sensor7 ){ srvdatas->sensor_log.items.B3_2.high_temp.itemp = state.sensor7; srvdatas->sensor_log.items.B3_2.last_high_time = ltime; } curSensorValue[6].itemp = state.sensor7; if(srvdatas->sensor_log.items.B3_3.high_temp.itemp < state.sensor8 ){ srvdatas->sensor_log.items.B3_3.high_temp.itemp = state.sensor8; srvdatas->sensor_log.items.B3_3.last_high_time = ltime; } curSensorValue[7].itemp = state.sensor8; if(srvdatas->sensor_log.items.B3_4.high_temp.itemp < state.sensor9 ){ srvdatas->sensor_log.items.B3_4.high_temp.itemp = state.sensor9; srvdatas->sensor_log.items.B3_4.last_high_time = ltime; } curSensorValue[8].itemp = state.sensor9; if(srvdatas->sensor_log.items.mbar1.high_temp.utemp < state.sensor11 ){ srvdatas->sensor_log.items.mbar1.high_temp.utemp = state.sensor11; srvdatas->sensor_log.items.mbar1.last_high_time = ltime; } curSensorValue[10].utemp = state.sensor11; if(srvdatas->sensor_log.items.mbar2.high_temp.utemp < state.sensor12 ){ srvdatas->sensor_log.items.mbar2.high_temp.utemp = state.sensor12; srvdatas->sensor_log.items.mbar2.last_high_time = ltime; } curSensorValue[11].utemp = state.sensor12; if(srvdatas->sensor_log.items.pcb.high_temp.itemp < state.sensor13 ){ srvdatas->sensor_log.items.pcb.high_temp.itemp = state.sensor13; srvdatas->sensor_log.items.pcb.last_high_time = ltime; } curSensorValue[12].itemp = state.sensor13; if(srvdatas->sensor_log.items.adc.high_temp.itemp < state.sensor14 ){ srvdatas->sensor_log.items.adc.high_temp.itemp = state.sensor14; srvdatas->sensor_log.items.adc.last_high_time = ltime; } curSensorValue[13].itemp = state.sensor14; } void OvenStatics::processErrorItems(error_item *item, error_exe_type errtype, const QString &MsgDesc, const QString &MsgTitle, time_t ltime){ qDebug() << (int) (item - &(srvdatas->err_log.values[0])) << "ERROR Fired!"; if(m_pLastErrItem == item ){ srvdatas->err_log.items.repeat_error.fired_cnt =item->fired_cnt; srvdatas->err_log.items.repeat_error.first_fired = item->first_fired; srvdatas->err_log.items.repeat_error.last_fried = item->last_fried; } m_pLastErrItem = item; 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,MsgTitle); 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{ //에러클리어 메시지 즉시 송신 udp->set(TG_ERROR_CLEAR,0xCECE); } } } realtime_data OvenStatics::getPartsRealtimeData(void){ return realdata; } uint8_t OvenStatics::getSensorTypeByIdx(uint16_t idx){ if(idx > MAX_LOG_SENSOR) return 0; return sensorTypeInfo[idx]; } type_temp OvenStatics::getCurSensorValueByIdx(uint16_t idx){ return curSensorValue[idx]; }