Browse Source

2022-03-28 / Simon Xue

1. [Add] Show alarm status in simple view page.
2. [Modify] LCM show summary page data.
3. [Add] Check EV Board communication & Relay Board communication

Files
As the following commit history

Image Version: v2.04.02
Simon Xue 3 years ago
parent
commit
679343ffd2

+ 78 - 22
EVSE/Projects/DD360UCar/Apps/CSU/Primary.c

@@ -64,6 +64,7 @@ void EnterLinkErrorPage()
     StartSystemTimeoutDet(Timeout_ReturnViewPage);
     //StartGunInfoTimeoutDet(pSysInfo->CurGunSelected,Timeout_LinkError);
 }
+/*
 void EnterDetailViewPage(uint8_t gunIndex)
 {
     log_info("Show Gun(%d) Detail View",gunIndex);
@@ -72,6 +73,7 @@ void EnterDetailViewPage(uint8_t gunIndex)
     StopGunInfoTimeoutDet(gunIndex);
     StartGunInfoTimeoutDet(gunIndex,Timeout_DetailView);
 }
+
 void EnterAuthorizeStopPage()
 {
     log_info("Select Gun(%d) in Stopping",pSysInfo->CurGunSelected);
@@ -86,6 +88,7 @@ void EnterAuthorizeStopPage()
     }
     StartSystemTimeoutDet(Timeout_ReturnViewPage);
 }
+*/
 void StopChargingBtn(uint8_t gunIndex)
 {
     pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
@@ -97,7 +100,6 @@ void EnterSummaryPage()
     StopSystemTimeoutDet();
     log_info("Showing Summary Page");
     pSysInfo->SystemPage = _LCM_SUMMARY;
-    StartSystemTimeoutDet(Timeout_ReturnViewPage);
 }
 // *****************************
 // Enter System status
@@ -106,10 +108,11 @@ void ReturnIDLE(uint8_t gunIndex)
 {
     log_info("Gun(%d) return to IDLE",gunIndex);
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-    EnterViewPage();
+    
     StopSystemTimeoutDet();
     StopGunInfoTimeoutDet(gunIndex);
     setChargerMode(gunIndex,MODE_IDLE);
+    EnterViewPage();
     //destroySelGun(gunIndex);
 }
 void ReturnAuthorize()
@@ -127,6 +130,7 @@ void showConfirmStopPage(uint8_t gunIndex)
 }
 void CheckLeftButton()
 {
+    DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
     uint8_t gunIndex = 0;
     switch (pSysInfo->SystemPage) {
         case _LCM_VIEW:
@@ -136,23 +140,41 @@ void CheckLeftButton()
                 EnterAuthorizePage(LEFT_GUN_NUM);
                 pSysInfo->SystemPage = _LCM_START_SCAN;
             } else if (pDcChargingInfo->SystemStatus == S_CHARGING) {
-                //EnterDetailViewPage(LEFT_GUN_NUM);
                 showConfirmStopPage(LEFT_GUN_NUM);
+            } else if (pDcChargingInfo->SystemStatus == S_ALARM) {
+                // 有進入充電時
+                if (ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM]) {
+                    // 有插槍時顯示錯誤畫面
+                    if (pDcChargingInfo->ConnectorPlugIn) {
+                        pSysInfo->SystemPage = _LCM_ERROR;
+                    } else {
+                        // 未插槍時顯示結算畫面
+                        pSysInfo->SystemPage = _LCM_SUMMARY;
+                    }
+                } else {
+                    // 未進入充電時顯示連線錯誤
+                    StopSystemTimeoutDet();
+                    StartSystemTimeoutDet(Timeout_LinkError);
+                    pSysInfo->SystemPage = _LCM_LINK_ERROR;
+                }
             }
             break;
         case _LCM_START_SCAN:
         case _LCM_START_AUTHORIZE_FAIL:
-        case _LCM_LINK_ERROR:
             if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
                 ReturnIDLE(pSysInfo->CurGunSelected);
             }
             break;
-        case _LCM_DETAIL_VIEW:
-        case _LCM_STOP_RFID:
-        case _LCM_STOP_APP:
-        case _LCM_STOP_RFID_FAIL:
-            EnterViewPage();
-        	break;
+        case _LCM_LINK_ERROR:
+            if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
+                if (pDcChargingInfo->ConnectorPlugIn) {
+                    pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
+                    StopSystemTimeoutDet();
+                    StartSystemTimeoutDet(Timeout_PlugOut);
+                } else
+                    ReturnIDLE(pSysInfo->CurGunSelected);
+            }
+            break;
         case _LCM_SUMMARY:
             if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM)
                 break;
@@ -160,11 +182,12 @@ void CheckLeftButton()
             ReturnIDLE(pSysInfo->CurGunSelected);
             break;
         case _LCM_ERROR:
-        	//EnterSummaryPage();
             if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM)
                 break;
-        	pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
-        	//ReturnIDLE(pSysInfo->CurGunSelected);
+            if (pDcChargingInfo->ConnectorPlugIn)
+                pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
+            else
+                pSysInfo->SystemPage = _LCM_SUMMARY;
             break;
         case _LCM_CONFIRM_STOP:
             if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
@@ -178,15 +201,18 @@ void CheckLeftButton()
                 ReturnIDLE(LEFT_GUN_NUM);
             break;
         case _LCM_WAIT_PLUGOUT:
-            EnterSummaryPage();
+            if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
+                if (pDcChargingInfo->ConnectorPlugIn && pDcChargingInfo->SystemStatus == S_ALARM) {
+                    pSysInfo->SystemPage = _LCM_VIEW;
+                }
+            }
             break;
     }
 }
 void CheckRightButton()
 {
-
     uint8_t gunIndex = 0;
-
+    DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
     switch (pSysInfo->SystemPage) {
         case _LCM_VIEW:
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
@@ -197,6 +223,23 @@ void CheckRightButton()
             } else if (pDcChargingInfo->SystemStatus == S_CHARGING) {
                 //EnterDetailViewPage(RIGHT_GUN_NUM);
                 showConfirmStopPage(RIGHT_GUN_NUM);
+            } else if (pDcChargingInfo->SystemStatus == S_ALARM) {
+                // 有進入充電時
+                if (ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM]) {
+                    // 有插槍時顯示錯誤畫面
+                    if (pDcChargingInfo->ConnectorPlugIn) {
+                        pSysInfo->SystemPage = _LCM_ERROR;
+                    } else {
+                        // 未插槍時顯示結算畫面
+                        pSysInfo->SystemPage = _LCM_SUMMARY;
+                        //ReturnIDLE(RIGHT_GUN_NUM);
+                    }
+                } else {
+                    // 未進入充電時顯示連線錯誤
+                    StopSystemTimeoutDet();
+                    StartSystemTimeoutDet(Timeout_LinkError);
+                    pSysInfo->SystemPage = _LCM_LINK_ERROR;
+                }
             }
             break;
         case _LCM_START_SCAN:
@@ -213,24 +256,37 @@ void CheckRightButton()
                 ReturnIDLE(RIGHT_GUN_NUM);
         	break;
         case _LCM_LINK_ERROR:
-            if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
-                break;
-            ReturnAuthorize();
+            if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
+                if (pDcChargingInfo->ConnectorPlugIn) {
+                    pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
+                    StopSystemTimeoutDet();
+                    StartSystemTimeoutDet(Timeout_PlugOut);
+                } else
+                    ReturnIDLE(pSysInfo->CurGunSelected);
+            }
             break;
+            /*
         case _LCM_DETAIL_VIEW:
             EnterAuthorizeStopPage();
             break;
         case _LCM_STOP_RFID_FAIL:
             EnterAuthorizeStopPage();
             break;
+            */
         case _LCM_WAIT_PLUGOUT:
