Эх сурвалжийг харах

2023-02-10 / Simon Xue [DD360_V2.00]

Action:
1. [Add] Support 21.5 inch LCM.
2. [Fix] Self test into Maintain mode until self time success.
3. [Fix] Titl sensor function for custom model name 'OL'.
4. [Mod] Dispenser will soft reset when gun into unknown status.
5. [Add] Power derating in some gun type.
6. [Add] Gun status into fault status when can't get gun temperature.
7. [Mod] Modify change gun button flash in "wait for plugin" page.
8. [Add] ReadCmdline add setrelay function.
9. [Mod] ReadCmdline unconditional function.
10. [Mod] Set Target Current and Voltage are zero to Cabinet when gun in Alarm mode.
11. [Mod] Send level 2 error code when occur level 2 in complete state.

Files
As the following commit history files

Image Version: V2.00.XX.XXXX.XX
Debug Version: V2.00.12
Simon Xue 2 жил өмнө
parent
commit
24e385df44
49 өөрчлөгдсөн 2645 нэмэгдсэн , 2519 устгасан
  1. 7 0
      EVSE/Projects/DD360/Apps/.vscode/settings.json
  2. 281 224
      EVSE/Projects/DD360/Apps/CSU/Primary.c
  3. 231 262
      EVSE/Projects/DD360/Apps/CSU/RFID.c
  4. 4 8
      EVSE/Projects/DD360/Apps/CSU/SelfTest.c
  5. 232 286
      EVSE/Projects/DD360/Apps/CSU/main.c
  6. 1 1
      EVSE/Projects/DD360/Apps/CSU/main.h
  7. 77 7
      EVSE/Projects/DD360/Apps/Config.h
  8. 1 3
      EVSE/Projects/DD360/Apps/DataBase/DataBase.c
  9. 22 12
      EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.c
  10. 2 5
      EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.h
  11. 61 105
      EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c
  12. 3 3
      EVSE/Projects/DD360/Apps/ModuleEvComm/AbnormalState.c
  13. 1 0
      EVSE/Projects/DD360/Apps/ModuleEvComm/Ev_Comm.c
  14. 1 0
      EVSE/Projects/DD360/Apps/ModuleEvComm/Ev_Comm.h
  15. 7 6
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c
  16. 20 105
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c
  17. 0 1
      EVSE/Projects/DD360/Apps/ModuleInternalComm/FanBoard.c
  18. 1 1
      EVSE/Projects/DD360/Apps/ModuleInternalComm/LEDlight.c
  19. 5 1
      EVSE/Projects/DD360/Apps/ModuleInternalComm/Module_InternalComm.h
  20. 172 288
      EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c
  21. 18 22
      EVSE/Projects/DD360/Apps/ModuleInternalComm/internalComm.c
  22. 7 1
      EVSE/Projects/DD360/Apps/ModuleInternalComm/internalComm.h
  23. 211 397
      EVSE/Projects/DD360/Apps/ModuleLcmCtrl/Module_LcmControl.c
  24. 52 63
      EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c
  25. 1 0
      EVSE/Projects/DD360/Apps/ModulePrimary/PrimaryComm.c
  26. 14 34
      EVSE/Projects/DD360/Apps/ModuleUpdateFW/Module_UpdateFW.c
  27. 58 1
      EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/LcmCommandDriver.c
  28. 400 182
      EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.c
  29. 21 19
      EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.h
  30. 319 180
      EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/Module_LcmItemList.c
  31. 313 300
      EVSE/Projects/DD360/Apps/ReadCmdline.c
  32. BIN
      EVSE/Projects/DD360/Apps/Script/LcmSet.db
  33. 1 1
      EVSE/Projects/DD360/Apps/ShareMemory/shmMem.c
  34. 94 0
      EVSE/Projects/DD360/Apps/common.c
  35. 7 1
      EVSE/Projects/DD360/Apps/common.h
  36. BIN
      EVSE/Projects/DD360/Images/ramdisk.gz
  37. BIN
      EVSE/Projects/DD360/output/FactoryConfig
  38. BIN
      EVSE/Projects/DD360/output/LcmSet.db
  39. BIN
      EVSE/Projects/DD360/output/Module_ChkSysTask
  40. BIN
      EVSE/Projects/DD360/output/Module_DoComm
  41. BIN
      EVSE/Projects/DD360/output/Module_EvComm
  42. BIN
      EVSE/Projects/DD360/output/Module_EventLogging
  43. BIN
      EVSE/Projects/DD360/output/Module_InternalComm
  44. BIN
      EVSE/Projects/DD360/output/Module_LcmControl
  45. BIN
      EVSE/Projects/DD360/output/Module_LcmWistronControl
  46. BIN
      EVSE/Projects/DD360/output/Module_PrimaryComm
  47. BIN
      EVSE/Projects/DD360/output/Module_UpdateFW
  48. BIN
      EVSE/Projects/DD360/output/ReadCmdline
  49. BIN
      EVSE/Projects/DD360/output/main

+ 7 - 0
EVSE/Projects/DD360/Apps/.vscode/settings.json

@@ -0,0 +1,7 @@
+{
+    "files.associations": {
+        "define.h": "c",
+        "shmmem.h": "c",
+        "common.h": "c"
+    }
+}

+ 281 - 224
EVSE/Projects/DD360/Apps/CSU/Primary.c

@@ -10,6 +10,7 @@
 
 #include "../SelectGun/SelectGun.h"
 #include "main.h"
+#include "../common.h"
 
 //------------------------------------------------------------------------------
 typedef struct StLedConfig {
@@ -208,115 +209,9 @@ void PrimaryLedIndicatorCtrlFork(void)
     }//fork
 }
 
-//------------------------------------------------------------------------------
-static void checkChargingInfoByDC(uint8_t systemStatus)
-{
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-
-    switch (systemStatus) {
-    case S_IDLE:
-    case S_RESERVATION:
-        if (isDetectPlugin(pSysInfo->CurGunSelected)) {
-            _DetectPlugInTimeout(pSysInfo->CurGunSelected);
-            destroySelGun(pSysInfo->CurGunSelected);
-            
-        } else {
-            if( pSysConfig->isAuthrizeByEVCCID && pSysInfo->ConnectorPage == _LCM_PRE_CHARGE) {
-                _evccidlinktimeout(pSysInfo->CurGunSelected);
-                pDcChargingInfo->isEVCCIDVerify = true;
-                break;
-            }
-#if !defined DD360Audi
-            break;
-#endif //!defined DD360Audi
-
-            if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                //printf("destroy gun = %d", pSysInfo->CurGunSelected);
-                destroySelGun(pSysInfo->CurGunSelected);
-            } else {
-                confirmSelGun(pSysInfo->CurGunSelected);
-                log_info("confirm select gun ............................... %d ",
-                         pSysInfo->CurGunSelected);
-            }
-        }
-        break;
-
-    case S_REASSIGN_CHECK:
-    case S_REASSIGN:
-    case S_PREPARNING:
-    case S_PREPARING_FOR_EV:
-    case S_PREPARING_FOR_EVSE:
-    case S_CCS_PRECHARGE_ST0:
-    case S_CCS_PRECHARGE_ST1:
-        // 取消充電
-        if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
-            AcChargingTerminalProcess();
-        } else {
-            ChargingTerminalProcess(pSysInfo->CurGunSelected);
-        }
-        break;
-
-    case S_CHARGING:
-        if (pSysConfig->StopChargingByButton == YES ||
-                pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE ||
-                pSysConfig->isAuthrizeByEVCCID) {
-            // 停止充電
-            ChargingTerminalProcess(pSysInfo->CurGunSelected);
-        }
-        break;
-
-    case S_COMPLETE:
-        break;
-    }
-}
-
-static void checkChargingInfoByAC(void)
-{
-    struct ChargingInfoData *pAcChargingInfo = NULL;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-
-    if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
-        return;
-    }
-
-    pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-    switch (pAcChargingInfo->SystemStatus) {
-    case S_IDLE:
-        if (isDetectPlugin(pSysInfo->CurGunSelected)) {
-            _DetectPlugInTimeout(pSysInfo->CurGunSelected);
-        }
-        break;
-
-    case S_REASSIGN_CHECK:
-    case S_REASSIGN:
-    case S_PREPARNING:
-    case S_PREPARING_FOR_EV:
-    case S_PREPARING_FOR_EVSE:
-    case S_CCS_PRECHARGE_ST0:
-    case S_CCS_PRECHARGE_ST1:
-        // 取消充電
-        AcChargingTerminalProcess();
-        break;
-
-    case S_CHARGING:
-        if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
-            // 停止充電
-            AcChargingTerminalProcess();
-        }
-        break;
-
-    case S_COMPLETE:
-        break;
-    }
-}
 void SetIDLE(int gunIndex)
 {
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
 	struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
@@ -334,112 +229,214 @@ void LeftBtnPress()
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-    struct ChargingInfoData* pDcChargingInfo = NULL;
-	strcpy((char*)pSysConfig->UserId, "");
-	switch (ShmDcCommonData->LcmPage) {
-	case _PAGE_SELECTGUN:
-		if (!ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].WaitForPlugit) {
-			ClearDetectPluginFlag(LEFT_GUN_NUM);
-			confirmSelGun(LEFT_GUN_NUM);
-			ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
-		}
-		pSysInfo->CurGunSelected = LEFT_GUN_NUM;
-		break;
-	case _PAGE_SELECT_PAY:
-		SetIDLE(pSysInfo->CurGunSelected);
-		break;
-    case _PAGE_LANGUAGE:
-		StopSystemTimeoutDet();
-		ShmDcCommonData->LcmPage = ShmDcCommonData->previousPage;
-		break;
-    case _PAGE_AUTHORIZING:
-		break;
-    case _PAGE_AUTHORIZE_COMPLETE:
-		break;
-    case _PAGE_AUTHORIZE_FAIL:
-		SetIDLE(pSysInfo->CurGunSelected);
-		break;
-    case _PAGE_WAIT_FOR_PLUGIN:
-    case _PAGE_PLUGIN_TIMEOUT:
-    case _PAGE_PRECHARGE:
-		SetIDLE(pSysInfo->CurGunSelected);
-    case _PAGE_CHARGING:
-		pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-		if (pSysConfig->StopChargingByButton) {
-			pDcChargingInfo->SystemStatus = S_TERMINATING;
-		} else {
-			if (pDcChargingInfo->StartMethod == _CHARGING_START_REMOTESTART)
-				ShmDcCommonData->LcmPage = _PAGE_APP_STOP;
-			else if (pDcChargingInfo->StartMethod == _CHARGING_START_RFID)
-				ShmDcCommonData->LcmPage = _PAGE_RFID_STOP;
-			else
-				pDcChargingInfo->SystemStatus = S_TERMINATING;
-			strcpy((char*)pSysConfig->UserId, "");
-		}
-		break;
-    case _PAGE_COMPLETE:
-		//ShmDcCommonData->LcmPage = _PAGE_SELECTGUN;
-		break;
-    case _PAGE_COMPLETE_RECEIPT:
+    struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+    if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
+        if (pSysInfo->SystemPage == _LCM_WAIT_FOR_PLUG) {
+            if (isDetectPlugin(LEFT_GUN_NUM)) {
+                _DetectPlugInTimeout(LEFT_GUN_NUM);
+                destroySelGun(LEFT_GUN_NUM);
+            }
+            if (isDetectPlugin(RIGHT_GUN_NUM)) {
+                _DetectPlugInTimeout(RIGHT_GUN_NUM);
+                destroySelGun(RIGHT_GUN_NUM);
+            }
+            //systemPageRestoreInit();
+            //connectorPageRestoreIdle();
+        }
 
-		//ShmDcCommonData->LcmPage = _PAGE_SELECTGUN;
-		break;
-    case _PAGE_APP_STOP:
-		ShmDcCommonData->LcmPage = _PAGE_CHARGING;
-		break;
-    case _PAGE_RFID_STOP:
-		ShmDcCommonData->LcmPage = _PAGE_CHARGING;
-		break;
-    case _PAGE_ALARM:
-		pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-		if (pDcChargingInfo->Replug_flag)
-			ShmDcCommonData->LcmPage = _PAGE_PRECHARGE_FAIL;
-		break;
-    case _PAGE_PRECHARGE_FAIL:
-		ShmDcCommonData->LcmPage = _PAGE_ALARM;
-		break;
-    case _PAGE_MAINTAIN:
-		break;
-    case _PAGE_EMG_BTN:
-		break;
-    case _PAGE_DEBUG:
-		break;
-	}
+        switch (pDcChargingInfo->SystemStatus) {
+        case S_IDLE:
+        case S_RESERVATION:
+            if (isDetectPlugin(pSysInfo->CurGunSelected)) {
+                _DetectPlugInTimeout(pSysInfo->CurGunSelected);
+                destroySelGun(pSysInfo->CurGunSelected);
+                
+            } else {
+                if( pSysConfig->isAuthrizeByEVCCID && pSysInfo->ConnectorPage == _LCM_PRE_CHARGE) {
+                    _evccidlinktimeout(pSysInfo->CurGunSelected);
+                    pDcChargingInfo->isEVCCIDVerify = true;
+                    break;
+                }
+    #if !defined DD360Audi
+                break;
+    #endif //!defined DD360Audi
+
+                if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
+                    //printf("destroy gun = %d", pSysInfo->CurGunSelected);
+                    destroySelGun(pSysInfo->CurGunSelected);
+                } else {
+                    confirmSelGun(pSysInfo->CurGunSelected);
+                    log_info("confirm select gun ............................... %d ",
+                            pSysInfo->CurGunSelected);
+                }
+            }
+            break;
+
+        case S_REASSIGN_CHECK:
+        case S_REASSIGN:
+        case S_PREPARNING:
+        case S_PREPARING_FOR_EV:
+        case S_PREPARING_FOR_EVSE:
+        case S_CCS_PRECHARGE_ST0:
+        case S_CCS_PRECHARGE_ST1:
+            // 取消充電
+            if (pSysConfig->StopChargingByButton == YES ||
+                pDcChargingInfo->StartMethod == _CHARGING_START_AUTOSTART ||
+                pDcChargingInfo->StartMethod == _CHARGING_START_EVCCID) {
+                    ChargingTerminalProcess(pSysInfo->CurGunSelected);
+            }
+            break;
+
+        case S_CHARGING:
+            if (pSysConfig->StopChargingByButton == YES ||
+                    pDcChargingInfo->StartMethod == _CHARGING_START_AUTOSTART ||
+                    pDcChargingInfo->StartMethod == _CHARGING_START_EVCCID) {
+                // 停止充電
+                ChargingTerminalProcess(pSysInfo->CurGunSelected);
+            }
+            break;
+
+        case S_COMPLETE:
+            break;
+        }
+    } else {
+        strcpy((char*)pSysConfig->UserId, "");
+        switch (ShmDcCommonData->LcmPage) {
+        case _PAGE_SELECTGUN:
+            if (!ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].WaitForPlugit) {
+                ClearDetectPluginFlag(LEFT_GUN_NUM);
+                confirmSelGun(LEFT_GUN_NUM);
+                ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
+                StopSystemTimeoutDet();   // Clear Timeout_SelectGun
+            }
+            pSysInfo->CurGunSelected = LEFT_GUN_NUM;
+            break;
+        case _PAGE_SELECT_PAY:
+            SetIDLE(pSysInfo->CurGunSelected);
+            break;
+        case _PAGE_SETTING:
+            ShmDcCommonData->LcmPage = ShmDcCommonData->previousPage;
+            StopSystemTimeoutDet();
+            break;
+        case _PAGE_BACKLIGHT:
+            ( ShmDcCommonData->MaxBlackLight >= BRIGHTNESS_LEVEL_5 ) ? (ShmDcCommonData->MaxBlackLight -=2) : ( ShmDcCommonData->MaxBlackLight = BRIGHTNESS_LEVEL_3);
+            StopSystemTimeoutDet();
+            break;
+        case _PAGE_LANGUAGE:
+            if (ShmDcCommonData->language >= 1)
+                ShmDcCommonData->language--;
+            StopSystemTimeoutDet();
+            break;
+        case _PAGE_AUTHORIZING:
+            break;
+        case _PAGE_AUTHORIZE_COMPLETE:
+            break;
+        case _PAGE_AUTHORIZE_FAIL:
+            SetIDLE(pSysInfo->CurGunSelected);
+            break;
+        case _PAGE_PLUGIN_TIMEOUT:
+        case _PAGE_WAIT_FOR_PLUGIN:
+            SetIDLE(pSysInfo->CurGunSelected);
+        case _PAGE_CHARGING:
+        case _PAGE_PRECHARGE:
+
+            if (pSysConfig->StopChargingByButton) {
+                pDcChargingInfo->SystemStatus = S_TERMINATING;
+            } else {
+                if (pDcChargingInfo->StartMethod == _CHARGING_START_REMOTESTART)
+                    ShmDcCommonData->LcmPage = _PAGE_APP_STOP;
+                else if (pDcChargingInfo->StartMethod == _CHARGING_START_RFID)
+                    ShmDcCommonData->LcmPage = _PAGE_RFID_STOP;
+                else
+                    pDcChargingInfo->SystemStatus = S_TERMINATING;
+                strcpy((char*)pSysConfig->UserId, "");
+            }
+            break;
+        case _PAGE_COMPLETE:
+        case _PAGE_COMPLETE_RECEIPT:
+            SetIDLE(pSysInfo->CurGunSelected);
+            //ShmDcCommonData->LcmPage = _PAGE_SELECTGUN;
+            break;
+        case _PAGE_APP_STOP:
+            ShmDcCommonData->LcmPage = _PAGE_CHARGING;
+            StopSystemTimeoutDet();   // Clear Timeout_ShowStopPage
+            break;
+        case _PAGE_RFID_STOP:
+            ShmDcCommonData->LcmPage = _PAGE_CHARGING;
+            StopSystemTimeoutDet();   // Clear Timeout_ShowStopPage
+            break;
+        case _PAGE_ALARM:
+            if (!pDcChargingInfo->ConnectorPlugIn) {
+                SetIDLE(pSysInfo->CurGunSelected);
+                break;
+            }
+            if (pDcChargingInfo->Replug_flag)
+                ShmDcCommonData->LcmPage = _PAGE_PRECHARGE_FAIL;
+            break;
+        case _PAGE_PRECHARGE_FAIL:
+            ShmDcCommonData->LcmPage = _PAGE_ALARM;
+            break;
+        case _PAGE_MAINTAIN:
+            break;
+        case _PAGE_EMG_BTN:
+            break;
+        case _PAGE_DEBUG:
+            ShmDcCommonData->LcmPage = ShmDcCommonData->previousPage;
+            StopSystemTimeoutDet();
+            break;
+        }
+    }
 }
 void RightBtnPress()
 {
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-	strcpy((char*)pSysConfig->UserId, "");
-	switch (ShmDcCommonData->LcmPage) {
-	case _PAGE_SELECTGUN:
-		if (!ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].WaitForPlugit) {
-			ClearDetectPluginFlag(RIGHT_GUN_NUM);
-			strcpy((char*)pSysConfig->UserId, "");
-			confirmSelGun(RIGHT_GUN_NUM);
-			ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
-		}
-		pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
-		break;
-	case _PAGE_LANGUAGE:
-		if (ShmDcCommonData->language < 5 )
-			ShmDcCommonData->language++;
-		else {
-			ShmDcCommonData->language = 5;
-		}
-		break;
-	//case _PAGE_SELECT_PAY:
-	//	SetIDLE(pSysInfo->CurGunSelected);
-	//	break;
-	case _PAGE_WAIT_FOR_PLUGIN:
-	case _PAGE_PRECHARGE:
-	case _PAGE_CHARGING:
-	case _PAGE_COMPLETE:
-	case _PAGE_COMPLETE_RECEIPT:
-		(pSysInfo->CurGunSelected == LEFT_GUN_NUM) ? (pSysInfo->CurGunSelected = RIGHT_GUN_NUM) : (pSysInfo->CurGunSelected = LEFT_GUN_NUM);
-		break;
-	}
+    if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
+
+    } else {
+        strcpy((char*)pSysConfig->UserId, "");
+        switch (ShmDcCommonData->LcmPage) {
+        case _PAGE_SELECTGUN:
+            if (!ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].WaitForPlugit) {
+                ClearDetectPluginFlag(RIGHT_GUN_NUM);
+                strcpy((char*)pSysConfig->UserId, "");
+                confirmSelGun(RIGHT_GUN_NUM);
+                ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
+            }
+            pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
+            break;
+        case _PAGE_SETTING:
+            if (ShmDcCommonData->LcmSetItem == _SET_LANGUAGE)
+                ShmDcCommonData->LcmSetItem = _SET_BACKLIGHT;
+            else
+                ShmDcCommonData->LcmSetItem = _SET_LANGUAGE;
+            StopSystemTimeoutDet();
+            break;
+        case _PAGE_BACKLIGHT:
+            ShmDcCommonData->MaxBlackLight >= BRIGHTNESS_LEVEL_11 ? (ShmDcCommonData->MaxBlackLight = BRIGHTNESS_LEVEL_11) : (ShmDcCommonData->MaxBlackLight += 2);
+            log_info("Black Light Max Value:%d",ShmDcCommonData->MaxBlackLight);
+            StopSystemTimeoutDet();
+            break;
+        case _PAGE_LANGUAGE:
+            ShmDcCommonData->language++;
+            if (ShmDcCommonData->language >= ShmDcCommonData->languageCount) {
+                ShmDcCommonData->language = ShmDcCommonData->languageCount;
+            }
+            StopSystemTimeoutDet();
+            break;
+        //case _PAGE_SELECT_PAY:
+        //	SetIDLE(pSysInfo->CurGunSelected);
+        //	break;
+        case _PAGE_WAIT_FOR_PLUGIN:
+        case _PAGE_PRECHARGE:
+        case _PAGE_CHARGING:
+        case _PAGE_COMPLETE:
+        case _PAGE_COMPLETE_RECEIPT:
+            (pSysInfo->CurGunSelected == LEFT_GUN_NUM) ? (pSysInfo->CurGunSelected = RIGHT_GUN_NUM) : (pSysInfo->CurGunSelected = LEFT_GUN_NUM);
+            break;
+        }
+    }
 }
 void CenterBtnPress()
 {
@@ -452,18 +449,36 @@ void CenterBtnPress()
 	case _PAGE_CHARGING:
 	case _PAGE_COMPLETE:
 	case _PAGE_COMPLETE_RECEIPT:
-        ShmDcCommonData->LcmPage = _PAGE_LANGUAGE;
+			ShmDcCommonData->LcmPage = _PAGE_SETTING;
 		break;
-	case _PAGE_LANGUAGE:
+	case _PAGE_SETTING:
 		StopSystemTimeoutDet();
-		ShmDcCommonData->LcmPage = ShmDcCommonData->previousPage;
+		if (ShmDcCommonData->LcmSetItem == _SET_LANGUAGE) {
+			ShmDcCommonData->LcmPage = _PAGE_LANGUAGE;
+		} else if (ShmDcCommonData->LcmSetItem == _SET_BACKLIGHT) {
+			ShmDcCommonData->LcmPage = _PAGE_BACKLIGHT;
+		}
+        StopSystemTimeoutDet();
+		break;
+	case _PAGE_BACKLIGHT:
+		ShmDcCommonData->LcmPage = _PAGE_SETTING;
+        StopSystemTimeoutDet();
+		break;
+	case _PAGE_LANGUAGE:
+		ShmDcCommonData->LcmPage = _PAGE_SETTING;
+        StopSystemTimeoutDet();
 		break;
 	case _PAGE_AUTHORIZE_FAIL:
 
 		break;
 	}
 }
-
+void setTouch()
+{
+    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
+	GetClockTime(&ShmDcCommonData->_touch_time);
+	ShmDcCommonData->isTouch = TRUE;
+}
 void ChkPrimaryStatus(void)
 {
     static bool leftBtnPush = false;
@@ -605,14 +620,19 @@ void ChkPrimaryStatus(void)
 
     if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
             !leftBtnPush ) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+        
 
-        if (!leftBtnPush) {
+        if (!leftBtnPush && !ShmDcCommonData->isTouch) {
             leftBtnPush = true;
-            LeftBtnPress();
-            log_info("left btn down...............................%x",
-                     pDcChargingInfo->SystemStatus);
-
+            GetClockTime(&ShmDcCommonData->SleepTimer);
+            ShmDcCommonData->BlackLight = ShmDcCommonData->MaxBlackLight;
+            if (!ShmDcCommonData->ScreenSave)
+                LeftBtnPress();
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+            log_info("left btn down...............................%d %d %d",
+                    pSysInfo->CurGunSelected, pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
+            ShmDcCommonData->ScreenSave = FALSE;
+            setTouch();
         }
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
         if (leftBtnPush) {
@@ -623,14 +643,19 @@ void ChkPrimaryStatus(void)
 
     if (ShmPrimaryMcuData->InputDet.bits.Key3 == BTN_PRESS &&
             !centerBtnPush ) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+        
 
-        if (!centerBtnPush) {
+        if (!centerBtnPush && !ShmDcCommonData->isTouch) {
             centerBtnPush = true;
-            CenterBtnPress();
-            log_info("center btn down...............................%x",
-                     pDcChargingInfo->SystemStatus);
-
+            GetClockTime(&ShmDcCommonData->SleepTimer);
+            ShmDcCommonData->BlackLight = ShmDcCommonData->MaxBlackLight;
+            if (!ShmDcCommonData->ScreenSave)
+                CenterBtnPress();
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+            log_info("center btn down...............................%d %d %d ",
+                     pSysInfo->CurGunSelected, pDcChargingInfo->SystemStatus, ShmDcCommonData->LcmPage);
+            ShmDcCommonData->ScreenSave = FALSE;
+            setTouch();
         }
     } else if (ShmPrimaryMcuData->InputDet.bits.Key3 == BTN_RELEASE) {
         if (centerBtnPush) {
@@ -639,13 +664,43 @@ void ChkPrimaryStatus(void)
         }
     }
 
+    bool isCharging = false;
+    if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
+        for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
+            if (IntoChargeProcess(pDcChargingInfo->SystemStatus)) {
+                isCharging = true;
+            }
+        }
+    }
+
     if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
             !rightBtnPush) {
-        if (!rightBtnPush) {
+        if (!rightBtnPush && !ShmDcCommonData->isTouch) {
             rightBtnPush = true;
-            RightBtnPress();
-            log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
+            if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
+                if (pSysInfo->SystemPage == _LCM_WAIT_FOR_PLUG && !isCharging) {
+                    return;
+                }
+                strcpy((char *)pSysConfig->UserId, "");
+                if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount) {
+                    pSysInfo->CurGunSelected++;
+                } else {
+                    pSysInfo->CurGunSelected = 0;
+                }
+                pSysInfo->SystemPage = _LCM_NONE;
 
+            } else {
+                GetClockTime(&ShmDcCommonData->SleepTimer);
+                ShmDcCommonData->BlackLight = ShmDcCommonData->MaxBlackLight;
+                if (!ShmDcCommonData->ScreenSave)
+                    RightBtnPress();
+                ShmDcCommonData->ScreenSave = FALSE;
+            }
+            setTouch();
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+            log_info("right btn down............................... %d %d %d", 
+                pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus, pSysInfo->SystemPage);
         }
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
         if (rightBtnPush) {
@@ -653,4 +708,6 @@ void ChkPrimaryStatus(void)
             //log_info("right btn up............................... ");
         }
     }
+
+
 }

+ 231 - 262
EVSE/Projects/DD360/Apps/CSU/RFID.c

