From 2189b57d9aab28ac708bd0ad6c2168a91badc6c8 Mon Sep 17 00:00:00 2001
From: byloveletter <byloveletter@falinux.com>
Date: Wed, 16 Aug 2017 17:04:22 +0900
Subject: [PATCH] GUI V0.3.15
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 - 0.3.15 버전 변경
 - 통신에러 30초간 감지 후 발생
---
 app/gui/oven_control/define.h        |  2 +-
 app/gui/oven_control/ovenstatics.cpp | 72 +++++++++++++++++++++++++++++++-----
 2 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/app/gui/oven_control/define.h b/app/gui/oven_control/define.h
index 19641f6..348fbab 100644
--- a/app/gui/oven_control/define.h
+++ b/app/gui/oven_control/define.h
@@ -5,7 +5,7 @@
 
 #define MAJOR_VER  0
 #define MINOR_VER   3
-#define HOTFIX_VER  14
+#define HOTFIX_VER  15
 
 namespace Define
 {
diff --git a/app/gui/oven_control/ovenstatics.cpp b/app/gui/oven_control/ovenstatics.cpp
index 5740909..956fef1 100644
--- a/app/gui/oven_control/ovenstatics.cpp
+++ b/app/gui/oven_control/ovenstatics.cpp
@@ -93,11 +93,11 @@ void OvenStatistics::onDataChanged()
     }
     curSysErrorState = state.system_error;
 
-    errstatetemp = state.communication_error;
-    if(errstatetemp!=0 && errstatetemp != curCommErrorState ){
-        processCommError( (errstatetemp & comm_err_mask[cookingstate][cfg->getConfigValue(Define::config_model).d32]),ltime );
-    }
-    curCommErrorState = errstatetemp;
+//    errstatetemp = state.communication_error;
+//    if(errstatetemp!=0 && errstatetemp != curCommErrorState ){
+//        processCommError( (errstatetemp & comm_err_mask[cookingstate][cfg->getConfigValue(Define::config_model).d32]),ltime );
+//    }
+//    curCommErrorState = errstatetemp;
 
     errstatetemp = state.sensor_error;
     if(errstatetemp!=0 && errstatetemp != curSensorErrorState ){
@@ -105,11 +105,11 @@ void OvenStatistics::onDataChanged()
     }
     curSensorErrorState = errstatetemp;
 
-    errstatetemp = state.controller_error;
-    if(errstatetemp != 0 && errstatetemp != curControlErrorState){
-        processStateError((errstatetemp&state_err_mask[cookingstate][cfg->getConfigValue(Define::config_model).d32]),ltime);
-    }
-    curControlErrorState = errstatetemp;
+//    errstatetemp = state.controller_error;
+//    if(errstatetemp != 0 && errstatetemp != curControlErrorState){
+//        processStateError((errstatetemp&state_err_mask[cookingstate][cfg->getConfigValue(Define::config_model).d32]),ltime);
+//    }
+//    curControlErrorState = errstatetemp;
 
 }
 
@@ -367,6 +367,14 @@ void OvenStatistics::oneSecTimerFired(void){
     static int nOneSecCnt=1;
     time_t ltime;
 
+    static int nStateErrValStableCnt = 0;
+    static int nCommErrValStableCnt = 0;
+    static uint16_t nCommErrVal = 0;
+    static uint16_t nStateErrVal = 0;
+    uint16_t errstatetemp=0;
+    int cookingstate=0;
+    if((control.cooking || oven->cooking() || oven->preheating() || oven->cooldown())) cookingstate  =1;
+
     ltime = time(NULL);
 
     nOneSecCnt++;
@@ -374,11 +382,55 @@ void OvenStatistics::oneSecTimerFired(void){
         srvdata->saveServiceData();
     }
 
+
     if(bDataRefreshed) bDataRefreshed= false;
     else{
         udp->fillControl(control);
         udp->fillData(state);
     }
+
+    if(nCommErrVal !=  state.communication_error){
+        nCommErrVal = state.communication_error;
+        if(nCommErrVal ==0) {
+            curCommErrorState = nCommErrVal;
+            nCommErrValStableCnt = 60;
+        }
+        else {
+            nCommErrValStableCnt=0;
+        }
+    }
+    else{
+        if(nCommErrValStableCnt >=60){
+            errstatetemp = state.communication_error;
+            if(errstatetemp!=0 && errstatetemp != curCommErrorState ){
+                processCommError( (errstatetemp & comm_err_mask[cookingstate][cfg->getConfigValue(Define::config_model).d32]),ltime );
+            }
+            curCommErrorState = errstatetemp;
+        }
+        else nCommErrValStableCnt++;
+    }
+
+    if(nStateErrVal != state.controller_error){
+        nStateErrVal = state.controller_error;
+        if(nStateErrVal == 0 ) {
+            curControlErrorState = nStateErrVal;
+            nStateErrValStableCnt=60;
+        }
+        else{
+            nStateErrValStableCnt=0;
+        }
+    }
+    else{
+        if(nStateErrValStableCnt>=60){
+            errstatetemp = state.controller_error;
+            if(errstatetemp != 0 && errstatetemp != curControlErrorState){
+                processStateError((errstatetemp&state_err_mask[cookingstate][cfg->getConfigValue(Define::config_model).d32]),ltime);
+            }
+            curControlErrorState = errstatetemp;
+        }
+        else nStateErrValStableCnt++;
+    }
+
     //가열부 시간 측정
     if( (state.onoff_state1 & LOAD_STATE1_STEAM_BUNNER) !=0){
         srvdata->use_log.items.steam_heat +=1;
-- 
2.1.4