-            EnterSummaryPage();
+            if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
+                if (pDcChargingInfo->ConnectorPlugIn && pDcChargingInfo->SystemStatus == S_ALARM) {
+                    pSysInfo->SystemPage = _LCM_VIEW;
+                }
+            }
             break;
         case _LCM_ERROR:
             if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
                 break;
-        	pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
-            //EnterSummaryPage();
+            if (pDcChargingInfo->ConnectorPlugIn)
+                pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
+            else
+                pSysInfo->SystemPage = _LCM_SUMMARY;
             break;
         case _LCM_CONFIRM_STOP:
             if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {

+ 6 - 1
EVSE/Projects/DD360UCar/Apps/CSU/SelfTest.c

@@ -28,13 +28,15 @@ void SelfTestRun(void)
     struct CHAdeMOData *ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
     struct GBTData *ShmGBTData = (struct GBTData *)GetShmGBTData();
     struct CcsData *ShmCcsData = (struct CcsData *)GetShmCcsData();
-
+    struct AlarmCodeData* pAlarmCode = (struct AlarmCodeData*)GetShmAlarmCodeData();
     struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     struct FanModuleData *ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
     struct RelayModuleData *ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
     struct ChargingInfoData *pAcChargingInfo = NULL;
 
+
+
     for(int i = 0; i < pSysConfig->TotalConnectorCount; i++)
     {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
@@ -83,6 +85,7 @@ void SelfTestRun(void)
                ) {
                 //log_info("Relay Board FW Rev = %s", pSysInfo->RelayModuleFwRev);
                 ShmRelayModuleData->SelfTest_Comp = YES;
+                pAlarmCode->AlarmEvents.bits.RelaySelftestFail = NO;
             }
 
 #if !defined NO_FAN_BOARD && !defined DD360ComBox
@@ -92,6 +95,7 @@ void SelfTestRun(void)
                ) {
                 //log_info("Fan Board FW Rev = %s", pSysInfo->FanModuleFwRev);
                 ShmFanModuleData->SelfTest_Comp = YES;
+                pAlarmCode->AlarmEvents.bits.FanboardStestFail = NO;
             }
 #else
             ShmFanModuleData->SelfTest_Comp = YES;
@@ -103,6 +107,7 @@ void SelfTestRun(void)
                ) {
                 //log_info("Primary FW Rev = %s", pSysInfo->CsuPrimFwRev);
                 ShmPrimaryMcuData->SelfTest_Comp = YES;
+                pAlarmCode->AlarmEvents.bits.PrimaryStestFail = NO;
             }
 
             // EV 小板

+ 75 - 55
EVSE/Projects/DD360UCar/Apps/CSU/main.c

@@ -83,7 +83,7 @@ uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
 char *fwVersion = "V2.04.00.0000.00"; // Phihong version
-char* DebugVersion = "v2.04.00";      // Software debug version
+char* DebugVersion = "v2.04.02";      // Software debug version
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -1576,7 +1576,6 @@ void _CcsPrechargeTimeout(uint8_t gunIndex)
 void _LinkErrorTimeout(uint8_t gunIndex)
 {
 	log_info("*********** _LinkErrorTimeout ***********");
-	setChargerMode(pSysInfo->CurGunSelected, S_IDLE);
 	pSysInfo->SystemPage = _LCM_VIEW;
 }
 
@@ -2381,6 +2380,7 @@ void KillAllTask(void)
 void StartSystemTimeoutDet(uint8_t flag)
 {
     if (pSysInfo->SystemTimeoutFlag != flag) {
+        log_info("Set System Timeout Flag %d", flag);
         GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
     }
     pSysInfo->SystemTimeoutFlag = flag;
@@ -2399,6 +2399,7 @@ void StartGunInfoTimeoutDet(uint8_t gunIndex, uint8_t flag)
     if (gunIndex < pSysConfig->TotalConnectorCount) {
         if (pDcChargingInfo->TimeoutFlag != flag) {
             gettimeofday(&pDcChargingInfo->TimeoutTimer, NULL);
+            log_info("Set Gun%d Timeout Flag %d", gunIndex,flag);
         }
         pDcChargingInfo->TimeoutFlag = flag;
     }
@@ -2462,11 +2463,14 @@ void CreateTimeoutFork(void)
                 break;
             case Timeout_ReturnViewPage:
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= RETURN_VIEWPAGE_TIMEOUT) {
+                    log_error("Timeout_ReturnViewPage");
                     StopSystemTimeoutDet();
                     pSysInfo->SystemPage = _LCM_VIEW;
                     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-                    if (pDcChargingInfo->SystemStatus == S_AUTHORIZING || pDcChargingInfo->SystemStatus == S_COMPLETE )
+                    if (pDcChargingInfo->SystemStatus == S_AUTHORIZING || pDcChargingInfo->SystemStatus == S_COMPLETE ||
+                        pDcChargingInfo->SystemStatus == S_ALARM) {
                         setChargerMode(pSysInfo->CurGunSelected, MODE_IDLE);
+                    }
                 }
             	break;
             case Timeout_Authorizing:
@@ -2496,6 +2500,7 @@ void CreateTimeoutFork(void)
             case Timeout_VerifyFail:
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT) {
                     if (pSysInfo->SystemPage ==_LCM_START_AUTHORIZE_FAIL ) {
+                        log_error("Timeout_VerifyFail authorize fail");
                         StopSystemTimeoutDet();
                         _AutoReturnTimeout();
                         //destroySelGun(pSysInfo->CurGunSelected);
@@ -2508,10 +2513,11 @@ void CreateTimeoutFork(void)
                             //sleep(1);
                             //system("/root/Module_DoComm &");
                         }*/
-                    } else if (pSysInfo->SystemPage ==_LCM_STOP_RFID_FAIL ) {
+                    } /*else if (pSysInfo->SystemPage == _LCM_STOP_RFID_FAIL) {
+                        log_error("Timeout_VerifyFail stop RFID fail");
                         StopSystemTimeoutDet();
                         pSysInfo->SystemPage = _LCM_VIEW;
-                    }
+                    }*/
                 }
                 break;
 
@@ -2544,13 +2550,28 @@ void CreateTimeoutFork(void)
                 break;
             case Timeout_Terminating:
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TERMINATING_TIMEOUT) {
-                    StopSystemTimeoutDet();
+                    
                     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
                     log_info("Terminating timeout");
+                    if (!ShmDcCommonData->finalcost_flag[pSysInfo->CurGunSelected] && pDcChargingInfo->ChargingFee < 0) {
+                        pDcChargingInfo->ChargingFee = pDcChargingInfo->PresentChargedEnergy * ShmDcCommonData->ChargingRate;
+                    }
                     setChargerMode(pSysInfo->CurGunSelected, S_COMPLETE);
                 }
                 break;
-
+            case Timeout_LinkError:
+                if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= LINKERROR_TIMEOUT) {
+                    StopSystemTimeoutDet();
+                    _LinkErrorTimeout(pSysInfo->CurGunSelected);
+                    destroySelGun(pSysInfo->CurGunSelected);
+                }
+                break;
+            case Timeout_PlugOut:
+                if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= PLUGOUT_TIMEOUT) {
+                    StopSystemTimeoutDet();
+                    pSysInfo->SystemPage = _LCM_VIEW;
+                }
+                break;
             }
             // 各槍
             for (uint8_t gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
@@ -2566,13 +2587,7 @@ void CreateTimeoutFork(void)
                     _evccidlinktimeout(gunIndex);
                 	}
                 break;