@@ -11,6 +11,7 @@
 
 #include "main.h"
 #include "../timeout.h"
+#include "../common.h"
 
 //------------------------------------------------------------------------------
 static char *rfidPortName = "/dev/ttyS2";
@@ -18,6 +19,7 @@ static char *rfidPortName = "/dev/ttyS2";
 static bool isCardScan = false;
 static DcCommonInfo* ShmDcCommonData = NULL;
 //------------------------------------------------------------------------------
+
 static bool canStartCharging(void)
 {
     uint8_t index = 0;
@@ -40,7 +42,6 @@ static bool canStartCharging(void)
 
 static void isAutorCompleteHandle(uint8_t *authorizeIndex)
 {
-    uint8_t i = 0;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
 
@@ -78,22 +79,7 @@ static void isAutorCompleteHandle(uint8_t *authorizeIndex)
         }
 
         ClearAuthorizedFlag();
-    }/* else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
-        // 白名單驗證
-        for (i = 0; i < 10; i++) {
-            if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
-                continue;
-            }
-
-            if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
-                ChargingTerminalProcess(*(authorizeIndex));
-                strcpy((char *)pSysConfig->UserId, "");
-                ClearAuthorizedFlag();
-
-                break;
-            }
-        }
-    }*/
+    }
 }
 
 static void UserScanFunction(void)
@@ -113,18 +99,15 @@ static void UserScanFunction(void)
     if (IsAuthorizingMode()) {
         isAutorCompleteHandle(&_authorizeIndex);
     }
-
+    
     //當前沒有選槍
-    if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL) {
-        strcpy((char *)pSysConfig->UserId, "");
-        return;
-    }
-    /*
-    if (pSysConfig->EVCCID_Authorize) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-        if (strcmp( (char *)pSysConfig->UserId, (char *) pDcChargingInfo->EVCCID) != EQUAL )
+    if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL) {
+            strcpy((char *)pSysConfig->UserId, "");
             return;
-    }*/
+        }
+    }
+
     // 先判斷現在是否可以提供刷卡
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 2. 停止充電
@@ -132,60 +115,27 @@ static void UserScanFunction(void)
         strcpy((char *)pSysConfig->UserId, "");
         return;
     }
-
+    
     for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
 
-        if (pDcChargingInfo->SystemStatus == S_CHARGING) {
+        if (IntoChargeProcess(pDcChargingInfo->SystemStatus)) {
             stopReq = i;
         }
 
         if (((pDcChargingInfo->SystemStatus == S_IDLE ||
             pDcChargingInfo->SystemStatus == S_RESERVATION) &&
-                pDcChargingInfo->IsAvailable == YES) ||
-                (pGunIndexInfo->AcGunIndex > 0 &&
-                 pAcChargingInfo->SystemStatus == S_IDLE &&
-                 pAcChargingInfo->IsAvailable)
-           ) {
+                pDcChargingInfo->IsAvailable == YES)) {
             idleReq = true;
         }
     }
-
-    if (pGunIndexInfo->AcGunIndex > 0 &&
-            pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX &&
-            pAcChargingInfo->SystemStatus == S_CHARGING) {
-        stopReq = DEFAULT_AC_INDEX;
-    }
-
     if (strlen((char *)pSysConfig->UserId) <= 0) {
         return;
     }
 
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
 
-    if (pGunIndexInfo->AcGunIndex > 0 &&
-            stopReq == DEFAULT_AC_INDEX &&
-            pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
-        log_info("ac stop charging ");
-        log_info("index = %d, card number = %s, UserId = %s ",
-                 pSysInfo->CurGunSelectedByAc,
-                 pAcChargingInfo->StartUserId,
-                 pSysConfig->UserId);
-
-        memset(value, 0, sizeof(value));
-        memcpy(value,
-               (uint8_t *)pAcChargingInfo->StartUserId,
-               ARRAY_SIZE(pAcChargingInfo->StartUserId));
-        if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) {
-            AcChargingTerminalProcess();
-        }
-        strcpy((char *)pSysConfig->UserId, "");
-    } else if (stopReq < pSysConfig->TotalConnectorCount &&
-               pDcChargingInfo->SystemStatus == S_CHARGING &&
-               (pGunIndexInfo->AcGunIndex <= 0 ||
-                (pGunIndexInfo->AcGunIndex > 0 &&
-                 pSysInfo->CurGunSelectedByAc == NO_DEFINE))
-              ) {
+    if (stopReq < pSysConfig->TotalConnectorCount && IntoChargeProcess(pDcChargingInfo->SystemStatus)) {
         log_info("stop charging ");
         log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelected,
@@ -198,13 +148,22 @@ static void UserScanFunction(void)
                ARRAY_SIZE(pDcChargingInfo->StartUserId));
 
         // 同一張卡直接停掉
-        if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) {
-            ChargingTerminalProcess(pSysInfo->CurGunSelected);
-            strcpy((char *)pSysConfig->UserId, "");
 
-            return;
+        if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5 ) {
+            if (strcmp((char *)pSysConfig->UserId, (char *)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].StartUserId) == EQUAL ) {
+                ChargingTerminalProcess(pSysInfo->CurGunSelected);
+                strcpy((char *)pSysConfig->UserId, "");
+                return;
+            }
+        } else {
+             if (strcmp((char *)pSysConfig->UserId, (char *)pDcChargingInfo->StartUserId) == EQUAL) {
+                ChargingTerminalProcess(pSysInfo->CurGunSelected);
+                strcpy((char *)pSysConfig->UserId, "");
+                return;
+            }
         }
 
+
         // 進驗證
         if (pGunIndexInfo->AcGunIndex > 0 &&
                 pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
@@ -212,36 +171,43 @@ static void UserScanFunction(void)
         } else {
             _authorizeIndex = pSysInfo->CurGunSelected;
         }
-
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
         strcpy((char *)pSysConfig->UserId, "");
-
         return;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
-
-        StartSystemTimeoutDet(Timeout_AuthorizingForStop);
-
-        AuthorizingStart();
     } else if (idleReq) {
-        if (pSysConfig->TotalConnectorCount > 1 &&
-                stopReq != 255 &&
-                pSysInfo->IsAlternatvieConf == YES) {
-            idleReq = false;
-            strcpy((char *)pSysConfig->UserId, "");
-        } else if ((pGunIndexInfo->AcGunIndex > 0 &&
-                    pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
-                   pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION) {
+        if (CheckDispenserGeneration() >= _DISPENSER_GENERATION_3_5) {
+            if (pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION) {
+                log_info("// LCM => Authorizing ID:%s",(char *)pSysConfig->UserId);
+                ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].WaitForPlugit = FALSE;
+                setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
+
+                // LCM => Authorizing
+                pSysInfo->SystemPage = _LCM_AUTHORIZING;
+
+                // 進入確認卡號狀態
+                AuthorizingStart();
+            } else {
+                strcpy((char *)pSysConfig->UserId, "");
+            }
+        } else {
             log_info("// LCM => Authorizing ID:%s",(char *)pSysConfig->UserId);
-            ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].WaitForPlugit = FALSE;
-            setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
+
+
+            for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
+
+                if (((pDcChargingInfo->SystemStatus == S_IDLE ||
+                    pDcChargingInfo->SystemStatus == S_RESERVATION) &&
+                        pDcChargingInfo->IsAvailable == YES)) {
+                    ShmDcCommonData->pGunInfo[i].WaitForPlugit = FALSE;
+                    setSelGunWaitToAuthor(i);
+                }
+            }
 
             // LCM => Authorizing
             pSysInfo->SystemPage = _LCM_AUTHORIZING;
 
             // 進入確認卡號狀態
             AuthorizingStart();
-        } else {
-            strcpy((char *)pSysConfig->UserId, "");
         }
     } else {
         strcpy((char *)pSysConfig->UserId, "");
@@ -262,74 +228,69 @@ void SetIsCardScan(bool value)
 
 void ScannerCardProcess(void)
 {
-    int i = 0;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
     SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
     ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
-#if (defined DD360Audi) || (SelectGunAction == 1)
-    if (!isDetectPlugin(pSysInfo->CurGunSelected) &&
-     (ShmDcCommonData->LcmPage == _PAGE_SELECT_PAY ||
-     ShmDcCommonData->LcmPage == _PAGE_RFID_STOP ) &&
-#else
-    if ((!isDetectPlugin(LEFT_GUN_NUM) || !isDetectPlugin(RIGHT_GUN_NUM)) &&
-        !isCardScan &&
-#endif
-            pSysWarning->Level != WARN_LV_ER /*&&
-            pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
-        isCardScan = true;
-        // 處理刷卡及驗證卡號的動作
-        UserScanFunction();
+    struct ChargingInfoData *pDcChargingInfo = NULL;
+    if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        if (!isDetectPlugin(pSysInfo->CurGunSelected) &&
+        (ShmDcCommonData->LcmPage == _PAGE_SELECT_PAY ||
+        ShmDcCommonData->LcmPage == _PAGE_RFID_STOP ||
+        ShmDcCommonData->LcmPage == _PAGE_CHARGING ||
+        ShmDcCommonData->LcmPage == _PAGE_PRECHARGE) &&
+        pSysWarning->Level != WARN_LV_ER) {
+            isCardScan = true;
+            // 處理刷卡及驗證卡號的動作
+            UserScanFunction();
+        }
+    } else {
+        if ((!isDetectPlugin(LEFT_GUN_NUM) || !isDetectPlugin(RIGHT_GUN_NUM)) &&!isCardScan &&
+                pSysWarning->Level != WARN_LV_ER ) {
+            isCardScan = true;
+            // 處理刷卡及驗證卡號的動作
+            UserScanFunction();
+        }
     }
 
     if (pSysInfo->SystemPage == _LCM_AUTHORIZING) {
-        if(!isAuthorizedComplete())
+        if(!isAuthorizedComplete()) {
             StartSystemTimeoutDet(Timeout_Authorizing);
-
-        //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
-        // 確認驗證卡號完成沒
-        if (isAuthorizedComplete()
-            /*
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-                || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
-#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-*/
-           ) {
-                //StopSystemTimeoutDet();
-#ifdef DD360Audi
+        } else {
+            //StopSystemTimeoutDet();
+            if (CheckCustomer() == _CUSTOM_AUDI) {
                 StartSystemTimeoutDet(Timeout_WaitBalance);
-
                 if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
-#endif
                     StopSystemTimeoutDet();
                     // 判斷後台回覆狀態
                     if (canStartCharging()) {
                     // LCM => Authorize complete
-                    pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
+                        pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
+                        strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].StartUserId,(char*)pSysConfig->UserId);
                     } else {
+                        // LCM => Authorize fail
+                        pSysInfo->SystemPage = _LCM_AUTHORIZ_FAIL;
+                        strcpy((char *)pSysConfig->UserId, "");
+                        ShmDcCommonData->AuthroizeType = IdTokenType_Central;
+                    }
+                }
+            } else {
+                StopSystemTimeoutDet();
+                // 判斷後台回覆狀態
+                if (canStartCharging()) {
+                // LCM => Authorize complete
+                    pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
+                    strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].StartUserId,(char*)pSysConfig->UserId);
+                } else {
                     // LCM => Authorize fail
                     pSysInfo->SystemPage = _LCM_AUTHORIZ_FAIL;
                     strcpy((char *)pSysConfig->UserId, "");
                     ShmDcCommonData->AuthroizeType = IdTokenType_Central;
-#ifdef DD360Audi
-                }
-#endif
-            } ClearAuthorizedFlag();
-        } /*else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
-            // 白名單驗證
-            for (i = 0; i < 10; i++) {
-                if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
-                    continue;
-                }
-                if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
-                    log_info("Local White Card [%d]:%s", i, pSysConfig->LocalWhiteCard[i]);
-                    pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
-                    ClearAuthorizedFlag();
-                    break;
                 }
             }
-        }*/
+            ClearAuthorizedFlag();
+        }
     } else if (pSysInfo->SystemPage == _LCM_AUTHORIZ_FAIL) {
         StartSystemTimeoutDet(Timeout_VerifyFail);
         isCardScan = false;
@@ -369,6 +330,8 @@ static int InitialRfidPort(void)
     return fd;
 }
 
+
+
 void CreateRfidFork(void)
 {
     pid_t rfidRecPid;
@@ -402,153 +365,159 @@ void CreateRfidFork(void)
                 continue;
             }
 