-                case Timeout_LinkError:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= LINKERROR_TIMEOUT) {
-                    	_LinkErrorTimeout(gunIndex);
-                    	StopGunInfoTimeoutDet(gunIndex);
-                        destroySelGun(gunIndex);
-                    }
-                	break;
+
                 case Timeout_Preparing:
                     if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_PREPARE_TIMEOUT) {
                         _PrepareTimeout(gunIndex);
@@ -2620,12 +2635,7 @@ void CreateTimeoutFork(void)
                     }
                     break;
                     */
-                case Timeout_DetailView:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= DETAILVIEW_TIMEOUT) {
-                        StopGunInfoTimeoutDet(gunIndex);
-                        pSysInfo->SystemPage = _LCM_VIEW;
-                    }
-                    break;
+
                 }
             }
             sleep(1);
@@ -3748,6 +3758,7 @@ void ResetIdleData(uint8_t gunIndex)
     strcpy((char *)pSysConfig->UserId, "");
     strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "");
     ShmDcCommonData->isIntoCharge[gunIndex] = FALSE;
+    ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
 
     ClearDetectPluginFlag();
     //Jerry add
@@ -3787,8 +3798,11 @@ void CheckErrorCode(uint8_t gunIndex)
         setChargerMode(gunIndex, MODE_FAULT);
     }
 }
+
 void AuthorizeStopCharging(uint8_t gunIndex)
 {
+    checkOCPPReqStop(gunIndex);
+    /*
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
     if ( pSysInfo->SystemPage == _LCM_STOP_APP ) {
         checkOCPPReqStop(gunIndex);
@@ -3803,6 +3817,7 @@ void AuthorizeStopCharging(uint8_t gunIndex)
             StartSystemTimeoutDet(Timeout_ReturnViewPage);
         }
     }
+    */
 }
 void showversion()
 {
@@ -4026,11 +4041,13 @@ int main(void)
             }
 
         }
+        /*
         if (is_idle == FALSE) {
             ShmFanModuleData->SetFan1Speed = 7000;
         } else {
             ShmFanModuleData->SetFan1Speed = 0;
         }
+        */
 
         checkChillerAlarmState();
 
@@ -4116,6 +4133,7 @@ CheckStatus:
                 if (pDcChargingInfo->SystemStatus == S_FAULT) {
                     systemPageRestoreInit();
                     setChargerMode(gunIndex, MODE_IDLE);
+                    break;
                 }
                 break;
 
@@ -4170,8 +4188,16 @@ CheckStatus:
 
                     if (!GetIsCardScan() && pSysInfo->CurGunSelected == gunIndex) {
                         pSysInfo->SystemPage = _LCM_WAIT_PLUGIN;
+                        break;
                     }
                 }
+                if (pSysInfo->CurGunSelected == gunIndex &&
+                    (pSysInfo->SystemPage != _LCM_START_AUTHORIZING &&
+                        pSysInfo->SystemPage != _LCM_START_AUTHORIZE_FAIL &&
+                        pSysInfo->SystemPage != _LCM_START_AUTHORIZE_FAIL)) {
+                    pSysInfo->SystemPage = _LCM_START_SCAN;
+                }
+
                 break;
 
             case S_REASSIGN_CHECK: {
@@ -4336,8 +4362,6 @@ CheckStatus:
                     strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].ResponseIdTagInfo.Status, ""); //DS60-120 add
                     ChangeStartOrStopDateTime(YES, gunIndex);
                     pSysInfo->SystemPage = _LCM_VIEW;
-                    StartGunInfoTimeoutDet(gunIndex,Timeout_DetailView);
-                    ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
                     ShmDcCommonData->isIntoCharge[gunIndex] = TRUE;
                 }
 
@@ -4382,22 +4406,20 @@ CheckStatus:
                         pSysInfo->SystemPage = _LCM_EMERGENCY;
                     break;
                 }
-                /*
-                if (pSysInfo->SystemPage == _LCM_SUMMARY) {
-                    StopSystemTimeoutDet();
-                    StartSystemTimeoutDet(Timeout_ReturnViewPage);
-                    break;
-                }*/
 
-                if (pDcChargingInfo->ConnectorPlugIn == NO ) {
-                    setChargerMode(gunIndex, MODE_COMPLETE);
-                }
-                if (pSysInfo->SystemPage == _LCM_WAIT_PLUGOUT) {
-					break;
-				}
-                if (pSysInfo->CurGunSelected == gunIndex) {
-                    pSysInfo->SystemPage = _LCM_ERROR;
+                if (pSysInfo->CurGunSelected == gunIndex &&
+                    (pSysInfo->SystemPage != _LCM_ERROR && pSysInfo->SystemPage != _LCM_LINK_ERROR) ){
+                    if (pDcChargingInfo->ConnectorPlugIn) {
+                        if (pSysInfo->SystemPage != _LCM_WAIT_PLUGOUT)
+                            pSysInfo->SystemPage = _LCM_VIEW;
+                        else {
+                        }
+                    } else {
+                        StopGunInfoTimeoutDet(gunIndex);
+                        pSysInfo->SystemPage = _LCM_SUMMARY;
+                    }
                 }
+
                 break;
 
             case S_TERMINATING:
@@ -4407,13 +4429,17 @@ CheckStatus:
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "Local");
                     }
                     StopGunInfoTimeoutDet(gunIndex);
-                    StartSystemTimeoutDet(Timeout_Terminating);
+                    
                     pSysInfo->CurGunSelected = gunIndex;
                 }
                 // For Precharging timeout
                 if (pDcChargingInfo->Type == _Type_Chademo) {
                     if (isEvStopCharging_chademo(gunIndex) == YES ||
                             isPrechargeStatus_chademo(gunIndex) <= 0 ) {
+
+                        if (!ShmDcCommonData->finalcost_flag[gunIndex])
+                            StartSystemTimeoutDet(Timeout_Terminating);
+
                         if (!ShmDcCommonData->isIntoCharge[gunIndex]) {
                             setChargerMode(gunIndex, MODE_COMPLETE);
                         } else if (ShmDcCommonData->finalcost_flag[gunIndex]) {
@@ -4423,6 +4449,10 @@ CheckStatus:
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                     if (isEvStopCharging_gb(gunIndex) == YES ||
                             isPrechargeStatus_gb(gunIndex) <= 0){
+
+                        if (!ShmDcCommonData->finalcost_flag[gunIndex])
+                            StartSystemTimeoutDet(Timeout_Terminating);
+
                         if (!ShmDcCommonData->isIntoCharge[gunIndex]) {
                             setChargerMode(gunIndex, MODE_COMPLETE);
                         } else if (ShmDcCommonData->finalcost_flag[gunIndex]) {
@@ -4435,6 +4465,10 @@ CheckStatus:
                              isPrechargeStatus_ccs(gunIndex) == 0  ||
                              isPrechargeStatus_ccs(gunIndex) == 13 ||
                              isPrechargeStatus_ccs(gunIndex) == 14) ) {
+
+                        if (!ShmDcCommonData->finalcost_flag[gunIndex])
+                            StartSystemTimeoutDet(Timeout_Terminating);
+
                         if (!ShmDcCommonData->isIntoCharge[gunIndex]) {
                             setChargerMode(gunIndex, MODE_COMPLETE);
                         } else if (ShmDcCommonData->finalcost_flag[gunIndex]) {
@@ -4455,32 +4489,18 @@ CheckStatus:
                     }
                     TheEndCharging(gunIndex);
                     StopSystemTimeoutDet();
-
                 }
-                /*
-                if (pDcChargingInfo->ConnectorPlugIn) {
-                	StopSystemTimeoutDet();
-                    pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
-                } else {
-					StartSystemTimeoutDet(Timeout_ReturnViewPage);
-					pSysInfo->SystemPage = _LCM_SUMMARY;
-                }*/
-                //if (pSysInfo->SystemPage == _LCM_ERROR) {
+
                 if (pSysInfo->SystemPage == _LCM_MAINTAIN) {
-                    StopSystemTimeoutDet();
                     break;
                 }
 
                 if (pSysInfo->CurGunSelected == gunIndex) {
                     if (pDcChargingInfo->ConnectorPlugIn) {
-                        if (pSysInfo->SystemPage != _LCM_SUMMARY)
-                            pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
+                        pSysInfo->SystemPage = _LCM_WAIT_PLUGOUT;
                     } else {
-                        if (pSysInfo->SystemPage == _LCM_WAIT_PLUGOUT) {
-                            StopSystemTimeoutDet();
-                            pSysInfo->SystemPage = _LCM_SUMMARY;
-                            StartSystemTimeoutDet(Timeout_ReturnViewPage);
-                        }
+                        pSysInfo->SystemPage = _LCM_SUMMARY;
+                        StartSystemTimeoutDet(Timeout_ReturnViewPage);
                     }
                 }
                 break;

+ 2 - 2
EVSE/Projects/DD360UCar/Apps/CSU/main.h

@@ -41,8 +41,8 @@
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 #define EVCCID_LINK_TIMEOUT                     (120)
 #define CONN_PLUG_TIMEOUT                       (40)
-#define DETAILVIEW_TIMEOUT                      (30)
-#define TERMINATING_TIMEOUT                     (120)
+#define PLUGOUT_TIMEOUT                         (30)
+#define TERMINATING_TIMEOUT                     (30)
 #define WHILE_LOOP_TIME                         (10000)
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 5 - 0
EVSE/Projects/DD360UCar/Apps/Config.h

@@ -152,10 +152,12 @@ enum _LCM_UAR_INDEX {
     _LCM_WAIT_PLUGIN            = 0x05,
     _LCM_PRECHARGE              = 0x06,
     _LCM_LINK_ERROR             = 0x07,
+    /*
     _LCM_DETAIL_VIEW            = 0x08,
     _LCM_STOP_RFID              = 0x09,
     _LCM_STOP_APP               = 0x0A,
     _LCM_STOP_RFID_FAIL         = 0x0B,
+    */
     _LCM_STOPPING               = 0x0C,
     _LCM_WAIT_PLUGOUT           = 0x0D,
     _LCM_SUMMARY                = 0x0E,
@@ -509,6 +511,9 @@ typedef struct StDcCommonInfo {
     time_t EVDisconnectTime[2];
     int EVDisconnectFlag[2];
     int isIntoCharge[2];
+    time_t RelayDisconnectTime;
+    time_t LedDisconnectTime;
+    time_t FanDisconnectTime;
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 15 - 7
EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -327,7 +327,12 @@ void CANReceiver(int fd)
                 if ((time((time_t*)NULL) - ShmDcCommonData->EVDisconnectTime[_index]) > 3 && !ShmDcCommonData->EVDisconnectFlag[_index]) {
                     ShmDcCommonData->EVDisconnectTime[_index] = time((time_t*)NULL);
                     ShmDcCommonData->EVDisconnectFlag[_index] = TRUE;
-                    log_info("Lost ev board %d can bus data.", _index);
+                    log_error("Lost ev board %d can bus data!!!!", _index);
+
+                    system("/sbin/ip link set can0 down");
+                    sleep(1);
+                    system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
+                    system("/sbin/ip link set can0 up");
                 }
                 CheckEvConnect(_index);
             }
@@ -509,20 +514,20 @@ void CANReceiver(int fd)
                 //printf("RemainChargingDuration = %d",  pDcChargingInfo->RemainChargingDuration);
 
                 if (pDcChargingInfo->Type == _Type_Chademo) {
-                    //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
-                    {
-                        ShmCHAdeMOData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
+                    if (ShmCHAdeMOData->ev[gunTypeIndex].PresentMsgFlowStatus != frame.data[0]) {
+                        log_info("CHAdeMo change evboard status to %d",(int) frame.data[0]);
                     }
+                    ShmCHAdeMOData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
 
                     ShmCHAdeMOData->ev[gunTypeIndex].EvDetection = frame.data[0];
                     ShmCHAdeMOData->ev[gunTypeIndex].SOC = pDcChargingInfo->EvBatterySoc;
                     ShmCHAdeMOData->ev[gunTypeIndex].TargetBatteryVoltage = (pDcChargingInfo->EvBatterytargetVoltage * 10);
                     ShmCHAdeMOData->ev[gunTypeIndex].ChargingCurrentRequest = (pDcChargingInfo->EvBatterytargetCurrent * 10);
                 } else if (pDcChargingInfo->Type == _Type_GB) {
-                    //if (ShmGBTData->ev[gunTypeIndex].EvDetection != frame.data[0])
-                    {
-                        ShmGBTData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
+                    if (ShmGBTData->ev[gunTypeIndex].PresentMsgFlowStatus != frame.data[0]) {
+                        log_info("GBT change evboard status to %d", (int)frame.data[0]);
                     }
+                    ShmGBTData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
 
                     ShmGBTData->ev[gunTypeIndex].EvDetection = frame.data[0];
                     ShmGBTData->ev[gunTypeIndex].SOC = pDcChargingInfo->EvBatterySoc;
@@ -530,6 +535,9 @@ void CANReceiver(int fd)
                     ShmGBTData->ev[gunTypeIndex].ChargingCurrentRequest = (pDcChargingInfo->EvBatterytargetCurrent * 10);
                 } else if (pDcChargingInfo->Type == _Type_CCS_2) {
                     if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
+                        if (ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].PresentMsgFlowStatus != frame.data[0]) {
+                            //log_info("CCS change evboard status to %d", (int)frame.data[0]);
+                        }
                         ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
                     }
                 }

+ 75 - 62
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/RelayBoard.c

@@ -801,6 +801,14 @@ void GetRelayOutputStatus(void)
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
         regRelay.relay_event.bits.AC_Contactor = pSysInfo->AcContactorStatus;
 #endif //!defined DD360 && !defined DD360Audi
+        ShmDcCommonData->RelayDisconnectTime = time((time_t*)NULL);
+        pAlarmCode->AlarmEvents.bits.RelayBoardCommFail = FALSE;
+    } else {
+        if ((time((time_t*)NULL) - ShmDcCommonData->RelayDisconnectTime) > 5) {
+            ShmDcCommonData->RelayDisconnectTime = time((time_t*)NULL);
+            pAlarmCode->AlarmEvents.bits.RelayBoardCommFail = TRUE;
+            log_info("Relay communcation Fail");
+        }
     }
 }
 
@@ -1238,6 +1246,8 @@ static void GetFanSpeed(void)
 //      log_info("SystemFanRotaSpeed_4 = %d ", fanSpeed.speed[3]);
         // Config_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed[0]);
         //SysInfoData (SystemFanRotaSpeed)
+    } else {
+
     }
 }
 
@@ -1384,12 +1394,13 @@ static void fanBoardSelfTest(void)
     if (ShmFanModuleData->SelfTest_Comp == YES) {
         return;
     }
-
+    pAlarmCode->AlarmEvents.bits.FanboardStestFail = YES;
     GetFwAndHwVersion_Fan();
     SetModelName_Fan();
     SetRtcData_Fan();
     sleep(1);
     gettimeofday(&gFanBoardRunTimer, NULL);
+    ShmDcCommonData->FanDisconnectTime = time((time_t*)NULL);
 }
 
 static void fanBoardPorcess(void)
@@ -1432,6 +1443,7 @@ static void GetFwAndHwVersion_Led(void)
         strcpy((char *) pSysInfo->LedModuleFwRev, ver.Version_FW);
         log_info("GetFwAndHwVersion_Led s1 = %s ", ver.Version_FW);
         ShmLedModuleData->SelfTest_Comp = YES;