-            if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) {
-                switch (rfid.snType) {
-#ifdef DD360Audi
-                case RFID_SN_TYPE_6BYTE:
-                    sprintf((char *) pSysConfig->UserId,
-                            "%02X%02X%02X%02X%02X%02X",
-                            rfid.currentCard[0], rfid.currentCard[1],
-                            rfid.currentCard[2], rfid.currentCard[3],
-                            rfid.currentCard[4], rfid.currentCard[5]);
-                    break;
-                case RFID_SN_TYPE_7BYTE:
-                    sprintf((char *) pSysConfig->UserId,
-                            "%02X%02X%02X%02X%02X%02X%02X",
-                            rfid.currentCard[0], rfid.currentCard[1],
-                            rfid.currentCard[2], rfid.currentCard[3],
-                            rfid.currentCard[4], rfid.currentCard[5],
-                            rfid.currentCard[6]);
-                    break;
-                case RFID_SN_TYPE_10BYTE:
-                    sprintf((char *) pSysConfig->UserId,
-                            "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
-                            rfid.currentCard[0], rfid.currentCard[1],
-                            rfid.currentCard[2], rfid.currentCard[3],
-                            rfid.currentCard[4], rfid.currentCard[5],
-                            rfid.currentCard[6], rfid.currentCard[7],
-                            rfid.currentCard[8], rfid.currentCard[9]);
-                    break;
-                case RFID_SN_TYPE_4BYTE:
-                    sprintf((char *) pSysConfig->UserId,
-                            "%02X%02X%02X%02X",
-                            rfid.currentCard[0], rfid.currentCard[1],
-                            rfid.currentCard[2], rfid.currentCard[3]);
-                    break;
-#else
-                case RFID_SN_TYPE_6BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[5], rfid.currentCard[4],
-                        rfid.currentCard[3], rfid.currentCard[2],
-                        rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_7BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[6], rfid.currentCard[5],
-                        rfid.currentCard[4], rfid.currentCard[3],
-                        rfid.currentCard[2], rfid.currentCard[1],
-                        rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_8BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[7], rfid.currentCard[6],
-                        rfid.currentCard[5], rfid.currentCard[4],
-                        rfid.currentCard[3], rfid.currentCard[2],
-                        rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_10BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[9], rfid.currentCard[8],
-                        rfid.currentCard[7], rfid.currentCard[6],
-                        rfid.currentCard[5], rfid.currentCard[4],
-                        rfid.currentCard[3], rfid.currentCard[2],
-                        rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_4BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X",
-                        rfid.currentCard[3], rfid.currentCard[2],
-                        rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-#endif
+            if (CheckCustomer() == _CUSTOM_AUDI) {
+                // Audi RFID endian
+                if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) {
+                    switch (rfid.snType) {
+                    case RFID_SN_TYPE_6BYTE:
+                        sprintf((char *) pSysConfig->UserId,
+                                "%02X%02X%02X%02X%02X%02X",
+                                rfid.currentCard[0], rfid.currentCard[1],
+                                rfid.currentCard[2], rfid.currentCard[3],
+                                rfid.currentCard[4], rfid.currentCard[5]);
+                        break;
+                    case RFID_SN_TYPE_7BYTE:
+                        sprintf((char *) pSysConfig->UserId,
+                                "%02X%02X%02X%02X%02X%02X%02X",
+                                rfid.currentCard[0], rfid.currentCard[1],
+                                rfid.currentCard[2], rfid.currentCard[3],
+                                rfid.currentCard[4], rfid.currentCard[5],
+                                rfid.currentCard[6]);
+                        break;
+                    case RFID_SN_TYPE_10BYTE:
+                        sprintf((char *) pSysConfig->UserId,
+                                "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+                                rfid.currentCard[0], rfid.currentCard[1],
+                                rfid.currentCard[2], rfid.currentCard[3],
+                                rfid.currentCard[4], rfid.currentCard[5],
+                                rfid.currentCard[6], rfid.currentCard[7],
+                                rfid.currentCard[8], rfid.currentCard[9]);
+                        break;
+                    case RFID_SN_TYPE_4BYTE:
+                        sprintf((char *) pSysConfig->UserId,
+                                "%02X%02X%02X%02X",
+                                rfid.currentCard[0], rfid.currentCard[1],
+                                rfid.currentCard[2], rfid.currentCard[3]);
+                        break;
+                    }
+                } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) {
+                    switch (rfid.snType) {
+                        case RFID_SN_TYPE_6BYTE:
+                            sprintf((char *) pSysConfig->UserId,
+                                    "%02X%02X%02X%02X%02X%02X",
+                                    rfid.currentCard[5], rfid.currentCard[4],
+                                    rfid.currentCard[3], rfid.currentCard[2],
+                                    rfid.currentCard[1], rfid.currentCard[0]);
+                            break;
+                        case RFID_SN_TYPE_7BYTE:
+                            sprintf((char *) pSysConfig->UserId,
+                                    "%02X%02X%02X%02X%02X%02X%02X",
+                                    rfid.currentCard[6], rfid.currentCard[5],
+                                    rfid.currentCard[4], rfid.currentCard[3],
+                                    rfid.currentCard[2], rfid.currentCard[1],
+                                    rfid.currentCard[0]);
+                            break;
+                        case RFID_SN_TYPE_10BYTE:
+                            sprintf((char *) pSysConfig->UserId,
+                                    "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+                                    rfid.currentCard[9], rfid.currentCard[8],
+                                    rfid.currentCard[7], rfid.currentCard[6],
+                                    rfid.currentCard[5], rfid.currentCard[4],
+                                    rfid.currentCard[3], rfid.currentCard[2],
+                                    rfid.currentCard[1], rfid.currentCard[0]);
+                            break;
+                        case RFID_SN_TYPE_4BYTE:
+                            sprintf((char *) pSysConfig->UserId,
+                                    "%02X%02X%02X%02X",
+                                    rfid.currentCard[3], rfid.currentCard[2],
+                                    rfid.currentCard[1], rfid.currentCard[0]);
+                            break;
+                    }
                 }
-            } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) {
-                switch (rfid.snType) {
-#ifdef DD360Audi
-                case RFID_SN_TYPE_6BYTE:
-                    sprintf((char *) pSysConfig->UserId,
+            } else {
+                if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) {
+                    // RFID Standard
+                    switch (rfid.snType) {
+                    case RFID_SN_TYPE_6BYTE:
+                        sprintf((char*)pSysConfig->UserId,
                             "%02X%02X%02X%02X%02X%02X",
                             rfid.currentCard[5], rfid.currentCard[4],
                             rfid.currentCard[3], rfid.currentCard[2],
                             rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_7BYTE:
-                    sprintf((char *) pSysConfig->UserId,
+                        break;
+                    case RFID_SN_TYPE_7BYTE:
+                        sprintf((char*)pSysConfig->UserId,
                             "%02X%02X%02X%02X%02X%02X%02X",
                             rfid.currentCard[6], rfid.currentCard[5],
                             rfid.currentCard[4], rfid.currentCard[3],
                             rfid.currentCard[2], rfid.currentCard[1],
                             rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_10BYTE:
-                    sprintf((char *) pSysConfig->UserId,
+                        break;
+                    case RFID_SN_TYPE_8BYTE:
+                        sprintf((char*)pSysConfig->UserId,
+                            "%02X%02X%02X%02X%02X%02X%02X%02X",
+                            rfid.currentCard[7], rfid.currentCard[6],
+                            rfid.currentCard[5], rfid.currentCard[4],
+                            rfid.currentCard[3], rfid.currentCard[2],
+                            rfid.currentCard[1], rfid.currentCard[0]);
+                        break;
+                    case RFID_SN_TYPE_10BYTE:
+                        sprintf((char*)pSysConfig->UserId,
                             "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
                             rfid.currentCard[9], rfid.currentCard[8],
                             rfid.currentCard[7], rfid.currentCard[6],
                             rfid.currentCard[5], rfid.currentCard[4],
                             rfid.currentCard[3], rfid.currentCard[2],
                             rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-                case RFID_SN_TYPE_4BYTE:
-                    sprintf((char *) pSysConfig->UserId,
+                        break;
+                    case RFID_SN_TYPE_4BYTE:
+                        sprintf((char*)pSysConfig->UserId,
                             "%02X%02X%02X%02X",
                             rfid.currentCard[3], rfid.currentCard[2],
                             rfid.currentCard[1], rfid.currentCard[0]);
-                    break;
-#else
-                case RFID_SN_TYPE_6BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[0], rfid.currentCard[1],
-                        rfid.currentCard[2], rfid.currentCard[3],
-                        rfid.currentCard[4], rfid.currentCard[5]);
-                    break;
-                case RFID_SN_TYPE_7BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[0], rfid.currentCard[1],
-                        rfid.currentCard[2], rfid.currentCard[3],
-                        rfid.currentCard[4], rfid.currentCard[5],
-                        rfid.currentCard[6]);
-                    break;
-                case RFID_SN_TYPE_8BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[0], rfid.currentCard[1],
-                        rfid.currentCard[2], rfid.currentCard[3],
-                        rfid.currentCard[4], rfid.currentCard[5],
-                        rfid.currentCard[6], rfid.currentCard[7]);
-                    break;
-                case RFID_SN_TYPE_10BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
-                        rfid.currentCard[0], rfid.currentCard[1],
-                        rfid.currentCard[2], rfid.currentCard[3],
-                        rfid.currentCard[4], rfid.currentCard[5],
-                        rfid.currentCard[6], rfid.currentCard[7],
-                        rfid.currentCard[8], rfid.currentCard[9]);
-                    break;
-                case RFID_SN_TYPE_4BYTE:
-                    sprintf((char*)pSysConfig->UserId,
-                        "%02X%02X%02X%02X",
-                        rfid.currentCard[0], rfid.currentCard[1],
-                        rfid.currentCard[2], rfid.currentCard[3]);
-                    break;
-#endif
+                        break;
+                    }
+                } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) {
+                    switch (rfid.snType) {
+                    case RFID_SN_TYPE_6BYTE:
+                        sprintf((char*)pSysConfig->UserId,
+                            "%02X%02X%02X%02X%02X%02X",
+                            rfid.currentCard[0], rfid.currentCard[1],
+                            rfid.currentCard[2], rfid.currentCard[3],
+                            rfid.currentCard[4], rfid.currentCard[5]);
+                        break;
+                    case RFID_SN_TYPE_7BYTE:
+                        sprintf((char*)pSysConfig->UserId,
+                            "%02X%02X%02X%02X%02X%02X%02X",
+                            rfid.currentCard[0], rfid.currentCard[1],
+                            rfid.currentCard[2], rfid.currentCard[3],
+                            rfid.currentCard[4], rfid.currentCard[5],
+                            rfid.currentCard[6]);
+                        break;
+                    case RFID_SN_TYPE_8BYTE:
+                        sprintf((char*)pSysConfig->UserId,
+                            "%02X%02X%02X%02X%02X%02X%02X%02X",
+                            rfid.currentCard[0], rfid.currentCard[1],
+                            rfid.currentCard[2], rfid.currentCard[3],
+                            rfid.currentCard[4], rfid.currentCard[5],
+                            rfid.currentCard[6], rfid.currentCard[7]);
+                        break;
+                    case RFID_SN_TYPE_10BYTE:
+                        sprintf((char*)pSysConfig->UserId,
+                            "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
+                            rfid.currentCard[0], rfid.currentCard[1],
+                            rfid.currentCard[2], rfid.currentCard[3],
+                            rfid.currentCard[4], rfid.currentCard[5],
+                            rfid.currentCard[6], rfid.currentCard[7],
+                            rfid.currentCard[8], rfid.currentCard[9]);
+                        break;
+                    case RFID_SN_TYPE_4BYTE:
+                        sprintf((char*)pSysConfig->UserId,
+                            "%02X%02X%02X%02X",
+                            rfid.currentCard[0], rfid.currentCard[1],
+                            rfid.currentCard[2], rfid.currentCard[3]);
+                        break;
+                    }
                 }
             }
             log_info("card number = %s", pSysConfig->UserId);

+ 4 - 8
EVSE/Projects/DD360/Apps/CSU/SelfTest.c

@@ -22,8 +22,6 @@ void SelfTestRun(void)
     uint8_t index = 0;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
-
     struct PsuData *ShmPsuData = (struct PsuData *)GetShmPsuData();
     struct CHAdeMOData *ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
     struct GBTData *ShmGBTData = (struct GBTData *)GetShmGBTData();
@@ -46,27 +44,25 @@ void SelfTestRun(void)
 
     StartSystemTimeoutDet(Timeout_SelftestChk);
     pSysInfo->SelfTestSeq = _STEST_VERSION;
-
+    log_info("Start self test... ");
     while (pSysInfo->SelfTestSeq != _STEST_COMPLETE) {
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
             return;
         }
         
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
-
+        /*
         if (pSysWarning->Level == WARN_LV_ER) {
             pSysInfo->SelfTestSeq = _STEST_FAIL;
             return;
         }
-
+        */
         if (pSysConfig->TotalConnectorCount <= 0) {
             pSysInfo->SelfTestSeq = _STEST_FAIL;
             return;
         }
 
-        if (ShmPsuData->Work_Step == _NO_WORKING ||
-                pSysInfo->SelfTestSeq == _STEST_FAIL) {
-            pSysInfo->SelfTestSeq = _STEST_FAIL;
+        if (pSysInfo->SelfTestSeq == _STEST_FAIL) {
             return;
         }
 

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 232 - 286
EVSE/Projects/DD360/Apps/CSU/main.c


+ 1 - 1
EVSE/Projects/DD360/Apps/CSU/main.h

@@ -104,5 +104,5 @@ void setChargerMode(uint8_t gun_index, uint8_t mode);
 
 void KillAllTask(void);
 void KillTask(void);
-
+void ClearDetectPluginFlag(int gunIndex);
 #endif /* _MAIN_H_ */

+ 77 - 7
EVSE/Projects/DD360/Apps/Config.h

@@ -100,7 +100,6 @@
 //------------------------------------------------------------------------------
 
 #define DC_CONNECTOR_COUNT          2
-#define SelectGunAction             1
 
 enum _SYSTEM_STATUS {
     S_BOOTING = 0,
@@ -342,6 +341,38 @@ enum _FUNCTION_SETTING {
     _SET_BACKLIGHT,
     _SET_NONE,
 };
+
+enum BRIGHTNESS_LEVEL
+{
+	BRIGHTNESS_LEVEL_0=0,
+	BRIGHTNESS_LEVEL_1,
+	BRIGHTNESS_LEVEL_2,
+	BRIGHTNESS_LEVEL_3,
+	BRIGHTNESS_LEVEL_4,
+	BRIGHTNESS_LEVEL_5,
+	BRIGHTNESS_LEVEL_6,
+	BRIGHTNESS_LEVEL_7,
+	BRIGHTNESS_LEVEL_8,
+	BRIGHTNESS_LEVEL_9,
+	BRIGHTNESS_LEVEL_10,
+	BRIGHTNESS_LEVEL_11,
+	BRIGHTNESS_LEVEL_AUTO,
+};
+enum _CUSTOM_NAME_ID 
+{
+    _CUSTOM_ZEROVA = 0,
+    _CUSTOM_AUDI,
+    _CUSTOM_UPOWER,
+    _CUSTOM_TCC,
+    _CUSTOM_WATTEV,
+    _CUSTOM_SHELL,
+};
+enum _DISPENSER_GENERATION
+{
+    _DISPENSER_GENERATION_3 = 0,
+    _DISPENSER_GENERATION_3_5 = 1,
+    _DISPENSER_GENERATION_4,
+};
 // Meter OCMF
 struct StructMeter
 {
@@ -370,11 +401,26 @@ enum _OCMF_INFO_READY_FLAG
 };
 enum _CHARGING_START_METHOD
 {
-    _CHARGING_START_RFID = 0,
+    _CHARGING_START_NONE = 0,
+    _CHARGING_START_RFID,
     _CHARGING_START_AUTOSTART,
     _CHARGING_START_REMOTESTART,
     _CHARGING_START_EVCCID,
 };
+enum _AMBINET_LUX_LEVEL
+{
+    _AMBINET_LUX_LEVEL_0 = 100,
+    _AMBINET_LUX_LEVEL_1,
+    _AMBINET_LUX_LEVEL_2,
+    _AMBINET_LUX_LEVEL_3,
+    _AMBINET_LUX_LEVEL_4,
+    _AMBINET_LUX_LEVEL_5,
+    _AMBINET_LUX_LEVEL_6,
+    _AMBINET_LUX_LEVEL_7,
+    _AMBINET_LUX_LEVEL_8,
+    _AMBINET_LUX_LEVEL_9,
+    _AMBINET_LUX_LEVEL_10,
+};
 
 //------------------------------------------------------------------------------
 //struct StructMeter {
@@ -500,18 +546,23 @@ typedef struct StGunInfo {
     char ChargeStartTime[32];
     char ChargeStopTime[32];
     char ChargeDuration[32];
+    // 背光調整時間
+    char BackLightDayTime[32];
+    char BackLightNightTime[32];
 
     uint8_t SendOcmfDataReq;
     char OcmfFileName[300];
     double curMeterValue;
     double _curTotalCharging;
     uint8_t EVStatus;
+    char StartUserId[32];
     struct {
         uint8_t withChiller:1;      //是否有水冷機
         uint8_t WaitForPlugit:1;    // 等待插槍FLAG
         uint8_t isMeterStart:1;
         uint8_t isMeterStop:1;
     };
+    uint8_t RelayTest;
 } GunInfo;
 
 
@@ -563,9 +614,22 @@ typedef struct stRecordTransactionInfo
 
 typedef struct stTestFlag
 {
-    uint8_t ledflag;
+    uint8_t ledflag:1;
+    uint8_t fanflag:1;
+    uint8_t chillerflag:1;
+    uint8_t relayflag:1;
+    uint8_t reserved:4;
 }TestFlag;
 
+typedef struct stLcmInfo
+{
+	int8_t verHW[32];
+	int8_t verFW_OS[32];
+	int8_t verFW_APK[32];
+	int8_t verFW_UI[32];
+	int8_t macAddr[32];
+	int8_t orientation[32];
+}LcmInfo;
 
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
@@ -639,7 +703,7 @@ typedef struct StDcCommonInfo {
     GunStatus pGunStatus[2];
     char DefaultPriceString[255];
     PowerConsumptionValue pConsumption;
-
+    LcmInfo pLcmInfo;
     uint8_t showNetPackage;
     uint8_t showCanPackage;
     char DebugVersion[32];
@@ -651,8 +715,9 @@ typedef struct StDcCommonInfo {
     int SDUPATENUM;
     int BlackLight;
     int MaxBlackLight;
-    time_t SleepTimer; // control by sleep mode
-    time_t lcmwatchdog; // Detect LCM alive or not
+    uint8_t ScreenSave;
+    struct timespec SleepTimer; // control by sleep mode
+    struct timespec lcmwatchdog; // Detect LCM alive or not
     int8_t lcmmacAddr[32];
     int8_t lcmcmd;
     float TempVolt[4];
@@ -667,7 +732,12 @@ typedef struct StDcCommonInfo {
 	// Ocmf Record resend
 	int ocmfTridRecord[DC_CONNECTOR_COUNT];
     uint8_t lcmstatus;
-    uint8_t LcmSetItem;
+    uint8_t LcmSetItem; //設定頁面功能選擇
+    uint8_t Lcmreset;
+    struct timespec _touch_time;
+    uint8_t isTouch;
+    int AmbinetLux;
+    uint8_t AdjustBackLight;
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 1 - 3
EVSE/Projects/DD360/Apps/DataBase/DataBase.c

@@ -205,7 +205,7 @@ int DB_Update_Operactive(uint8_t gunIndex, uint8_t IsAvailable)
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 gunIndex,
                 IsAvailable); //DS60-120 add
-        log_info("sqlStr= %s", sqlStr);
+        //log_info("sqlStr= %s", sqlStr);
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             log_info( "update config error message: %s", errMsg);
@@ -603,8 +603,6 @@ void DB_Upload_ocmf(uint8_t gun_index, int txid)
 {
 	char* errMsg = NULL;
 	char insertSql[4096];
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
 	memset(insertSql, 0, sizeof(insertSql));
 	sprintf(insertSql, "update ocmf_record set status=1 where transactionId=%d and connector=%d;",txid,gun_index);
 	if (sqlite3_open(DB_FILE, &localDb))

+ 22 - 12
EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.c

@@ -16,6 +16,7 @@
 
 #include "../ShareMemory/shmMem.h"
 #include "Module_ChkSysTask.h"
+#include "../common.h"
 
 struct SysConfigData *pSysConfig = NULL;
 struct SysInfoData *pSysInfo = NULL;
@@ -75,7 +76,7 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 	unsigned char count_interComm	= GetProcessCount("Module_InternalComm");
 	unsigned char count_eventComm	= GetProcessCount("Module_EventLogging");
 	unsigned char count_primaryComm	= GetProcessCount("Module_PrimaryComm");
-	if (SelectGunAction == 1)
+	if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5)
 		count_lcmComm	    = GetProcessCount("Module_LcmWistronControl");
 	else
 		count_lcmComm	    = GetProcessCount("Module_LcmControl");
@@ -83,7 +84,12 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
 	unsigned char count_updateFW	= GetProcessCount("Module_UpdateFW");
 	unsigned char count_DcMeter  	= GetProcessCount("Module_DcMeter");
-
+	int lcmcount = 0;
+	if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
+		lcmcount = _SYSTEM_TASK_COUNT_LCM_7;
+	} else {
+		lcmcount = _SYSTEM_TASK_COUNT_LCM_21_5;
+	}
 	//if (systemPage != _LCM_FIX )
 	{
 		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
@@ -96,7 +102,7 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 			system("killall Module_EventLogging");
 			system("killall Module_PrimaryComm");
 			system("killall Module_EvComm");
-			if (SelectGunAction == 1)
+			if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5)
 				system("killall Module_LcmWistronControl");
 			else
 				system("killall Module_LcmControl");
@@ -142,16 +148,17 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 				sleep(3);
 				system("/root/Module_PrimaryComm &");
 			}
-			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
+			if (count_lcmComm < lcmcount )
 			{
-				if (SelectGunAction == 1) {
-					system("killall Module_LcmWistronControl");
-					sleep(3);
-					system("/root/Module_LcmWistronControl &");
-				} else {
+				if (CheckDispenserGeneration() != _DISPENSER_GENERATION_3_5) {
 					system("killall Module_LcmControl");
 					sleep(3);
 					system("/root/Module_LcmControl &");
+				} else {
+					system("killall Module_LcmWistronControl");
+					sleep(3);
+					system("/root/Module_LcmWistronControl &");
+
 				}
 			}
 			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
@@ -192,7 +199,7 @@ unsigned char CheckSystemTask(unsigned char systemPage)
         result = _SYSTEM_TASK_LOST_ITEM_EVENTLOG;
     else if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM)
         result = _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM;
-    else if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM)
+    else if (count_lcmComm < lcmcount)
         result = _SYSTEM_TASK_LOST_ITEM_LCMCONTROL;
     else if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
         result = _SYSTEM_TASK_LOST_ITEM_INTERCOMM;
@@ -204,6 +211,9 @@ unsigned char CheckSystemTask(unsigned char systemPage)
         result = _SYSTEM_TASK_LOST_ITEM_UPDATEFW;
     else if (count_DcMeter < _SYSTEM_TASK_COUNT_DCMETER && pSysConfig->ModelName[3] == 'P')
         result = _SYSTEM_TASK_LOST_ITEM_DCMETER;
+	else{
+
+	}
 
 	return result;
 }
@@ -246,11 +256,11 @@ void CheckSystemTaskAlive()
 }
 
 
-void main(void)
+int main(void)
 {
     if (CreateAllCsuShareMemory() == FAIL) {
         log_error("create share memory error");
-        return ;
+        return FAIL;
     }
     MappingGunChargingInfo("CheckSystem Task");
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();

+ 2 - 5
EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.h

@@ -53,11 +53,8 @@
 #define _SYSTEM_TASK_COUNT_INTERNALCOMM     2
 #define _SYSTEM_TASK_COUNT_EVENTLOGGING     1
 #define _SYSTEM_TASK_COUNT_PRIMARYCOMM      1
-#if (SelectGunAction == 1)
-#define _SYSTEM_TASK_COUNT_LCM              2
-#else
-#define _SYSTEM_TASK_COUNT_LCM              1
-#endif
+#define _SYSTEM_TASK_COUNT_LCM_21_5              2
+#define _SYSTEM_TASK_COUNT_LCM_7              1
 
 #define _SYSTEM_TASK_COUNT_DOCOMM           1
 #define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1

+ 61 - 105
EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c

@@ -29,7 +29,7 @@
 #include "../timeout.h"
 #include "../DataBase/DataBase.h"
 #include "DoComm.h"
-
+#include "../common.h"
 //------------------------------------------------------------------------------
 static DoCommGblData gDoCommGblData             = {0};
 static MoreInfoReq gMoreInfoReq[2]              = {0};
@@ -73,10 +73,6 @@ static int writeGroundFaultDetection(int fd, uint8_t status, uint8_t id);
 //------------------------------------------------------------------------------
 //--- Common function ---
 //------------------------------------------------------------------------------
-void GetClockTime(struct timespec *_now_time, void *null)
-{
-    clock_gettime(CLOCK_MONOTONIC, _now_time);
-}
 
 static int DiffTimeb(struct timeb ST, struct timeb ET)
 {
@@ -89,64 +85,6 @@ static int DiffTimeb(struct timeb ST, struct timeb ET)
     return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
 }
 
-/**
- * [hexdump : check data]
- * @Author   Jerry
- * @DateTime 2018-12-21
- * @param    p          [description]
- * @param    size       [description]
- */
-static void Hexdump(const void *p, size_t size)
-{
-    const uint8_t *c = p;
-    char message[10240] = {0};
-    uint32_t i = 0;
-    uint32_t message_len = 0;
-
-    assert(p);
-
-    //printf("Dumping %u bytes from %p:\n", size, p);
-    message_len += sprintf(&message[message_len], "\nDumping %u bytes from %p:\n",  (unsigned int)size, p);
-
-    while (size > 0) {
-        for (i = 0; i < 16; i++) {
-            if (i < size) {
-                //printf("%02x ", c[i]);
-                message_len += sprintf(&message[message_len], "%02x ", c[i]);
-            } else {
-                //printf("   ");
-                message_len += sprintf(&message[message_len], "   ");
-            }
-        }
-
-        for (i = 0; i < 16; i++) {
-            if (i < size) {
-                //printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.');
-                message_len += sprintf(&message[message_len], "%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.');
-            } else {
-                //printf(" ");
-                message_len += sprintf(&message[message_len], " ");
-            }
-        }
-
-        //printf("\n");
-        message_len += sprintf(&message[message_len], "\n");
-        c += 16;
-
-        if (size <= 16) {
-            break;
-        }
-
-        size -= 16;
-    }
-
-    //message_len += sprintf(&message[message_len], "\n");
-    if( strcmp(old_Hexdump,message) != EQUAL ) {
-        log_info("%s", message);
-        strcpy(old_Hexdump,message);
-    }
-}
-
 static int string2ByteArray(char *input, uint8_t *output)
 {
     int loop = 0;
@@ -195,7 +133,10 @@ static void InitSocketSigPipe(void)
 //------------------------------------------------------------------------------
 static void setTcpStatus(uint8_t setValue)
 {
+    if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo != setValue)
+        log_info("Disconnect from Cabinet");
     pAlarmCode->AlarmEvents.bits.DisconnectedFromDo = setValue;
+
 }
 
 //------------------------------------------------------------------------------
@@ -533,7 +474,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
 
     string2ByteArray((char *)data, (uint8_t *)ShmDcCommonData->QRCodeString);
     string2Date((char*)data, (uint8_t*)_setTime);
-    //printf("SystemId =  %s", pSysConfig->SystemId);
+
     if (!timecmp((uint8_t *)localTime,(uint8_t *)_setTime)) {
         //log_info("Set Timer:%s", _setTime);
         sprintf((char*)cmdBuf, "date -u -s \"%s\" >> /dev/null &", _setTime);
@@ -693,13 +634,12 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 clearMiscCommand();
                 break;
             }
-
-#if defined DD360Audi
-            if (getConfirmSelectedGun(plugNum) == FAIL) {
-                log_info("Remote start not select gun");
-                break;
+            if (CheckCustomer() == _CUSTOM_AUDI) {
+                if (getConfirmSelectedGun(plugNum) == FAIL) {
+                    log_info("Remote start not select gun");
+                    break;
+                }
             }
-#endif //DD360Audi
 
             ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
             log_info("%d misc balance = %.2f", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
@@ -728,6 +668,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
         case MISC_CMD_WEB_STOP_CHARGING:
             pSysConfig->StopChargingByButton = value;
+            log_info("Stop Charging By Button is %s",value ? "ON" : "OFF");
             break;
 
         //--- Control Dispenser ---
@@ -763,7 +704,9 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 break;
             }
             log_info("Remote start charging plugNum = %d", plugNum);
-
+            // Restart timer
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
+            pDcChargingInfo->TimeoutFlag = Timeout_None;
 #if defined DD360Audi
             if (getSelGunWaitToAuthor(plugNum) == FAIL) {
                 log_error("Remote start gun already charging");
@@ -779,7 +722,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                     pSysInfo->WaitForPlugit = NO;
                     sleep(1); //Jerry add
                     pSysInfo->SystemPage = _LCM_SELECT_GUN;
-                    GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
+                    GetClockTime(&pSysInfo->SystemTimeoutTimer);
                     pSysInfo->SystemTimeoutFlag = Timeout_None;
                 }
 
@@ -791,7 +734,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                     pSysInfo->WaitForPlugit = NO;
                     sleep(1); //Jerry add
                     pSysInfo->SystemPage = _LCM_SELECT_GUN;
-                    GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
+                    GetClockTime(&pSysInfo->SystemTimeoutTimer);
                     pSysInfo->SystemTimeoutFlag = Timeout_None;
                 }
 
@@ -823,7 +766,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 #ifdef DD360Audi
             pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #endif
-            GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
+            GetClockTime(&pSysInfo->SystemTimeoutTimer);
             pSysInfo->SystemTimeoutFlag = Timeout_None;
             destroySelectGun(plugNum);
 
@@ -844,7 +787,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 #ifdef DD360Audi
                 pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #endif
-                GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
+                GetClockTime(&pSysInfo->SystemTimeoutTimer);
                 pSysInfo->SystemTimeoutFlag = Timeout_None;
                 destroySelectGun(plugNum);
             } else {
@@ -1137,7 +1080,6 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t remaindLen = 0;
     //uint8_t statusCodeError = 0;
     if (dataLen > 0) {
-        //Hexdump((uint8_t *)data, dataLen);
 
         remaindLen = dataLen % WARNING_CODE_SIZE;
 
@@ -1148,7 +1090,6 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
 
         if (dataLen < WARNING_CODE_SIZE) {
             log_error("fail status code length = %d", dataLen);
-            //Hexdump(data, dataLen);
             if (pSysWarning->WarningCount > 0) {
                 for (i = 0; i < pSysWarning->WarningCount; i++) {
                     usleep(128);
@@ -1218,7 +1159,6 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     } else {
         if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
             log_error("power cabinet status code data length is zero, but have data");
-            //Hexdump((uint8_t *)data, WARNING_CODE_SIZE);
         }
     }
 
@@ -1261,7 +1201,6 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
     SoftwareUpdInfo *pSoftwareUpd = NULL;
     PcPsuOutput *pPcPsuOutput = NULL;
 
-    //Hexdump((uint8_t *)pCsuResult, sizeof(CmdHead) + pCsuResult->Head.DataLen);
     if (compareOpcode(pCsuResult->Head.OP) == FAIL ||
             compareResult(pCsuResult->Data.Result) == FAIL ||
             compareRegister(pCsuResult->Data.Register, reg) == FAIL) {
@@ -1605,8 +1544,6 @@ static int composeSocketData(int fd,
 
     sendPktLen = csuCmdPkt.Head.DataLen + sizeof(csuCmdPkt.Head);
 
-    //Hexdump((uint8_t *)&csuCmdPkt, sendPktLen);
-
     //send command packet
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
         log_error("TCP socket send packet fail = %d", size);
@@ -1981,15 +1918,27 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
         pConnState->State = CONN_ST_CHARGING;    //charging
     } else if (pDcChargingInfo->SystemStatus == S_TERMINATING ||
             pDcChargingInfo->SystemStatus == S_COMPLETE) {
-        if (pSysConfig->ModelName[3] == 'P' && !ShmDcCommonData->pGunInfo[plugNum].isMeterStop) {
-            return FAIL;
+        if (pSysConfig->ModelName[3] == 'P') {
+            if (!ShmDcCommonData->pGunInfo[plugNum].isMeterStop) {
+                return FAIL;
+            }
+        } else {
+            if (pDcChargingInfo->RelayK1K2Status == YES) {
+                return FAIL;
+            }
         }
         pConnState->State = CONN_ST_TERMINATING;    //terminating
 
     } else if ((pDcChargingInfo->SystemStatus == S_ALARM) ||
                (pDcChargingInfo->SystemStatus == S_FAULT)) {
-        if (pSysConfig->ModelName[3] == 'P' && !ShmDcCommonData->pGunInfo[plugNum].isMeterStop && pDcChargingInfo->SystemStatus == S_ALARM) {
-            return FAIL;
+        if (pSysConfig->ModelName[3] == 'P') {
+            if (!ShmDcCommonData->pGunInfo[plugNum].isMeterStop && pDcChargingInfo->SystemStatus == S_ALARM) {
+                return FAIL;
+            }
+        } else {
+            if (pDcChargingInfo->RelayK1K2Status == YES && pDcChargingInfo->SystemStatus == S_ALARM) {
+                return FAIL;
+            }
         }
         pConnState->State = CONN_ST_ALARM;
         strncpy((char *)pConnState->WarningCode,
@@ -2024,7 +1973,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
         }
     }
     if (gunstatus[plugNum] != pConnState->State) {
-        log_info("Gun%d Status[%d] to OCPP Backend",plugNum,pConnState->State);
+        log_info("Gun%d Status[%d] to OCPP Backend VendorErrorCode[%s]",plugNum,pConnState->State,(char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
         gunstatus[plugNum] = pConnState->State;
     }
 
@@ -2166,6 +2115,12 @@ static int writeChargingTarget(int fd, uint8_t plugNum, uint8_t id)
     uint8_t dataBuf[4] = {0};
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
 
+    if ((pDcChargingInfo->SystemStatus <= S_PREPARING_FOR_EV || pDcChargingInfo->SystemStatus >= S_TERMINATING) &&
+        pDcChargingInfo->SystemStatus != S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus != S_CCS_PRECHARGE_ST1) {
+        pDcChargingInfo->EvBatterytargetVoltage = 0;
+        pDcChargingInfo->EvBatterytargetCurrent = 0;
+    }
+
     ChargingVolt = pDcChargingInfo->EvBatterytargetVoltage;
     ChargingAmp = pDcChargingInfo->EvBatterytargetCurrent;
     ChargingVolt *= 10;
@@ -2424,26 +2379,27 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
 {
     int ret = 0;
     uint8_t gunID = 0;
-    struct timeb AuthNowTime;
+    struct timeb AuthNowTime = {0};
 
-#if defined DD360Audi || SelectGunAction == 1
-    gunID = gDoCommGblData.ConnectorID[pSysInfo->CurGunSelected];
-    //gunID = gDoCommGblData.ConnectorID[plugNum];
-    if (pSysConfig->AuthorisationMode) {
+    if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        gunID = ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ConnectorID;
+        //gunID = gDoCommGblData.ConnectorID[plugNum];
+        if (pSysConfig->AuthorisationMode != AUTH_MODE_ENABLE) {
+            gunID = ID_REGISTER;
+            ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
+        }
+    } else {
         gunID = ID_REGISTER;
-        ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
-    }
-#else
-    gunID = ID_REGISTER;
+        ShmSelectGunInfo->PricesInfo[plugNum].Balance = 0.0; //非Audi 不需要等待主櫃回報餘額
 
-    ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0; //非Audi 不需要等待主櫃回報餘額
-#endif // DD360Audi
+    }
 
     if ((ShmOCPP16Data->SpMsg.bits.AuthorizeReq == YES) ||
             (pSysInfo->AuthorizeFlag == YES)) {
         ftime(&AuthNowTime);
 
-        if (DiffTimeb(gRegTimeUp[plugNum][REG_USER_ID], AuthNowTime) > LOOP_RETRY_TIME) {
+        if (DiffTimeb(gRegTimeUp[plugNum][REG_USER_ID], AuthNowTime) > LOOP_RETRY_TIME ||
+            DiffTimeb(gRegTimeUp[plugNum][REG_USER_ID], AuthNowTime) < 0) {
             ret = writeUserID(fd,
                               gunID,
                               pSysConfig->UserId);
@@ -2457,7 +2413,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
                 } else {
                     strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted");
                 }
-
+                log_info("Gun%d %s authorize %s",gunID,pSysConfig->UserId,ret ? "Pass" : "Fail");
                 //printf("%d Balance = %.2f, %.2f\n",
                 //       plugNum,
                 //       ShmSelectGunInfo->PricesInfo[plugNum].Balance,
@@ -2472,7 +2428,10 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
                 }
             }
             ftime(&gRegTimeUp[plugNum][REG_USER_ID]);
+        } else {
+            //log_info("Wait Gun%d %s authorizing ....", gunID,pSysConfig->UserId);
         }
+
     }
 }
 
@@ -2617,14 +2576,14 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             curReg = REG_QRCODE_URL_INFO;
             break;
         case REG_QRCODE_URL_INFO:
-            if (gunID == 1) {
+            //if (gunID == 1) {
                 if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10) ||
                     DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0
                     ) {
                     readQRcodeURLAndSystemDate(fd);
                     ftime(&gRegTimeUp[plugNum][curReg]);
                 }
-            }
+            //}
 #ifdef DD360Audi
         curReg = REG_POWER_CONSUMPTION_INFO;
 #else
@@ -2837,12 +2796,8 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8_t gunID)
 {
     uint8_t i = 0;
-    int j;
     struct timeb AuthNowTime = {0};
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
-\
-    struct timeb SeqEndTime;
-    struct tm* tm;
 
     switch (pDcChargingInfo->SystemStatus) {
     case S_IDLE:
@@ -2852,6 +2807,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
     case S_AUTHORIZING:
         
         if(pDcChargingInfo->SystemStatus == S_ALARM) {
+            writeChargingTarget(fd, plugNum, gunID);
             ftime(&AuthNowTime);
             if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
                 DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0

+ 3 - 3
EVSE/Projects/DD360/Apps/ModuleEvComm/AbnormalState.c

@@ -27,10 +27,10 @@ bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode)
     //iflog_info("NOTIFICATION_EV_STOP : Err Code = %s \n", string);
 
     if (strncmp(string, "000000", 6) == EQUAL ||
-            strncmp(string, "012219", 6) == EQUAL ||
+            strncmp(string, "023983", 6) == EQUAL  ||
             strncmp(string, "023979", 6) == EQUAL )
     {
-		log_info("NOTIFICATION_EV_STOP : EvCode = %s", string);
+		log_info("NOTIFICATION_EV_STOP : NormalEvCode = %s", string);
         return false;
     }
 
@@ -39,7 +39,7 @@ bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode)
     }
 
     memcpy(pDcChargingInfo->EvConnAlarmCode, string, 6);
-    log_info("NOTIFICATION_EV_STOP : EvConnAlarmCode = %s", pDcChargingInfo->EvConnAlarmCode);
+    log_info("----------------- NOTIFICATION_EV_STOP : EvConnAlarmCode = %s -----------------", pDcChargingInfo->EvConnAlarmCode);
 
     if (strcmp(string, "023700") == EQUAL) { pInfoCode->InfoEvents.bits.ChademoEvCommFail = YES; }
     if (strcmp(string, "023704") == EQUAL) { pInfoCode->InfoEvents.bits.ChademoBatteryMalfun = YES; }

+ 1 - 0
EVSE/Projects/DD360/Apps/ModuleEvComm/Ev_Comm.c

@@ -14,6 +14,7 @@
 #include "Ev_Comm.h"
 #include "Module_EvComm.h"
 #include "../Config.h"
+#include "../ShareMemory/shmMem.h"
 //------------------------------------------------------------------------------
 int PackageIdCmd(int cmd)
 {

+ 1 - 0
EVSE/Projects/DD360/Apps/ModuleEvComm/Ev_Comm.h

@@ -40,6 +40,7 @@
 #define ACK_GET_OUTPUT_REQ                      (0x08000900)
 #define ACK_GET_EV_BATTERY_INFO                 (0x08000A00)
 #define ACK_GET_MISCELLANEOUS_INFO              (0x08000D00)
+#define ACK_DOWNLOAD_FINISH                     (0x08001100)
 #define ACK_EVSE_ISOLATION_STATUS               (0x08001200)
 #define ACK_EVSE_PRECHAGE_INFO                  (0x08001500)
 #define ACK_EVCCID_REQ                          (0x08001600)

+ 7 - 6
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -9,6 +9,7 @@
 
 #include <linux/can.h>
 #include <linux/can/raw.h>
+#include <time.h>
 
 #include "../Config.h"
 #include "../Log/log.h"
@@ -230,7 +231,6 @@ static void AddrAssignment(uint8_t *data)
 
 void CheckEvConnect(int gunIndex)
 {
-    int isSameType = FALSE;
     int isDisconnect = FALSE;
     int gunType = _Type_CCS_2;
     struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
@@ -243,7 +243,6 @@ void CheckEvConnect(int gunIndex)
         pDcChargingInfo_1 = (struct ChargingInfoData*)GetDcChargingInfoData(1);
 
     if (pDcChargingInfo_0->Type == pDcChargingInfo_1->Type) {
-        isSameType = TRUE;
         isDisconnect = ShmDcCommonData->pGunStatus[0].EVLoseFlag | ShmDcCommonData->pGunStatus[1].EVLoseFlag;
         gunType = pDcChargingInfo_0->Type;
     } else {
@@ -309,7 +308,6 @@ void CANReceiver(int fd)
         uint8_t lastConnTemp[2] = {0, 0};
         struct can_frame frame;
         ChillerTemp chiilerTemp = {0};
-        time_t CCS_PlugoutTimer[2] = { 0 };
         struct ChargingInfoData *pDcChargingInfo = NULL;
         int len = 0;
         char _info[1024];
@@ -332,8 +330,6 @@ void CANReceiver(int fd)
         ShmDcCommonData->pGunStatus[1].EVLoseTimer = time((time_t*)NULL);
 
         //log_info("Module_EvRXComm Child's PID is %d", getpid());
-        CCS_PlugoutTimer[0] = time((time_t*)NULL);
-        CCS_PlugoutTimer[1] = time((time_t*)NULL);
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
 
@@ -428,7 +424,7 @@ void CANReceiver(int fd)
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(targetGun);
             gunTypeIndex = pDcChargingInfo->type_index;
 
-
+    
             switch (intCmd) {
             case NOTIFICATION_EV_STATUS:
                 if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
@@ -774,9 +770,11 @@ void CANReceiver(int fd)
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                          pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                     // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
+                    /*
                     log_info("----------------------------- Gun%d NOTIFICATION_EV_STOP err level = %d -----------------------------",
                              targetGun,
                              frame.data[0]);
+                             */
                     if (frame.data[0] == 0x02) {
                         if (AbnormalStopAnalysis(targetGun, frame.data + 1) == true) {
                             pDcChargingInfo->StopChargeFlag = YES;
@@ -811,6 +809,9 @@ void CANReceiver(int fd)
                     log_info( "Gun %d->EVCCID = %s ", targetGun, pDcChargingInfo->EVCCID );
                 }
                 break;
+            case ACK_DOWNLOAD_FINISH:
+                log_info("Gun %d image download finish",targetGun);
+                break;
             default:
                 log_info("EV board = %d, Ack none defined. intCmd = %d  ", targetGun, intCmd);
                 break;

+ 20 - 105
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -25,7 +25,7 @@
 #include "Ev_Comm.h"
 #include "Module_EvComm.h"
 #include "../CSU/main.h"
-
+#include "../common.h"
 //------------------------------------------------------------------------------
 static struct SysConfigData *pSysConfig = NULL;
 static struct SysInfoData *pSysInfo = NULL;
@@ -70,23 +70,6 @@ int GetCanFd(void)
     return CanFd;
 }
 
-void GetClockTime(struct timespec *_now_time, void *null)
-{
-    clock_gettime(CLOCK_MONOTONIC, _now_time);
-}
-
-unsigned long GetClockTimeoutValue(struct timespec _start_time)
-{
-    struct timespec ts_end;
-    unsigned long ret = 0;
-
-    clock_gettime(CLOCK_MONOTONIC, &ts_end);
-
-    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000)));
-
-    return ret;
-}
-
 uint32_t GetTimeoutValue(struct timeval _sour_time)
 {
     struct timeval _end_time;
@@ -433,24 +416,24 @@ static void SetPresentChargingOutputCap(void)
         }
     }
     // Chiller 錯誤或溫度降載
-    if (chargingData_1->ChillerTemp <= 70 && ShmDcCommonData->pGunInfo[0].withChiller && !ischillerHighTemp[0]) {
+    if (chargingData_1->ChillerTemp <= 60 && ShmDcCommonData->pGunInfo[0].withChiller && !ischillerHighTemp[0]) {
         ischillerHighTemp[0] = TRUE;
         if (cur1 > 2500) {
             log_info("Gun0 chiller temperature(%d) too high set current less than 250A", chargingData_1->ChillerTemp);
             cur1 = 2500;
         }
-    } else if (chargingData_1->ChillerTemp > 75 && ischillerHighTemp[0]) {
-        cur1 = 2500;
+    } else if (chargingData_1->ChillerTemp > 70 && ischillerHighTemp[0]) {
+        //cur1 = 2500;
     }
 
-    if (chargingData_2->ChillerTemp <= 70 && ShmDcCommonData->pGunInfo[1].withChiller && !ischillerHighTemp[1]) {
+    if (chargingData_2->ChillerTemp <= 60 && ShmDcCommonData->pGunInfo[1].withChiller && !ischillerHighTemp[1]) {
         ischillerHighTemp[1] = TRUE;
         if (cur2 > 2500) {
             log_info("Gun1 chiller temperature(%d) too high set current less than 250A", chargingData_2->ChillerTemp);
             cur2 = 2500;
         }
-    } else if (chargingData_2->ChillerTemp > 75 && ischillerHighTemp[1]) {
-        cur1 = 2500;
+    } else if (chargingData_2->ChillerTemp > 70 && ischillerHighTemp[1]) {
+        //cur2 = 2500;
     }
 
     if (ShmPrimaryMcuData->InputDet.bits.Ac_Drop == ABNORMAL) {
@@ -517,80 +500,6 @@ static void GetMaxVolAndCurMethod(uint8_t index, float *vol, float *cur)
     }
 }
 
-static uint8_t waitPsuVolwithRealyVol(uint8_t gunIndex)
-{
-    PcPsuOutput *pPcPsuOutput = (PcPsuOutput *)&ShmDcCommonData->PcPsuOutput[gunIndex];
-    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-    int vol = 0;
-
-    vol = abs(pPcPsuOutput->Voltage - pDcChargingInfo->FireChargingVoltage);
-    if (vol <= 10) {
-        return YES;
-    }
-
-    return NO;
-}
-
-/**
- * [SetPresentChargingOutputFromPcPsu 充電狀態讀取電源櫃PSU輸出電壓電流,縮小誤差值]
- * @Author   Jerry
- * @DateTime 2021-07-05
- */
-static void SetPresentChargingOutputFromPcPsu(uint8_t gunCount)
-{
-    float vol1 = 0, cur1 = 0;
-    float vol2 = 0, cur2 = 0;
-    PcPsuOutput *pPcPsuOutput0 = NULL;
-    PcPsuOutput *pPcPsuOutput1 = NULL;
-    struct ChargingInfoData *chargingData0 = NULL;
-    struct ChargingInfoData *chargingData1 = NULL;
-
-    switch (gunCount) {
-    case 1:
-        pPcPsuOutput0 = (PcPsuOutput *)&ShmDcCommonData->PcPsuOutput[0];
-        pPcPsuOutput1 = (PcPsuOutput *)&ShmDcCommonData->PcPsuOutput[0];
-        chargingData0 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
-        chargingData1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
-        break;
-
-    case 2:
-        pPcPsuOutput0 = (PcPsuOutput *)&ShmDcCommonData->PcPsuOutput[0];
-        pPcPsuOutput1 = (PcPsuOutput *)&ShmDcCommonData->PcPsuOutput[1];
-        chargingData0 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
-        chargingData1 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
-        break;
-    }
-
-    vol1 = pPcPsuOutput0->Voltage == 0 ? chargingData0->FireChargingVoltage : (((float)pPcPsuOutput0->Voltage));
-    cur1 = (chargingData0->PresentChargingCurrent * 10);//(((float)pPcPsuOutput0->Current) * 0.1);
-    vol2 = pPcPsuOutput1->Voltage == 0 ? chargingData1->FireChargingVoltage : (((float)pPcPsuOutput1->Voltage));
-    cur2 = (chargingData1->PresentChargingCurrent * 10);//(((float)pPcPsuOutput1->Current) * 0.1);
-
-    if (
-        (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] >= vol1 + CHK_VOL_RANGE) ||
-        (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] <= vol1 - CHK_VOL_RANGE) ||
-        (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] >= cur1 + CHK_CUR_RANGE) ||
-        (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] <= cur1 - CHK_CUR_RANGE) ||
-        (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] >= vol2 + CHK_VOL_RANGE) ||
-        (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] <= vol2 - CHK_VOL_RANGE) ||
-        (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
-        (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
-    ) {
-        log_info("G1->Out Vol=%.1f,Out Cur=%.1f - G2->Out Vol=%.1f,Out Cur=%.1f",
-                 vol1,
-                 cur1 / 10,
-                 vol2,
-                 cur2 / 10);
-
-        LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] = vol1;
-        LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] = cur1;
-        LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] = vol2;
-        LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] = cur2;
-    }
-
-    SetPresentOutputPower(vol1, cur1, vol2, cur2);
-}
-
 static void SetPresentChargingOutputPower(void)
 {
     float vol1 = 0, cur1 = 0;
@@ -952,19 +861,19 @@ int main(int argc, char *argv[])
                     if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
                         if (!chkChademoPermission[gunIndex]) {
                             chkChademoPermission[gunIndex] = true;
-                            GetClockTime(&_chk_chademo_permission_timeout[gunIndex], NULL);
+                            GetClockTime(&_chk_chademo_permission_timeout[gunIndex]);
                             SendCommunicationOnly(gunIndex);
                             log_info("Send Communication command");
                         } else {
                             _timeBuf = GetClockTimeoutValue(_chk_chademo_permission_timeout[gunIndex]);
 
                             if (_timeBuf < 0) {
-                                GetClockTime(&_chk_chademo_permission_timeout[gunIndex], NULL);
+                                GetClockTime(&_chk_chademo_permission_timeout[gunIndex]);
                             } else {
                                 if (_timeBuf / 1000 > 10000) {
                                     SendCommunicationOnly(gunIndex);
                                     log_info("Send Communication command");
-                                    GetClockTime(&_chk_chademo_permission_timeout[gunIndex], NULL);
+                                    GetClockTime(&_chk_chademo_permission_timeout[gunIndex]);
                                 }
                             }
                         }
@@ -1108,7 +1017,7 @@ int main(int argc, char *argv[])
                     GetEvBatteryInfo(gunIndex, pDcChargingInfo->Evboard_id);
                 }
 
-                GetClockTime(&_chk_ratingPower_timeout[gunIndex], NULL);
+                GetClockTime(&_chk_ratingPower_timeout[gunIndex]);
                 break;
 
             case S_PREPARING_FOR_EVSE:
@@ -1197,9 +1106,7 @@ int main(int argc, char *argv[])
                 break;
 
             case S_CHARGING:
-                //if (waitPsuVolwithRealyVol(gunIndex) == NO) {
-                //    continue;
-                //}
+
                 GetEvBatteryInfo(gunIndex, pDcChargingInfo->Evboard_id); //DS60-120 add
                 // 計算 Power
                 pDcChargingInfo->PresentChargingPower =
@@ -1278,6 +1185,10 @@ int main(int argc, char *argv[])
                 setCurrentOutput();
                 SetPresentChargingOutputPower();
 
+                pDcChargingInfo->PresentChargingPower =
+                    ((float)((pDcChargingInfo->PresentChargingVoltage) *
+                             (pDcChargingInfo->PresentChargingCurrent)) / 1000);
+
                 // 槍鎖還在,則代表是樁端要求的停止
                 if (pDcChargingInfo->GunLocked == START ||
                         pDcChargingInfo->Type == _Type_CCS_2) {
@@ -1328,6 +1239,10 @@ int main(int argc, char *argv[])
 
                 CalOutputPowerAndEnergy(gunIndex);
 
+                pDcChargingInfo->PresentChargingPower =
+                    ((float)((pDcChargingInfo->PresentChargingVoltage) *
+                             (pDcChargingInfo->PresentChargingCurrent)) / 1000);
+
                 if (priorityLow == 1) {
                     // 樁端輸出能力
                     maxVol = pDcChargingInfo->MaximumChargingVoltage;

+ 0 - 1
EVSE/Projects/DD360/Apps/ModuleInternalComm/FanBoard.c

@@ -20,7 +20,6 @@ static struct SysInfoData *pSysInfo = NULL;
 static struct AlarmCodeData *pAlarmCode = NULL;
 static struct FanModuleData *ShmFanModuleData = NULL;
 static struct PsuData *ShmPsuData = NULL;
-static DcCommonInfo* ShmDcCommonData = NULL;
 
 static int Uart5Fd = 0;
 static struct timeval gFanBoardRunTimer;

+ 1 - 1
EVSE/Projects/DD360/Apps/ModuleInternalComm/LEDlight.c

@@ -202,7 +202,7 @@ static void SetLedColor(void)
     }
 
     if (_checkLedChanged > 0) {
-        if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color) == PASS) {
+        if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color,2) == PASS) {
             _checkLedChanged--;
 
             cur_led_color.Connect_1_Red     = led_color.Connect_1_Red;

+ 5 - 1
EVSE/Projects/DD360/Apps/ModuleInternalComm/Module_InternalComm.h

@@ -1,6 +1,6 @@
 #ifndef _MODULE_INTERNAL_COMM_H_
 #define _MODULE_INTERNAL_COMM_H_
-
+#include "../Config.h"
 //------------------------------------------------------------------------------
 #define RELAY_CHECK_TIME                        (5)       // s
 #define OUTPUT_VOL_CHK_TIME                     (200)     // ms
@@ -10,7 +10,11 @@
 #define ENV_TEMP_MIN                            (45)
 #define ENV_TEMP_MAX                            (50)
 #define DEFAULT_AC_INDEX                        (2)
+
+#define COLOR_MAX_LV_G3_5                       (10)
+
 #define COLOR_MAX_LV                            (100)
+
 #define COLOR_MIN_LV                            (0)
 
 #define AC_DEFAULT_VOL                          (220)

+ 172 - 288
EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c

@@ -13,7 +13,7 @@
 #include "../Log/log.h"
 #include "Module_InternalComm.h"
 #include "internalComm.h"
-
+#include "../common.h"
 //------------------------------------------------------------------------------
 static struct SysConfigData *pSysConfig = NULL;
 static struct SysInfoData *pSysInfo = NULL;
@@ -37,6 +37,7 @@ static Led_Color cur_led_color = {COLOR_MIN_LV};
 static Led_Color led_color;
 static struct timespec _led_priority_time;
 int ReservationLed;
+bool LcmLoseFlash;
 time_t ReservationFlashTimer;
 //static bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 //static struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
@@ -50,23 +51,6 @@ static struct timespec _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTI
 static void SetLedColor(void);
 static struct timespec _close_ac_contactor;
 
-void GetClockTime(struct timespec *_now_time, void *null)
-{
-    clock_gettime(CLOCK_MONOTONIC, _now_time);
-}
-
-// return value unit: 1us
-unsigned long GetClockTimeoutValue(struct timespec _start_time)
-{
-    struct timespec ts_end;
-    unsigned long ret = 0;
-
-    clock_gettime(CLOCK_MONOTONIC, &ts_end);
-
-    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000)));
-
-    return ret;
-}
 //------------------------------------------------------------------------------
 static void RunForceStopProcess(void)
 {
@@ -76,12 +60,12 @@ static void RunForceStopProcess(void)
 
     if (isCriticalStop == NO) {
         isCriticalStop = YES;
-        GetClockTime(&_psuCriticalStop, NULL);
+        GetClockTime(&_psuCriticalStop);
     } else {
         _timebuf = GetClockTimeoutValue(_psuCriticalStop);
 
         if (_timebuf < 0) {
-            GetClockTime(&_psuCriticalStop, NULL);
+            GetClockTime(&_psuCriticalStop);
         } else {
             if (_timebuf / 1000 >= (FORCE_STOP_TIME * 1000)) {
                 isCriticalStop = NO;
@@ -105,7 +89,7 @@ static void StartCheckRelayInfo(uint8_t _chkIndex, uint8_t toState)
     //uint8_t *pCheckRelayState = (uint8_t *)ShmDcCommonData->CheckRelayStatus[_chkIndex];
 
     if (ShmDcCommonData->CheckRelayStatus[_chkIndex] == STOP) {
-        GetClockTime(&lastCheckRelayStateTimer[_chkIndex], NULL);
+        GetClockTime(&lastCheckRelayStateTimer[_chkIndex]);
         ShmDcCommonData->CheckRelayStatus[_chkIndex] = START;
     } else {
         if ((GetClockTimeoutValue(lastCheckRelayStateTimer[_chkIndex]) / 1000000) >= 1) {
@@ -115,7 +99,7 @@ static void StartCheckRelayInfo(uint8_t _chkIndex, uint8_t toState)
             } else {
                 ShmDcCommonData->CheckRelayStatus[_chkIndex] = RELAY_STATUS_ERROR_WELDING;
             }
-            GetClockTime(&lastCheckRelayStateTimer[_chkIndex], NULL);
+            GetClockTime(&lastCheckRelayStateTimer[_chkIndex]);
         }
     }
 }
@@ -160,33 +144,14 @@ static bool IsNoneMatchRelayStatus(void)
     bool result = false;
 
     if (
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-        (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) ||
-        (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) ||
-#endif //!defined DD360 && !defined DD360Audi
         (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)
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-        ||
-        (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)
-#endif //!defined DD360 && !defined DD360Audi
     ) {
         result = true;
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-    if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
-        log_info("AC Contact Relay none match. ");
-    }
-
-    if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
-        log_info("CCS Precharge Relay none match. ");
-    }
-#endif //
-
     if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
         //log_info("SMR1:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
@@ -215,86 +180,9 @@ static bool IsNoneMatchRelayStatus(void)
         StopCheckRelayInfo(RELAY_SMR2_N_STATUS);
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-    if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
-        //log_info("Parallel:D+ Relay none match. ");
-        StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
-    } else {
-        StopCheckRelayInfo(RELAY_PARA_P_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
-        //log_info("Parallel:D- Relay none match. ");
-        StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
-    } else {
-        StopCheckRelayInfo(RELAY_PARA_N_STATUS);
-    }
-#endif //
-
     return result;
 }
 