+        pAlarmCode->AlarmEvents.bits.LedboardStestFail = NO;
     } else {
         //log_info("GetFwAndHwVersion_Led fail ");
     }
@@ -1633,7 +1645,7 @@ static void LEDBoardSelfTest(void)
     if (ShmLedModuleData->SelfTest_Comp == YES) {
         return;
     }
-
+    pAlarmCode->AlarmEvents.bits.LedboardStestFail = YES;
 #if defined DD360 ||defined DD360Audi || defined DD360UCar
     GetFwAndHwVersion_Led();
     sleep(1);
@@ -1653,6 +1665,7 @@ static void LEDBoardSelfTest(void)
             pAlarmCode->AlarmEvents.bits.LedboardStestFail = YES;
         }
     }
+    ShmDcCommonData->LedDisconnectTime = time((time_t*)NULL);
 }
 
 static void LEDBoardProcess(void)
@@ -1730,10 +1743,12 @@ void RelayBoardTask(int uartFD)
 
             // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
             if (ShmRelayModuleData->SelfTest_Comp == NO && isRelayBypass == false) {
+                pAlarmCode->AlarmEvents.bits.RelaySelftestFail = TRUE;
                 GetFwAndHwVersion_Relay();
                 SetModelName_Relay(); //DS60-120 add
                 SetRtcData_Relay();
                 sleep(1);
+                ShmDcCommonData->RelayDisconnectTime = time((time_t*)NULL);
             }
 
 #if !defined NO_FAN_BOARD && !defined DD360ComBox
@@ -1825,76 +1840,74 @@ void RelayBoardTask(int uartFD)
                     }
                 }
 
-                    // 橋接 relay
-                    SetParalleRelayStatus();
-
-                    // 搭上 AC Contactor
-                    //if (isCharging) {
-                    //    outputRelay.relay_event.bits.AC_Contactor = YES;
-                    //} else {
-                    //    outputRelay.relay_event.bits.AC_Contactor = NO;
-                    //}
-
-                    if (isCharging ||
-                            (ShmPsuData->Work_Step >= _TEST_MODE &&
-                             ShmPsuData->Work_Step <= _TEST_MODE)) {
-                        isStopChargingCount = false;
-                        outputRelay.relay_event.bits.AC_Contactor = YES;
+                // 橋接 relay
+                SetParalleRelayStatus();
+
+                // 搭上 AC Contactor
+                //if (isCharging) {
+                //    outputRelay.relay_event.bits.AC_Contactor = YES;
+                //} else {
+                //    outputRelay.relay_event.bits.AC_Contactor = NO;
+                //}
+
+                if (isCharging ||
+                        (ShmPsuData->Work_Step >= _TEST_MODE &&
+                            ShmPsuData->Work_Step <= _TEST_MODE)) {
+                    isStopChargingCount = false;
+                    outputRelay.relay_event.bits.AC_Contactor = YES;
+                } else {
+                    if (!isStopChargingCount) {
+                        gettimeofday(&_close_ac_contactor, NULL);
+                        isStopChargingCount = true;
                     } else {
-                        if (!isStopChargingCount) {
-                            gettimeofday(&_close_ac_contactor, NULL);
-                            isStopChargingCount = true;
-                        } else {
-                            if ((outputRelay.relay_event.bits.AC_Contactor == YES &&
-                                    GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
-                                outputRelay.relay_event.bits.AC_Contactor = NO;
-                            }
+                        if ((outputRelay.relay_event.bits.AC_Contactor == YES &&
+                                GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
+                            outputRelay.relay_event.bits.AC_Contactor = NO;
                         }
                     }
+                }
 
-                    if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
-                        outputRelay.relay_event.bits.AC_Contactor = NO;
-                    }
+                if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL) {
+                    outputRelay.relay_event.bits.AC_Contactor = NO;
+                }
 
-                    if (pAlarmCode->AlarmEvents.bits.PsuFailureAlarm == ABNORMAL) {
-                        RunForceStopProcess();
-                        outputRelay.relay_event.bits.AC_Contactor = NO;
-                    }
+                if (pAlarmCode->AlarmEvents.bits.PsuFailureAlarm == ABNORMAL) {
+                    RunForceStopProcess();
+                    outputRelay.relay_event.bits.AC_Contactor = NO;
+                }
 
-                    if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
-                        outputRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_P = YES;
-                    }
+                if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
+                    outputRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_P = YES;
+                }
 
-                    // 搭上/鬆開 Relay
-                    if (IsNoneMatchRelayStatus()) {
-                        if (Config_Relay_Output(Uart5Fd, ADDR_RELAY, &outputRelay)) {
-                            //regRelay.relay_event.bits.AC_Contactor = pSysInfo->AcContactorStatus;
-
-                            //regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
-                            //regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
-                            //regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
-                            //regRelay.relay_event.bits.Gun2_P = outputRelay.relay_event.bits.Gun2_P;
-                            //regRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_N;
-                            //regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
-                            //regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
-
-                            //MatchRelayStatus();
-
-                            //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x ",
-                            //         regRelay.relay_event.bits.AC_Contactor,
-                            //         regRelay.relay_event.bits.Gun1_P,
-                        //         regRelay.relay_event.bits.Gun1_N,
-                        //         regRelay.relay_event.bits.Gun2_P,
-                        //         regRelay.relay_event.bits.Gun2_N,
-                        //         regRelay.relay_event.bits.CCS_Precharge,
-                        //         regRelay.relay_event.bits.Gun1_Parallel_P,
-                        //         regRelay.relay_event.bits.Gun1_Parallel_N);
+                // 搭上/鬆開 Relay
+                if (IsNoneMatchRelayStatus()) {
+                    if (Config_Relay_Output(Uart5Fd, ADDR_RELAY, &outputRelay)) {
+                        //regRelay.relay_event.bits.AC_Contactor = pSysInfo->AcContactorStatus;
+
+                        //regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
+                        //regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
+                        //regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
+                        //regRelay.relay_event.bits.Gun2_P = outputRelay.relay_event.bits.Gun2_P;
+                        //regRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_N;
+                        //regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
+                        //regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
+
+                        //MatchRelayStatus();
+
+                        //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x ",
+                        //         regRelay.relay_event.bits.AC_Contactor,
+                        //         regRelay.relay_event.bits.Gun1_P,
+                    //         regRelay.relay_event.bits.Gun1_N,
+                    //         regRelay.relay_event.bits.Gun2_P,
+                    //         regRelay.relay_event.bits.Gun2_N,
+                    //         regRelay.relay_event.bits.CCS_Precharge,
+                    //         regRelay.relay_event.bits.Gun1_Parallel_P,
+                    //         regRelay.relay_event.bits.Gun1_Parallel_N);
 
                     }
                 }
-            }
-            else if(isRelayBypass == true)
-            {
+            } else if(isRelayBypass == true) {
                 for(i = 0; i < pSysConfig->TotalConnectorCount; i++)
                 {
                     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);

+ 106 - 144
EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -16,6 +16,8 @@
 #include "../Define/define.h"
 #include "../Config.h"
 #include "../SelectGun/SelectGun.h"
+#include "main.h"
+#include "../timeout.h"
 #define uSEC_VAL                                (1000000)
 //------------------------------------------------------------------------------
 //struct SysConfigAndInfo         *ShmSysConfigAndInfo;
@@ -41,6 +43,26 @@ char *pPortName           = "/dev/ttyS3";
 char *moduleName          = "DMT80480T070_09WT";
 bool is_show = false;
 uint8_t _everyPageRollChange;
+
+void GetClockTime(struct timespec* _now_time, void* null)
+{
+    clock_gettime(CLOCK_MONOTONIC, _now_time);
+}
+
+void StartSystemTimeoutDet(uint8_t flag)
+{
+    if (pSysInfo->SystemTimeoutFlag != flag) {
+        log_info("Set System Timeout Flag %d", flag);
+        GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
+    }
+    pSysInfo->SystemTimeoutFlag = flag;
+}
+
+void StopSystemTimeoutDet(void)
+{
+    GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
+    pSysInfo->SystemTimeoutFlag = Timeout_None;
+}
 //==========================================
 // Open and Close RS232 and R/W
 //==========================================
@@ -271,12 +293,22 @@ void ChangeCurPage()
         case _LCM_VIEW:
             if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_IDLE ) {
                 pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
-            } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus != S_CHARGING) {
+            } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_IDLE) {
                 pSysInfo->PageIndex = __VIEW_LEFT_CHARGE_;
-            } else if(pDcChargingInfo_0->SystemStatus != S_CHARGING && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
+            } else if(pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
                 pSysInfo->PageIndex = __VIEW_RIGHT_CHARGE_;
             } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
                 pSysInfo->PageIndex = __VIEW_ALL_CHARGE_;
+            } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
+                pSysInfo->PageIndex = __VIEW_L_FAIL_R_CHARGE;
+            } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_ALARM) {
+                pSysInfo->PageIndex = __VIEW_L_CHARGE_R_FAIL;
+            } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && pDcChargingInfo_1->SystemStatus == S_IDLE) {
+                pSysInfo->PageIndex = __VIEW_L_FAIL_R_IDLE;
+            } else if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_ALARM) {
+                pSysInfo->PageIndex = __VIEW_L_IDLE_R_FAIL;
+            } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && pDcChargingInfo_1->SystemStatus == S_ALARM) {
+                pSysInfo->PageIndex = __VIEW_ALL_FAIL;
             }
             break;
         case _LCM_START_SCAN:
@@ -309,20 +341,24 @@ void ChangeCurPage()
             else
                 pSysInfo->PageIndex = __LINKING_ERROR_RIGHT;
             break;
+            /*
         case _LCM_DETAIL_VIEW:
             pSysInfo->PageIndex =__DETAIL_VIEW_;
             break;
+
         case _LCM_STOP_RFID:
             pSysInfo->PageIndex =__STOP_SCAN_RFID_;
             break;
+            
         case _LCM_STOP_APP:
             pSysInfo->PageIndex =__STOP_SCAN_APP_;
             break;
         case _LCM_STOP_RFID_FAIL:
             pSysInfo->PageIndex =__STOP_RFID_FAIL_;
             break;
+            */
         case _LCM_STOPPING:
-            pSysInfo->PageIndex =__STOP_AUTHORIZE_;
+            pSysInfo->PageIndex = __STOP_AUTHORIZE_;
             break;
         case _LCM_WAIT_PLUGOUT:
             if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
@@ -365,7 +401,8 @@ void ChangeCurPage()
             break;
     }
     if (_currentPage != pSysInfo->PageIndex) {
-        _currentPage = pSysInfo->PageIndex;
+        //_currentPage = pSysInfo->PageIndex;
+        log_info("Change Page :%d", pSysInfo->PageIndex);
         ChangeToOtherPage(pSysInfo->PageIndex);
     }
 }
@@ -411,29 +448,49 @@ void ShowViewChargingTime(uint8_t gunIndex,int time)
     int min,sec;
     min = time/60;
     sec = time % 60;
-    sprintf((char *)value,"%d:%02d",min,sec);
+    //sprintf((char *)value,"%d:%02d",min,sec);
     if (gunIndex == LEFT_GUN_NUM) {
-        DisplayValueToLcm(_LeftGun_info_time, (uint8_t *)value, sizeof(value));
-    } else
-        DisplayValueToLcm(_RightGun_info_time, (uint8_t *)value, sizeof(value));
+        ChangeDisplay2Value(_LeftGun_time_min, min);
+        ChangeDisplay2Value(_LeftGun_time_sec, sec);
+    } else {
+        ChangeDisplay2Value(_RightGun_time_min, min);
+        ChangeDisplay2Value(_RightGun_time_sec, sec);
+    }
 }
 void ShowViewChargingEngery(uint8_t gunIndex, float energy)
 {
-    uint8_t value[10] = { 0 };
-
+    float data = energy * 10;
+    if (energy < 0)
+        data = fabs(energy);
+    if (gunIndex == LEFT_GUN_NUM) {
+        ChangeDisplay2Value(_LeftGun_info_cap, data);
+    } else
+        ChangeDisplay2Value(_RightGun_info_cap, data);
+    /*
     if(energy < 100)
         sprintf((char*)value, "%.1f", energy);
     else
         sprintf((char*)value, "%d", (int)energy);
+
     //log_info("gun[%d] energy:%.1f", gunIndex, energy);
     if (gunIndex == LEFT_GUN_NUM) {
         DisplayValueToLcm(_LeftGun_info_cap, (uint8_t*)value, sizeof(value));
     }
     else
         DisplayValueToLcm(_RightGun_info_cap, (uint8_t*)value, sizeof(value));
+        */
 }
 void ShowViewCharingMoney(uint8_t gunIndex,float money)
 {
+    uint8_t value[10] = { 0 };
+    float data = money;
+    if (money < 0)
+        data = fabs(money);
+    if (gunIndex == LEFT_GUN_NUM) {
+        ChangeDisplay2Value(_LeftGun_info_money, data);
+    } else
+        ChangeDisplay2Value(_RightGun_info_money, data);
+    /*
     uint8_t value[10] = {0};
     sprintf((char *)value,"%d",(int)money);
     //log_info("gun[%d] money:%.1f", gunIndex, money);
@@ -441,6 +498,7 @@ void ShowViewCharingMoney(uint8_t gunIndex,float money)
         DisplayValueToLcm(_LeftGun_info_money, (uint8_t *)value, sizeof(value));
     } else
         DisplayValueToLcm(_RightGun_info_money, (uint8_t *)value, sizeof(value));
+        */
 }
 void ShowViewChargingPower(uint8_t gunIndex,float power)
 {
@@ -625,92 +683,6 @@ void ShowSelectGunIcon()
         DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
     }
 }
-/*
- * Detail View Page
- */
-void SetDetailViewPage()
-{
-    uint8_t data;
-    float float_data;
-    uint8_t value[10] = {0};
-    ShowSelectGunIcon();
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-    if (pDcChargingInfo->SystemStatus != S_CHARGING) {
-        SetViewPage();
-        return;
-    }
-    log_info("PowerConsumption:%.1f",pDcChargingInfo->PowerConsumption);
-    uint8_t digits = pDcChargingInfo->EvBatterySoc % 10;
-    uint8_t tens = (pDcChargingInfo->EvBatterySoc / 10) %10;
-    uint8_t hundreds = pDcChargingInfo->EvBatterySoc / 100;
-    // Show Numbers.
-    ChangeDisplay2Value(_Percent_Number_Digits,_ICON_White_Num_0+digits);
-    ChangeDisplay2Value(_Percent_Number_Tens,_ICON_White_Num_0+tens);
-    if (hundreds == 0 ) {
-        ChangeDisplay2Value(_Percent_Number_Hundreds,_ICON_Empty);
-        if (tens == 0)
-            ChangeDisplay2Value(_Percent_Number_Tens,_ICON_Empty);
-    } else {
-        ChangeDisplay2Value(_Percent_Number_Hundreds,_ICON_White_Num_1);
-    }
-
-    // Show Progress Bar
-    if (hundreds) {
-    	ChangeDisplay2Value(_ProgressBar_LEVEL, _ICON_BTY_100);
-    }
-    else {
-        // 0 ~ 19 % show in progress bar 10%
-        if (pDcChargingInfo->EvBatterySoc < 10) {
-            if (_everyPageRollChange % 3 == 0)
-                ChangeDisplay2Value(_ProgressBar_LEVEL, _ICON_BTY_10);
-            else if (_everyPageRollChange % 3 == 1)
-                ChangeDisplay2Value(_ProgressBar_LEVEL, _ICON_BTY_12);
-            else
-                ChangeDisplay2Value(_ProgressBar_LEVEL, _ICON_BTY_14);
-        }
-        else {
-            ChangeDisplay2Value(_ProgressBar_LEVEL, _ICON_BTY_10 + (tens * 10) + (_everyPageRollChange % 5) * 2);
-        }
-        /*
-    	if (tens == 1)
-    		tens = 0;
-		if (_everyPageRollChange%2 == 0)
-			ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+tens*2);
-		else
-			ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+tens*2+1);
-            */
-		_everyPageRollChange++;
-    }
-
-    // Show Power
-    if (pDcChargingInfo->PresentChargingPower >= 0 &&
-        pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
-        float_data = pDcChargingInfo->PresentChargingPower;
-    } else {
-        float_data = 0;
-    }
-    sprintf((char *)value,"%.1f",float_data);
-    DisplayValueToLcm(_Detail_Power_Num,value, sizeof(value));
-
-    // Show Time
-    data = (pDcChargingInfo->PresentChargedDuration)/60;
-    sprintf((char *)value,"%d",data);
-    DisplayValueToLcm(_Detail_Time_Num,value, sizeof(value));
-    // Show Energy
-    if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
-            pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
-    	float_data = pDcChargingInfo->PresentChargedEnergy;
-    } else
-    	float_data = 0;
-    sprintf((char *)value,"%.1f",float_data);
-    log_info("Energy:%s",value);
-    DisplayValueToLcm(_Detail_Cap_Num,value, sizeof(value));
-
-    // Show Money
-    //data = pDcChargingInfo->ChargingFee;
-    sprintf((char *)value,"%.1f",pDcChargingInfo->ChargingFee);
-    DisplayValueToLcm(_Detail_Money_Num,value, sizeof(value));
-}
 
 void ShowCountDownTimer()
 {
@@ -755,12 +727,16 @@ void ClearQrCode()
 }
 void ChangeQrCode()
 {
-    char cmd[250];
+    char cmd[200];
     pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-    // https://nhoatcc.lineapid.tw/web/tologin?sn=ABC123&cid=2
-    memset(cmd, '\0', 256);
-    int len = sprintf(cmd, "https://nhoatcc.lineapid.tw/web/tologin?sn=%s&cid=%d", pSysConfig->SystemId, ShmDcCommonData->ConnectorId[pSysInfo->CurGunSelected]);
-    DisplayValueToLcm(_QR_CODE_AUTHORIZE, cmd, len + 1);
+
+    memset(cmd, 0 , 200);
+    int len = sprintf(cmd, "https://qrcode.u-power.app/connector?chargebox=%s&connectorno=%d", pSysConfig->SystemId, ShmDcCommonData->ConnectorId[pSysInfo->CurGunSelected]);
+    //int len = sprintf(cmd, "http://www.u-power.com.tw/");
+    if (len > 200) {
+        log_info("QR Code URL length too long");
+    }
+    DisplayValueToLcm(_QR_CODE_AUTHORIZE, cmd, 200);
 }
 void ShowProgressBar()
 {
@@ -781,9 +757,11 @@ void ShowSummaryPage()
     data = pDcChargingInfo->ChargingFee;
     sprintf((char *)value,"%.1f",data);
     int discount,settlement = 0;
-    //DisplayValueToLcm(_Summary_total_money, (uint8_t *)value, sizeof(value));
-    //DisplayValueToLcm(_Summary_cal_Total_money, (uint8_t *)value, sizeof(value));
-    ChangeDisplay2Value(_Summary_total_money, (int)pDcChargingInfo->ChargingFee);
+
+    discount = ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Discount;
+    ChangeDisplay2Value(_Summary_cal_discount, discount*(-1));
+    settlement = (int)pDcChargingInfo->ChargingFee - discount;
+    ChangeDisplay2Value(_Summary_total_money, (int)settlement);
     ChangeDisplay2Value(_Summary_cal_Total_money, (int)pDcChargingInfo->ChargingFee);
     /*
     log_info("start time:%s",pDcChargingInfo->StartDateTime);
@@ -797,11 +775,19 @@ void ShowSummaryPage()
     t_hr = atoi(start_hr) + (ShmDcCommonData->TzOffset / 60);
     if (t_hr >= 24)
         t_hr -= 24;
+    if (!ShmDcCommonData->isIntoCharge[pSysInfo->CurGunSelected]) {
+        t_hr = 0;
+        strcpy(start_min,"0");
+    }
     ChangeDisplay2Value(_Summary_Start_time_hr, t_hr);
     ChangeDisplay2Value(_Summary_Start_time_min, atoi(start_min));
     t_hr = atoi(end_hr) + (ShmDcCommonData->TzOffset / 60);
     if (t_hr >= 24)
         t_hr -= 24;
+    if (!ShmDcCommonData->isIntoCharge[pSysInfo->CurGunSelected]) {
+        t_hr = 0;
+        strcpy(end_min, "0");
+    }
     ChangeDisplay2Value(_Summary_end_time_hr, t_hr);
     ChangeDisplay2Value(_Summary_end_time_min, atoi(end_min));
     /*
@@ -827,21 +813,7 @@ void ShowSummaryPage()
         data = 0;
     //sprintf((char *)value,"%.1f",data);
     ChangeDisplay2Value(_Summary_cap, data);
-    //DisplayValueToLcm(_Summary_cap, (uint8_t *)value, sizeof(value));
-    discount = ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Discount;
-    sprintf((char *)value,"%.1f", discount);
-    DisplayValueToLcm(_Summary_cal_discount, (uint8_t *)value, sizeof(value));
-    settlement = pDcChargingInfo->ChargingFee - discount;
-    sprintf((char *)value,"%.1f",settlement);
-    DisplayValueToLcm(_Summary_cal_Settlement, (char *)value, sizeof(value));
-    /*
-    if(pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
-        sprintf((char *)value,"%.1f",ChargeMaxPower_0);
-    } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
-        sprintf((char *)value,"%.1f",ChargeMaxPower_1);
-    }
-    DisplayValueToLcm(_Summary_max_power, (uint8_t *)value, sizeof(value));
-     */
+
     if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
         ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_0);
     }
@@ -866,34 +838,28 @@ void ProcessPageInfo()
             pSysInfo->SystemPage = _LCM_EMERGENCY;
         return;;
     }
+
     switch (pSysInfo->SystemPage) {
     case _LCM_VIEW:
         // Confirm Charging Gun Number.
         SetViewPage();
         break;
-    case _LCM_DETAIL_VIEW:
-        ShowGunCountDownTimer();
-        SetDetailViewPage();
-        break;
     case _LCM_START_SCAN:
         ChangeQrCode();
-    case _LCM_STOP_RFID:
-    case _LCM_STOP_APP:
         ShowSelectGunIcon();
         ShowCountDownTimer();
         break;
     case _LCM_START_AUTHORIZING:
     case _LCM_PRECHARGE:
     case _LCM_STOPPING:
-        //ShowProgressBar();
         ChangeDisplay2Value(_Animation_Running, 1);
         break;
     case _LCM_START_AUTHORIZE_FAIL:
-    case _LCM_STOP_RFID_FAIL:
     case _LCM_LINK_ERROR:
         ShowCountDownTimer();
         break;
     case _LCM_SUMMARY:
+        StartSystemTimeoutDet(Timeout_ReturnViewPage);
         ShowCountDownTimer();
         ShowSummaryPage();
         break;
@@ -903,7 +869,6 @@ void ProcessPageInfo()
     	break;
     case _LCM_WAIT_PLUGIN:
     case _LCM_WAIT_PLUGOUT:
-    	ShowSelectGunIcon();
         break;
     case _LCM_EMERGENCY:
         break;
@@ -1046,12 +1011,12 @@ void DemoFunction()
                 for (i = 0; i <= 100; i++) {
                     ChangeDisplay2Value(_Summary_total_money, i);
                     ChangeDisplay2Value(_Summary_cal_Total_money, i);
-                    ChangeDisplay2Value(_Summary_Start_time_hr, i/60);
-                    ChangeDisplay2Value(_Summary_Start_time_min, i%60);
-                    ChangeDisplay2Value(_Summary_end_time_hr, i/60);
-                    ChangeDisplay2Value(_Summary_end_time_min, i%60);
+                    ChangeDisplay2Value(_Summary_Start_time_hr, i);
+                    ChangeDisplay2Value(_Summary_Start_time_min, i);
+                    ChangeDisplay2Value(_Summary_end_time_hr, i);
+                    ChangeDisplay2Value(_Summary_end_time_min, i);
                     ChangeDisplay2Value(_Summary_duration_min, i);
-                    ChangeDisplay2Value(_Summary_duration_sec, i%60);
+                    ChangeDisplay2Value(_Summary_duration_sec, i);
 
                     ChangeDisplay2Value(_Summary_cap, i);
                     ChangeDisplay2Value(_Summary_cal_discount,i);
@@ -1095,10 +1060,12 @@ void DemoFunction()
         case 5:
             pSysInfo->CurGunSelected = 0;
             ChangeQrCode();
+            sleep(5);
             break;
         case 31:
             pSysInfo->CurGunSelected = 1;
             ChangeQrCode();
+            sleep(5);
             break;
     }
 }
@@ -1309,11 +1276,10 @@ int main(void)
             }
 
             // 頁面資訊處理
-            
             ProcessPageInfo();
-
             // 換頁處理
-            //GetCurrentPage(); //DS60-120 add
+            GetCurrentPage(); //DS60-120 add
+            ChangeCurPage();
             /*
             if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _LCM_VIEW) {
                 InformationShow();
@@ -1324,20 +1290,16 @@ int main(void)
                 if (is_show)
                     _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
                 is_show = false;
-            }*/
-            
-            GetCurrentPage(); //DS60-120 add
-            ChangeCurPage();
-            
+            }
+            */
             /*
-            pSysInfo->PageIndex = _LCM_WAIT_PLUGIN;
+            pSysInfo->PageIndex = index;
             GetCurrentPage();
-            ChangeToOtherPage(_LCM_WAIT_PLUGIN);
+            ChangeToOtherPage(index);
             GetCurrentPage();
             DemoFunction();
             index >= 34 ? index = 1 : index++;
             */
-            //usleep(100000);
             usleep(1000000);
 
         }

+ 21 - 7
EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -34,11 +34,17 @@
 #define __WAIT_PLUGIN_          0x0008
 #define __LINKING_ERROR_LEFT    0x0009
 #define __PRE_CHARGE_           0x000A
+#define __VIEW_ALL_FAIL         0x000B
+#define __VIEW_L_FAIL_R_CHARGE  0x000C
+#define __VIEW_L_CHARGE_R_FAIL  0x000D
+/*
 #define __DETAIL_VIEW_          0x000B
 #define __STOP_SCAN_RFID_       0x000C
 #define __STOP_SCAN_APP_        0x000D
+*/
 #define __STOP_AUTHORIZE_       0x000E
-#define __STOP_RFID_FAIL_       0x000F
+//#define __STOP_RFID_FAIL_       0x000F
+
 #define __WAIT_PLUGOUT_LEFT         0x0010
 #define __SUMMARY_LEFT              0x0011
 #define __EMERGENCY_BUTTON_     0x0012
@@ -58,6 +64,8 @@
 #define __COMMUNICATION_PROCESS        0x0020
 #define __GFD_PROCESS           0x0021
 #define __PRECHARGE_PROCESS     0x0022
+#define __VIEW_L_FAIL_R_IDLE    0x0023
+#define __VIEW_L_IDLE_R_FAIL    0x0024
 
 // ICON Map Address
 #define _LeftGun_type_pic_U         0x0001
@@ -86,18 +94,24 @@
 #define _Animation_Running          0x003D
 #define _LeftGun_ConnectorId        0x003F
 #define _RightGun_ConnectorId       0x0041
+
+#define _LeftGun_time_min           0x0043
+#define _LeftGun_time_sec           0x0045
+#define _LeftGun_info_cap           0x0047
+#define _LeftGun_info_money         0x0049
+#define _RightGun_time_min          0x004B
+#define _RightGun_time_sec          0x004E
+#define _RightGun_info_cap          0x0051
+#define _RightGun_info_money        0x0053
+
 // String Map Address
 #define _LeftGun_location           0x0100
 #define _LeftGun_info_power         0x0110
-#define _LeftGun_info_time          0x0120
-#define _LeftGun_info_cap           0x0130
-#define _LeftGun_info_money         0x0140
+
 #define _LeftGun_info_power_number  0x0150
 #define _RightGun_location          0x0200
 #define _RightGun_info_power        0x0210
-#define _RightGun_info_time         0x0220
-#define _RightGun_info_cap          0x0230
-#define _RightGun_info_money        0x0240
+
 #define _RightGun_info_power_number 0x0250
 #define _Confirm_Gun_Left_name      0x0300
 #define _Confirm_Gun_Right_name     0x0310

+ 2 - 2
EVSE/Projects/DD360UCar/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -214,7 +214,8 @@ static void checkChillerStatus(Gpio_out *gpio)
         {
             pChillerInfo->ChillerSwitch = YES;
             pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-            ShmFanModuleData->SetFan1Speed = 7000;
+            if (chillerCount >= 2)
+                ShmFanModuleData->SetFan1Speed = 7000;
         }
         else
         {
@@ -477,7 +478,6 @@ int main(void)
             //log_info("(407) Get Fw and Hw Ver. ");
             GetFwAndHwVersion(Uart1Fd);
             sleep(1);
-            ShmPrimaryMcuData->SelfTest_Comp = PASS;
         } else {
             SetOutputGpio(Uart1Fd, ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0]);
 

+ 1 - 1
EVSE/Projects/DD360UCar/Apps/timeout.h

@@ -51,7 +51,7 @@ enum Timeout_flag {
     Timeout_WaitBalance            = 14,
     Timeout_EVCCID_Link            = 15,
 	Timeout_LinkError              = 16,
-	Timeout_DetailView             = 17,
+	Timeout_PlugOut                = 17,
 	Timeout_Terminating            = 18,
 };
 

BIN
EVSE/Projects/DD360UCar/Images/ramdisk.gz


BIN
EVSE/Projects/DD360UCar/output/FactoryConfig


BIN
EVSE/Projects/DD360UCar/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360UCar/output/Module_DoComm


BIN
EVSE/Projects/DD360UCar/output/Module_EvComm


BIN
EVSE/Projects/DD360UCar/output/Module_EventLogging


BIN
EVSE/Projects/DD360UCar/output/Module_InternalComm


BIN
EVSE/Projects/DD360UCar/output/Module_LcmControl


BIN
EVSE/Projects/DD360UCar/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360UCar/output/Module_UpdateFW


BIN
EVSE/Projects/DD360UCar/output/ReadCmdline


BIN
EVSE/Projects/DD360UCar/output/main


BIN
EVSE/Projects/DD360UCar/output/simulation