-static void SetParalleRelayStatus(void)
-{
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
-    return;
-#endif //!defined  DD360 || !defined DD360Audi || !defined DD360ComBox
-
-    struct ChargingInfoData *pDcChargingInfo0 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
-    struct ChargingInfoData *pDcChargingInfo1 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
-
-    // 之後雙槍單模機種,橋接都會上
-    if (pSysConfig->TotalConnectorCount >= 2) {
-        if (pDcChargingInfo0->SystemStatus == S_BOOTING || pDcChargingInfo1->SystemStatus == S_BOOTING ||
-                (pDcChargingInfo0->SystemStatus == S_IDLE && pDcChargingInfo1->SystemStatus == S_IDLE)) {
-            // 初始化~ 不搭橋接
-            if (regRelay.relay_event.bits.Gun1_Parallel_P == YES) {
-                outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-            } else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES) {
-                outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-            }
-        } else {
-            if (pDcChargingInfo0->IsReadyToCharging == YES ||
-                    pDcChargingInfo1->IsReadyToCharging == YES) {
-                // ************需考慮在切換中 - 切開 relay 與搭回 relay 的時機點************
-                if (pSysInfo->MainChargingMode == _MAIN_CHARGING_MODE_MAX) {
-                    if (pSysInfo->ReAssignedFlag < _REASSIGNED_RELAY_M_TO_A) {
-                        // 最大充 - 搭上橋接
-                        if (regRelay.relay_event.bits.Gun1_Parallel_N == NO) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
-                        } else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_P = YES;
-                        }
-                    } else {
-                        // 平均充 - 不搭
-                        if (regRelay.relay_event.bits.Gun1_Parallel_P == YES) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-                        } else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-                        }
-                    }
-                } else if (pSysInfo->MainChargingMode == _MAIN_CHARGING_MODE_AVER) {
-                    if (pSysInfo->ReAssignedFlag < _REASSIGNED_RELAY_A_TO_M) {
-                        // 平均充 - 不搭
-                        if (regRelay.relay_event.bits.Gun1_Parallel_P == YES) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-                        } else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-                        }
-                    } else {
-                        // 最大充 - 搭上橋接
-                        if (regRelay.relay_event.bits.Gun1_Parallel_N == NO) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
-                        } else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO) {
-                            outputRelay.relay_event.bits.Gun1_Parallel_P = YES;
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
-
 static void GetGfdAdc(void)
 {
     int gunIndex = 0;
@@ -397,17 +285,15 @@ void CheckOutputPowerOverCarReq(uint8_t index)
         if (fireV >= (carV + (carV * 0.02))) {
             if (!_isOvpChkTimeFlag[index]) {
                 if ((pDcChargingInfo->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
-                    GetClockTime(&_checkOutputVolProtectTimer[index], NULL);
+                    GetClockTime(&_checkOutputVolProtectTimer[index]);
                     _isOvpChkTimeFlag[index] = YES;
                 }
             } else {
-                log_info("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f ",
+                log_error("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f, OVP = %f",
                          pDcChargingInfo->FireChargingVoltage,
-                         (pDcChargingInfo->EvBatterytargetVoltage * 10));
+                         (pDcChargingInfo->EvBatterytargetVoltage * 10),
+                         (carV + (carV * 0.02)));
 
-                log_error("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f ",
-                          pDcChargingInfo->FireChargingVoltage,
-                          (pDcChargingInfo->EvBatterytargetVoltage * 10));
                 if ((GetClockTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
                     if (pDcChargingInfo->Type == _Type_Chademo) {
                         //pAlarmCode->AlarmEvents.bits.SystemChademoOutputOVP = YES;
@@ -823,9 +709,7 @@ void CableCheckDetected(uint8_t index)
 void GetRelayOutputStatus(void)
 {
     if (Query_Relay_Output(Uart5Fd, ADDR_RELAY, &regRelay) == PASS) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-        regRelay.relay_event.bits.AC_Contactor = pSysInfo->AcContactorStatus;
-#endif //!defined DD360 && !defined DD360Audi
+
     }
 }
 
@@ -1055,15 +939,15 @@ void GetPersentOutputVol(void)
     if (Query_Present_OutputVoltage(Uart5Fd, ADDR_RELAY, &outputVoltage) != PASS) {
         return;
     }
+    /*
+    log_info("Conn1 fuse 1 = %f ", outputVoltage.behindFuse_Voltage_C1);
+    log_info("Conn1 relay 1 = %f ", outputVoltage.behindRelay_Voltage_C1);
+    log_info("Conn2 fuse 2 = %f ", outputVoltage.behindFuse_Voltage_C2);
+    log_info("Conn2 relay 2 = %f ", outputVoltage.behindRelay_Voltage_C2);
 
-    //log_info("Conn1 fuse 1 = %f ", outputVoltage.behindFuse_Voltage_C1);
-    //log_info("Conn1 relay 1 = %f ", outputVoltage.behindRelay_Voltage_C1);
-    //log_info("Conn2 fuse 2 = %f ", outputVoltage.behindFuse_Voltage_C2);
-    //log_info("Conn2 relay 2 = %f ", outputVoltage.behindRelay_Voltage_C2);
-
-    //log_info("outputVoltage.behindFuse_Voltage_C1 = %f ", outputVoltage.behindFuse_Voltage_C1);
-    //log_info("outputVoltage.behindFuse_Voltage_C2 = %f ", outputVoltage.behindFuse_Voltage_C2);
-
+    log_info("outputVoltage.behindFuse_Voltage_C1 = %f ", outputVoltage.behindFuse_Voltage_C1);
+    log_info("outputVoltage.behindFuse_Voltage_C2 = %f ", outputVoltage.behindFuse_Voltage_C2);
+    */
     ShmRelayModuleData->Gun1FuseOutputVolt = outputVoltage.behindFuse_Voltage_C1;
     ShmRelayModuleData->Gun1RelayOutputVolt = outputVoltage.behindRelay_Voltage_C1;
     ShmRelayModuleData->Gun2FuseOutputVolt = outputVoltage.behindFuse_Voltage_C2;
@@ -1075,30 +959,19 @@ void GetPersentOutputVol(void)
 
         switch (targetID) {
         case 0x01:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
             pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
             pDcChargingInfo->PresentChargingCurrent = ((float)ShmRelayModuleData->Gun1FuseOutputVolt) / 10;
             pDcChargingInfo->PresentChargingVoltage = ((float)pDcChargingInfo->FireChargingVoltage) / 10;
             pDcChargingInfo->FuseChargingVoltage = pDcChargingInfo->FireChargingVoltage;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
-
-            pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
-            pDcChargingInfo->FuseChargingVoltage = ShmRelayModuleData->Gun1FuseOutputVolt;
-            break;
 
         case 0x02:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
             pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
             pDcChargingInfo->PresentChargingCurrent = ((float)ShmRelayModuleData->Gun2FuseOutputVolt) / 10;
             pDcChargingInfo->PresentChargingVoltage = ((float)pDcChargingInfo->FireChargingVoltage) / 10;
             pDcChargingInfo->FuseChargingVoltage = pDcChargingInfo->FireChargingVoltage;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
 
-            pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
-            pDcChargingInfo->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
-            break;
         }
 
         //log_info("%d persent vol = %f, cur = %f",
@@ -1269,7 +1142,7 @@ static void GetFanSpeed(void)
 
 static void GetFanSpeedByFunction(void)
 {
-    if (ShmDcCommonData->debugflag== YES) {
+    if (ShmDcCommonData->pTest.fanflag== YES) {
         ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
         return;
     }
@@ -1448,7 +1321,7 @@ static void fanBoardSelfTest(void)
     SetModelName_Fan();
     SetRtcData_Fan();
     sleep(1);
-    GetClockTime(&gFanBoardRunTimer, NULL);
+    GetClockTime(&gFanBoardRunTimer);
 }
 
 static void fanBoardPorcess(void)
@@ -1467,7 +1340,7 @@ static void fanBoardPorcess(void)
             GetFanSpeedByFunction();
             GetFanSpeed();
             pSysInfo->SystemFanRotaSpeed = _setFanSpeed;
-            GetClockTime(&gFanBoardRunTimer, NULL);
+            GetClockTime(&gFanBoardRunTimer);
             /*
             ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
@@ -1526,7 +1399,10 @@ static void SetLedColor(void)
     struct ChargingInfoData *chargingData_1 = NULL;
     struct ChargingInfoData *chargingData_2 = NULL;
     uint8_t _colorBuf = COLOR_MAX_LV * LED_INTENSITY_BRIGHTEST;
-
+    if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        _colorBuf = COLOR_MAX_LV_G3_5 * LED_INTENSITY_BRIGHTEST;
+    }
+    
     if (pSysConfig->TotalConnectorCount == 1) {
         chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
         chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
@@ -1540,7 +1416,23 @@ static void SetLedColor(void)
     } else if (pSysConfig->LedInfo.Intensity == _LED_INTENSITY_MEDIUM) {
         _colorBuf = COLOR_MAX_LV * LED_INTENSITY_MEDIUM;
     }
-
+    if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        if (CheckCustomer() == _CUSTOM_AUDI) {
+            led_color.Connect_3_Green = 100;
+            led_color.Connect_3_Blue = 100;
+            led_color.Connect_3_Red = 100;
+            led_color.Connect_4_Green = 100;
+            led_color.Connect_4_Blue = 100;
+            led_color.Connect_4_Red = 100;
+        } else {
+            led_color.Connect_3_Green = 100;
+            led_color.Connect_3_Blue = 0;
+            led_color.Connect_3_Red = 0;
+            led_color.Connect_4_Green = 100;
+            led_color.Connect_4_Blue = 0;
+            led_color.Connect_4_Red = 0;
+        }
+    }
     //printf("chargingData_1->SystemStatus=%d\n",chargingData_1->SystemStatus);
     //printf("chargingData_2->SystemStatus=%d\n",chargingData_2->SystemStatus);
     //printf("pSysWarning->Level=%d\n",pSysWarning->Level);
@@ -1552,149 +1444,110 @@ static void SetLedColor(void)
         led_color.Connect_2_Blue = COLOR_MIN_LV;
         led_color.Connect_2_Red = _colorBuf;
     } else {
-        if (pSysInfo->IsAlternatvieConf) {
-            if ((chargingData_1->SystemStatus == S_BOOTING ||
-                    chargingData_1->SystemStatus == S_IDLE ) &&
-                    (chargingData_2->SystemStatus == S_BOOTING ||
-                     chargingData_2->SystemStatus == S_IDLE)) {
-#if defined DD360Audi
-                led_color.Connect_1_Green = _colorBuf;
-                led_color.Connect_1_Blue = _colorBuf;
-                led_color.Connect_1_Red = _colorBuf;
-
-                led_color.Connect_2_Green = _colorBuf;
-                led_color.Connect_2_Blue = _colorBuf;
-                led_color.Connect_2_Red = _colorBuf;
-#else
-                led_color.Connect_1_Green = _colorBuf;
-                led_color.Connect_1_Blue = COLOR_MIN_LV;
-                led_color.Connect_1_Red = COLOR_MIN_LV;
+        //實際操作
+        if (chargingData_1->SystemStatus == S_BOOTING ||
+                chargingData_1->SystemStatus == S_IDLE) {
 
-                led_color.Connect_2_Green = _colorBuf;
-                led_color.Connect_2_Blue = COLOR_MIN_LV;
-                led_color.Connect_2_Red = COLOR_MIN_LV;
-#endif
-            } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_1->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
-                       (chargingData_2->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_2->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
-                led_color.Connect_1_Green = COLOR_MIN_LV;
-                led_color.Connect_1_Blue = _colorBuf;
-                led_color.Connect_1_Red = COLOR_MIN_LV;
-                led_color.Connect_2_Green = COLOR_MIN_LV;
-                led_color.Connect_2_Blue = _colorBuf;
-                led_color.Connect_2_Red = COLOR_MIN_LV;
-            } else if ( chargingData_1->SystemStatus == S_UPDATE ||
-                        chargingData_1->SystemStatus == S_FAULT ||
-                        chargingData_1->SystemStatus == S_MAINTAIN) {
+            if (chargingData_1->IsAvailable == NO) { //For Audi
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = COLOR_MIN_LV;
                 led_color.Connect_1_Red = _colorBuf;
-            } else if (chargingData_1->SystemStatus == S_RESERVATION ||
-                chargingData_2->SystemStatus == S_RESERVATION) {
-                if (ReservationLed) {
-                    led_color.Connect_1_Green = COLOR_MIN_LV;
-                    led_color.Connect_2_Green = COLOR_MIN_LV;
-                } else {
-                    led_color.Connect_1_Green = _colorBuf;
-                    led_color.Connect_2_Green = _colorBuf;
-                }
+            } else {
+                led_color.Connect_1_Green = _colorBuf;
                 led_color.Connect_1_Blue = COLOR_MIN_LV;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
-
-                led_color.Connect_2_Blue = COLOR_MIN_LV;
-                led_color.Connect_2_Red = COLOR_MIN_LV;
-            }
-        } else {
-            //實際操作
-            if (chargingData_1->SystemStatus == S_BOOTING ||
-                    chargingData_1->SystemStatus == S_IDLE) {
-
-                if (chargingData_1->IsAvailable == NO) { //For Audi
-                    led_color.Connect_1_Green = COLOR_MIN_LV;
-                    led_color.Connect_1_Blue = COLOR_MIN_LV;
-                    led_color.Connect_1_Red = _colorBuf;
-                } else {
-#if defined DD360Audi
+                if (CheckCustomer() == _CUSTOM_AUDI) {
                     led_color.Connect_1_Green = _colorBuf;
                     led_color.Connect_1_Blue = _colorBuf;
                     led_color.Connect_1_Red = _colorBuf;
-#else
-                    led_color.Connect_1_Green = _colorBuf;
-                    led_color.Connect_1_Blue = COLOR_MIN_LV;
-                    led_color.Connect_1_Red = COLOR_MIN_LV;
-#endif
                 }
-            } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_1->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
-                led_color.Connect_1_Green = COLOR_MIN_LV;
-                led_color.Connect_1_Blue = _colorBuf;
-                led_color.Connect_1_Red = COLOR_MIN_LV;
-            }else if ( chargingData_1->SystemStatus == S_UPDATE ||
-                chargingData_1->SystemStatus == S_FAULT ||
-                    chargingData_1->SystemStatus == S_MAINTAIN) {
+            }
+        } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING &&
+                    chargingData_1->SystemStatus <= S_COMPLETE) ||
+                (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+                    chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            led_color.Connect_1_Green = COLOR_MIN_LV;
+            led_color.Connect_1_Blue = _colorBuf;
+            led_color.Connect_1_Red = COLOR_MIN_LV;
+        }else if ( chargingData_1->SystemStatus == S_UPDATE ||
+            chargingData_1->SystemStatus == S_FAULT ||
+                chargingData_1->SystemStatus == S_MAINTAIN) {
+            led_color.Connect_1_Green = COLOR_MIN_LV;
+            led_color.Connect_1_Blue = COLOR_MIN_LV;
+            led_color.Connect_1_Red = _colorBuf;
+        } else if (chargingData_1->SystemStatus == S_RESERVATION) {
+            if (ReservationLed) {
                 led_color.Connect_1_Green = COLOR_MIN_LV;
-                led_color.Connect_1_Blue = COLOR_MIN_LV;
-                led_color.Connect_1_Red = _colorBuf;
-            } else if (chargingData_1->SystemStatus == S_RESERVATION) {
-                if (ReservationLed) {
-                    led_color.Connect_1_Green = COLOR_MIN_LV;
-                } else {
-                    led_color.Connect_1_Green = _colorBuf;
-                }
-                led_color.Connect_1_Blue = COLOR_MIN_LV;
-                led_color.Connect_1_Red = COLOR_MIN_LV;
+            } else {
+                led_color.Connect_1_Green = _colorBuf;
             }
+            led_color.Connect_1_Blue = COLOR_MIN_LV;
+            led_color.Connect_1_Red = COLOR_MIN_LV;
+        }
 
-            // --------------------------------------------------------------------------
-            if (chargingData_2->SystemStatus == S_BOOTING ||
-                    chargingData_2->SystemStatus == S_IDLE) {
-                if (chargingData_2->IsAvailable == NO) {
-                    led_color.Connect_2_Green = COLOR_MIN_LV;
-                    led_color.Connect_2_Blue = COLOR_MIN_LV;
-                    led_color.Connect_2_Red = _colorBuf;
-                } else {
-#if defined DD360Audi
-                    led_color.Connect_2_Green = _colorBuf;
-                    led_color.Connect_2_Blue = _colorBuf;
-                    led_color.Connect_2_Red = _colorBuf;
-#else
-                    led_color.Connect_2_Green = _colorBuf;
-                    led_color.Connect_2_Blue = COLOR_MIN_LV;
-                    led_color.Connect_2_Red = COLOR_MIN_LV;
-#endif
-                }
-            } else if ((chargingData_2->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_2->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
-                led_color.Connect_2_Green = COLOR_MIN_LV;
-                led_color.Connect_2_Blue = _colorBuf;
-                led_color.Connect_2_Red = COLOR_MIN_LV;
-            }else if ( chargingData_2->SystemStatus == S_UPDATE ||
-                    chargingData_2->SystemStatus == S_FAULT ||
-                    chargingData_2->SystemStatus == S_MAINTAIN) {
+        // --------------------------------------------------------------------------
+        if (chargingData_2->SystemStatus == S_BOOTING ||
+                chargingData_2->SystemStatus == S_IDLE) {
+            if (chargingData_2->IsAvailable == NO) {
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = COLOR_MIN_LV;
                 led_color.Connect_2_Red = _colorBuf;
-            } else if (chargingData_2->SystemStatus == S_RESERVATION) {
-                if (ReservationLed) {
-                    led_color.Connect_2_Green = COLOR_MIN_LV;
-                } else {
-                    led_color.Connect_2_Green = _colorBuf;
-                }
+            } else {
+
+                led_color.Connect_2_Green = _colorBuf;
                 led_color.Connect_2_Blue = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+                if (CheckCustomer() == _CUSTOM_AUDI) {
+                    led_color.Connect_2_Green = _colorBuf;
+                    led_color.Connect_2_Blue = _colorBuf;
+                    led_color.Connect_2_Red = _colorBuf;
+                }
             }
+        } else if ((chargingData_2->SystemStatus >= S_AUTHORIZING &&
+                    chargingData_2->SystemStatus <= S_COMPLETE) ||
+                (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+                    chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            led_color.Connect_2_Green = COLOR_MIN_LV;
+            led_color.Connect_2_Blue = _colorBuf;
+            led_color.Connect_2_Red = COLOR_MIN_LV;
+        }else if ( chargingData_2->SystemStatus == S_UPDATE ||
+                chargingData_2->SystemStatus == S_FAULT ||
+                chargingData_2->SystemStatus == S_MAINTAIN) {
+            led_color.Connect_2_Green = COLOR_MIN_LV;
+            led_color.Connect_2_Blue = COLOR_MIN_LV;
+            led_color.Connect_2_Red = _colorBuf;
+        } else if (chargingData_2->SystemStatus == S_RESERVATION) {
+            if (ReservationLed) {
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+            } else {
+                led_color.Connect_2_Green = _colorBuf;
+            }
+            led_color.Connect_2_Blue = COLOR_MIN_LV;
+            led_color.Connect_2_Red = COLOR_MIN_LV;
+        }
 
+    }
+
+    
+    if (pAlarmCode->AlarmEvents.bits.LcmModuleCommFail && CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        if (LcmLoseFlash) {
+            led_color.Connect_3_Red = COLOR_MIN_LV;
+            led_color.Connect_3_Green = COLOR_MIN_LV;
+            led_color.Connect_3_Blue = 100;
+            led_color.Connect_4_Red = COLOR_MIN_LV;
+            led_color.Connect_4_Green = COLOR_MIN_LV;
+            led_color.Connect_4_Blue = COLOR_MIN_LV;
+        } else {
+            led_color.Connect_3_Red = COLOR_MIN_LV;
+            led_color.Connect_3_Green = COLOR_MIN_LV;
+            led_color.Connect_3_Blue = COLOR_MIN_LV;
+            led_color.Connect_4_Red = COLOR_MIN_LV;
+            led_color.Connect_4_Green = COLOR_MIN_LV;
+            led_color.Connect_4_Blue = 100;
         }
+        _checkLedChanged = 3;
     }
+    
     if (ShmDcCommonData->pTest.ledflag) {
         led_color.Connect_1_Red = pSysConfig->LedInfo.Red[0];
         led_color.Connect_1_Green = pSysConfig->LedInfo.Green[0];
@@ -1702,17 +1555,46 @@ static void SetLedColor(void)
         led_color.Connect_2_Red = pSysConfig->LedInfo.Red[0];
         led_color.Connect_2_Green = pSysConfig->LedInfo.Green[0];
         led_color.Connect_2_Blue = pSysConfig->LedInfo.Blue[0];
+        if (strcmp((char*)pSysInfo->LedModuleFwRev,"D0.03.L0") != EQUAL) {
+            led_color.Connect_3_Red = pSysConfig->LedInfo.Red[0];
+            led_color.Connect_3_Green = pSysConfig->LedInfo.Green[0];
+            led_color.Connect_3_Blue = pSysConfig->LedInfo.Blue[0];
+            led_color.Connect_4_Red = pSysConfig->LedInfo.Red[0];
+            led_color.Connect_4_Green = pSysConfig->LedInfo.Green[0];
+            led_color.Connect_4_Blue = pSysConfig->LedInfo.Blue[0];
+        }
     }
+
     if (_checkLedChanged > 0) {
-        if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color) == PASS) {
+        int ledNum = 2;
+        if (strcmp((char*)pSysInfo->LedModuleFwRev,"D0.03.L0") == EQUAL) {
+            ledNum = 2;
+        } else {
+            ledNum = 4;
+        }
+        if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color,ledNum) == PASS) {
             _checkLedChanged--;
-
-            cur_led_color.Connect_1_Red     = led_color.Connect_1_Red;
-            cur_led_color.Connect_1_Green   = led_color.Connect_1_Green;
-            cur_led_color.Connect_1_Blue    = led_color.Connect_1_Blue;
-            cur_led_color.Connect_2_Red     = led_color.Connect_2_Red;
-            cur_led_color.Connect_2_Green   = led_color.Connect_2_Green;
-            cur_led_color.Connect_2_Blue    = led_color.Connect_2_Blue;
+            if (ledNum == 2) {
+                cur_led_color.Connect_1_Red     = led_color.Connect_1_Red;
+                cur_led_color.Connect_1_Green   = led_color.Connect_1_Green;
+                cur_led_color.Connect_1_Blue    = led_color.Connect_1_Blue;
+                cur_led_color.Connect_2_Red     = led_color.Connect_2_Red;
+                cur_led_color.Connect_2_Green   = led_color.Connect_2_Green;
+                cur_led_color.Connect_2_Blue    = led_color.Connect_2_Blue;
+            } else {
+                cur_led_color.Connect_1_Red     = led_color.Connect_1_Red;
+                cur_led_color.Connect_1_Green   = led_color.Connect_1_Green;
+                cur_led_color.Connect_1_Blue    = led_color.Connect_1_Blue;
+                cur_led_color.Connect_2_Red     = led_color.Connect_2_Red;
+                cur_led_color.Connect_2_Green   = led_color.Connect_2_Green;
+                cur_led_color.Connect_2_Blue    = led_color.Connect_2_Blue;
+                cur_led_color.Connect_3_Red     = led_color.Connect_3_Red;
+                cur_led_color.Connect_3_Green   = led_color.Connect_3_Green;
+                cur_led_color.Connect_3_Blue    = led_color.Connect_3_Blue;
+                cur_led_color.Connect_4_Red     = led_color.Connect_4_Red;
+                cur_led_color.Connect_4_Green   = led_color.Connect_4_Green;
+                cur_led_color.Connect_4_Blue    = led_color.Connect_4_Blue;
+                }
         }
     } else if (IsNoneMatchLedColor()) {
         _checkLedChanged = 3;
@@ -1729,7 +1611,7 @@ static void LEDBoardSelfTest(void)
 #if defined DD360 ||defined DD360Audi
     GetFwAndHwVersion_Led();
     sleep(1);
-    GetClockTime(&_led_priority_time, NULL);
+    GetClockTime(&_led_priority_time);
 
     return;
 #endif //defined DD360 || defined DD360Audi
@@ -1738,7 +1620,7 @@ static void LEDBoardSelfTest(void)
     if (pSysInfo->SelfTestSeq <= _STEST_PSU_CAP) {
         GetFwAndHwVersion_Led();
         sleep(1);
-        GetClockTime(&_led_priority_time, NULL);
+        GetClockTime(&_led_priority_time);
     } else {
         // 自檢階段沒有問到版號
         if (pAlarmCode->AlarmEvents.bits.LedboardStestFail == NO) {
@@ -1764,9 +1646,10 @@ static void LEDBoardProcess(void)
             else
                 ReservationLed = 1;
         }
+        LcmLoseFlash ? (LcmLoseFlash = 0) : (LcmLoseFlash = 1);
 
         SetLedColor();
-        GetClockTime(&_led_priority_time, NULL);
+        GetClockTime(&_led_priority_time);
     }
 }
 
@@ -1916,9 +1799,6 @@ void RelayBoardTask(int uartFD)
                     }
                 }
 
-                    // 橋接 relay
-                    SetParalleRelayStatus();
-
                     // 搭上 AC Contactor
                     //if (isCharging) {
                     //    outputRelay.relay_event.bits.AC_Contactor = YES;
@@ -1933,7 +1813,7 @@ void RelayBoardTask(int uartFD)
                         outputRelay.relay_event.bits.AC_Contactor = YES;
                     } else {
                         if (!isStopChargingCount) {
-                            GetClockTime(&_close_ac_contactor, NULL);
+                            GetClockTime(&_close_ac_contactor);
                             isStopChargingCount = true;
                         } else {
                             if ((outputRelay.relay_event.bits.AC_Contactor == YES &&
@@ -1955,7 +1835,11 @@ void RelayBoardTask(int uartFD)
                     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 (ShmDcCommonData->pTest.relayflag) {
+                        outputRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_P = ShmDcCommonData->pGunInfo[0].RelayTest;
+                        if (pSysConfig->TotalConnectorCount > 1)
+                            outputRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_P = ShmDcCommonData->pGunInfo[1].RelayTest;
+                    }
                     // 搭上/鬆開 Relay
                     if (IsNoneMatchRelayStatus()) {
                         if (Config_Relay_Output(Uart5Fd, ADDR_RELAY, &outputRelay)) {

+ 18 - 22
EVSE/Projects/DD360/Apps/ModuleInternalComm/internalComm.c

@@ -992,37 +992,33 @@ int Config_CSU_Mode(uint8_t fd, uint8_t targetAddr)
     return result;
 }
 
-int Config_Led_Color(uint8_t fd, uint8_t targetAddr, Led_Color *Ret_Buf)
+int Config_Led_Color(uint8_t fd, uint8_t targetAddr, Led_Color *Ret_Buf, uint8_t ledNum)
 {
     int result = FAIL;
-    uint8_t tx[13] = {0xaa,
-                      0x00,
-                      targetAddr,
-                      CMD_CONFIG_LEN_COLOR,
-                      0x06,
-                      0x00,
-                      Ret_Buf->Connect_1_Red,
-                      Ret_Buf->Connect_1_Green,
-                      Ret_Buf->Connect_1_Blue,
-                      Ret_Buf->Connect_2_Red,
-                      Ret_Buf->Connect_2_Green,
-                      Ret_Buf->Connect_2_Blue
-                     };
+    int tx_size = 0;
+    int pack_size = 7;
+    tx_size = pack_size + ledNum * 3;
+    uint8_t tx[19];
+    tx[0] = 0xaa;
+    tx[1] = 0x00;
+    tx[2] = targetAddr;
+    tx[3] = CMD_CONFIG_LEN_COLOR;
+    tx[4] = ledNum * 3;
+    tx[5] = 0x00;
+
+    for(int i = 0 ; i < ledNum*3 ; i++) {
+        tx[6+i] = *(&(Ret_Buf->Connect_1_Red)+i);
+    }
+
     uint8_t rx[512];
     uint8_t chksum = 0x00;
 
     for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++) {
         chksum ^= tx[6 + idx];
     }
-    tx[12] = chksum;
-
-//  for(int i = 0; i < 13; i++)
-//          printf ("tx = %x \n", tx[i]);
+    tx[tx_size-1] = chksum;
 
-    uint8_t len = tranceive(fd, tx, sizeof(tx), rx);
-
-//  for(int i = 0; i < len; i++)
-//      printf ("rx = %x \n", rx[i]);
+    uint8_t len = tranceive(fd, tx, tx_size, rx);
 
     if (len > 6) {
         if (len < 6 + (rx[4] | rx[5] << 8)) {

+ 7 - 1
EVSE/Projects/DD360/Apps/ModuleInternalComm/internalComm.h

@@ -179,6 +179,12 @@ typedef struct LED_Color {
     uint8_t Connect_2_Red;
     uint8_t Connect_2_Green;
     uint8_t Connect_2_Blue;
+    uint8_t Connect_3_Red;
+    uint8_t Connect_3_Green;
+    uint8_t Connect_3_Blue;
+    uint8_t Connect_4_Red;
+    uint8_t Connect_4_Green;
+    uint8_t Connect_4_Blue;
 } Led_Color;
 
 typedef struct AC_Status {
@@ -242,7 +248,7 @@ int Config_Legacy_Req(uint8_t fd, uint8_t targetAddr, uint8_t _switch);
 int Config_Ac_Duty(uint8_t fd, uint8_t targetAddr, uint8_t _value);
 int Config_CSU_Mode(uint8_t fd, uint8_t targetAddr);
 int Config_Reset_MCU(uint8_t fd, uint8_t targetAddr);
-int Config_Led_Color(uint8_t fd, uint8_t targetAddr, Led_Color *Ret_Buf);
+int Config_Led_Color(uint8_t fd, uint8_t targetAddr, Led_Color *Ret_Buf, uint8_t ledNum);
 
 int Update_Start(uint8_t fd, uint8_t targetAddr, uint32_t crc32);
 int Update_Abord(uint8_t fd, uint8_t targetAddr);

+ 211 - 397
EVSE/Projects/DD360/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -17,6 +17,7 @@
 #include "../Config.h"
 #include "../SelectGun/SelectGun.h"
 #include "../CSU/main.h"
+#include "../common.h"
 //------------------------------------------------------------------------------
 //struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 //struct StatusCodeData           *ShmStatusCodeData;
@@ -447,154 +448,109 @@ void ChangeWarningFunc()
 //================================================
 void ChangeQrCode_Idle(char *input)
 {
-#if defined DD360Audi
-    int len = strlen(input) + 3;
-    int loop = 0;
-    int i = 0, j = 0, k = 0, l = 0;
-    uint8_t qrUrl[128] = {0};
-    uint16_t urlLen = 0;
-    uint8_t cmd[len];
-    uint8_t tmpBuf[15] = {0};
-    //uint8_t tmpLen = sizeof(tmpBuf) - 1;
-
-    strncpy((char *)cmd, " ", len);
-
-    while (input[loop] != '\0') {
-        cmd[i++] = input[loop++];
-        l = loop - 1;
-        if (len >= 25) {
-            if (i >= 16 && i <= 19) {
-                tmpBuf[k++] = input[l];
-                //printf("tmpBuf = %s", tmpBuf);
-            } else if (i >= 21 && i <= 23) {
-                tmpBuf[k++] = input[l];
+    if (CheckCustomer() == _CUSTOM_AUDI) {
+        int len = strlen(input) + 3;
+        int loop = 0;
+        int i = 0, j = 0, k = 0, l = 0;
+        uint8_t qrUrl[128] = {0};
+        uint16_t urlLen = 0;
+        uint8_t cmd[len];
+        uint8_t tmpBuf[15] = {0};
+
+        strncpy((char *)cmd, " ", len);
+
+        while (input[loop] != '\0') {
+            cmd[i++] = input[loop++];
+            l = loop - 1;
+            if (len >= 25) {
+                if (i >= 16 && i <= 19) {
+                    tmpBuf[k++] = input[l];
+                } else if (i >= 21 && i <= 23) {
+                    tmpBuf[k++] = input[l];
+                }
             }
         }
-    }
-    tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s", tmpBuf);
-    j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
-    cmd[len - 1] = '\0';
-    urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
-    qrUrl[urlLen] = '\0';
-    //printf("qr url = %s", qrUrl);
-    DisplayValueToLcm(__qr_code, qrUrl, urlLen);
-
-    j = 0;
-    j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
-    tmpBuf[k + j] = '\0';
-
-    //if (len < 25) {
-    //    strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
-    //}
-    //tmpBuf[tmpLen] = '\0';
-    DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
+        tmpBuf[k] = '\0';
+        j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
+        cmd[len - 1] = '\0';
+        urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
+        qrUrl[urlLen] = '\0';
+        DisplayValueToLcm(__qr_code, qrUrl, urlLen);
+
+        j = 0;
+        j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
+        tmpBuf[k + j] = '\0';
 
-    /*if (len > sizeof(tmpBuf)) {
-        strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
         DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
 
-        memset(tmpBuf, 0, sizeof(tmpBuf));
-        strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
     } else {
-        DisplayValueToLcm(__custStationIdL1, cmd, len);
-
-        strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
-    }*/
-
-#else
-    int len = strlen(input);
-    uint8_t cmd[len];
-
-    int loop = 0;
-    int i = 0;
-
-    while (input[loop] != '\0') {
-        cmd[i++] = input[loop++];
+        uint8_t cmd[200];
+        memset(cmd,0,200);
+        int len = sprintf((char*)cmd,input);
+        if (len > 200) {
+            log_info("QR Code URL length too long");
+        }
+        DisplayValueToLcm(__qr_code, cmd, 200);
     }
-
-    DisplayValueToLcm(__qr_code, cmd, len + 1);
-#endif //defined DD360Audi
 }
 
 void ChangeQrCode_Charge(char *input)
 {
-#if defined DD360Audi
-    int len = strlen(input) + 3;
-    int loop = 0;
-    int i = 0, j = 0, k = 0, l = 0;
-    uint8_t qrUrl[128] = {0};
-    uint16_t urlLen = 0;
-    uint8_t cmd[len];
-    uint8_t tmpBuf[15] = {0};
-    //uint8_t tmpLen = sizeof(tmpBuf) - 1;
-
-    strncpy((char *)cmd, " ", len);
-
-    while (input[loop] != '\0') {
-        cmd[i++] = input[loop++];
-        l = loop - 1;
-        if (len >= 25) {
-            if (i >= 16 && i <= 19) {
-                tmpBuf[k++] = input[l];
-                //printf("tmpBuf = %s", tmpBuf);
-            } else if (i >= 21 && i <= 23) {
-                tmpBuf[k++] = input[l];
+    if (CheckCustomer() == _CUSTOM_AUDI) {
+        int len = strlen(input) + 3;
+        int loop = 0;
+        int i = 0, j = 0, k = 0, l = 0;
+        uint8_t qrUrl[128] = {0};
+        uint16_t urlLen = 0;
+        uint8_t cmd[len];
+        uint8_t tmpBuf[15] = {0};
+        //uint8_t tmpLen = sizeof(tmpBuf) - 1;
+
+        strncpy((char *)cmd, " ", len);
+
+        while (input[loop] != '\0') {
+            cmd[i++] = input[loop++];
+            l = loop - 1;
+            if (len >= 25) {
+                if (i >= 16 && i <= 19) {
+                    tmpBuf[k++] = input[l];
+                    //printf("tmpBuf = %s", tmpBuf);
+                } else if (i >= 21 && i <= 23) {
+                    tmpBuf[k++] = input[l];
+                }
             }
         }
-    }
-    tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s", tmpBuf);
-    j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
-    cmd[len - 1] = '\0';
-    urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
-    qrUrl[urlLen] = '\0';
-    DisplayValueToLcm(__qr_code, qrUrl, urlLen);
-
-    j = 0;
-    j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
-    tmpBuf[k + j] = '\0';
-
-    if (len < 25) {
-        strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
-    }
-    //tmpBuf[tmpLen] = '\0';
-    DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
-    /*if (len > sizeof(tmpBuf)) {
-        strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
+        tmpBuf[k] = '\0';
+        //printf("tmpBuf = %s", tmpBuf);
+        j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
+        cmd[len - 1] = '\0';
+        urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
+        qrUrl[urlLen] = '\0';
+        DisplayValueToLcm(__qr_code, qrUrl, urlLen);
+
+        j = 0;
+        j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
+        tmpBuf[k + j] = '\0';
+
+        if (len < 25) {
+            strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
+        }
+        //tmpBuf[tmpLen] = '\0';
         DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
-
-        memset(tmpBuf, 0, sizeof(tmpBuf));
-        strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
+    
     } else {
-        DisplayValueToLcm(__custStationIdL1, cmd, len);
+        int len = strlen(input);
+        uint8_t cmd[len];
 
-        strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
-    }*/
+        int loop = 0;
+        int i = 0;
 
-#else
-    int len = strlen(input);
-    uint8_t cmd[len];
-
-    int loop = 0;
-    int i = 0;
+        while (input[loop] != '\0') {
+            cmd[i++] = input[loop++];
+        }
 
-    while (input[loop] != '\0') {
-        cmd[i++] = input[loop++];
+        DisplayValueToLcm(__qr_code_pre, cmd, len + 1);
     }
-
-    DisplayValueToLcm(__qr_code_pre, cmd, len + 1);
-#endif //defined DD360Audi
 }
 
 //================================================
@@ -1055,9 +1011,9 @@ void DisplayMoneyCur(uint8_t *cur)
 }
 void DisplayReceipt(char* pString)
 {
-    char data[200];
+    uint8_t data[200];
     memset(data, '\0', sizeof(data));
-    strcpy(data, pString);
+    strcpy((char*)data, pString);
     DisplayValueToLcm(__Receipt_value, data, 200);
 }
 
@@ -1108,7 +1064,6 @@ void RefreshPageAnimation(uint8_t value)
 void RefreshConnStatus()
 {
     // Wifi priority is higher than Ethernet
-#if defined DD360 ||defined DD360Audi || defined DD360ComBox
     uint8_t i = 0;
     uint8_t ethstatus = 0;
 
@@ -1175,172 +1130,6 @@ void RefreshConnStatus()
         }
     }
 
-    //uint8_t flag[4] = {0};
-
-    /*for (i = 0; i < pSysWarning->WarningCount; i++) {
-        //printf("status code = %s", &pSysWarning->WarningCode[i][0]);
-        if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
-            flag[0] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043625", 6) == 0) {
-            //disconnected from AP through WiFi
-            flag[1] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043627", 6) == 0) { //wifi disabled
-            flag[1] = 2;
-            continue;
-        }
-
-        if ((memcmp(&pSysWarning->WarningCode[i][0], "033900", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i][0], "033901", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i][0], "033902", 6) == 0)) {
-            flag[2] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043626", 6) == 0) {
-            //disconnected from APN through 3G/4G
-            flag[3] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043628", 6) == 0) { //4g disabled
-            flag[3] = 2;
-            continue;
-        }
-    }
-
-
-    if (flag[0] == 1) {
-        ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
-    } else {
-        ChangeDisplay2Value(__ethernet_status, _eth_connect);
-    }
-
-    //ChangeDisplay2Value(__wifi_status, _disappear);
-    //ChangeDisplay2Value(__conn_status, _disappear);
-    //ChangeDisplay2Value(__3G4G_status, _disappear);
-
-    if (flag[1] == 1) {
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
-    } else if (flag[1] == 2) {
-        ChangeDisplay2Value(__wifi_status, _disappear);
-    } else {
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        ChangeDisplay2Value(__wifi_status, _wifi_connect);
-    }
-
-    if (flag[2] == 1) {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    } else {
-        ChangeDisplay2Value(__conn_status, _connect);
-    }
-
-    if (flag[1] == 2) {
-        ChangeDisplay2Value(__3G4G_status, _disappear);
-        if (flag[3] == 1) {
-            ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
-        } else if (flag[3] == 2) {
-            ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        } else {
-            ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
-        }
-    } else {
-        if (flag[3] == 1) {
-            ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
-        } else if (flag[3] == 2) {
-            ChangeDisplay2Value(__3G4G_status, _disappear);
-        } else {
-            ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
-        }
-    }
-    */
-#else
-// eth
-    if (pSysInfo->ethInternetConn == YES) {
-        ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
-    } else {
-        ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
-    }
-
-    // Wifi
-    if ((pSysConfig->ModelName[10] == 'W' ||
-            pSysConfig->ModelName[10] == 'D') &&
-            pSysConfig->AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE) {
-        if (pSysConfig->AthInterface.WifiNetworkConn == YES ||
-                pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
-            ChangeDisplay2Value(__wifi_status, _wifi_connect);
-        } else {
-            ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
-        }
-    } else {
-        ChangeDisplay2Value(__wifi_status, _disappear);
-    }
-
-    if ((pSysConfig->ModelName[10] == 'T' ||
-            pSysConfig->ModelName[10] == 'D') &&
-            pSysConfig->TelecomInterface.TelcomEnabled != NO) {
-        if (pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_DISABLE) {
-            ChangeDisplay2Value(__3G4G_status, _disappear);
-            // 3G/4G
-            if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES)
-            { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
-            else
-            { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
-        } else {
-            ChangeDisplay2Value(__3G4G_move_status, _disappear);
-            // 3G/4G
-            if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES)
-            { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
-
-            else
-            { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
-        }
-    } else {
-        ChangeDisplay2Value(__3G4G_status, _disappear);
-
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-    }
-
-    // 連線到後台
-    if (pSysInfo->OcppConnStatus == YES) {
-        ChangeDisplay2Value(__conn_status, _connect);
-    } else {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    }
-
-    /*if (pSysConfig->AthInterface.WifiNetworkConn == YES ||
-            pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
-        _wifi_conn_status = true;
-        ChangeDisplay2Value(__wifi_status, _wifi_connect);
-        ChangeDisplay2Value(__ethernet_status, _disappear);
-    } else {
-        _wifi_conn_status = false;
-        ChangeDisplay2Value(__wifi_status, _disappear);
-    }
-
-    if (!_wifi_conn_status) {
-        if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES ||
-                pSysInfo->InternetConn == YES) {
-            ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
-        } else {
-            ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
-        }
-    }
-
-    // 連線到後台
-    if (pSysInfo->OcppConnStatus == YES) {
-        ChangeDisplay2Value(__conn_status, _connect);
-    } else {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    }
-    */
-#endif //defined DD360 || defined DD360Audi
 }
 
 uint8_t FirstPageChanged()
@@ -1708,34 +1497,38 @@ void ShowDateTime()
 {
     struct timeb SeqEndTime;
     struct tm* tm;
-    char _date[20];
-    char _time[20];
-    char _am_pm[10];
+    uint8_t _date[20];
+    uint8_t _time[20];
+    uint8_t _am_pm[10];
+    time_t showtime;
 
     ftime(&SeqEndTime);
     SeqEndTime.time = time(NULL);
     
     tm = localtime(&SeqEndTime.time);
 
-    sprintf(_date, "%04d/%02d/%02d",
+	showtime = mktime(tm) +(ShmDcCommonData->TZOffset * 60);
+	tm = gmtime(&showtime);
+
+    sprintf((char*)_date, "%04d/%02d/%02d",
         tm->tm_year + 1900,
         tm->tm_mon + 1,
         tm->tm_mday);
 
     if (tm->tm_hour >= 12) {
-        sprintf(_am_pm,"p.m.");
-        sprintf(_time, "%02d:%02d",
+        sprintf((char*)_am_pm,"p.m.");
+        sprintf((char*)_time, "%02d:%02d",
             tm->tm_hour-12,
             tm->tm_min);
     } else {
-        sprintf(_am_pm, "a.m.");
-        sprintf(_time, "%02d:%02d",
+        sprintf((char*)_am_pm, "a.m.");
+        sprintf((char*)_time, "%02d:%02d",
             tm->tm_hour,
             tm->tm_min);
     }
-    DisplayValueToLcm(__date_map, _date, strlen(_date)+1);
-    DisplayValueToLcm(__time_map, _time, strlen(_time)+1);
-    DisplayValueToLcm(__time_am_pm, _am_pm, strlen(_am_pm)+1);
+    DisplayValueToLcm(__date_map, _date, strlen((char*)_date)+1);
+    DisplayValueToLcm(__time_map, _time, strlen((char*)_time)+1);
+    DisplayValueToLcm(__time_am_pm, _am_pm, strlen((char*)_am_pm)+1);
 }
 uint8_t old_string[255];
 void ShowAnimationPrice(char* pString)
@@ -1743,20 +1536,63 @@ void ShowAnimationPrice(char* pString)
     uint8_t cmd[230];
     memset(cmd, 0x00, sizeof(cmd));
     string2ByteArray((uint8_t*)pString,cmd);
-    int len = strlen(pString);
+    
 
     if (strcmp((char*)old_string, pString) != EQUAL) {
         strcpy((char*)old_string, pString);
         DisplayFeeValueToLcm(__Animation_Price, cmd, sizeof(cmd));
     }
 }
+
+void ChangeDisplayMoneyInfo()
+{
+    if (pSysConfig->BillingData.isBilling) {
+        struct timeb csuTime;
+        struct tm *tmCSU;
+        char price[30];
+        ftime(&csuTime);
+        tmCSU = localtime(&csuTime.time);
+
+        ChangeDisplay2Value(__money_rate_map, _charging_money);
+#if defined DD360Audi
+        uint8_t curGun = pSysInfo->CurGunSelected;
+        if (ShmSelectGunInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
+            DisplayMoneyRate(ShmSelectGunInfo->PricesInfo[curGun].UserPrices);
+        } else {
+#endif //defined DD360Audi
+
+            pSysConfig->BillingData.Cur_fee = pSysConfig->BillingData.Fee[tmCSU->tm_hour];
+
+#if defined DD360Audi
+            if (tmCSU->tm_hour <= 23) {
+                DisplayMoneyRate(pSysConfig->BillingData.Cur_fee);
+            }
+#else
+            ChangeDisplay2Value(__money_by_rate, _disappear);
+            sprintf(price,"%.2f",ShmDcCommonData->ChargingRate);
+            ShowAnimationPrice(price);
+#endif
+            if (pSysConfig->BillingData.Currency <= 53) {
+                DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
+            }
+#if defined DD360Audi
+        }
+#endif //defined DD360Audi
+    } else {
+        ChangeDisplay2Value(__money_rate_map, _disappear);
+        ChangeDisplay2Value(__money_by_rate, _disappear);
+        ChangeDisplay2Value(__money_rate, _disappear);
+        ShowAnimationPrice("");
+    }
+}
+
+
 void ProcessPageInfo()
 {
     _page_reload = IsPageReloadChk();
     pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-    struct InfoCodeData *pInfoCode = (struct InfoCodeData *)GetShmInfoCodeData();
-    struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
 
+    char price[30];
     bool isCharging = false;
     for (uint8_t i = 0; i < _totalCount; i++) {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
@@ -1770,9 +1606,18 @@ void ProcessPageInfo()
     }
 
     // 隨插即充 - 可省略該按鈕 //DS60-120 add
-    //if (pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE) {
+    /*
+    if (pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE) {    
         ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
+    } else {
+        ChangeDisplay2Value(__ret_home_btn, _disappear);
+    }
+    */
+#if defined DD360Audi
+        if (_totalCount >= 2) {
+#else
         if (_totalCount >= 2 && isCharging /*&& pSysInfo->IsAlternatvieConf == NO*/) {
+#endif
             ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
         } else {
             ChangeDisplay2Value(__sel_gun_btn, _disappear);
@@ -1793,6 +1638,7 @@ void ProcessPageInfo()
             ChangeDisplay2Value(__right_gun_map, _right_gun_enable_map);
         }
         ChangeDisplay2Value(__add_chk_btn, _select_gun_btn);
+        ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
         break;
 #endif //defined DD360Audi
 
@@ -1826,17 +1672,15 @@ void ProcessPageInfo()
         //if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
         if (pSysConfig->isQRCode) {
             needReloadQr = false;
-            ChangeQrCode_Idle((char*)ShmDcCommonData->QRCodeString);
-            /*
-            if (pSysConfig->QRCodeMadeMode == NO) {
-                //uint8_t len = strlen((char *)pSysConfig->SystemId);
-                ChangeQrCode_Idle((char *)pSysConfig->SystemId);
+            if (strcmp(ShmDcCommonData->QRCodeString,"") != EQUAL) {
+                ChangeQrCode_Idle((char*)ShmDcCommonData->QRCodeString);
             } else {
-                //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
-                ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
+                if (pSysConfig->QRCodeMadeMode == NO) {
+                    ChangeQrCode_Idle((char *)pSysConfig->SystemId);
+                } else {
+                    ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
+                }
             }
-            //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
-            */
         }
         //}
 
@@ -1883,10 +1727,12 @@ void ProcessPageInfo()
             ChangeDisplay2Value(__show_waitgunplug_value, _showwaitgunplug_right);
 #endif
         FirstPageChanged();
-        if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
+        //if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
             // 新增隨插即充功能預設在等待插槍頁面在開啟
-            ChangeDisplay2Value(__ret_home_btn, _disappear);
-        }
+        //    ChangeDisplay2Value(__ret_home_btn, _disappear);
+        //} else {
+            ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
+        //}
         bool isCharging = false;
         for (uint8_t i = 0; i < _totalCount; i++) {
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
@@ -1911,7 +1757,7 @@ void ProcessPageInfo()
     case _LCM_COMPLETE: {
         bool isShowAc = false;
         uint8_t gunTargetIndex = 0;
-
+        /*
         if (acgunCount > 0) {
             gunTargetIndex = 2;
             if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
@@ -1946,11 +1792,10 @@ void ProcessPageInfo()
                         ChangeChargingEnergyValue(0);
                     }
 
-                    if (strcmp((char *)pAcChargingInfo->StartUserId, "") == 0 ||
-                            pSysConfig->StopChargingByButton == YES) {
+                    if (pSysConfig->StopChargingByButton == YES ) {
                         ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
-                    } else {
-                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
+                    } else{
+                        ChangeDisplay2Value(__stop_method_btn,_stop_charging_btn_scan );
                     }
                 } else if (_currentPage == _LCM_COMPLETE) {
                     ChangeAcBattMapAndValue(_LCM_COMPLETE);
@@ -1998,14 +1843,14 @@ void ProcessPageInfo()
                     ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_dark);
                 }
             }
-        } else {
+        } else { */
             //ChangeDisplay2Value(__gun_type_index + (2 * 2), _disappear); //DS60-120 remove
             if (_totalCount > 1) {
                 gunTargetIndex = 2;
                 ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _disappear);
                 ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _disappear);
             }
-        }
+        //}
 
         //ChangeDisplay2Value(__money_by_rate, _disappear);
 
@@ -2080,10 +1925,22 @@ void ProcessPageInfo()
                     // Total Cost
                     ChangeTotalCostValue(pDcChargingInfo->ChargingFee, _currentPage);
                     if (pSysConfig->BillingData.isBilling) {
-                        ShowAnimationPrice(ShmDcCommonData->pGunInfo[i].UserPriceString);
+                        
+                        if (strlen(ShmDcCommonData->pGunInfo[i].UserPriceString) <= 0 ) {
+                            sprintf(price,"%.2f",ShmDcCommonData->ChargingRate);
+                            ShowAnimationPrice(price);
+                        } else
+                            ShowAnimationPrice(ShmDcCommonData->pGunInfo[i].UserPriceString);
                     } else {
                         ShowAnimationPrice("");
                     }
+                    if (pSysConfig->StopChargingByButton == YES ||
+                        pDcChargingInfo->StartMethod == _CHARGING_START_AUTOSTART ||
+                        pDcChargingInfo->StartMethod == _CHARGING_START_EVCCID) {
+                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn); 
+                    } else{
+                        ChangeDisplay2Value(__stop_method_btn,_stop_charging_btn_scan );
+                    }
                 }
             } else if (_currentPage == _LCM_CHARGING && !isShowAc) {
                 if (pSysInfo->CurGunSelected == i) {
@@ -2109,11 +1966,12 @@ void ProcessPageInfo()
                         ChangeChargingEnergyValue(0);
                     }
 
-                    if (strcmp((char *)pDcChargingInfo->StartUserId, "") == 0 ||
-                            pSysConfig->StopChargingByButton == YES) {
+                    if (pSysConfig->StopChargingByButton == YES ||
+                        pDcChargingInfo->StartMethod == _CHARGING_START_AUTOSTART ||
+                        pDcChargingInfo->StartMethod == _CHARGING_START_EVCCID) {
                         ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
-                    } else {
-                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
+                    } else{
+                        ChangeDisplay2Value(__stop_method_btn,_stop_charging_btn_scan );
                     }
                     /////////////////////// CTEP Add ///////////////////////
                     // EnergyCost
@@ -2126,7 +1984,11 @@ void ProcessPageInfo()
                     }
 
                     if (pSysConfig->BillingData.isBilling) {
-                        ShowAnimationPrice(ShmDcCommonData->pGunInfo[i].UserPriceString);
+                        if (strlen(ShmDcCommonData->pGunInfo[i].UserPriceString) <= 0 ) {
+                            sprintf(price,"%.2f",ShmDcCommonData->ChargingRate);
+                            ShowAnimationPrice(price);
+                        } else
+                            ShowAnimationPrice(ShmDcCommonData->pGunInfo[i].UserPriceString);
                     } else {
                         ShowAnimationPrice("");
                     }
@@ -2200,6 +2062,7 @@ void ProcessPageInfo()
                         ChangeDisplay2Value(__charging_fee_map, _money_map);
                     }
 #ifdef DD360Audi
+                    struct InfoCodeData *pInfoCode = (struct InfoCodeData *)GetShmInfoCodeData();
                     // Warming Occur in prepare or precharing state, turn into complete mode
                     if (pInfoCode->InfoEvents.bits.Stop_by_EV_with_unknow_reason) {
                         RunFullTargetFunction(true);
@@ -2233,17 +2096,15 @@ void ProcessPageInfo()
                 if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
                     if (pSysConfig->isQRCode) {
                         needReloadQr = false;
-                        //ChangeQrCode_Charge((char *)pSysConfig->SystemId); //DS60-120 remove
-                        ChangeQrCode_Charge((char*)ShmDcCommonData->QRCodeString);
-                        /*
-                        if (pSysConfig->QRCodeMadeMode == NO) {
-                            //uint8_t len = strlen((char *)pSysConfig->SystemId);
-                            ChangeQrCode_Charge((char *)pSysConfig->SystemId);
+                        if (strcmp(ShmDcCommonData->QRCodeString,"") != EQUAL) {
+                            ChangeQrCode_Idle((char*)ShmDcCommonData->QRCodeString);
                         } else {
-                            //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
-                            ChangeQrCode_Charge((char *)pSysConfig->QRCodeContent);
+                            if (pSysConfig->QRCodeMadeMode == NO) {
+                                ChangeQrCode_Idle((char *)pSysConfig->SystemId);
+                            } else {
+                                ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
+                            }
                         }
-                        */
                     }
                 }
             }
@@ -2276,48 +2137,6 @@ void ProcessPageInfo()
     }
 }
 
-void ChangeDisplayMoneyInfo()
-{
-    uint8_t curGun = pSysInfo->CurGunSelected;
-
-    if (pSysConfig->BillingData.isBilling) {
-        struct timeb csuTime;
-        struct tm *tmCSU;
-
-        ftime(&csuTime);
-        tmCSU = localtime(&csuTime.time);
-
-        ChangeDisplay2Value(__money_rate_map, _charging_money);
-#if defined DD360Audi
-        if (ShmSelectGunInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
-            DisplayMoneyRate(ShmSelectGunInfo->PricesInfo[curGun].UserPrices);
-        } else {
-#endif //defined DD360Audi
-
-            pSysConfig->BillingData.Cur_fee = pSysConfig->BillingData.Fee[tmCSU->tm_hour];
-
-#if defined DD360Audi
-            if (tmCSU->tm_hour <= 23) {
-                DisplayMoneyRate(pSysConfig->BillingData.Cur_fee);
-            }
-#else
-            ChangeDisplay2Value(__money_by_rate, _disappear);
-            ShowAnimationPrice(ShmDcCommonData->DefaultPriceString);
-#endif
-            if (pSysConfig->BillingData.Currency <= 53) {
-                DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
-            }
-#if defined DD360Audi
-        }
-#endif //defined DD360Audi
-    } else {
-        ChangeDisplay2Value(__money_rate_map, _disappear);
-        ChangeDisplay2Value(__money_by_rate, _disappear);
-        ChangeDisplay2Value(__money_rate, _disappear);
-        ShowAnimationPrice("");
-    }
-}
-
 /*void Initialization()
 {
     bool isPass = false;
@@ -2414,7 +2233,6 @@ int main(void)
     _port = CreateCommunicationLcmPort();
     uint8_t changeWarningPriority = 0;
     uint8_t curWarningCount = 255;
-    uint8_t changeInfoPriority = 0;
     ChangeBackLight(true);
     _totalCount = pSysConfig->TotalConnectorCount;
     acgunCount = pSysConfig->AcConnectorCount;
@@ -2428,7 +2246,6 @@ int main(void)
     }
 
     uint8_t _verShowCount = 5;
-    DefaultIconStatus(); //DS60-120 add
 
     while (_port != -1) {
         if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
@@ -2438,12 +2255,14 @@ int main(void)
 #ifndef DD360ComBox
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
 #endif
+            DefaultIconStatus(); //DS60-120 add
 		    if (_verShowCount > 0) {
 			    log_info("LCM Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
 			    _verShowCount--;
 		    }
         } else {
             //DemoFunction();
+
 #ifndef DD360ComBox
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
 #endif
@@ -2479,12 +2298,7 @@ int main(void)
             ChangeDisplayMoneyInfo();
 #else
             InformationShow();
-            /*
-            if (changeInfoPriority == 0) { ////For Audi
-                //ChangeDisplayMoneyInfo();
-                
-            }
-            */
+
 #endif //defined DD360Audi
 
             changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);

+ 52 - 63
EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -35,10 +35,10 @@
 #include "../ShareMemory/shmMem.h"
 #include "PrimaryComm.h"
 #include "Module_PrimaryComm.h"
-
+#include "../common.h"
 //------------------------------------------------------------------------------
 //struct SysConfigAndInfo *ShmSysConfigAndInfo;
-//struct StatusCodeData *ShmStatusCodeData;
+struct StatusCodeData *ShmStatusCodeData;
 static struct SysConfigData *pSysConfig = NULL;
 static struct SysInfoData *pSysInfo = NULL;
 static struct AlarmCodeData *pAlarmCode = NULL;
@@ -57,9 +57,11 @@ bool _isNeedChkTilt = FALSE;
 struct timespec _tilt_time;
 uint8_t tilt = NO;
 bool _chargeSwitch;
+struct timespec _tilt_on_time;
 //================================================
 // Function
 //================================================
+
 bool GetFwAndHwVersion(int fd)
 {
     Ver ver = {0};
@@ -100,7 +102,7 @@ void GetInputGpioStatus(int fd)
 #else
     if (gpio_in.Emergency_Btn && (EmgBtn_flag != gpio_in.Emergency_Btn))
     {
-            EmgBtn_count++;
+        EmgBtn_count++;
         if (EmgBtn_count > SensorTrigCount) {
            EmgBtn_flag = 1;
            EmgBtn_count = 0; // Avoid Overflow
@@ -149,6 +151,7 @@ void GetInputGpioStatus(int fd)
 #if defined DD360ComBox
     Door_flag = 0;
 #else
+    //log_info("Door_Open pin:%d",gpio_in.Door_Open);
     if (Door_flag == gpio_in.Door_Open) {
         Door_count++;
         if (Door_count == 3 ) {
@@ -159,22 +162,6 @@ void GetInputGpioStatus(int fd)
         Door_flag = gpio_in.Door_Open;
         Door_count = 0;
     }
-    /*
-    if (gpio_in.Door_Open == 0 && (Door_flag == gpio_in.Door_Open))
-    {
-        Door_count++;
-        if (Door_count > SensorTrigCount) {
-            Door_flag = 1;
-            Door_count = 0; // Avoid Overflow
-       }
-    } else if (gpio_in.Door_Open && Door_flag) {
-        Door_count++;
-        if (Door_count > SensorTrigCount) {
-            Door_flag = 0;
-            Door_count = 0;
-        }
-    }
-    */
 #endif 
 #if defined DD360ComBox
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
@@ -182,20 +169,17 @@ void GetInputGpioStatus(int fd)
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = ~Door_flag;
 #endif
 
-/*
+    /*
     log_info("Emergency Button Count = %d , Emergency flag = %d",
             EmgBtn_count,EmgBtn_flag);
     log_info("Door Sensor Count = %d , Door Sensor flag = %d",
             Door_count,Door_flag);
-*/
+    */
 
     ShmPrimaryMcuData->InputDet.bits.Key0 = ~gpio_in.Key[0] & 0x01;
     ShmPrimaryMcuData->InputDet.bits.Key1 = ~gpio_in.Key[1] & 0x01;
     ShmPrimaryMcuData->InputDet.bits.Key2 = ~gpio_in.Key[2] & 0x01;
-
     return;
-
-
 }
 
 static void checkChillerStatus(Gpio_out *gpio)
@@ -245,13 +229,14 @@ static void checkChillerStatus(Gpio_out *gpio)
                 }
             } else {
                 pChillerInfo->ChillerSwitch = NO;
-                ShmFanModuleData->SetFan1Speed = 0;
+                if (!ShmDcCommonData->pTest.fanflag)
+                    ShmFanModuleData->SetFan1Speed = 0;
             }
         }
         // 檢查Chiller溫度點,若小於零下時開啟heater,大於10度時關閉heater
-        if (pDcChargingInfo->ChillerTemp < 70) {
+        if (pDcChargingInfo->ChillerTemp < 60) {
             pGpio->AC_Breaker = YES;
-        } else if(pDcChargingInfo->ChillerTemp > 75) {
+        } else if(pDcChargingInfo->ChillerTemp > 70) {
             pGpio->AC_Breaker = NO;
         }
         //log_info("Gun%d Set Heater %s", gunIndex, pGpio->AC_Breaker ? "ON" : "OFF");
@@ -262,13 +247,14 @@ static void checkChillerStatus(Gpio_out *gpio)
         pChillerInfo = (ChillerInfo*)&fChillerInfo[gunIndex];
         if (pChillerInfo->ChillerSwitch == YES) {
             _chillerNeedOn = YES;
-            ShmFanModuleData->SetFan1Speed = 7000;
+            if (!ShmDcCommonData->pTest.fanflag)
+                ShmFanModuleData->SetFan1Speed = 7000;
         }
     }
-    /*
-    if (ShmDcCommonData->debugflag == YES)
+    
+    if (ShmDcCommonData->pTest.chillerflag == YES && !_chillerNeedOn)
         _chillerNeedOn = ShmDcCommonData->chillerCtrl;
-    */
+    
     if (ShmPrimaryMcuData->InputDet.bits.Ac_Drop == ABNORMAL) {
         _chillerNeedOn = NO;
     }
@@ -287,7 +273,7 @@ void SetOutputGpio(int fd, uint8_t outputValue)
     LedConfig *pLedConfig = (LedConfig *)&outputValue;
     static uint8_t flash = NO;
 
-    if (strcmp((char *)pSysInfo->LcmHwRev, " ") == 0x00) {
+    if (pAlarmCode->AlarmEvents.bits.LcmModuleCommFail) {
         if (flash == NO) {
             flash = YES;
         } else {
@@ -313,8 +299,21 @@ void SetOutputGpio(int fd, uint8_t outputValue)
     if (_isNeedChkTilt) {
         gpio.System_LED[0] = 0x00;
         gpio.System_LED[1] = 0x00;
-        gpio.System_LED[2] = tilt;
-        gpio.System_LED[3] = tilt;
+        gpio.System_LED[2] = 0x00;
+        if (tilt == YES) {
+            if ((GetClockTimeoutValue(_tilt_on_time) / 1000) > 100) {
+                gpio.System_LED[2] = tilt;
+            }
+            gpio.System_LED[3] = tilt;
+        } else {
+            gpio.System_LED[2] = tilt;
+            gpio.System_LED[3] = tilt;
+        }
+    } else {
+        gpio.System_LED[0] = 0x00;
+        gpio.System_LED[1] = 0x00;
+        gpio.System_LED[2] = 0x00;
+        gpio.System_LED[3] = 0x00;
     }
 #endif
     checkChillerStatus(&gpio);
@@ -414,6 +413,7 @@ void GetTimespecFunc(struct timespec *time)
 {
 	clock_gettime(CLOCK_MONOTONIC_COARSE, time);
 }
+
 static bool IsPrimaryProcessNeedPause(void)
 {
     bool _pause = false;
@@ -436,32 +436,18 @@ static bool IsPrimaryProcessNeedPause(void)
 
     return _pause;
 }
-bool CheckCustomer()
-{
-	bool result = false;
-	char _buf[3] = {0};
 
-	memcpy(_buf, &pSysConfig->ModelName[12], 2);
-	if (strcmp(_buf, "OL") == EQUAL)
-		result = true;
-	return result;
-}
 void TiltSensorSwitch(bool _switch)
 {
-	if (tilt != _switch)
+	if (tilt != _switch) {
 		tilt = _switch;
-
-}
-bool isChargingStatus(unsigned char status)
-{
-    if ((status >= S_REASSIGN_CHECK && status <= S_ALARM) ||
-        status == S_CCS_PRECHARGE_ST0 || status == S_CCS_PRECHARGE_ST1 ) {
-        return TRUE;
-    } else {
-        return FALSE;
+        if (tilt == YES) {
+            GetClockTime(&_tilt_on_time);
+        }
     }
 }
-void ChkTiltSensor(fd)
+
+void ChkTiltSensor(int fd)
 {
     struct ChargingInfoData *pDcChargingInfo = NULL;
     bool isCharing = NO;
@@ -473,7 +459,7 @@ void ChkTiltSensor(fd)
     for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++)
     {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-        if (isChargingStatus(pDcChargingInfo->SystemStatus) || ShmPrimaryMcuData->SelfTest_Comp != PASS) {
+        if (IntoChargeProcess(pDcChargingInfo->SystemStatus) || ShmPrimaryMcuData->SelfTest_Comp != PASS) {
             isCharing = YES;
         }
     }
@@ -495,10 +481,11 @@ void ChkTiltSensor(fd)
 			{
 				case _TILT_SENSOR_STEP_PIN_ON:
 				{
-					TiltSensorSwitch(YES);
-					GetTimespecFunc(&_tilt_time);
+
 					log_info("---- Tilt Sensor : _TILT_SENSOR_STEP_PIN_WAIT ---- ");
 					ShmDcCommonData->_tiltSensorStep = _TILT_SENSOR_STEP_PIN_WAIT;
+                    TiltSensorSwitch(YES);
+                    GetTimespecFunc(&_tilt_time);
 				}
 				break;
 				case _TILT_SENSOR_STEP_PIN_WAIT:
@@ -508,7 +495,7 @@ void ChkTiltSensor(fd)
 						GetTimespecFunc(&_tilt_time);
 					else if (_time > 1)
 					{
-						if (gpio_in.Door_Open == NO)
+						if (gpio_in.Door_Open)
 							pAlarmCode->AlarmEvents.bits.TiltSensorStestFail = YES;
 						else
 							pAlarmCode->AlarmEvents.bits.TiltSensorStestFail = NO;
@@ -608,7 +595,10 @@ int main(void)
     //Initialization();
 
     // 需要判斷這個的客戶碼 : OL
-	//_isNeedChkTilt = CheckCustomer();
+    if (CheckCustomer() == _CUSTOM_SHELL)
+        _isNeedChkTilt = true;
+    else
+        _isNeedChkTilt = false;
 
     for (;;) {
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
@@ -629,15 +619,14 @@ int main(void)
             } else {
                 ShmPrimaryMcuData->SelfTest_Comp = PASS;
             }
+            SetOutputGpio(Uart1Fd, ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0]);
         } else {
-            if (_isNeedChkTilt) {
-                ChkTiltSensor(Uart1Fd);
-            }
+
             SetOutputGpio(Uart1Fd, ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0]);
 
             GetInputGpioStatus(Uart1Fd);
         }
-        usleep(50000);
+        usleep(10000);
     }
 
     return FAIL;

+ 1 - 0
EVSE/Projects/DD360/Apps/ModulePrimary/PrimaryComm.c

@@ -135,6 +135,7 @@ int Query_Gpio_Input(uint8_t fd, uint8_t targetAddr, Gpio_in *Ret_Buf)
             Ret_Buf->Key[2]             = (rx[7] >> 5) & 0x01;
             Ret_Buf->Key[3]             = (rx[7] >> 6) & 0x01;
             Ret_Buf->Button3             = (rx[7] >> 7) & 0x01;
+            
             result = PASS;
         }
     }

+ 14 - 34
EVSE/Projects/DD360/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -81,7 +81,6 @@ void setChargerMode(uint8_t gunIndex, uint8_t mode)
 
     pDcChargingInfo->SystemStatus = mode;
 
-    log_info(" ====== System Status:%d ======",mode);
 }
 void TryCloseWatchdog()
 {
@@ -314,6 +313,7 @@ bool CreateAdVideoForLcmFile(char *file)
 
 	return result;
 }
+
 static int CheckUpdateProcess(void)
 {
     //bool isPass = true;
@@ -328,6 +328,7 @@ static int CheckUpdateProcess(void)
     int CanFd = 0;
     int uartFd = 0;
     unsigned int Type = 0;
+    uint8_t NameError = 0;
     long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
     DIR *d;
     struct dirent *dir;
@@ -357,6 +358,7 @@ static int CheckUpdateProcess(void)
             
             fd = open(new_str, O_RDONLY);
             if (fd < 0) {
+                retFail++;
                 return FAIL;
             }
 
@@ -365,12 +367,17 @@ static int CheckUpdateProcess(void)
 
             //get the image length
             ImageLen = read(fd, ptr, MaxLen);
+            NameError = FALSE;
             for (uint8_t i = 0; i < 16; i++) {
                 if (pSysConfig->ModelName[i] != ptr[i]) {
-                    return FAIL;
+                    NameError = TRUE;
                 }
             }
-
+            if (NameError) {
+                retFail++;
+                log_info("model name check fail. ");
+                continue;
+            }
             log_info("model name check pass. ");
             if (ImageLen > 20) {
                 Type = (((unsigned int)ptr[16]) << 24 |
@@ -434,34 +441,7 @@ static int CheckUpdateProcess(void)
                     sprintf(Buf, "rm -rvf /mnt/%s", new_str);
                     system(Buf);
                     //isPass = true;
-#if 0
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            //if (!isPass) {
-                            //    break;
-                            //}
-                            if (chargingInfo[index]->Type == _Type_CCS_2) {
-                                if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
-                                    //isPass = false;
-                                    log_info("Upgrade %x Failed", Type);
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_error("Upgrade CCS open CAN FD fail.");
-                        //isPass = false;
-                        return FAIL;
-                    }
 
-                    if (retFail != 0) {
-                        break;
-                    } else {
-                        retSucc++;
-                    }
-                    //return isPass;
-#endif //0
                     break;
 
                 case 0x10000006:
@@ -573,7 +553,7 @@ static int CheckUpdateProcess(void)
                     if (CreateAdVideoForLcmFile(new_str)) {
                         system("chmod 777 /mnt/videoPresent.mp4");
                         log_info("Start Upgrade Ad Video");
-                        if (system("ftpput -u zerova -p zerova@2022 192.168.0.60 /srv/ads/videoPresent.mp4 /mnt/videoPresent.mp4")) {
+                        if (system("ftpput -u ftpuser -p ftppasswd 192.168.0.60 /srv/ads/videoPresent.mp4 /mnt/videoPresent.mp4")) {
                             retSucc++;
                             return PASS;
                         } else
@@ -625,10 +605,10 @@ void CheckFwUpdateFunction(void)
             log_info("ftp : update fail. ");
         }
 
-        pSysInfo->FirmwareUpdate = NO;
         sleep(5);
+        pSysInfo->FirmwareUpdate = NO;
         system("reboot -f");
-    } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
+    }/* else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
 
         if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
@@ -673,7 +653,7 @@ void CheckFwUpdateFunction(void)
             sleep(5);
             system("reboot -f");
         }
-    }
+    }*/
 }
 
 int main(int argc, char *argv[])

+ 58 - 1
EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/LcmCommandDriver.c

@@ -823,7 +823,7 @@ int publish_apngview_store(struct mosquitto *mosq,uint8_t page)
 	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
 	json_object_put(payload);
 
-	return publish_data(mosq, "client/page/apngview", outputStr);
+	return publish_data(mosq, "client/page/storeapng", outputStr);
 }
 ////////////////////////////////////////////////////////////////////////////
 int	publish_textview_push(Text_List* textList, uint8_t listCount)
@@ -943,6 +943,35 @@ void PushPageInfoToLcm(struct mosquitto *mosq,int page)
 	clearPushBuffer();
 }
 
+
+int publish_image_remove(struct mosquitto *mosq, Image_List *imageList, uint8_t ListCount)
+{
+	json_object *payload = json_object_new_object();
+	json_object *image = json_object_new_array();
+
+	char outputStr[2048]={0};
+
+	// Remove image view
+	for(int idx=0;idx<ListCount;idx++)
+	{
+		if (imageList[idx].imageviewIndex == 0) {
+			continue;
+		}
+		json_object *imageview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", imageList[idx].imageviewIndex);
+		json_object_object_add(imageview, "imageviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(image, imageview);
+	}
+	json_object_object_add(payload, "rm_imageview_list", image);
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/remove", outputStr);
+}
+
 int publish_apng_remove(struct mosquitto *mosq, APNG_List *apngList, uint8_t apngListCount)
 {
 	json_object *payload = json_object_new_object();
@@ -968,5 +997,33 @@ int publish_apng_remove(struct mosquitto *mosq, APNG_List *apngList, uint8_t apn
 	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
 	json_object_put(payload);
 
+	return publish_data(mosq, "client/layout/remove", outputStr);
+}
+
+int publish_vido_remove(struct mosquitto *mosq, Video_List *videoList, uint8_t ListCount)
+{
+	json_object *payload = json_object_new_object();
+	json_object *video = json_object_new_array();
+
+	char outputStr[2048]={0};
+
+	// Remove image view
+	for(int idx=0;idx<ListCount;idx++)
+	{
+		if (videoList[idx].videoviewIndex == 0) {
+			continue;
+		}
+		json_object *videoview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", videoList[idx].videoviewIndex);
+		json_object_object_add(videoview, "videoviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(video, videoview);
+	}
+	json_object_object_add(payload, "rm_videoview_list", video);
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
 	return publish_data(mosq, "client/layout/remove", outputStr);
 }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 400 - 182
EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.c


+ 21 - 19
EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/Module_LcmControl_Wistron.h

@@ -49,6 +49,9 @@
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
+#define NOODOE_QR_CODE_URL                      "https://ev.noodoe.com/station?id=" ////For Audi
+
+
 enum TIMER_IDX
 {
 	TMR_IDX_0=0,
@@ -204,22 +207,6 @@ char _lang_String[100][200];
 char _lang_List[10][20];
 char _lang_Name[10][20];
 
-enum BRIGHTNESS_LEVEL
-{
-	BRIGHTNESS_LEVEL_0=0,
-	BRIGHTNESS_LEVEL_1,
-	BRIGHTNESS_LEVEL_2,
-	BRIGHTNESS_LEVEL_3,
-	BRIGHTNESS_LEVEL_4,
-	BRIGHTNESS_LEVEL_5,
-	BRIGHTNESS_LEVEL_6,
-	BRIGHTNESS_LEVEL_7,
-	BRIGHTNESS_LEVEL_8,
-	BRIGHTNESS_LEVEL_9,
-	BRIGHTNESS_LEVEL_10,
-	BRIGHTNESS_LEVEL_11,
-	BRIGHTNESS_LEVEL_AUTO,
-};
 
 enum FONT_SIZE
 {
@@ -294,12 +281,13 @@ extern int publish_textview_store(struct mosquitto *mosq,uint8_t page);
 extern int publish_textscroll_store(struct mosquitto* mosq,uint8_t page);
 extern int publish_imageview_store(struct mosquitto *mosq,uint8_t page);
 extern int publish_apngview_store(struct mosquitto *mosq,uint8_t page);
-
+extern int publish_image_remove(struct mosquitto *mosq, Image_List *imageList, uint8_t ListCount);
 extern int publish_textview_push(Text_List *textList, uint8_t listCount);
 extern int publish_textscroll_push(TextScroll_List* textList, uint8_t listCount);
 extern int publish_imageview_push(Image_List *imageList, uint8_t listCount);
 extern int publish_apngview_push(APNG_List *apngList, uint8_t listCount);
 extern void PushPageInfoToLcm(struct mosquitto *mosq,int page);
+extern int publish_vido_remove(struct mosquitto *mosq, Video_List *videoList, uint8_t ListCount);
 
 extern void ItemListGetMem(struct mosquitto* _mosq);
 extern int DB_Set_Language(int sel);
@@ -354,10 +342,15 @@ extern void showDefaultUserPrice();
 extern void showAlarmQRCode();
 extern void CompleteUnplugAction();
 extern void showReceiptInfo();
+extern void AlarmCodeUnplugAction();
 extern void GetColorTitle(Text_List* textList);
 extern void GetColorText1(Text_List* textList);
 extern void GetColorText2(Text_List* textList);
 extern void GetColorText3(Text_List* textList);
+extern void showTextBackLightPage();
+extern void showAuthorizeBalance();
+extern void showBackLightIcon(int sel);
+extern void showSetItemFrame(int sel);
 void InitPageInfo(struct mosquitto *mosq);
 enum _SUPPORT_LANGUAGE {
 	_SUPPORT_ZH_TW,
@@ -389,8 +382,9 @@ enum _PHIHONG_WISTRON_BG_ {
 	_background = 001,
 	_background2 = 17,
 	_background_charging,
-	_backgroud_complete_plugout,
+	_backgroud_complete_receipt,
 	_backgroud_complete,
+	_backgroud_complete_plugout,
 	_LOGO_ = 98,
 };
 
@@ -408,6 +402,9 @@ enum _PHIHONG_WISTRON_BTN_ {
 	_btn_Select_Current,  // Also for left gun
 	_btn_Select_Non,	  // Also for right
 	_btn_previous,
+	_btn_Subtrace,
+	_btn_Add,
+	_btn_ErroInfo = 22,
 };
 
 enum _PHIHONG_WISTRON_ICON_ {
@@ -474,6 +471,8 @@ enum _PHIHONG_WISTRON_ICON_ {
 	_icon_debugL,
 	_icon_debugC,
 	_icon_debugR,
+	_icon_Audi_Etron,
+	_icon_test_gray,
 };
 
 enum _PHIHONG_LANGUAGE_INDEX {
@@ -506,7 +505,7 @@ enum _PHIHONG_LANGUAGE_INDEX {
 	_lang_time,
 	_lang_ParkingFee,
 	_lang_TotalCost,
-	_lang_RemainAmount,
+	_lang_balance,
 	_lang_StopCharging,
 	_lang_CompleteTitle,
 	_lang_CompletePlugoutTitle,
@@ -529,6 +528,9 @@ enum _PHIHONG_LANGUAGE_INDEX {
 	_lang_SetLanguage,
 	_lang_SetBackLight,
 	_lang_Previous,
+	_lang_Increase,
+	_lang_Decrease,
+	_lang_ErrorInfo,
 };
 
 enum _PHIHONG_TEXT_INDEX {

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 319 - 180
EVSE/Projects/DD360/Apps/Module_LcmControl_Wistron/Module_LcmItemList.c


+ 313 - 300
EVSE/Projects/DD360/Apps/ReadCmdline.c

@@ -44,7 +44,7 @@
 #include "Config.h"
 #include "./ModuleEvComm/Module_EvComm.h"
 #include "./CSU/main.h"
-
+#include "common.h"
 //------------------------------------------------------------------------------
 #define CMD_KEY_WAIT                                (1)
 #define CMD_KEY_DONT_WAIT                           (0)
@@ -61,7 +61,12 @@
 #define TTY_PATH                                    "/dev/tty"
 #define STTY_US                                     "stty raw -echo -F "
 #define STTY_DEF                                    "stty -raw echo -F "
-
+#define OPTION_CNT              4
+#define STR_OPTION              '-'
+#define OPTION_REFLASH          0x00000001
+#define OPTION_LOOP             0x00000002
+#define OPTION_OUTPUT_FILE      0x00000004
+#define OPTION_TIME             0x00000008
 //------------------------------------------------------------------------------
 uint8_t _curAutoRunCount = 0;
 uint8_t _usingAutoRun = 0;
@@ -80,7 +85,6 @@ static struct GBTData *ShmGBTData = NULL;
 static struct FanModuleData *ShmFanModuleData = NULL;
 static struct RelayModuleData *ShmRelayModuleData = NULL;
 static struct LedModuleData *ShmLedModuleData = NULL;
-static struct PsuData *ShmPsuData = NULL;
 static struct OCPP16Data *ShmOCPP16Data = NULL;
 static SelectGunInfo *ShmSelectGunInfo = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
@@ -188,60 +192,188 @@ unsigned long GetTimeoutValue(struct timeval _sour_time)
     return (_end_time.tv_sec - _sour_time.tv_sec);
 }
 
-void RunStatusProc(char *v1, char *v2)
+// return command length
+int ParsingCmd(char *inputString, char *outputString)
 {
-    printf("OrderCharging = %d \n", pSysInfo->OrderCharging);
-    printf("WaitForPlugit = %d \n", pSysInfo->WaitForPlugit);
-    if (strcmp(v1, "ac") == 0) {
-        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
-        //    printf("FindChargingInfoData (AC) false \n");
-        //}
-        printf("AC Status = %d \n", pAcChargingInfo->ConnectorPlugIn);
-        return;
+    bool valid = false, done = false;
+    int len = 0, start = 0;
+
+    for(int i = 0; i < strlen(inputString); i++)
+    {
+        if(!valid)
+        {
+            if(inputString[i] != ' ' && inputString[i] != '\0' && inputString[i] != '\r' && inputString[i] != '\n')
+            {
+                valid = true;
+                start = i;
+            }
+        }
+        else
+        {
+            if(inputString[i] == ' ' || inputString[i] == '\0' || inputString[i] == '\r' || inputString[i] == '\n' || len >= 128)
+            {
+                done = true;
+                break;
+            }
+        }
+
+        len = (valid && !done) ? len + 1 : len;
     }
 
-    int _index = atoi(v1);
+    if(valid)
+    {
+        memcpy(outputString, &inputString[start], len);
+        outputString[len] = '\0';
+    }
 
-    if (_index <= 1) {
-        //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-        //    printf ("FindChargingInfoData error\n");
-        //    return;
-        //}
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+    return len;
+}
+void ConsoleReflash(int groupCnt, int lineCnt)
+{
+    for(int i = 0; i < groupCnt; i++)
+    {
+        for(int i = 0; i < lineCnt; i++)
+        {
+            printf("\033[1A");
+            printf("\033[K");
+        }
+    }
+    printf("\r");
+}
 
-        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-            // get
-            printf ("index = %x, status = %x (%d) Reservation is :%s\n",
-                    _index,
-                    pDcChargingInfo->SystemStatus,
-                    pDcChargingInfo->IsAvailable,
-                    ShmDcCommonData->pGunInfo[_index].ReservationStatus ? "trigger" : "expired");
-            if (ShmDcCommonData->pGunInfo[_index].ReservationStatus)
-                printf("Reservation idTag:%s\n", ShmDcCommonData->pGunInfo[_index].ReservationID);
-
-            printf("SystemTimeoutFlag = %d, PageIndex = %d\n",
-                    pSysInfo->SystemTimeoutFlag, pSysInfo->PageIndex);
-        } else {
-            // set
-            pDcChargingInfo->SystemStatus = atoi(v2);
+int GetCommandSring(char *outputCmdString)
+{
+    int len = 0, cnt = 0;
+    int cmdLen = 0, totalLen = 0;
+    char word[128];
+
+    memset(word, 0x00, sizeof(word));
+    get_char(word);
+
+    len = strlen(word);
+    if(len == 0)
+    {
+        return -1;
+    }
+
+    int start = 0;
+    while(start < len - 1)
+    {
+        if(word[start] != ' ' && word[start] != '\0')
+        {
+            cmdLen = ParsingCmd(&word[start], &outputCmdString[totalLen]);
+
+            char newCmd[128];
+            memset(newCmd, 0x00, 128);
+            memcpy(newCmd, &outputCmdString[totalLen], cmdLen);
+
+            cnt = cmdLen > 0 ? cnt + 1 : cnt;
+            totalLen += cmdLen + 1;
+            start += cmdLen;
         }
-    } else {
-        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
-        //    printf("FindChargingInfoData (AC) false \n");
-        //}
-        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
+        else
+        {
+            start++;
+        }
+    }
 
-        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-            // get
-            printf ("AC Type, status = %x (%d)\n",
-                    pAcChargingInfo->SystemStatus,
-                    pAcChargingInfo->IsAvailable);
-        } else {
-            // set
-            pAcChargingInfo->SystemStatus = atoi(v2);
+    return cnt;
+}
+
+bool IsLoopStopCmd(void)
+{
+    bool stop = false;
+    int cnt = 0;
+    char cmd[256];
+    char totalCmd[256];
+
+    memset(cmd, 0x00, 256);
+    memset(totalCmd, 0x00, 256);
+
+    cnt = GetCommandSring(totalCmd);
+    if(cnt > 0)
+    {
+        strcpy(&cmd[0], totalCmd);
+
+        if(strcmp(&cmd[0], "c") == 0)
+        {
+            stop = true;
         }
     }
+    return stop;
+}
+
+
+char* GetStartMethodName(int method)
+{
+    if (method == _CHARGING_START_RFID) {
+        return "RFID";
+    } else if (method == _CHARGING_START_AUTOSTART) {
+        return "AuthoStartCharging";
+    } else if (method == _CHARGING_START_REMOTESTART) {
+        return "RemoteStart";
+    } else if (method == _CHARGING_START_EVCCID){
+        return "EVCCID";
+    } else {
+        return "None";
+    }
+}
+void GunEnableInfo(uint8_t index)
+{
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
+    char _time[30];
+    sprintf(_time,"%02d:%02d:%02d",(pDcChargingInfo->PresentChargedDuration/3600),(pDcChargingInfo->PresentChargedDuration%3600)/60,pDcChargingInfo->PresentChargedDuration%60);
+    printf("\n");
+    printf("%s Gun Status = %s   \t%s\n\tStartMethod:%s\tDuration:[%s] Temp:[%d:%d]\n",index ? "Right":"Left",GetStatusName(pDcChargingInfo->SystemStatus),pDcChargingInfo->ConnectorPlugIn ? "PlugIn" : "Unplug",GetStartMethodName(pDcChargingInfo->StartMethod),_time,ShmDcCommonData->ConnectorTemp[index][0],ShmDcCommonData->ConnectorTemp[index][1]);
+    printf("\tEV Status:%d\tSoc:%d\n\tTargetVoltage:\t%05.2f V\t\tTargetCurrent:\t%05.2f A\n",ShmDcCommonData->pGunInfo[index].EVStatus,pDcChargingInfo->EvBatterySoc,pDcChargingInfo->EvBatterytargetVoltage,pDcChargingInfo->EvBatterytargetCurrent);
+    printf("\tPresentVoltage:\t%05.2f V\t\tPresentCurrent:\t%05.2f A\n\tPresentPower:\t%05.2f kW\t\tPresentEngergy:\t%05.2f kWh\n", pDcChargingInfo->PresentChargingVoltage,pDcChargingInfo->PresentChargingCurrent,pDcChargingInfo->PresentChargingPower,pDcChargingInfo->PresentChargedEnergy);
+}
+
+void RunStatusProc()
+{
+    
+    bool keepRun = true;
+    int time = 0;
+    int dispenserLine = 0;
+    struct timespec _Loop_time;
+
+    printf("\r\n");
+    printf("Dispenser Info\r\n");
+    do
+    {
+        time = GetClockTimeoutValue(_Loop_time) / 1000;
+
+        if(time >= 1000)
+        {
+
+            ConsoleReflash(1, 2);
+            ConsoleReflash(pSysConfig->TotalConnectorCount, 7);
+            dispenserLine = dispenserLine > 0 ? (dispenserLine + 1) : dispenserLine;
+            ConsoleReflash(1, dispenserLine);
+            dispenserLine = 0;
+            printf("Dispenser Total Connector: %d chiller Temp[%03d:%03d:%03d:%03d]\r\n",pSysConfig->TotalConnectorCount,
+                ShmDcCommonData->SystemTemp[0],ShmDcCommonData->SystemTemp[1],
+                ShmDcCommonData->SystemTemp[2],ShmDcCommonData->SystemTemp[3]);
+            for(int i = 0; i < pSysConfig->TotalConnectorCount; i++)
+            {
+                GunEnableInfo(i);
+            }
+
+            GetClockTime(&_Loop_time);
+        }
+        if(keepRun)
+        {
+            if (readCmdKey(CMD_KEY_DONT_WAIT) == NO) {
+                continue;
+            }
+            if (strcmp(newString[0], "c") == 0) {
+                printf("Stop show status\n");
+                keepRun = FALSE;
+            }
+        }
+    }while(keepRun);
+    printf("\r\n");
+    
 }
 
 void RunCardProc(char *v1, char *v2)
@@ -327,21 +459,6 @@ void RunSelfProc()
 
 void GetFwVerProc(void)
 {
-    int _index = 0;
-    int isContinue = 1;
-    char *usageMsg = "Usage:\n"
-                     "      model\n"
-                     "      407\n"
-                     "      conn index, ex: conn 0 | 1\n"
-                     "      relay\n"
-                     "      fan\n"
-                     "      dc\n"
-                     "      led\n"
-                     "      ac\n"
-                     "      exit | c | C\n"
-                     "      help | ? | h\n";
-
-
     printf("ModelName = %s\r\n", pSysConfig->ModelName);
     printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
     printf("DC Main Debug Version = %s \n", ShmDcCommonData->DebugVersion);
@@ -351,57 +468,18 @@ void GetFwVerProc(void)
     printf("Relay Board Version = %s \n", pSysInfo->RelayModuleFwRev);
     printf("FAN Version = %s \n", pSysInfo->FanModuleFwRev);
     printf("LED Version = %s \n", pSysInfo->LedModuleFwRev);
-    printf("LCM FW Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
-    printf("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s \n",
+    if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+        printf("LCM HW Version = %s \n", ShmDcCommonData->pLcmInfo.verHW);
+        printf("LCM OS Version = %s \n", ShmDcCommonData->pLcmInfo.verFW_OS);
+        printf("LCM APK Version = %s \n", ShmDcCommonData->pLcmInfo.verFW_APK);
+        printf("LCM UI Version = %s \n", ShmDcCommonData->pLcmInfo.verFW_UI);
+    } else {
+        printf("LCM FW Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
+    }
+    printf("Dispenser Network Information checked: IP = %s Netmask = %s, Gateway = %s \n",
         pSysConfig->Eth0Interface.EthIpAddress,
         pSysConfig->Eth0Interface.EthSubmaskAddress,
         pSysConfig->Eth0Interface.EthGatewayAddress);
-    /*
-    while (isContinue) {
-        if (readCmdKey(CMD_KEY_WAIT) == NO) {
-            continue;
-        }
-
-        if (strcmp(newString[0], "407") == 0) {
-            printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
-        } else if (strcmp(newString[0], "model") == 0) {
-            printf("ModelName = %s\r\n", pSysConfig->ModelName);
-        } else if (strcmp(newString[0], "conn") == 0) {
-            if (strcmp(newString[1], "-1") == 0  ||
-                    strcmp(newString[1], "") == 0 ||
-                    atoi(newString[1]) >= pSysConfig->TotalConnectorCount
-               ) {
-                printf("index over flow\r\n");
-                continue;
-            }
-
-            _index = atoi(newString[1]);
-
-            if (_index == 0) {
-                printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
-            } else if (_index == 1) {
-                printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
-            }
-        } else if (strcmp(newString[0], "relay") == 0) {
-            printf("RB Version = %s \n", pSysInfo->RelayModuleFwRev);
-        } else if (strcmp(newString[0], "fan") == 0) {
-            printf("FAN Version = %s \n", pSysInfo->FanModuleFwRev);
-        } else if (strcmp(newString[0], "dc") == 0) {
-            printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
-        } else if (strcmp(newString[0], "led") == 0) {
-            printf("LED Version = %s \n", pSysInfo->LedModuleFwRev);
-        } else if (strcmp(newString[0], "ac") == 0) {
-            pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-            printf("AC Version = %s \n", pAcChargingInfo->version);
-        } else if (exitCmd() == YES) {
-            return;
-        } else if (helpCmd() == YES) {
-            printf ("%s\n", usageMsg);
-        }
-
-    }//while
-    */
 }
 
 void CreateOneError(char *v1)
@@ -420,18 +498,87 @@ void GetAuthorizeFlag(char *v1)
         pSysInfo->AuthorizeFlag = atoi(v1);
     }
 }
-
 void GetRelayStatus(char *v1)
 {
-    int _index = atoi(v1);
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+    uint8_t _GunIndex = 0;
+    _GunIndex = atoi((char *)newString[1]);
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+    if (_GunIndex >= pSysConfig->TotalConnectorCount)
+        _GunIndex = 0;
+    printf("Gun%d RelayK1K2Status = %d \n", _GunIndex,pDcChargingInfo->RelayK1K2Status);
+    //printf("Gun%d RelayKPK2Status = %d \n", _GunIndex,pDcChargingInfo->RelayKPK2Status);
+}
+void SetRelayStatus()
+{
+    uint8_t _GunIndex = 0;
+    int isContinue = 1;
+    uint32_t sleepTime = 500000;
+    uint8_t status = 0;
+    char *usageMsg = "Usage:\n"
+                     "       set <index> <status>, ex: set 0 1\n"
+                     "       exit | c | C\n"
+                     "       help | ? | h\n"
+                     "\r\n";
+
+    ShmDcCommonData->pTest.relayflag = YES;
+    printf ("%s\n", usageMsg);
+
+    while (isContinue) {
+        if (readCmdKey(CMD_KEY_WAIT) == NO) {
+            sleep(sleepTime);
+            continue;
+        }
+
+        if (helpCmd() == YES) {
+            printf ("%s\n", usageMsg);
+            continue;
+        } else if (exitCmd() == YES) {
+            ShmDcCommonData->pTest.relayflag = NO;
+            ShmDcCommonData->pGunInfo[0].RelayTest = NO;
+            ShmDcCommonData->pGunInfo[1].RelayTest = NO;
+            sleep(1);
+            return;
+        } else if (strcmp(newString[0], "get") == 0) {
+            GetRelayStatus((char*)newString[1]);
+        }
+
+        if ((strcmp(newString[0], "set") != 0) &&
+                (strcmp(newString[1], "-1") == 0 ||
+                 strcmp(newString[1], "") == 0)
+           ) {
+            printf("argc 1 is error parameter\r\n");
+            continue;
+        }
+
+        if (strcmp(newString[0], "set") == 0) {
+            if (atoi(newString[2]) > 1 ||
+                    atoi(newString[2]) == -1 ) {
+                printf("set value overflow\r\n");
+                continue;
+            }
+        } else {
+            if (atoi(newString[2]) < 0 ) {
+                    printf("set value underflow\r\n");
+                    continue;
+                }
+        }
+
+        _GunIndex = atoi((char *)newString[1]);
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+        if (_GunIndex >= pSysConfig->TotalConnectorCount) {
+            printf("gun index over total connector\r\n");
+            continue;
+        }
+
+        if (strcmp(newString[0], "set") == 0) {//修改relay狀態
+            status = atoi((char *)newString[2]);
+            status ? (ShmDcCommonData->pGunInfo[_GunIndex].RelayTest = YES) : (ShmDcCommonData->pGunInfo[_GunIndex].RelayTest = NO);
+            printf("gun%d relay set %s\n",_GunIndex,ShmDcCommonData->pGunInfo[_GunIndex].RelayTest ? "ON" : "OFF");
+        }
+
+        usleep(sleepTime);
+    }//while
 
-    printf("RelayK1K2Status = %d \n", pDcChargingInfo->RelayK1K2Status);
-    printf("RelayKPK2Status = %d \n", pDcChargingInfo->RelayKPK2Status);
 }
 
 void FwUpdateFlagProc()
@@ -439,13 +586,6 @@ void FwUpdateFlagProc()
     pSysInfo->FirmwareUpdate = 0x01;
 }
 
-void CheckAcStatus(char *v1)
-{
-    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
-        printf("AC Status = %d \n", pSysInfo->AcContactorStatus);
-    }
-}
-
 void SetCableChkStatus(char *v1, char *v2)
 {
     int _index = atoi(v1);
@@ -502,18 +642,13 @@ void GetSystemInfo()
     pSysConfig->ShowInformation = YES;
 }
 
-void ChangeGunNum()
+void ChangeGunstate(char *v1,char *v2)
 {
-    if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount) {
-        pSysInfo->CurGunSelected += 1;
-        pSysInfo->CurGunSelectedByAc = NO_DEFINE;
-    } else if (pSysConfig->AcConnectorCount > 0 &&
-               pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
-        pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
-    } else {
-        pSysInfo->CurGunSelected = 0;
-        pSysInfo->CurGunSelectedByAc = NO_DEFINE;
-    }
+    int _index = atoi((char*)v1);
+    int status = atoi((char*)v2);
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+    pDcChargingInfo->SystemStatus = status;
+    printf("Change Gun%d status into %s",_index,GetStatusName(status));
 }
 
 void GetGunSelectedNum(char *v1)
@@ -541,12 +676,16 @@ void GetGunSelectedNum(char *v1)
 void SetFanSpeed(char *v1)
 {
     int speed = atoi(v1);
-    if(ShmDcCommonData->debugflag == YES) {
+    if(speed > 0 ) {
+        ShmDcCommonData->pTest.fanflag = YES;
         ShmFanModuleData->TestFanSpeed = speed;
         printf("Set Fan speed: %d \n",ShmFanModuleData->TestFanSpeed);
     }
-    else
-        printf("Please open debug mode\n");
+    else {
+        ShmFanModuleData->TestFanSpeed = 0;
+        ShmDcCommonData->pTest.fanflag = NO;
+        printf("Close Fan set\n");
+    }
 }
 
 void GetFanSpeed()
@@ -573,15 +712,6 @@ void SetGFDMode(char *v1)
     pSysConfig->AlwaysGfdFlag = mode;
 }
 
-void GetPsuTemp()
-{
-    for (uint8_t index = 0; index < ShmPsuData->GroupCount; index++) {
-        for (uint8_t count = 0; count < ShmPsuData->PsuGroup[index].GroupPresentPsuQuantity; count++) {
-            printf("PSU Temp = %d \n", ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp);
-        }
-    }
-}
-
 void GetAcInputVol()
 {
     printf("L1N_L12 = %f, L2N_L23 = %f, L3N_L31 = %f \n",
@@ -590,91 +720,6 @@ void GetAcInputVol()
            pSysInfo->InputVoltageT);
 }
 
-void GetPsuInformation(char *v1, char *v2, char *v3)
-{
-    printf("**********************AC Contact needed*************************\n");
-    if (strcmp(v1, "count") == 0) {
-        for (int i = 0; i < 4; i++) {
-            printf("Group Index = %d, Module Count = %d \n",
-                   i,
-                   ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity);
-        }
-    } else if (strcmp(v1, "ver") == 0) {
-        for (int i = 0; i < ShmPsuData->SystemPresentPsuQuantity; i++) {
-            printf("Psu Index = %d, PriVersion = %s, SecVersion = %s \n",
-                   i, ShmPsuData->PsuVersion[i].FwPrimaryVersion,
-                   ShmPsuData->PsuVersion[i].FwSecondVersion);
-        }
-
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            for (int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++) {
-                printf("Group Index = %d, Psu Index = %d, Version = %s \n",
-                       i,
-                       j,
-                       ShmPsuData->PsuGroup[i].PsuModule[j].FwVersion);
-            }
-        }
-    } else if (strcmp(v1, "cap") == 0) {
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            printf("Group Index = %d, MaxCur = %d, Power = %d \n",
-                   i,
-                   ShmPsuData->PsuGroup[i].GroupAvailableCurrent,
-                   ShmPsuData->PsuGroup[i].GroupAvailablePower);
-        }
-    } else if (strcmp(v1, "input") == 0) {
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            for (uint8_t count = 0; count < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; count++) {
-                printf("gp = %d, Index = %d, volR = %d, volS = %d, volT = %d \n",
-                       i,
-                       count,
-                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL1,
-                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL2,
-                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL3);
-            }
-        }
-    } else if (strcmp(v1, "output") == 0) {
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            printf("Group Index = %d, OutputV = %d, OutputC = %d \n",
-                   i,
-                   ShmPsuData->PsuGroup[i].GroupPresentOutputVoltage,
-                   ShmPsuData->PsuGroup[i].GroupPresentOutputCurrent);
-        }
-
-        for (int i = 0; i < pSysConfig->TotalConnectorCount; i++) {
-            //if (!FindChargingInfoData(i, &_chargingData[0])) {
-            //    printf ("FindChargingInfoData error\n");
-            //    continue;
-            //}
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-
-            printf("Form RB : Group Index = %d, OutputV = %f \n",
-                   i,
-                   pDcChargingInfo->FireChargingVoltage);
-        }
-    } else if (strcmp(v1, "test") == 0) {
-        int mode = atoi(v2);
-
-        if (mode >= _TEST_MODE && mode <= _TEST_MODE) {
-            ShmPsuData->Work_Step = mode;
-        }
-    } else if (strcmp(v1, "out") == 0) {
-        float vol = atof(v2);
-        float cur = atof(v3);
-
-        if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
-            //if (!FindChargingInfoData(0, &_chargingData[0])) {
-            //    printf ("FindChargingInfoData error\n");
-            //    return;
-            //}
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(0);
-
-            pDcChargingInfo->EvBatterytargetVoltage = vol;
-            pDcChargingInfo->EvBatterytargetCurrent = cur;
-        }
-    }
-    printf("*************************************************\n");
-}
-
 void GetConnectorCapInfo(char *v1)
 {
     int _GunIndex = atoi(v1);
@@ -833,12 +878,14 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
     }
     //kill ev task
     ShmDcCommonData->debugflag = YES;
+    ShmDcCommonData->pTest.chillerflag = NO;
+
     system("killall Module_EvComm");
 
     pSysInfo->CurGunSelected = _GunIndex;
 
     while (isContinue) {
-
+        memset(&ShmDcCommonData->pTest,0,sizeof(ShmDcCommonData->pTest));
         curGun = pSysInfo->CurGunSelected;
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
         if (!pDcChargingInfo->IsAvailable) {
@@ -852,19 +899,22 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
                 ShmDcCommonData->LcmPage = _PAGE_SELECT_PAY;
                 sleep(3);
-#if defined DD360Audi || SelectGunAction == 1
-                setConfirmSelGun(curGun);
-#endif //defined DD360Audi
+                //if (CheckDispenserGeneration() == _DISPENSER_GENERATION_3_5) {
+                    setConfirmSelGun(curGun);
+                //}
+
                 strcpy((char *)pSysConfig->UserId, "AutoStartCharging");
                 pDcChargingInfo->ConnectorPlugIn = 1;
                 printf ("[UnconditionalCharge - S_IDLE]\n");
                 pDcChargingInfo->Type = 9;
+                pDcChargingInfo->StartMethod = _CHARGING_START_AUTOSTART;
                 sleep(1);
 
             }
             if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
                 pSysInfo->StartToChargingFlag = 0x01;
                 pDcChargingInfo->SystemStatus = S_PREPARNING;
+                strcpy((char *)pSysConfig->UserId, "");
             }
             break;
 
@@ -880,10 +930,6 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             }
             //main 會在此階段判斷以下資料跳到下一個 state
             //用來得知 AC 是否有搭上 (搭上模組的資訊才會出來) 因為每次  AC_Contactor
-            //ShmPsuData->SystemPresentPsuQuantity;
-            //ShmPsuData->PsuGroup[gun_index].GroupPresentPsuQuantity;
-            //ShmPsuData->PsuGroup[gun_index].GroupAvailablePower;
-            //_chargingData[gun_index]->AvailableChargingPower;
 
             //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
             //sleep(10);
@@ -953,15 +999,15 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 
             //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
             //確定模組己升壓完成
-            if (pDcChargingInfo->GroundFaultStatus == 0x01 ||
-                    pDcChargingInfo->GroundFaultStatus == 0x03) {
+            if (pDcChargingInfo->GroundFaultStatus == GFD_PASS ||
+                    pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
                 printf ("First Ground Fault State (%d)\n",
                         pDcChargingInfo->GroundFaultStatus);
                 printf ("Wait K1K2 = %f \n", pDcChargingInfo->PresentChargingVoltage);
                 sleep(5);
                 //EV done
                 pDcChargingInfo->SystemStatus = S_CHARGING;
-            } else if (pDcChargingInfo->GroundFaultStatus > 0x02) {
+            } else if (pDcChargingInfo->GroundFaultStatus > GFD_FAIL) {
                 printf ("First Ground Fault check Fail (%d)\n",
                         pDcChargingInfo->GroundFaultStatus);
                 pDcChargingInfo->SystemStatus = S_TERMINATING;
@@ -976,6 +1022,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                     //充電電壓電流
                     pDcChargingInfo->EvBatterytargetVoltage = _Voltage;
                     pDcChargingInfo->EvBatterytargetCurrent = _Current;
+                    pDcChargingInfo->EvBatteryMaxVoltage = _Voltage * 10;
                 } else {
                     _curAutoRunCount = 0;
                     gettimeofday(&_autoTime, NULL);
@@ -1070,7 +1117,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 ((float)((pDcChargingInfo->PresentChargingVoltage) *
                          (pDcChargingInfo->PresentChargingCurrent)) / 1000);
 
-            if (pDcChargingInfo->GroundFaultStatus == 0x02) {
+            if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
                 printf ("Charging Ground Fault check Fail (%d)\n",
                         pDcChargingInfo->GroundFaultStatus);
                 pDcChargingInfo->SystemStatus = S_TERMINATING;
@@ -1229,7 +1276,6 @@ int printTimeMsg(const char *fmt, ...)
     va_list args;
     struct timeb  SeqEndTime;
     struct tm *tm;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
 
     va_start(args, fmt);
     rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
@@ -1323,7 +1369,6 @@ static void resdGunAndChillerTemp(void)
 }
 static void writeOTPTemp(void)
 {
-    uint8_t _GunIndex = 0;
     int isContinue = 1;
     uint32_t sleepTime = 500000;
     char *usageMsg = "Usage:\n"
@@ -1373,14 +1418,15 @@ static void writeOTPTemp(void)
 
 void writeChillerStatus(char *v1)
 {
-    if (ShmDcCommonData->debugflag == YES) {
         ShmDcCommonData->chillerCtrl = atoi(newString[1]);
-        if (ShmDcCommonData->chillerCtrl)
+        if (ShmDcCommonData->chillerCtrl) {
+            ShmDcCommonData->pTest.chillerflag = YES;
             printf("Chiller set on\n");
-        else
+        } else {
+            ShmDcCommonData->pTest.chillerflag = NO;
             printf("Chiller set off\n");
-    } else
-        printf("Please open Debug mode\n");
+        }
+
 }
 
 void showNetworkPage(char* v1)
@@ -1538,16 +1584,8 @@ static void writeGunAndChillerTemp(void)
 
 void setledcolor(int on_off)
 {
-    if (on_off)
-        ShmDcCommonData->pTest.ledflag = TRUE;
-    else {
-        ShmDcCommonData->pTest.ledflag = FALSE;
-        return;
-    }
-
     int isContinue = 1;
     uint32_t sleepTime = 500000;
-    uint32_t color_value;
     char* usageMsg = "Usage:\n"
         "       r	0~100\n"
         "       g	0~100\n"
@@ -1555,7 +1593,8 @@ void setledcolor(int on_off)
         "       exit | c | C\n"
         "       help | ? | h\n"
         "\r\n";
-
+    printf("%s\n", usageMsg);
+    ShmDcCommonData->pTest.ledflag = TRUE;
     while (isContinue) {
         if (readCmdKey(CMD_KEY_WAIT) == NO) {
             sleep(sleepTime);
@@ -1627,13 +1666,12 @@ void setlcmtest(char* v1)
         return;
     }
 
-    uint8_t _GunIndex = 0;
     int isContinue = 1;
     uint32_t sleepTime = 500000;
     char *usageMsg = "Usage:\n"
 			        "\n ===== main menu =================================="
                     "\n  1: publish_profile_sample."
-                    "\n  2: publish_upgrade_sample."
+                    "\n  2: upgrade_lcm_sdcard."
                     "\n  3: publish_restart_sample."
                     "\n  4: publish_power_saving_sample."
                     "\n  5: publish_back_dimming_sample."
@@ -1647,6 +1685,7 @@ void setlcmtest(char* v1)
                     "\n  13: publish_trigger_report_status."
                     "\n  14: publish_qr_code_image."
                     "\n  15: publish_power_saving_wake"
+                    "\n  15: upgrade_lcm_apk"
                     "\n =================================================="
                     "\n  Please input item to test: \n"
                      "       exit | c | C\n"
@@ -1701,7 +1740,6 @@ void ShowPowerConsumption(char* v1)
 }
 int main(void)
 {
-    uint8_t _GunIndex = 0;
     int isContinue = 1;
     char *usageMsg = "Usage:\n"
                      "       state <index>                     : get gun state\n"
@@ -1712,11 +1750,11 @@ int main(void)
                      "       self                              : self test state (x)\n"
                      "       ver| v | -v                       : version of board (407 or relay or other)\n"
                      "       update                            : update firmware\n"
-                     "       ac                                : get ac relay state (x) \n"
                      "       cable <index> <state>             : set ground fault state\n"
                      "       pow <index> <power>               : set power value\n"
                      "       model                             : get system information\n"
-                     "       temp                              : get PSU temperature\n"
+                     "       relay                             : get relay information\n"
+                     "       setrelay                          : set relay on/off\n"
                      "       fan <speed>                       : set fan board speed\n"
                      "       strchg <auto>                     : auto test charging\n"
                      "       strchg <index> <voltage <current> : select gun test charging\n"
@@ -1753,17 +1791,10 @@ int main(void)
     ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
     ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
     ShmLedModuleData = (struct LedModuleData *)GetShmLedModuleData();
-    ShmPsuData = (struct PsuData *)GetShmPsuData();
     ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
     ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
-//    for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
-//        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-//        pDcChargingInfo->SystemStatus = S_IDLE;
-//    }
-
     while (isContinue) {
 
         if (readCmdKey(CMD_KEY_WAIT) == NO) {
@@ -1771,13 +1802,8 @@ int main(void)
         }
 
         if (strcmp(newString[0], "state") == 0) {
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0) {
-                continue;
-            }
-
             // 槍狀態
-            RunStatusProc(newString[1], newString[2]);
+            RunStatusProc();
         } else if (strcmp(newString[0], "card") == 0) {
             // 刷卡狀態
             RunCardProc(newString[1], newString[2]);
@@ -1812,9 +1838,6 @@ int main(void)
         } else if (strcmp(newString[0], "update") == 0) {
             // 更新
             FwUpdateFlagProc(newString[1]);
-        } else if (strcmp(newString[0], "ac") == 0) {
-            // AC contactor 狀態
-            CheckAcStatus(newString[1]);
         } else if (strcmp(newString[0], "cable") == 0) {
             if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
                 continue;
@@ -1836,7 +1859,7 @@ int main(void)
             GetGunSelectedNum(newString[1]);
         } else if (strcmp(newString[0], "change") == 0) {
             // 模擬按鈕改變選槍
-            ChangeGunNum();
+            ChangeGunstate(newString[1],newString[2]);
         } else if (strcmp(newString[0], "fan") == 0) {
             // 設定風扇速度
             SetFanSpeed(newString[1]);
@@ -1849,21 +1872,9 @@ int main(void)
         } else if (strcmp(newString[0], "gfd") == 0) {
             // 設定盲沖使用 GFD 功能
             SetGFDMode(newString[1]);
-        } else if (strcmp(newString[0], "temp") == 0) {
-            // 取得 PSU 溫度
-            GetPsuTemp();
         } else if (strcmp(newString[0], "acin") == 0) {
             // 取得三向輸入電壓
             GetAcInputVol();
-        } else if (strcmp(newString[0], "psu") == 0) {
-            //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0) {
-                printf ("PSU : Param fail..Please retry again......\n");
-                continue;
-            }
-            // 取得 PSU 資訊
-            GetPsuInformation(newString[1], newString[2], newString[3]);
         } else if (strcmp(newString[0], "cap") == 0) {
             GetConnectorCapInfo(newString[1]);
         } else if (strcmp(newString[0], "error") == 0) {
@@ -1872,6 +1883,8 @@ int main(void)
             GetAuthorizeFlag(newString[1]);
         } else if (strcmp(newString[0], "relay") == 0) {
             GetRelayStatus(newString[1]);
+        } else if (strcmp(newString[0], "setrelay") == 0) {
+            SetRelayStatus(newString[1],newString[2]);
         } else if (strcmp(newString[0], "ccid") == 0) {
             if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
                     strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
@@ -1911,7 +1924,7 @@ int main(void)
         } else if (strcmp(newString[0], "powerconsumption") == 0) { // Power Consumption
             ShowPowerConsumption(newString[1]);
         } else if (strcmp(newString[0], "led") == 0) {              // LED
-            setledcolor(newString[1]);
+            setledcolor(atoi(newString[1]));
         } else if (strcmp(newString[0], "l") == 0) {
         	ShmPrimaryMcuData->InputDet.bits.Button1 = BTN_PRESS;
         	sleep(1);
@@ -1921,9 +1934,9 @@ int main(void)
         	sleep(1);
         	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_RELEASE;
         } else if (strcmp(newString[0], "c") == 0) {
-        	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_PRESS;
+        	ShmPrimaryMcuData->InputDet.bits.Key3 = BTN_PRESS;
         	sleep(1);
-        	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_RELEASE;
+        	ShmPrimaryMcuData->InputDet.bits.Key3 = BTN_RELEASE;
         } else if (strcmp(newString[0], "DcMeter") == 0) {
 
         } else if (strcmp(newString[0], "lcmtest") == 0) {

BIN
EVSE/Projects/DD360/Apps/Script/LcmSet.db


+ 1 - 1
EVSE/Projects/DD360/Apps/ShareMemory/shmMem.c

@@ -468,7 +468,7 @@ void InitialShareMemoryInfo(void)
            ARRAY_SIZE(pSysConfig->CsuBootLoadFwRev));
 
     strcpy((char *) pSysConfig->UserId, "");
-    pSysConfig->QRCodeMadeMode = NO; //DS60-120 add
+    //pSysConfig->QRCodeMadeMode = NO; //DS60-120 add
     pSysConfig->SwitchDebugFlag = NO;
     pSysConfig->AlwaysGfdFlag = NO;
 

+ 94 - 0
EVSE/Projects/DD360/Apps/common.c

@@ -2,8 +2,13 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
+#include <sys/time.h>
+#include <sys/timeb.h>
+#include <time.h>
 
 #include "Config.h"
+#include "Define/define.h"
+#include "ShareMemory/shmMem.h"
 
 //------------------------------------------------------------------------------
 void trim(char *s)
@@ -58,3 +63,92 @@ void split(char **arr, char *str, const char *del)
         s = strtok(NULL, del);
     }
 }
+
+uint8_t CheckDispenserGeneration()
+{
+	uint8_t result = _DISPENSER_GENERATION_3;
+    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+
+	if (pSysConfig->ModelName[11] == 'F' || pSysConfig->ModelName[11] == 'D') {
+        result = _DISPENSER_GENERATION_3_5;
+    }
+    
+	return result;
+}
+
+uint8_t CheckCustomer()
+{
+	uint8_t result = _CUSTOM_ZEROVA;
+	char _buf[3] = {0};
+    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+	memcpy(_buf, &pSysConfig->ModelName[12], 2);
+	if (strcmp(_buf, "AD") == EQUAL || strcmp(_buf, "A7") == EQUAL)
+		result = _CUSTOM_AUDI;
+    else if (strcmp(_buf, "OL") == EQUAL || strcmp(_buf, "O7") == EQUAL)
+		result = _CUSTOM_SHELL;
+    
+	return result;
+}
+
+
+unsigned long GetClockTimeoutValue(struct timespec _start_time)
+{
+    struct timespec ts_end;
+    unsigned long ret = 0;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000)));
+
+    return ret;
+}
+void GetClockTime(struct timespec *_now_time)
+{
+    clock_gettime(CLOCK_MONOTONIC, _now_time);
+}
+
+bool IntoChargeProcess(int status)
+{
+    if ((status >= S_AUTHORIZING && status <= S_CHARGING) ||
+        status == S_CCS_PRECHARGE_ST0 || status == S_CCS_PRECHARGE_ST1) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+bool IntoOperateProcess(int status)
+{
+    if ((status >= S_AUTHORIZING && status <= S_ALARM) ||
+        status == S_CCS_PRECHARGE_ST0 || status == S_CCS_PRECHARGE_ST1) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+char* GetStatusName(int status)
+{
+    switch (status) {
+        case S_BOOTING: return "BOOTING"; break;
+        case S_IDLE:     return "IDLE"; break;
+        case S_AUTHORIZING: return "AUTHORIZING"; break;
+        case S_REASSIGN_CHECK: return "REASSIGN_CHECK"; break;
+        case S_REASSIGN: return "REASSIGN"; break;
+        case S_PREPARNING: return "PREPARING"; break;
+        case S_PREPARING_FOR_EV: return "PREPARING_FOR_EV"; break;
+        case S_PREPARING_FOR_EVSE: return "PREPARING_FOR_EVSE"; break;
+        case S_CHARGING: return "CHARGING"; break;
+        case S_TERMINATING: return "TERMINATING"; break;
+        case S_COMPLETE: return "COMPLETE"; break;
+        case S_ALARM: return "ALARM"; break;
+        case S_FAULT: return "FAULT"; break;
+        case S_RESERVATION: return "RESERVATION"; break;
+        case S_BOOKING: return "BOOKNG"; break;
+        case S_MAINTAIN: return "MAINTAIN"; break;
+        case S_DEBUG: return "DEBUG"; break;
+        case S_CCS_PRECHARGE_ST0: return "CCS_PRECHARGE_ST0"; break;
+        case S_CCS_PRECHARGE_ST1: return "CCS_PRECHARGE_ST1"; break;
+        case S_UPDATE: return "UPDATE"; break;
+        case S_NONE: return "NONE"; break;
+    }
+    return "";
+}

+ 7 - 1
EVSE/Projects/DD360/Apps/common.h

@@ -9,5 +9,11 @@ void trim(char *s);
 int mystrcmp(char *p1, char *p2);
 void substr(char *dest, const char *src, uint32_t start, uint32_t cnt);
 void split(char **arr, char *str, const char *del);
-
+uint8_t CheckDispenserGeneration();
+uint8_t CheckCustomer();
+void GetClockTime(struct timespec *_now_time);
+unsigned long GetClockTimeoutValue(struct timespec _start_time);
+bool IntoChargeProcess(int status);
+bool IntoOperateProcess(int status);
+char* GetStatusName(int status);
 #endif /* _COMMON_H_ */

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


BIN
EVSE/Projects/DD360/output/FactoryConfig


BIN
EVSE/Projects/DD360/output/LcmSet.db


BIN
EVSE/Projects/DD360/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360/output/Module_DoComm


BIN
EVSE/Projects/DD360/output/Module_EvComm


BIN
EVSE/Projects/DD360/output/Module_EventLogging


BIN
EVSE/Projects/DD360/output/Module_InternalComm


BIN
EVSE/Projects/DD360/output/Module_LcmControl


BIN
EVSE/Projects/DD360/output/Module_LcmWistronControl


BIN
EVSE/Projects/DD360/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360/output/Module_UpdateFW


BIN
EVSE/Projects/DD360/output/ReadCmdline


BIN
EVSE/Projects/DD360/output/main


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно