Pārlūkot izejas kodu

2021.04.27 / Jerry Wang

Actions:
1. Debug GBT charging relay did not catch up issue.
2. The model name and serial nubmer can't restore by WEB modify.

Files:
1. As follow as commit history.
Jerry_Wang 4 gadi atpakaļ
vecāks
revīzija
f4669e4ace
48 mainītis faili ar 833 papildinājumiem un 1737 dzēšanām
  1. 37 14
      EVSE/Modularization/Module_RatedCurrent.c
  2. 31 5
      EVSE/Modularization/Module_RatedCurrent.h
  3. 8 0
      EVSE/Projects/DD360/Apps/FactoryConfig.c
  4. 71 145
      EVSE/Projects/DD360/Apps/ReMain.c
  5. 3 155
      EVSE/Projects/DD360/Apps/ReModule_EvComm.c
  6. 142 176
      EVSE/Projects/DD360/Apps/ReModule_InternalComm.c
  7. 0 64
      EVSE/Projects/DD360/Apps/ReModule_PrimaryComm.c
  8. BIN
      EVSE/Projects/DD360/Images/ramdisk.gz
  9. BIN
      EVSE/Projects/DD360/output/DoComm
  10. BIN
      EVSE/Projects/DD360/output/FactoryConfig
  11. BIN
      EVSE/Projects/DD360/output/Module_EvComm
  12. BIN
      EVSE/Projects/DD360/output/Module_EventLogging
  13. BIN
      EVSE/Projects/DD360/output/Module_InternalComm
  14. BIN
      EVSE/Projects/DD360/output/Module_LcmControl
  15. BIN
      EVSE/Projects/DD360/output/Module_PrimaryComm
  16. BIN
      EVSE/Projects/DD360/output/ReadCmdline
  17. BIN
      EVSE/Projects/DD360/output/main
  18. 8 0
      EVSE/Projects/DD360Audi/Apps/FactoryConfig.c
  19. 71 145
      EVSE/Projects/DD360Audi/Apps/ReMain.c
  20. 96 253
      EVSE/Projects/DD360Audi/Apps/ReModule_EvComm.c
  21. 142 176
      EVSE/Projects/DD360Audi/Apps/ReModule_InternalComm.c
  22. 0 64
      EVSE/Projects/DD360Audi/Apps/ReModule_PrimaryComm.c
  23. BIN
      EVSE/Projects/DD360Audi/Images/ramdisk.gz
  24. BIN
      EVSE/Projects/DD360Audi/output/DoComm
  25. BIN
      EVSE/Projects/DD360Audi/output/FactoryConfig
  26. BIN
      EVSE/Projects/DD360Audi/output/Module_EvComm
  27. BIN
      EVSE/Projects/DD360Audi/output/Module_EventLogging
  28. BIN
      EVSE/Projects/DD360Audi/output/Module_InternalComm
  29. BIN
      EVSE/Projects/DD360Audi/output/Module_LcmControl
  30. BIN
      EVSE/Projects/DD360Audi/output/Module_PrimaryComm
  31. BIN
      EVSE/Projects/DD360Audi/output/ReadCmdline
  32. BIN
      EVSE/Projects/DD360Audi/output/main
  33. 8 0
      EVSE/Projects/DD360ComBox/Apps/FactoryConfig.c
  34. 71 145
      EVSE/Projects/DD360ComBox/Apps/ReMain.c
  35. 3 155
      EVSE/Projects/DD360ComBox/Apps/ReModule_EvComm.c
  36. 142 176
      EVSE/Projects/DD360ComBox/Apps/ReModule_InternalComm.c
  37. 0 64
      EVSE/Projects/DD360ComBox/Apps/ReModule_PrimaryComm.c
  38. BIN
      EVSE/Projects/DD360ComBox/Apps/UnsafetyOutputTask
  39. BIN
      EVSE/Projects/DD360ComBox/Images/ramdisk.gz
  40. BIN
      EVSE/Projects/DD360ComBox/output/DoComm
  41. BIN
      EVSE/Projects/DD360ComBox/output/FactoryConfig
  42. BIN
      EVSE/Projects/DD360ComBox/output/Module_EvComm
  43. BIN
      EVSE/Projects/DD360ComBox/output/Module_EventLogging
  44. BIN
      EVSE/Projects/DD360ComBox/output/Module_InternalComm
  45. BIN
      EVSE/Projects/DD360ComBox/output/Module_LcmControl
  46. BIN
      EVSE/Projects/DD360ComBox/output/Module_PrimaryComm
  47. BIN
      EVSE/Projects/DD360ComBox/output/ReadCmdline
  48. BIN
      EVSE/Projects/DD360ComBox/output/main

+ 37 - 14
EVSE/Modularization/Module_RatedCurrent.c

@@ -10,6 +10,8 @@
 
 #include "Module_RatedCurrent.h"
 
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 #define PASS                                    (1)
 #define FAIL                                    (-1)
@@ -207,6 +209,9 @@ static uint16_t exchangeRatingCur(uint32_t key)
         return RC_125A; //rating current 125A
 
     //200A U
+    case DD_CE_180_U:
+    case DD_CE_360_U:
+
     case DS_UL_90_U:
     case DS_UL_120_U:
     case DS_UL_150_U:
@@ -217,6 +222,8 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_CNS_120_U:
     case DS_CNS_150_U:
     case DS_CNS_180_U:
+
+    case DD_CNS_180_U:
     case DD_CNS_360_U:
 
     //200A E
@@ -231,6 +238,7 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_CE_150_K:
     case DS_CE_180_K:
 
+    case DD_CE_180_K:
     case DD_CE_360_K:
 
     case DS_UL_90_K:
@@ -238,6 +246,7 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_UL_150_K:
     case DS_UL_180_K:
 
+    case DD_UL_180_K:
     case DD_UL_360_K:
         return RC_200A; //rating current 200A
 
@@ -251,6 +260,7 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_CE_150_T:
     case DS_CE_180_T:
 
+    case DD_CE_180_T:
     case DD_CE_360_T:
 
     case DS_UL_90_T:
@@ -258,6 +268,7 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_UL_150_T:
     case DS_UL_180_T:
 
+    case DD_UL_180_T:
     case DD_UL_360_T:
 
     case DS_CNS_90_T:
@@ -265,6 +276,7 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_CNS_150_T:
     case DS_CNS_180_T:
 
+    case DD_CNS_180_T:
     case DD_CNS_360_T:
 
     //300A D
@@ -272,6 +284,8 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_CE_120_D:
     case DS_CE_150_D:
     case DS_CE_180_D:
+
+    case DD_CE_180_D:
     case DD_CE_360_D:
 
     case DS_UL_90_D:
@@ -279,6 +293,7 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_UL_150_D:
     case DS_UL_180_D:
 
+    case DD_UL_180_D:
     case DD_UL_360_D:
 
     case DS_CNS_90_D:
@@ -286,14 +301,24 @@ static uint16_t exchangeRatingCur(uint32_t key)
     case DS_CNS_150_D:
     case DS_CNS_180_D:
 
+    case DD_CNS_180_D:
     case DD_CNS_360_D:
         return RC_300A;
 
     //500A V
-    case DD_UL_360_V:
+    case DD_CE_180_V:
+    case DD_UL_180_V:
+    case DD_CNS_180_V:
 
+    case DD_CE_360_V:
+    case DD_UL_360_V:
     case DD_CNS_360_V:
 
+    case DO_CE_180_V:
+    case DO_UL_180_V:
+    case DO_CNS_180_V:
+
+    case DO_CE_360_V:
     case DO_UL_360_V:
     case DO_CNS_360_V:
 
@@ -407,7 +432,6 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
     uint8_t reguKey = 0;
     uint8_t powerKey = 0;
     uint8_t gunTypeKey = 0;
-    uint16_t powerVal = 0;
     uint16_t ratingCurVal = 0;
     int i = 0;
     uint32_t ret = 0;
@@ -433,6 +457,9 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
     strncpy(power, &pModuleName[4], 2);
     power[2] = '\0';
 
+    //get max power value
+    powerKey = keyfromstring(&power[0], &powerTable[0], sizeof(powerTable) / sizeof(SymStruct));
+    pParsingInfo->Power = exchangePowerValue(powerKey);
 
     pParsingInfo->GetGunCount = 0;
     for (i = 0; i < sizeof(pParsingInfo->ParsingInfo) / sizeof(GunRateCurInfo); i++) {
@@ -441,9 +468,9 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
         if (i == 0) {
             gunTypeIndex = DC_ONE;
         } else if (i == 1) {
-            gunTypeIndex = AC_ONE;
-        } else if (i == 2) {
             gunTypeIndex = DC_SEC;
+        } else if (i == 2) {
+            gunTypeIndex = AC_ONE;
         }
 
         strncpy(gunType, &pModuleName[gunTypeIndex], 1);
@@ -451,29 +478,26 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
 
         modelKey = keyfromstring(&model[0], &modelTable[0], sizeof(modelTable) / sizeof(SymStruct));
         reguKey = keyfromstring(&regulation[0], &regulationTable[0], sizeof(regulationTable) / sizeof(SymStruct));
-        powerKey = keyfromstring(&power[0], &powerTable[0], sizeof(powerTable) / sizeof(SymStruct));
         if ((gunTypeKey = keyfromstring(&gunType[0], &gunTypeTable[0], sizeof(gunTypeTable) / sizeof(SymStruct))) == GUN_TYPE_0) {
-            log_error("The type of gun is none\r\n");
+            log_error("Rated Current Parsing the type of gun is none\r\n");
             continue;
+            //return FAIL;
         }
 
         ret = 0;
         ret = ((modelKey << 24) | (reguKey << 16) | (powerKey << 8) | gunTypeKey);
         ratingCurVal = exchangeRatingCur(ret);
         if (ratingCurVal == RC_0A) {
-            log_error("Model name format none match\r\n");
-            continue;
-            //return FAIL;
+            log_error("Rated Current Parsing model name format none match\r\n");
+            return FAIL;
         }
 
         memset((uint8_t *)&fGunAndVol, 0, sizeof(GunTypeAndVolInfo));
         exchangeGunTypeAndVolValue(gunTypeKey, &fGunAndVol);
-        powerVal = exchangePowerValue(powerKey);
 
         pGunRateCurInfo->GunType = fGunAndVol.GunType;
         pGunRateCurInfo->Current = ratingCurVal;
         pGunRateCurInfo->Voltage = fGunAndVol.GunVoltage;
-        pGunRateCurInfo->Power = powerVal;
 
         pParsingInfo->GetGunCount++;
 
@@ -483,7 +507,6 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
         //         pGunRateCurInfo->Current,
         //         pGunRateCurInfo->Voltage,
         //         pGunRateCurInfo->Power);
-
     }
 
     return PASS;
@@ -505,7 +528,7 @@ void TestParsingRatingCurrent(void)
                  fParsingRateCur.ParsingInfo[i].GunType,
                  fParsingRateCur.ParsingInfo[i].Current,
                  fParsingRateCur.ParsingInfo[i].Voltage,
-                 fParsingRateCur.ParsingInfo[i].Power);
+                 fParsingRateCur.Power);
     }
     //log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
     //         0,
@@ -522,6 +545,6 @@ void TestParsingRatingCurrent(void)
                  fParsingRateCur.ParsingInfo[i].GunType,
                  fParsingRateCur.ParsingInfo[i].Current,
                  fParsingRateCur.ParsingInfo[i].Voltage,
-                 fParsingRateCur.ParsingInfo[i].Power);
+                 fParsingRateCur.Power);
     }
 }

+ 31 - 5
EVSE/Modularization/Module_RatedCurrent.h

@@ -1,6 +1,10 @@
 #ifndef _MODULE_NAME_PARSING_H_
 #define _MODULE_NAME_PARSING_H_
 
+//------------------------------------------------------------------------------
+#include <stdint.h>
+
+//------------------------------------------------------------------------------
 #define BADKEY                                  (-1)
 
 //------------------------------------------------------------------------------
@@ -135,6 +139,9 @@
 #define DS_CNS_180_J                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_J))
 
 //U
+#define DD_CE_180_U                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_U))
+#define DD_CE_360_U                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_U))
+
 #define DW_UL_30_U                              ((uint32_t)((MODEL_DW << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_U))
 #define DM_UL_30_U                              ((uint32_t)((MODEL_DM << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_U))
 
@@ -147,6 +154,7 @@
 #define DS_UL_150_U                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_U))
 #define DS_UL_180_U                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_U))
 
+#define DD_UL_180_U                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_U))
 #define DD_UL_360_U                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_U))
 
 #define DS_CNS_60_U                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_60W << 8) | GUN_TYPE_U))
@@ -155,15 +163,24 @@
 #define DS_CNS_150_U                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_U))
 #define DS_CNS_180_U                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_U))
 
-#define DD_CNS_360_U                             ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_U))
+#define DD_CNS_180_U                             ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_U))
+#define DD_CNS_360_U                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_U))
 
 //V
-#define DD_UL_360_V                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+#define DD_CE_180_V                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_V))
+#define DD_UL_180_V                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_V))
+#define DD_CNS_180_V                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_V))
 
+#define DD_CE_360_V                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+#define DD_UL_360_V                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_V))
 #define DD_CNS_360_V                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_V))
 
-#define DO_UL_360_V                             ((uint32_t)((MODEL_DO << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+#define DO_CE_180_V                             ((uint32_t)((MODEL_DO << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_V))
+#define DO_UL_180_V                             ((uint32_t)((MODEL_DO << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_V))
+#define DO_CNS_180_V                            ((uint32_t)((MODEL_DO << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_V))
 
+#define DO_CE_360_V                             ((uint32_t)((MODEL_DO << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+#define DO_UL_360_V                             ((uint32_t)((MODEL_DO << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_V))
 #define DO_CNS_360_V                            ((uint32_t)((MODEL_DO << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_V))
 
 //E
@@ -193,6 +210,7 @@
 #define DS_CE_150_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_T))
 #define DS_CE_180_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_T))
 
+#define DD_CE_180_T                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_T))
 #define DD_CE_360_T                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_T))
 
 #define DS_UL_90_T                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_T))
@@ -200,6 +218,7 @@
 #define DS_UL_150_T                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_T))
 #define DS_UL_180_T                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_T))
 
+#define DD_UL_180_T                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_T))
 #define DD_UL_360_T                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_T))
 
 #define DS_CNS_90_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_90W << 8) | GUN_TYPE_T))
@@ -207,6 +226,7 @@
 #define DS_CNS_150_T                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_T))
 #define DS_CNS_180_T                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_T))
 
+#define DD_CNS_180_T                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_T))
 #define DD_CNS_360_T                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_T))
 
 //D
@@ -215,6 +235,7 @@
 #define DS_CE_150_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_D))
 #define DS_CE_180_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_D))
 
+#define DD_CE_180_D                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_D))
 #define DD_CE_360_D                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_D))
 
 #define DS_UL_90_D                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_D))
@@ -222,6 +243,7 @@
 #define DS_UL_150_D                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_D))
 #define DS_UL_180_D                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_D))
 
+#define DD_UL_180_D                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_D))
 #define DD_UL_360_D                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_D))
 
 #define DS_CNS_90_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_90W << 8) | GUN_TYPE_D))
@@ -229,6 +251,7 @@
 #define DS_CNS_150_D                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_D))
 #define DS_CNS_180_D                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_D))
 
+#define DD_CNS_180_D                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_D))
 #define DD_CNS_360_D                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_D))
 
 //K
@@ -237,6 +260,7 @@
 #define DS_CE_150_K                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_K))
 #define DS_CE_180_K                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_K))
 
+#define DD_CE_180_K                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_K))
 #define DD_CE_360_K                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_K))
 
 #define DS_UL_90_K                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_K))
@@ -244,6 +268,7 @@
 #define DS_UL_150_K                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_K))
 #define DS_UL_180_K                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_K))
 
+#define DD_UL_180_K                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_K))
 #define DD_UL_360_K                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_K))
 
 //M
@@ -287,13 +312,14 @@ typedef struct StGunRateCurInfo {
     uint8_t GunType;
     uint16_t Current;       //* 0.1A
     uint16_t Voltage;       //* 0.1V
-    uint16_t Power;
-    uint8_t Reserved;
+    uint8_t Reserved[3];
 } GunRateCurInfo;
 
 typedef struct StParsingRatingCur {
     uint8_t GetGunCount;
+    uint16_t Power;
     GunRateCurInfo ParsingInfo[3];
+    uint8_t Reserved;
 } ParsingRatedCur;
 
 //------------------------------------------------------------------------------

+ 8 - 0
EVSE/Projects/DD360/Apps/FactoryConfig.c

@@ -229,6 +229,14 @@ int main(int argc, char *argv[])
         helpOutput();
     }
 
+    if (argc == 4) {
+        strcpy((char *)SysConfig.ModelName, argv[2]);
+        strcpy((char *)SysConfig.SerialNumber, argv[3]);
+    } else {
+        strcpy((char *)SysConfig.ModelName, "DDYC182V0UE2AD");
+        strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
+    }
+
     /*
      * Configuration bin file generate
     */

+ 71 - 145
EVSE/Projects/DD360/Apps/ReMain.c

@@ -102,11 +102,6 @@ int whileLoopTime = 10000; // 10 ms
 int wtdFd = -1;
 byte _authorizeIndex = NO_DEFINE;
 
-#if defined METER_ENABLE
-bool relayWeldingCheck = false;
-bool relayDrivingCheck = false;
-#endif //defined METER_ENABLE
-
 bool IsAuthorizingMode();
 void ClearAuthorizedFlag();
 bool isDetectPlugin();
@@ -160,11 +155,6 @@ struct ChargingInfoData         *ac_chargingInfo[AC_QUANTITY];
 struct timeb                    startChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeb                    endChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-#if defined METER_ENABLE
-struct MeterInformation         *ShmCsuMeterData;
-struct DcCommonInformation      *ShmDcCommonData;
-#endif //defined METER_ENABLE
-
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
 static AudiCustInfo             *gAudiCustInfo = NULL; //Jerry add
 #endif //defined DD360Audi
@@ -812,22 +802,6 @@ int CreateShareMemory()
     }
     // memset(ShmOCPP16Data,0,sizeof(struct OCPP16Data));
 
-#if defined METER_ENABLE
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-    memset(ShmCsuMeterData, 0, sizeof(struct MeterInformation));
-
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-    memset(ShmDcCommonData, 0, sizeof(struct DcCommonInformation));
-#endif //defined METER_ENABLE
-
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     //creat Audi customization info
     if ((MeterSMId = shmget(ShmAudiCustInfoKey, sizeof(AudiCustInfo), IPC_CREAT | 0777)) < 0) {
@@ -1617,10 +1591,6 @@ void InitialShareMemoryInfo()
     ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag = NO;
     ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag = NO;
 
-#if defined METER_ENABLE
-    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V015S0; //DS60-120
-#endif //defined METER_ENABLE
-
     log_info("3InitialShareMemoryInfo done...\r\n");
 }
 
@@ -3645,14 +3615,7 @@ bool CheckConnectorTypeStatus()
                 if (type == NO_DEFINE) {
                     type = chargingInfo[gunIndex]->Type;
                 }
-#if defined METER_ENABLE
-                else {
-                    // 雙槍都是同一個 type
-                    if (type == chargingInfo[gunIndex]->Type) {
-                        ShmDcCommonData->SysGunAreSameType = YES;
-                    }
-                }
-#endif //METER_ENABLE
+
                 if (chargingInfo[gunIndex]->Evboard_id == 0x00) {
                     result = false;
                 }
@@ -4244,7 +4207,7 @@ void GetSystemTime()
 //          date[12], date[13]);
 }
 
-void CheckFactoryConfigFunction()
+void CheckFactoryConfigFunction(void)
 {
     char Buf[256] = {0};
 
@@ -5717,10 +5680,7 @@ int main(void)
 
         if ((GetTimeoutValue(_cmdMainPriority_time) / 1000) > 5000) {
             CheckTask();
-#if defined METER_ENABLE
-            relayWeldingCheck = false;
-            relayDrivingCheck = false;
-#endif //defined METER_ENABLE
+
             for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++) {
                 //if (chargingInfo[_index]->SystemStatus == S_CHARGING) {
                 //    CheckSmartChargeProfile(_index);
@@ -5740,28 +5700,10 @@ int main(void)
                         _ocppProfileChkFlag++;
                     }
                 }
-
-#if defined METER_ENABLE
-                if (ShmDcCommonData->SysGunAreSameType == YES) {
-                    if (ShmDcCommonData->GunRelayWeldingOccur[_index] == YES) {
-                        relayWeldingCheck = true;
-                    }
-                    if (ShmDcCommonData->GunRelayDrivingOccur[_index] == YES) {
-                        relayDrivingCheck = true;
-                    }
-                }
-#endif //defined METER_ENABLE
             }
             gettimeofday(&_cmdMainPriority_time, NULL);
         }
 
-#if defined METER_ENABLE
-        if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-            CheckStatusOfMeter();
-        }
-#endif //defined METER_ENABLE
-
         for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++) {
             autoStartChargingForComBox(gun_index); //for DD360ComBox
 
@@ -5769,10 +5711,6 @@ int main(void)
             CheckErrorOccurStatus(gun_index);
             ChkOcppStatus(gun_index);
 
-#if defined METER_ENABLE
-            CheckRelayWeldingOrDrivingFault(gun_index);
-#endif //defined METER_ENABLE
-
             if ((chargingInfo[gun_index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
                     chargingInfo[gun_index]->SystemStatus <= S_CHARGING) ||
                     (chargingInfo[gun_index]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
@@ -5888,100 +5826,84 @@ int main(void)
                         ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
                     }
 
-#if defined METER_ENABLE
-                    if (PrecheckIsPass(gun_index)) {
-                        if (chargingInfo[gun_index]->SystemStatus == S_FAULT) {
-                            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-                            setChargerMode(gun_index, MODE_IDLE);
-                        }
-#endif //defined METER_ENABLE
-
-                        if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
-                            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                    if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
+                        if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
 #if defined DD360Audi
-                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
+                            ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
 #else
-                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
+                            ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
 #endif //
-                            }
-                        } else {
-                            // Idle 正常程序起點
-                            // 判斷是否有啟用檢查插槍
-                            if (isDetectPlugin()) {
-                                // 卡號驗證成功後,等待充電槍插入充電車
-                                if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
-                                    if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
-                                            chargingInfo[gun_index]->IsAvailable) {
-                                        PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
-                                        chargingInfo[gun_index]->RemoteStartFlag = NO;
-                                        chargingInfo[gun_index]->isRemoteStart = YES; //DS60-120
-                                        ChangeGunSelectByIndex(gun_index);
-                                        AddPlugInTimes(gun_index);
-                                        setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                        strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
-                                        ClearDetectPluginFlag();
-                                        continue;
-                                    }
-                                } else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE) {
-                                    if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
-                                            chargingInfo[gun_index]->IsAvailable &&
-                                            chargingInfo[gun_index]->SystemStatus == S_IDLE
+                        }
+                    } else {
+                        // Idle 正常程序起點
+                        // 判斷是否有啟用檢查插槍
+                        if (isDetectPlugin()) {
+                            // 卡號驗證成功後,等待充電槍插入充電車
+                            if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
+                                if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
+                                        chargingInfo[gun_index]->IsAvailable) {
+                                    PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
+                                    chargingInfo[gun_index]->RemoteStartFlag = NO;
+                                    chargingInfo[gun_index]->isRemoteStart = YES; //DS60-120
+                                    ChangeGunSelectByIndex(gun_index);
+                                    AddPlugInTimes(gun_index);
+                                    setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                    strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
+                                    ClearDetectPluginFlag();
+                                    continue;
+                                }
+                            } else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE) {
+                                if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
+                                        chargingInfo[gun_index]->IsAvailable &&
+                                        chargingInfo[gun_index]->SystemStatus == S_IDLE
 #if defined DD360Audi
-                                            && (waitRightGunPlugIt(gun_index) == PASS ||
-                                                waitLeftGunPlugIt(gun_index) == PASS)
+                                        && (waitRightGunPlugIt(gun_index) == PASS ||
+                                            waitLeftGunPlugIt(gun_index) == PASS)
 #endif //defined DD360Audi
-                                       ) {
-                                        PRINTF_FUNC("-----------------2----------------- \n");
-                                        ChangeGunSelectByIndex(gun_index);
-                                        AddPlugInTimes(gun_index);
-                                        strcpy((char *)chargingInfo[gun_index]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
-                                        PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
-                                        strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-                                        // 當前操作的槍號,進入 Preparing
-                                        setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                        ClearDetectPluginFlag();
-                                        continue;
-                                    }
-                                }
-
-                                if (!isCardScan) {
-                                    // LCM => Waiting for plugging
-                                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
-                                }
-                            } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION) {
-                                if (!isReservationExpired(gun_index)) {
-                                    chargingInfo[gun_index]->SystemStatus = S_IDLE;
-                                }
-                            } else if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
-                                       (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable)) {
-                                PRINTF_FUNC("-----------------3----------------- \n");
-                                bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
-
-                                if (isCanStartChargingFlag) {
+                                   ) {
+                                    PRINTF_FUNC("-----------------2----------------- \n");
                                     ChangeGunSelectByIndex(gun_index);
                                     AddPlugInTimes(gun_index);
+                                    strcpy((char *)chargingInfo[gun_index]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
+                                    PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
+                                    strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+                                    // 當前操作的槍號,進入 Preparing
                                     setChargerMode(gun_index, MODE_REASSIGN_CHECK);
                                     ClearDetectPluginFlag();
                                     continue;
                                 }
-                            } else {
-                                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                            }
+
+                            if (!isCardScan) {
+                                // LCM => Waiting for plugging
+                                ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
+                            }
+                        } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION) {
+                            if (!isReservationExpired(gun_index)) {
+                                chargingInfo[gun_index]->SystemStatus = S_IDLE;
+                            }
+                        } else if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
+                                   (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable)) {
+                            PRINTF_FUNC("-----------------3----------------- \n");
+                            bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
+
+                            if (isCanStartChargingFlag) {
+                                ChangeGunSelectByIndex(gun_index);
+                                AddPlugInTimes(gun_index);
+                                setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                ClearDetectPluginFlag();
+                                continue;
+                            }
+                        } else {
+                            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
 #if defined DD360Audi
-                                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
+                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
 #else
-                                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
+                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
 #endif // defined DD360Audi
-                                }
                             }
-                        } // Idle 正常程序終點
-#if defined METER_ENABLE
-                    } else {
-                        setChargerMode(gun_index, MODE_FAULT);
-                        if (gun_index == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
-                            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_FIX;
                         }
-                    }
-#endif //defined METER_ENABLE
+                    } // Idle 正常程序終點
                 }
             }
             break;
@@ -6225,7 +6147,8 @@ int main(void)
                     }
                 } else if (chargingInfo[gun_index]->Type == _Type_GB) {
                     // 檢查樁端的 GFD 結果
-                    if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9) {
+                    //if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9) {
+                    if (isPrechargeStatus_gb(gun_index) > 9) {
                         setChargerMode(gun_index, MODE_CHARGING);
                     }
 
@@ -6428,7 +6351,10 @@ int main(void)
                     //    setChargerMode(gun_index, MODE_COMPLETE);
                     //}
                 } else if (chargingInfo[gun_index]->Type == _Type_GB) {
-                    log_info("************ GB lock Status = %d, status = %d \n", isEvStopCharging_gb(gun_index), isPrechargeStatus_gb(gun_index));
+                    //log_info("************ GB lock Status = %d, status = %d \n",
+                    //         isEvStopCharging_gb(gun_index),
+                    //         isPrechargeStatus_gb(gun_index));
+
                     // 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
                     //if (isEvStopCharging_chademo(gun_index) == YES) {
                     //    /*+++ 20200908, vern, disable it for DD360 +++*/

+ 3 - 155
EVSE/Projects/DD360/Apps/ReModule_EvComm.c

@@ -54,10 +54,6 @@ struct CHAdeMOData              *ShmCHAdeMOData;
 struct GBTData                  *ShmGBTData;
 struct CcsData                  *ShmCcsData;
 struct PsuData                  *ShmPsuData;
-#if defined METER_ENABLE //DS60-120 add
-struct MeterInformation         *ShmCsuMeterData;
-struct DcCommonInformation      *ShmDcCommonData;
-#endif //defined METER_ENABLE
 
 byte gun_count;
 int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
@@ -283,20 +279,6 @@ int InitShareMemory()
         }
     }
 
-#if defined METER_ENABLE //DS60-120 add
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-#endif //define METER_ENABLE
-
     return result;
 }
 
@@ -2248,7 +2230,6 @@ void CANReceiver()
             if (nbytes > 0) {
                 byte target;
                 byte targetGun = 0x00;
-                byte findIndex = 0x00; //DS60-120 add
                 intCmd = (int) (frame.can_id & CAN_EFF_MASK);
 
                 if (!isClearBuf) { //DS60-120 add
@@ -2256,25 +2237,15 @@ void CANReceiver()
                 }
 
                 if (intCmd == ADDRESS_REQ) {
-#if defined METER_ENABLE
-                    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
-#endif //defined METER_ENABLE
                     AddrAssignment(frame.data);
                     continue;
                 }
+
                 intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
 
                 target = ((byte) (frame.can_id & 0x000000FF));      // 0x01 or 0x02
 
                 for (byte _index = 0; _index < gun_count; _index++) {                    // 假設有找到回應的 Index
-                    findIndex = target;
-#if defined METER_ENABLE
-                    if (gun_count == 1 &&
-                            _chargingData[_index]->Type == _Type_CCS_2 &&
-                            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                        target -= 1;
-                    }
-#endif //defined METER_ENABLE
                     if (_chargingData[_index]->Evboard_id == target) {
                         targetGun = _index;
                         break;
@@ -2286,13 +2257,6 @@ void CANReceiver()
                     PRINTF_FUNC("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
                     continue;
                 }
-#if defined METER_ENABLE
-                else if (gun_count == 1 && targetGun == 0 && findIndex == 1 &&
-                         ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                    // 這樣的條件下~ 也是單槍 CCS 舊版本的狀況 : 因為舊版 CCS 不會 timeout, then send request id
-                    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
-                }
-#endif //defined METER_ENABLE
 
                 if (intCmd == 256) {
                     continue;
@@ -2844,42 +2808,6 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
     return result;
 }
 
-#if defined METER_ENABLE
-void SendCommunicationOnly(byte index)
-{
-    byte targetID = _chargingData[index]->Evboard_id;
-
-    if (gun_count == 1 &&
-            _chargingData[index]->Type == _Type_CCS_2 &&
-            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-        targetID += 1;
-    }
-
-    SetChargingPermission(index, COMMUNICATION,
-                          _chargingData[index]->AvailableChargingPower,
-                          0,
-                          0,
-                          targetID);
-}
-
-void SendStopOnly(byte index)
-{
-    byte targetID = _chargingData[index]->Evboard_id;
-
-    if (gun_count == 1 &&
-            _chargingData[index]->Type == _Type_CCS_2 &&
-            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-        targetID += 1;
-    }
-
-    SetChargingPermission(index, STOP,
-                          _chargingData[index]->AvailableChargingPower,
-                          0,
-                          0,
-                          targetID);
-}
-#endif //defined METER_ENABLE
-
 void FormatVoltageAndCurrent()
 {
     char isLowCur = 0x00;
@@ -2979,43 +2907,6 @@ void FormatVoltageAndCurrent()
     }
 }
 
-// 如果是使用 Meter 計算的話
-void CalOutputPowerAndEnergy(int _index)
-{
-    if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-            ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-        //printf("(%d), totalChargingValue = %f \n", _index, ShmCsuMeterData->_meter[_index]._curTotalCharging / 100);
-#if defined METER_ENABLE
-        float totalChargingValue = ShmCsuMeterData->_meter[_index]._curTotalCharging / 100;
-
-        _chargingData[_index]->PresentChargedEnergy = totalChargingValue;
-        _chargingData[_index]->PowerConsumption = totalChargingValue;
-
-        if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
-            _chargingData[_index]->ChargingFee = totalChargingValue * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-        }
-#endif //METER_ENABLE
-    } else {
-        if (chargingTime[_index] == 0 ||
-                chargingTime[_index] > _chargingData[_index]->PresentChargedDuration) {
-            chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
-        } else {
-            int passTime = _chargingData[_index]->PresentChargedDuration - chargingTime[_index];
-
-            if (passTime > 0) {
-                float changingPow = (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
-                if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
-                    _chargingData[_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-                }
-
-                _chargingData[_index]->PresentChargedEnergy += changingPow;
-                _chargingData[_index]->PowerConsumption += changingPow;
-                chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
-            }
-        }
-    }
-}
-
 int main(int argc, char *argv[])
 {
     if (InitShareMemory() == FAIL) {
@@ -3054,15 +2945,6 @@ int main(int argc, char *argv[])
 
     while (CanFd) {
         for (byte _index = 0; _index < gun_count; _index++) {
-            byte targetID = _chargingData[_index]->Evboard_id;
-
-#if defined METER_ENABLE //DS60-120 add
-            if (gun_count == 1 &&
-                    _chargingData[_index]->Type == _Type_CCS_2 &&
-                    ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                targetID += 1;
-            }
-#endif //defined METER_ENABLE
 
             if (priorityLow == 1) {
                 // 優先權較低 - 只要有回應即不會再詢問
@@ -3096,24 +2978,6 @@ int main(int argc, char *argv[])
             case S_RESERVATION:
                 if (_chargingData[_index]->Type == _Type_Chademo) {
                     ClearAbnormalStatus_Chademo(_index);
-
-#if defined METER_ENABLE //DS60-120 add
-                    if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG) {
-                        if (!chkChademoPermission[_index]) {
-                            chkChademoPermission[_index] = true;
-                            gettimeofday(&_chk_chademo_permission_timeout[_index], NULL);
-                            SendCommunicationOnly(_index);
-                        } else {
-                            if (GetTimeoutValue(_chk_chademo_permission_timeout[_index]) / 1000 > 10000) {
-                                SendCommunicationOnly(_index);
-                                gettimeofday(&_chk_chademo_permission_timeout[_index], NULL);
-                            }
-                        }
-                    } else if (chkChademoPermission[_index]) {
-                        chkChademoPermission[_index] = false;
-                        SendStopOnly(_index);
-                    }
-#endif //defined METER_ENABLE
                 } else if (_chargingData[_index]->Type == _Type_GB) {
                     ClearAbnormalStatus_GB(_index);
                 } else if (_chargingData[_index]->Type == _Type_CCS_2) {
@@ -3146,21 +3010,6 @@ int main(int argc, char *argv[])
                     //maxChargingPow = (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
                     //DS60-120 add
                     SendErrorCount[_index] = 0;
-#if defined METER_ENABLE //DS60-120 add
-                    // 使用 Meter 狀況
-                    if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                            ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-                        if (ShmCsuMeterData->_meter[_index].isCalculation == NO) {
-                            if (ShmCsuMeterData->_meter[_index].curMeterValue != 0 ||
-                                    ShmCsuMeterData->_meter[_index]._chargingValue != 0 ||
-                                    ShmCsuMeterData->_meter[_index]._curTotalCharging != 0 ) {
-                                ShmCsuMeterData->_meter[_index].curMeterValue = 0;
-                                ShmCsuMeterData->_meter[_index]._chargingValue = 0;
-                                ShmCsuMeterData->_meter[_index]._curTotalCharging = 0;
-                            }
-                        }
-                    }
-#endif //defined METER_ENABLE
 
                     //maxChargingPow = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
                     // ShmPsuData->SystemAvailablePower 已是 * 10
@@ -3336,8 +3185,6 @@ int main(int argc, char *argv[])
                 // 計算 Power
                 _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
 
-                //CalOutputPowerAndEnergy(_index); //DS60-120 add
-
                 //DS60-120 remove
                 if (chargingTime[_index] == 0 ||
                         chargingTime[_index] > _chargingData[_index]->PresentChargedDuration) {
@@ -3445,7 +3292,8 @@ int main(int argc, char *argv[])
                         maxCur = _chargingData[_index]->AvailableChargingCurrent;
 
                         GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
-                        SetChargingPermission(_index, STOP,
+                        SetChargingPermission(_index,
+                                              STOP,
                                               _chargingData[_index]->AvailableChargingPower,
                                               maxCur,
                                               maxVol,

+ 142 - 176
EVSE/Projects/DD360/Apps/ReModule_InternalComm.c

@@ -122,10 +122,9 @@ struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
 bool _isOutputNoneMatch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-#if !defined METER_ENABLE
 bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-#endif //!defined METER_ENABLE
+
 bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 
@@ -1017,11 +1016,29 @@ void SetFanModuleSpeed()
     }
 }
 
+typedef struct StGunPNState {
+    uint8_t GunP: 1;
+    uint8_t GunN: 1;
+    uint8_t Reserved: 6;
+} GunPNState;
+
+typedef struct StPreCharginState {
+    uint8_t AcContactor : 1;     //bit 0
+    uint8_t CcsPrecharge : 1;    //bit 1
+    uint8_t Reserved: 6;
+} PreChargingState;
+
 //==========================================
 // Common Function
 //==========================================
 void SetK1K2RelayStatus(byte index)
 {
+    PreChargingState *pRegPreChargingState = NULL;
+    PreChargingState *pOutputPreChargingState = NULL;
+    GunPNState *pRegGunPNState = NULL;
+    GunPNState *pOutputGunPNState = NULL;
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)_chargingData[index];
+
     if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
         if (regRelay.relay_event.bits.Gun1_N == NO) {
             outputRelay.relay_event.bits.Gun1_N = YES;
@@ -1031,6 +1048,94 @@ void SetK1K2RelayStatus(byte index)
         return;
     }
 
+#if 0
+    pRegPreChargingState = (PreChargingState *)&regRelay.relay_event.relay_status[0];
+    pOutputPreChargingState = (PreChargingState *)&outputRelay.relay_event.relay_status[0];
+    if (index == 0) {
+        pRegGunPNState = (GunPNState *)&regRelay.relay_event.relay_status[1];
+        pOutputGunPNState = (GunPNState *)&outputRelay.relay_event.relay_status[1];
+    } else if (index == 1) {
+        pRegGunPNState = (GunPNState *)&regRelay.relay_event.relay_status[2];
+        pOutputGunPNState = (GunPNState *)&outputRelay.relay_event.relay_status[2];
+    }
+
+    switch (pDcChargingInfo->SystemStatus) {
+    case S_BOOTING:
+    case S_IDLE:
+    case S_AUTHORIZING:
+    case S_REASSIGN_CHECK:
+    case S_REASSIGN:
+    case S_PREPARNING:
+    case S_PREPARING_FOR_EV:
+        if (pRegGunPNState->GunP == YES) {
+            pOutputGunPNState->GunP = NO;
+        } else if (pRegGunPNState->GunN == YES) {
+            pOutputGunPNState->GunN = NO;
+        }
+
+        if (index == 1 && pDcChargingInfo->Type == _Type_CCS_2) {
+            if (pRegPreChargingState->CcsPrecharge == YES) {
+                pOutputPreChargingState->CcsPrecharge = NO;
+            }
+        }
+        break;
+
+    case S_PREPARING_FOR_EVSE:
+    case S_CHARGING:
+        //if (pDcChargingInfo->RelayWeldingCheck != YES) {
+        //    break;
+        //}
+
+        if (pRegGunPNState->GunN == NO) {
+            pOutputGunPNState->GunN = YES;
+        } else if (pRegGunPNState->GunP == NO) {
+            pOutputGunPNState->GunP = YES;
+        }
+        break;
+
+    case S_TERMINATING:
+    case S_COMPLETE:
+    case S_ALARM:
+        if ((pDcChargingInfo->PresentChargingCurrent * 10) <= SEFETY_SWITCH_RELAY_CUR) {
+            if (pRegGunPNState->GunP == YES) {
+                pOutputGunPNState->GunP = NO;
+            } else if (pRegGunPNState->GunN == YES) {
+                pOutputGunPNState->GunN = NO;
+            }
+        }
+        break;
+
+    case S_CCS_PRECHARGE_ST0:
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+        break;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+        if (pDcChargingInfo->Type == _Type_CCS_2 && index == 1) {
+            if (pRegPreChargingState->CcsPrecharge == NO) {
+                pOutputPreChargingState->CcsPrecharge = YES;
+            } else if (pRegPreChargingState->CcsPrecharge == YES) {
+                pRegGunPNState->GunP = NO;
+            }
+        }
+        break;
+
+    case S_CCS_PRECHARGE_ST1:
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+        break;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+        if (pDcChargingInfo->Type == _Type_CCS_2 && index == 1) {
+            if (pRegGunPNState->GunP == NO) {
+                pOutputGunPNState->GunP = YES;
+            } else if (pRegGunPNState->GunP == YES) {
+                pOutputPreChargingState->CcsPrecharge = NO;
+            }
+        }
+        break;
+    }
+#endif //0
+
+#if 1
     if (_chargingData[index]->SystemStatus < S_PREPARING_FOR_EVSE) {
         //if (_chargingData[index]->Evboard_id == 0x01) {
         if (index == 0) {
@@ -1061,10 +1166,7 @@ void SetK1K2RelayStatus(byte index)
         }
     } else if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
                 _chargingData[index]->SystemStatus <= S_CHARGING)) {
-#if !defined METER_ENABLE
-        if (_chargingData[index]->RelayWeldingCheck == YES)
-#endif //!defined METER_ENABLE
-        {
+        if (_chargingData[index]->RelayWeldingCheck == YES) {
             //if (_chargingData[index]->Evboard_id == 0x01) {
             if (index == 0) {
                 if (regRelay.relay_event.bits.Gun1_N == NO) {
@@ -1154,6 +1256,7 @@ void SetK1K2RelayStatus(byte index)
 #endif //!defined DD360 && !defined DD360Audi
         }
     }
+#endif //0
 }
 
 void CheckAcInputOvpStatus(byte index)
@@ -1204,8 +1307,12 @@ void CheckPhaseLossStatus(byte index)
     }
 }
 
-void SetParalleRelayStatus()
+void SetParalleRelayStatus(void)
 {
+#if defined  DD360 || defined DD360Audi || defined DD360ComBox
+    return;
+#endif //!defined  DD360 || !defined DD360Audi || !defined DD360ComBox
+
     // 之後雙槍單模機種,橋接都會上
     if (gunCount >= 2) {
         if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
@@ -1518,14 +1625,6 @@ int InitShareMemory()
         result = FAIL;
     }
 
-#if defined METER_ENABLE
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-#endif//defined METER_ENABLE
-
     return result;
 }
 
@@ -1643,32 +1742,6 @@ void Initialization()
     }
 }
 
-#if defined METER_ENABLE
-void StartCheckRelayInfo(byte _chkIndex, byte toState)
-{
-    if (ShmDcCommonData->RelayCheckStatus[_chkIndex] == STOP) {
-        gettimeofday(&_relayStateChkTimer[_chkIndex], NULL);
-        ShmDcCommonData->RelayCheckStatus[_chkIndex] = START;
-    } else {
-        if ((GetTimeoutValue(_relayStateChkTimer[_chkIndex]) / 1000) > RELAY_CHECK_TIME * 1000) {
-            //log_info ("relay welding or driving fault = %d \n", _chkIndex);
-            if (toState == 1) {
-                ShmDcCommonData->RelayCheckStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
-            } else {
-                ShmDcCommonData->RelayCheckStatus[_chkIndex] = RELAY_STATUS_ERROR_WELDING;
-            }
-        }
-    }
-}
-
-void StopCheckRelayInfo(byte _chkIndex)
-{
-    if (ShmDcCommonData->RelayCheckStatus[_chkIndex] != STOP) {
-        ShmDcCommonData->RelayCheckStatus[_chkIndex] = STOP;
-    }
-}
-#endif //defined METER_ENABLE
-
 bool IsNoneMatchRelayStatus()
 {
     bool result = false;
@@ -1691,24 +1764,31 @@ bool IsNoneMatchRelayStatus()
         /*if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
             log_info("AC Contact Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
             log_info("CCS Precharge Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
             log_info("SMR1:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
             log_info("SMR1:D- Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
             log_info("SMR2:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
             log_info("SMR2:D- Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
             log_info("Parallel:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
             log_info("Parallel:D- Relay none match. \n");
         }*/
@@ -1716,61 +1796,6 @@ bool IsNoneMatchRelayStatus()
         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, try to switch to %d \n", outputRelay.relay_event.bits.AC_Contactor);
-    }
-
-    if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
-        //log_info("CCS Precharge Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.CCS_Precharge);
-    }
-#endif //!defined DD360 && !defined DD360Audi
-
-    if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
-        //StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
-        //log_info("SMR1:D+ Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_P);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
-        //log_info("SMR1:D+ Release %d \n");
-    }
-
-    if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
-        //StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
-        //log_info("SMR1:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_N);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
-        //StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
-        //log_info("SMR2:D+ Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun2_P);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
-        //StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
-        //log_info("SMR2:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun2_N);
-    } else {
-        //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) {
-        //StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
-        //log_info("Parallel:D+ Relay none match, try to switch to %d \n", 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) {
-        //StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
-        //log_info("Parallel:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_Parallel_N);
-    } else {
-        //StopCheckRelayInfo(RELAY_PARA_N_STATUS);
-    }
-#endif //!defined DD360 && !defined DD360Audi
-
     return result;
 }
 
@@ -1924,7 +1949,6 @@ void CheckOutputVolNoneMatchFire(byte index)
 
 void CheckRelayWeldingStatus(byte index)
 {
-#if !defined METER_ENABLE
     if (!_isRelayWelding[index]) {
         if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
             gettimeofday(&_checkRelayWeldingTimer[index], NULL);
@@ -1949,7 +1973,6 @@ void CheckRelayWeldingStatus(byte index)
             _chargingData[index]->StopChargeFlag = YES;
         }
     }
-#endif //!defined METER_ENABLE
 }
 
 void GetPsuTempForFanSpeed()
@@ -2384,8 +2407,6 @@ void ResetDetAlarmStatus(byte gun)
 
 int main(void)
 {
-    byte relayMatchFlag = NO;
-
     if (InitShareMemory() == FAIL) {
         log_error("InitShareMemory NG\n");
         if (ShmStatusCodeData != NULL) {
@@ -2507,10 +2528,8 @@ int main(void)
 #endif //!defined DD360 && !defined DD360Audi
 
                 if (_chargingData[i]->SystemStatus == S_IDLE) {
-#if !defined METER_ENABLE
                     _chargingData[i]->RelayWeldingCheck = NO;
                     _isRelayWelding[i] = NO;
-#endif //!defined METER_ENABLE
                     _isOvpChkTimeFlag[i] = NO;
                     ResetDetAlarmStatus(i); //DS60-120 add
                 }
@@ -2524,14 +2543,14 @@ int main(void)
                     isCharging = true;
 
                     // 限定只有在槍類別為 GBT 的時候才做 relay welding 的判斷
-                    if (_chargingData[i]->Type == _Type_GB) {
-                        if (_chargingData[i]->SystemStatus >= S_PREPARING_FOR_EVSE &&
-                                _chargingData[i]->RelayWeldingCheck == NO) {
-                            CheckRelayWeldingStatus(i);
-                        }
-                    } else {
-                        _chargingData[i]->RelayWeldingCheck = YES;
-                    }
+                    //if (_chargingData[i]->Type == _Type_GB) {
+                    //    if (_chargingData[i]->SystemStatus >= S_PREPARING_FOR_EVSE &&
+                    //            _chargingData[i]->RelayWeldingCheck == NO) {
+                    //        CheckRelayWeldingStatus(i);
+                    //    }
+                    //} else {
+                    _chargingData[i]->RelayWeldingCheck = YES;
+                    //}
 
                     if (_chargingData[i]->SystemStatus == S_CHARGING) {
                         CheckOutputPowerOverCarReq(i);
@@ -2543,20 +2562,23 @@ int main(void)
                     _chargingData[i]->IsReadyToCharging = NO;
                 }
             }
+
             // Cable check (Get)
             GetGfdAdc();
 
             // 橋接 relay
-            //SetParalleRelayStatus();
+            SetParalleRelayStatus();
 
             // 搭上 AC Contactor
-//          if (isCharging)
-//              outputRelay.relay_event.bits.AC_Contactor = YES;
-//          else
-//              outputRelay.relay_event.bits.AC_Contactor = NO;
+            //if (isCharging) {
+            //    outputRelay.relay_event.bits.AC_Contactor = YES;
+            //} else {
+            //    outputRelay.relay_event.bits.AC_Contactor = NO;
+            //}
 
             if (isCharging ||
-                    (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)) {
+                    (ShmPsuData->Work_Step >= _TEST_MODE &&
+                     ShmPsuData->Work_Step <= _TEST_MODE)) {
                 isStopChargingCount = false;
                 outputRelay.relay_event.bits.AC_Contactor = YES;
             } else {
@@ -2564,7 +2586,8 @@ int main(void)
                     gettimeofday(&_close_ac_contactor, NULL);
                     isStopChargingCount = true;
                 } else {
-                    if ((outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
+                    if ((outputRelay.relay_event.bits.AC_Contactor == YES &&
+                            GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
                         outputRelay.relay_event.bits.AC_Contactor = NO;
                     }
                 }
@@ -2576,10 +2599,8 @@ int main(void)
 
             // 搭上/鬆開 Relay
             if (IsNoneMatchRelayStatus()) {
-                relayMatchFlag = NO;
                 if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay)) {
                     //regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-#if defined DD360 ||defined DD360Audi || defined DD360ComBox
                     regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
                     regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
                     regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
@@ -2587,7 +2608,7 @@ int main(void)
                     regRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_N;
                     regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
                     regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
-#endif //defined DD360 || defined DD360Audi
+
                     //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
                     //            regRelay.relay_event.bits.AC_Contactor,
                     //            regRelay.relay_event.bits.Gun1_P,
@@ -2600,61 +2621,6 @@ int main(void)
 
                 }
             }
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-            else if (relayMatchFlag == NO) {
-                relayMatchFlag = YES;
-                log_info("======== Relay Status Start========\n");
-                if (regRelay.relay_event.bits.AC_Contactor == YES) {
-                    log_info("AC Power : ON \n");
-                } else {
-                    log_info("AC Power : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_P == YES) {
-                    log_info("Conn1(+) : ON \n");
-                } else {
-                    log_info("Conn1(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_N == YES) {
-                    log_info("Conn1(-) : ON \n");
-                } else {
-                    log_info("Conn1(-) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun2_P == YES) {
-                    log_info("Conn2(+) : ON \n");
-                } else {
-                    log_info("Conn2(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun2_N == YES) {
-                    log_info("Conn2(-) : ON \n");
-                } else {
-                    log_info("Conn2(-) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.CCS_Precharge == YES) {
-                    log_info("Precharge : ON \n");
-                } else {
-                    log_info("Precharge : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_Parallel_P == YES) {
-                    log_info("Parallel(+) : ON \n");
-                } else {
-                    log_info("Parallel(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_Parallel_N == YES) {
-
-                    log_info("Parallel(-) : ON \n");
-                } else {
-                    log_info("Parallel(-) : OFF \n");
-                }
-                log_info("======== Relay Status End========\n");
-            }
-#endif //!defined DD360 && !defined DD360Audi
         }
 
 #if !defined NO_FAN_BOARD && !defined DD360ComBox
@@ -2681,7 +2647,7 @@ int main(void)
         }
 #endif //NO_FAN_BOARD
 
-#if defined DD360ComBox
+#if !defined DD360ComBox
         if (ShmLedModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000) {
                 if (gunCount == 1) {

+ 0 - 64
EVSE/Projects/DD360/Apps/ReModule_PrimaryComm.c

@@ -60,9 +60,6 @@ typedef unsigned char       byte;
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 struct PrimaryMcuData           *ShmPrimaryMcuData;
-#if defined METER_ENABLE //DS60-120 add
-struct MeterInformation         *ShmCsuMeterData;
-#endif //defined METER_ENABLE
 
 void trim(char *s);
 int mystrcmp(char *p1, char *p2);
@@ -233,14 +230,6 @@ int InitShareMemory()
         result = FAIL;
     }
 
-#if defined METER_ENABLE //DS60-120 add
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-#endif //defined METER_ENABLE
-
     return result;
 }
 
@@ -373,48 +362,6 @@ void GetInputGpioStatus()
     }
 }
 
-#if defined METER_ENABLE //DS60-120 add
-void GetMeterConsumption(byte index)
-{
-    if (Query_Meter_value(Uart1Fd, Addr.IoExtend, &ShmCsuMeterData->_meter[index], &ShmCsuMeterData->isWorking, index) == PASS) {
-        // meter value (Resolution) : 10
-        if (!ShmCsuMeterData->isWorking) {
-            //ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = YES;
-            return;
-        }
-
-        if (ShmCsuMeterData->_meter[index].isCalculation == YES) {
-//          printf("Meter%d, Comsumption = %.1f, curMeterValue = %.1f \n",
-//                  index,
-//                  ShmCsuMeterData->_meter[index].newMeterValue,
-//                  ShmCsuMeterData->_meter[index].curMeterValue);
-
-            if (ShmCsuMeterData->_meter[index].curMeterValue == 0) {
-                ShmCsuMeterData->_meter[index].curMeterValue = ShmCsuMeterData->_meter[index].newMeterValue;
-            } else {
-                // 最大充時,兩個都會累加,但只輸出給一槍使用
-                ShmCsuMeterData->_meter[index]._chargingValue += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-
-                if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX ||
-                        (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER &&
-                         ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY_A_TO_M)) {
-                    for (byte subIndex = 0; subIndex < gun_count; subIndex++) {
-                        if (ChargingData[subIndex]->SystemStatus == S_CHARGING) {
-                            ShmCsuMeterData->_meter[subIndex]._curTotalCharging += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-                            break;
-                        }
-                    }
-                } else {
-                    ShmCsuMeterData->_meter[index]._curTotalCharging += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-                }
-
-                ShmCsuMeterData->_meter[index].curMeterValue = ShmCsuMeterData->_meter[index].newMeterValue;
-            }
-        }
-    }
-}
-#endif //defined METER_ENABLE
-
 static void checkChillerStatus(Gpio_out *gpio)
 {
     uint8_t gunIndex = 0;
@@ -673,17 +620,6 @@ int main(void)
             SetOutputGpio(ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0]);
 
             GetInputGpioStatus();
-
-#if defined METER_ENABLE //DS60-120 add
-            if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                    ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-                GetMeterConsumption(_count);
-                _count++;
-                if (_count >= gun_count) {
-                    _count = 0;
-                }
-            }
-#endif //defined METER_ENABLE
         }
 
         usleep(50000);

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


BIN
EVSE/Projects/DD360/output/DoComm


BIN
EVSE/Projects/DD360/output/FactoryConfig


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_PrimaryComm


BIN
EVSE/Projects/DD360/output/ReadCmdline


BIN
EVSE/Projects/DD360/output/main


+ 8 - 0
EVSE/Projects/DD360Audi/Apps/FactoryConfig.c

@@ -229,6 +229,14 @@ int main(int argc, char *argv[])
         helpOutput();
     }
 
+    if (argc == 4) {
+        strcpy((char *)SysConfig.ModelName, argv[2]);
+        strcpy((char *)SysConfig.SerialNumber, argv[3]);
+    } else {
+        strcpy((char *)SysConfig.ModelName, "DDYC182V0UE2AD");
+        strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
+    }
+
     /*
      * Configuration bin file generate
     */

+ 71 - 145
EVSE/Projects/DD360Audi/Apps/ReMain.c

@@ -102,11 +102,6 @@ int whileLoopTime = 10000; // 10 ms
 int wtdFd = -1;
 byte _authorizeIndex = NO_DEFINE;
 
-#if defined METER_ENABLE
-bool relayWeldingCheck = false;
-bool relayDrivingCheck = false;
-#endif //defined METER_ENABLE
-
 bool IsAuthorizingMode();
 void ClearAuthorizedFlag();
 bool isDetectPlugin();
@@ -160,11 +155,6 @@ struct ChargingInfoData         *ac_chargingInfo[AC_QUANTITY];
 struct timeb                    startChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeb                    endChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-#if defined METER_ENABLE
-struct MeterInformation         *ShmCsuMeterData;
-struct DcCommonInformation      *ShmDcCommonData;
-#endif //defined METER_ENABLE
-
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
 static AudiCustInfo             *gAudiCustInfo = NULL; //Jerry add
 #endif //defined DD360Audi
@@ -812,22 +802,6 @@ int CreateShareMemory()
     }
     // memset(ShmOCPP16Data,0,sizeof(struct OCPP16Data));
 
-#if defined METER_ENABLE
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-    memset(ShmCsuMeterData, 0, sizeof(struct MeterInformation));
-
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-    memset(ShmDcCommonData, 0, sizeof(struct DcCommonInformation));
-#endif //defined METER_ENABLE
-
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     //creat Audi customization info
     if ((MeterSMId = shmget(ShmAudiCustInfoKey, sizeof(AudiCustInfo), IPC_CREAT | 0777)) < 0) {
@@ -1617,10 +1591,6 @@ void InitialShareMemoryInfo()
     ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag = NO;
     ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag = NO;
 
-#if defined METER_ENABLE
-    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V015S0; //DS60-120
-#endif //defined METER_ENABLE
-
     log_info("3InitialShareMemoryInfo done...\r\n");
 }
 
@@ -3645,14 +3615,7 @@ bool CheckConnectorTypeStatus()
                 if (type == NO_DEFINE) {
                     type = chargingInfo[gunIndex]->Type;
                 }
-#if defined METER_ENABLE
-                else {
-                    // 雙槍都是同一個 type
-                    if (type == chargingInfo[gunIndex]->Type) {
-                        ShmDcCommonData->SysGunAreSameType = YES;
-                    }
-                }
-#endif //METER_ENABLE
+
                 if (chargingInfo[gunIndex]->Evboard_id == 0x00) {
                     result = false;
                 }
@@ -4244,7 +4207,7 @@ void GetSystemTime()
 //          date[12], date[13]);
 }
 
-void CheckFactoryConfigFunction()
+void CheckFactoryConfigFunction(void)
 {
     char Buf[256] = {0};
 
@@ -5717,10 +5680,7 @@ int main(void)
 
         if ((GetTimeoutValue(_cmdMainPriority_time) / 1000) > 5000) {
             CheckTask();
-#if defined METER_ENABLE
-            relayWeldingCheck = false;
-            relayDrivingCheck = false;
-#endif //defined METER_ENABLE
+
             for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++) {
                 //if (chargingInfo[_index]->SystemStatus == S_CHARGING) {
                 //    CheckSmartChargeProfile(_index);
@@ -5740,28 +5700,10 @@ int main(void)
                         _ocppProfileChkFlag++;
                     }
                 }
-
-#if defined METER_ENABLE
-                if (ShmDcCommonData->SysGunAreSameType == YES) {
-                    if (ShmDcCommonData->GunRelayWeldingOccur[_index] == YES) {
-                        relayWeldingCheck = true;
-                    }
-                    if (ShmDcCommonData->GunRelayDrivingOccur[_index] == YES) {
-                        relayDrivingCheck = true;
-                    }
-                }
-#endif //defined METER_ENABLE
             }
             gettimeofday(&_cmdMainPriority_time, NULL);
         }
 
-#if defined METER_ENABLE
-        if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-            CheckStatusOfMeter();
-        }
-#endif //defined METER_ENABLE
-
         for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++) {
             autoStartChargingForComBox(gun_index); //for DD360ComBox
 
@@ -5769,10 +5711,6 @@ int main(void)
             CheckErrorOccurStatus(gun_index);
             ChkOcppStatus(gun_index);
 
-#if defined METER_ENABLE
-            CheckRelayWeldingOrDrivingFault(gun_index);
-#endif //defined METER_ENABLE
-
             if ((chargingInfo[gun_index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
                     chargingInfo[gun_index]->SystemStatus <= S_CHARGING) ||
                     (chargingInfo[gun_index]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
@@ -5888,100 +5826,84 @@ int main(void)
                         ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
                     }
 
-#if defined METER_ENABLE
-                    if (PrecheckIsPass(gun_index)) {
-                        if (chargingInfo[gun_index]->SystemStatus == S_FAULT) {
-                            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-                            setChargerMode(gun_index, MODE_IDLE);
-                        }
-#endif //defined METER_ENABLE
-
-                        if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
-                            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                    if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
+                        if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
 #if defined DD360Audi
-                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
+                            ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
 #else
-                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
+                            ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
 #endif //
-                            }
-                        } else {
-                            // Idle 正常程序起點
-                            // 判斷是否有啟用檢查插槍
-                            if (isDetectPlugin()) {
-                                // 卡號驗證成功後,等待充電槍插入充電車
-                                if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
-                                    if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
-                                            chargingInfo[gun_index]->IsAvailable) {
-                                        PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
-                                        chargingInfo[gun_index]->RemoteStartFlag = NO;
-                                        chargingInfo[gun_index]->isRemoteStart = YES; //DS60-120
-                                        ChangeGunSelectByIndex(gun_index);
-                                        AddPlugInTimes(gun_index);
-                                        setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                        strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
-                                        ClearDetectPluginFlag();
-                                        continue;
-                                    }
-                                } else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE) {
-                                    if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
-                                            chargingInfo[gun_index]->IsAvailable &&
-                                            chargingInfo[gun_index]->SystemStatus == S_IDLE
+                        }
+                    } else {
+                        // Idle 正常程序起點
+                        // 判斷是否有啟用檢查插槍
+                        if (isDetectPlugin()) {
+                            // 卡號驗證成功後,等待充電槍插入充電車
+                            if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
+                                if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
+                                        chargingInfo[gun_index]->IsAvailable) {
+                                    PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
+                                    chargingInfo[gun_index]->RemoteStartFlag = NO;
+                                    chargingInfo[gun_index]->isRemoteStart = YES; //DS60-120
+                                    ChangeGunSelectByIndex(gun_index);
+                                    AddPlugInTimes(gun_index);
+                                    setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                    strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
+                                    ClearDetectPluginFlag();
+                                    continue;
+                                }
+                            } else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE) {
+                                if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
+                                        chargingInfo[gun_index]->IsAvailable &&
+                                        chargingInfo[gun_index]->SystemStatus == S_IDLE
 #if defined DD360Audi
-                                            && (waitRightGunPlugIt(gun_index) == PASS ||
-                                                waitLeftGunPlugIt(gun_index) == PASS)
+                                        && (waitRightGunPlugIt(gun_index) == PASS ||
+                                            waitLeftGunPlugIt(gun_index) == PASS)
 #endif //defined DD360Audi
-                                       ) {
-                                        PRINTF_FUNC("-----------------2----------------- \n");
-                                        ChangeGunSelectByIndex(gun_index);
-                                        AddPlugInTimes(gun_index);
-                                        strcpy((char *)chargingInfo[gun_index]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
-                                        PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
-                                        strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-                                        // 當前操作的槍號,進入 Preparing
-                                        setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                        ClearDetectPluginFlag();
-                                        continue;
-                                    }
-                                }
-
-                                if (!isCardScan) {
-                                    // LCM => Waiting for plugging
-                                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
-                                }
-                            } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION) {
-                                if (!isReservationExpired(gun_index)) {
-                                    chargingInfo[gun_index]->SystemStatus = S_IDLE;
-                                }
-                            } else if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
-                                       (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable)) {
-                                PRINTF_FUNC("-----------------3----------------- \n");
-                                bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
-
-                                if (isCanStartChargingFlag) {
+                                   ) {
+                                    PRINTF_FUNC("-----------------2----------------- \n");
                                     ChangeGunSelectByIndex(gun_index);
                                     AddPlugInTimes(gun_index);
+                                    strcpy((char *)chargingInfo[gun_index]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
+                                    PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
+                                    strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+                                    // 當前操作的槍號,進入 Preparing
                                     setChargerMode(gun_index, MODE_REASSIGN_CHECK);
                                     ClearDetectPluginFlag();
                                     continue;
                                 }
-                            } else {
-                                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                            }
+
+                            if (!isCardScan) {
+                                // LCM => Waiting for plugging
+                                ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
+                            }
+                        } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION) {
+                            if (!isReservationExpired(gun_index)) {
+                                chargingInfo[gun_index]->SystemStatus = S_IDLE;
+                            }
+                        } else if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
+                                   (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable)) {
+                            PRINTF_FUNC("-----------------3----------------- \n");
+                            bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
+
+                            if (isCanStartChargingFlag) {
+                                ChangeGunSelectByIndex(gun_index);
+                                AddPlugInTimes(gun_index);
+                                setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                ClearDetectPluginFlag();
+                                continue;
+                            }
+                        } else {
+                            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
 #if defined DD360Audi
-                                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
+                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
 #else
-                                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
+                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
 #endif // defined DD360Audi
-                                }
                             }
-                        } // Idle 正常程序終點
-#if defined METER_ENABLE
-                    } else {
-                        setChargerMode(gun_index, MODE_FAULT);
-                        if (gun_index == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
-                            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_FIX;
                         }
-                    }
-#endif //defined METER_ENABLE
+                    } // Idle 正常程序終點
                 }
             }
             break;
@@ -6225,7 +6147,8 @@ int main(void)
                     }
                 } else if (chargingInfo[gun_index]->Type == _Type_GB) {
                     // 檢查樁端的 GFD 結果
-                    if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9) {
+                    //if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9) {
+                    if (isPrechargeStatus_gb(gun_index) > 9) {
                         setChargerMode(gun_index, MODE_CHARGING);
                     }
 
@@ -6428,7 +6351,10 @@ int main(void)
                     //    setChargerMode(gun_index, MODE_COMPLETE);
                     //}
                 } else if (chargingInfo[gun_index]->Type == _Type_GB) {
-                    log_info("************ GB lock Status = %d, status = %d \n", isEvStopCharging_gb(gun_index), isPrechargeStatus_gb(gun_index));
+                    //log_info("************ GB lock Status = %d, status = %d \n",
+                    //         isEvStopCharging_gb(gun_index),
+                    //         isPrechargeStatus_gb(gun_index));
+
                     // 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
                     //if (isEvStopCharging_chademo(gun_index) == YES) {
                     //    /*+++ 20200908, vern, disable it for DD360 +++*/

+ 96 - 253
EVSE/Projects/DD360Audi/Apps/ReModule_EvComm.c

@@ -54,10 +54,6 @@ struct CHAdeMOData              *ShmCHAdeMOData;
 struct GBTData                  *ShmGBTData;
 struct CcsData                  *ShmCcsData;
 struct PsuData                  *ShmPsuData;
-#if defined METER_ENABLE //DS60-120 add
-struct MeterInformation         *ShmCsuMeterData;
-struct DcCommonInformation      *ShmDcCommonData;
-#endif //defined METER_ENABLE
 
 byte gun_count;
 int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
@@ -126,15 +122,13 @@ struct Ev_Board_Cmd Ev_Cmd = {
 
 unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
 
-void PRINTF_FUNC(char *string, ...);
-
 void GetMaxVolAndCurMethod(byte index, float *vol, float *cur);
 void GetMaxPowerMethod(byte index, float *pow);
 unsigned long GetTimeoutValue(struct timeval _sour_time);
 
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 
 unsigned long GetTimeoutValue(struct timeval _sour_time)
 {
@@ -186,17 +180,6 @@ int DiffTimeb(struct timeb ST, struct timeb ET)
     return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
 }
 
-void PRINTF_FUNC(char *string, ...)
-{
-    va_list args;
-    char buffer[4096];
-    va_start(args, string);
-    vsnprintf(buffer, sizeof(buffer), string, args);
-    va_end(args);
-
-    DEBUG_INFO("%s \n", buffer);
-}
-
 //=================================
 // Common routine
 //=================================
@@ -283,20 +266,6 @@ int InitShareMemory()
         }
     }
 
-#if defined METER_ENABLE //DS60-120 add
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-#endif //define METER_ENABLE
-
     return result;
 }
 
@@ -320,19 +289,19 @@ int InitCanBus()
     tv.tv_usec = 10000;
     if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
 #ifdef SystemLogMessage
-        DEBUG_ERROR("Set SO_RCVTIMEO NG");
+        log_error("Set SO_RCVTIMEO NG");
 #endif
     }
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
 #ifdef SystemLogMessage
-        DEBUG_ERROR("Set SO_RCVBUF NG");
+        log_error("Set SO_RCVBUF NG");
 #endif
     }
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
 #ifdef SystemLogMessage
-        DEBUG_ERROR("Set SO_SNDBUF NG");
+        log_error("Set SO_SNDBUF NG");
 #endif
     }
 
@@ -390,21 +359,21 @@ void AddrAssignment(byte *data)
     {
         //DS60-120 add
         if (_chargingData[index - 1]->Type == _Type_Chademo) {
-            PRINTF_FUNC("Set EV board info : (Chademo) TargetAddr = %d \n", index);
+            log_info("Set EV board info : (Chademo) TargetAddr = %d \n", index);
         } else if (_chargingData[index - 1]->Type == _Type_CCS_2) {
-            PRINTF_FUNC("Set EV board info : (CCS) TargetAddr = %d \n", index);
+            log_info("Set EV board info : (CCS) TargetAddr = %d \n", index);
         } else if (_chargingData[index - 1]->Type == _Type_GB) {
-            PRINTF_FUNC("Set EV board info : (GB) TargetAddr = %d \n", index);
+            log_info("Set EV board info : (GB) TargetAddr = %d \n", index);
         }
-        //PRINTF_FUNC("EV board id = %x \n", index); //DS60-120 remove
+        //log_info("EV board id = %x \n", index); //DS60-120 remove
 
-//      PRINTF_FUNC("target_number[0] = %x \n", target_number[0]);
-//      PRINTF_FUNC("target_number[1] = %x \n", target_number[1]);
-//      PRINTF_FUNC("target_number[2] = %x \n", target_number[2]);
-//      PRINTF_FUNC("target_number[3] = %x \n", target_number[3]);
-//      PRINTF_FUNC("target_number[4] = %x \n", target_number[4]);
+//      log_info("target_number[0] = %x \n", target_number[0]);
+//      log_info("target_number[1] = %x \n", target_number[1]);
+//      log_info("target_number[2] = %x \n", target_number[2]);
+//      log_info("target_number[3] = %x \n", target_number[3]);
+//      log_info("target_number[4] = %x \n", target_number[4]);
 
-        PRINTF_FUNC("SetTargetAddr = %d, type = %d \n", index, _chargingData[index - 1]->Type);
+        log_info("SetTargetAddr = %d, type = %d \n", index, _chargingData[index - 1]->Type);
         SetTargetAddr(target_number, index);
     }
 }
@@ -595,7 +564,7 @@ void ClearAbnormalStatus_Chademo(byte gun_index)
     if (isCleanCheck) {
         for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
             if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1) {
-                PRINTF_FUNC("CHA clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
+                log_info("CHA clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
                 if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL) {
                     if (strncmp(code, "023700", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = NO; }
                     if (strncmp(code, "023704", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = NO; }
@@ -963,7 +932,7 @@ void ClearAbnormalStatus_GB(byte gun_index)
     if (isCleanCheck) {
         for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
             if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1) {
-                PRINTF_FUNC("GBT clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
+                log_info("GBT clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
                 if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL) {
                     if (strncmp(code, "023702", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail = NO; }
                     if (strncmp(code, "023900", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 = NO; }
@@ -1772,7 +1741,7 @@ void ClearAbnormalStatus_CCS(byte gun_index)
     if (isCleanCheck) {
         for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
             if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1) {
-                PRINTF_FUNC("CCS clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
+                log_info("CCS clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
                 if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL) {
                     if (strncmp(code, "012219", 6) == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = NO; }
                     if (strncmp(code, "023701", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = NO; }
@@ -1930,7 +1899,7 @@ bool AbnormalStopAnalysis(byte gun_index, byte *errCode)
     char string[7];
     sprintf(string, "%d%d%d%d%d%d", *(errCode + 0), *(errCode + 1), *(errCode + 2), *(errCode + 3), *(errCode + 4), *(errCode + 5));
 
-    PRINTF_FUNC("NOTIFICATION_EV_STOP : Err Code = %s \n", string);
+    log_info("NOTIFICATION_EV_STOP : Err Code = %s \n", string);
     //if (strncmp(string, "000000", 6) == EQUAL ||
     //        strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "", 6) != EQUAL) {
     //    return;
@@ -1945,7 +1914,7 @@ bool AbnormalStopAnalysis(byte gun_index, byte *errCode)
     }
 
     memcpy(_chargingData[gun_index]->EvConnAlarmCode, string, 6);
-    PRINTF_FUNC("NOTIFICATION_EV_STOP : EvConnAlarmCode = %s \n", _chargingData[gun_index]->EvConnAlarmCode);
+    log_info("NOTIFICATION_EV_STOP : EvConnAlarmCode = %s \n", _chargingData[gun_index]->EvConnAlarmCode);
     //OVP error
     if (strcmp(string, "012217") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = YES; }
     if (strcmp(string, "012219") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = YES; }
@@ -2205,6 +2174,8 @@ void CANReceiver()
     canRecPid = fork();
 
     if (canRecPid > 0) {
+        uint8_t temperatureP[2] = {0};
+        uint8_t temperatureN[2] = {0};
         int nbytes;
         struct can_frame frame;
         int intCmd;
@@ -2221,7 +2192,7 @@ void CANReceiver()
             isPass = true;
             for (byte _index = 0; _index < gun_count; _index++) {
                 if (!FindChargingInfoData(_index, &_chargingData[0])) {
-                    DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
+                    log_error("EvComm (main) : FindChargingInfoData false \n");
                     isPass = false;
                     break;
                 }
@@ -2241,14 +2212,13 @@ void CANReceiver()
             for (byte _index = 0; _index < gun_count; _index++) {
                 if (GetTimeoutValue(_cmd_ack_timeout[_index]) >= 5000000) {
                     // ACK timeout
-                    //PRINTF_FUNC("gun = %x, ack timeout \n", _index);
+                    //log_info("gun = %x, ack timeout \n", _index);
                 }
             }
 
             if (nbytes > 0) {
                 byte target;
                 byte targetGun = 0x00;
-                byte findIndex = 0x00; //DS60-120 add
                 intCmd = (int) (frame.can_id & CAN_EFF_MASK);
 
                 if (!isClearBuf) { //DS60-120 add
@@ -2256,43 +2226,26 @@ void CANReceiver()
                 }
 
                 if (intCmd == ADDRESS_REQ) {
-#if defined METER_ENABLE
-                    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
-#endif //defined METER_ENABLE
                     AddrAssignment(frame.data);
                     continue;
                 }
+
                 intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
 
                 target = ((byte) (frame.can_id & 0x000000FF));      // 0x01 or 0x02
 
                 for (byte _index = 0; _index < gun_count; _index++) {                    // 假設有找到回應的 Index
-                    findIndex = target;
-#if defined METER_ENABLE
-                    if (gun_count == 1 &&
-                            _chargingData[_index]->Type == _Type_CCS_2 &&
-                            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                        target -= 1;
-                    }
-#endif //defined METER_ENABLE
                     if (_chargingData[_index]->Evboard_id == target) {
                         targetGun = _index;
                         break;
                     }
                 }
-                //PRINTF_FUNC("target = %d, %d, %d\r\n", target, _chargingData[targetGun]->Evboard_id, targetGun);
+                //log_info("target = %d, %d, %d\r\n", target, _chargingData[targetGun]->Evboard_id, targetGun);
 
                 if (targetGun < 0 || targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY) {
-                    PRINTF_FUNC("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
+                    log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
                     continue;
                 }
-#if defined METER_ENABLE
-                else if (gun_count == 1 && targetGun == 0 && findIndex == 1 &&
-                         ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                    // 這樣的條件下~ 也是單槍 CCS 舊版本的狀況 : 因為舊版 CCS 不會 timeout, then send request id
-                    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
-                }
-#endif //defined METER_ENABLE
 
                 if (intCmd == 256) {
                     continue;
@@ -2302,22 +2255,22 @@ void CANReceiver()
                 switch (intCmd) {
                 case NOTIFICATION_EV_STATUS: {
                     if (_chargingData[targetGun]->ConnectorPlugIn != frame.data[0]) {
-                        //PRINTF_FUNC("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
+                        //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
 
                         if (frame.data[0] == PLUG) {
-                            PRINTF_FUNC("Conn %d, Plugin. \n", targetGun);
+                            log_info("Conn %d, Plugin. \n", targetGun);
                         } else if (frame.data[0] == UNPLUG) {
-                            PRINTF_FUNC("Conn %d, Unplug. \n", targetGun);
+                            log_info("Conn %d, Unplug. \n", targetGun);
                         } else {
-                            PRINTF_FUNC("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
+                            log_info("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
                         }
                     }
 
                     _chargingData[targetGun]->ConnectorPlugIn = frame.data[0];
                     _chargingData[targetGun]->PilotVoltage = frame.data[1];
 
-                    //PRINTF_FUNC("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
-                    //PRINTF_FUNC("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
+                    //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
+                    //log_info("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
                 }
                 break;
                 case ACK_EV_FW_VERSION: {
@@ -2328,12 +2281,12 @@ void CANReceiver()
                         memcpy(ver, frame.data, frame.can_dlc);
                         memcpy(ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
                         ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-                        //PRINTF_FUNC("chademo ver. : %s\n", ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
+                        //log_info("chademo ver. : %s\n", ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
                     } else if (_chargingData[targetGun]->Type == _Type_GB) {
                         memcpy(ver, frame.data, frame.can_dlc);
                         memcpy(ShmGBTData->evse[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
                         ShmGBTData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-                        //PRINTF_FUNC("gbt ver. : %s\n", ShmGBTData->evse[_chargingData[targetGun]->type_index].version);
+                        //log_info("gbt ver. : %s\n", ShmGBTData->evse[_chargingData[targetGun]->type_index].version);
                     } else if (_chargingData[targetGun]->Type == _Type_CCS_2) {
                         if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
                             memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
@@ -2350,7 +2303,7 @@ void CANReceiver()
 
                             memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
                             ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-                            //PRINTF_FUNC("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
+                            //log_info("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
                         }
                     }
 
@@ -2364,7 +2317,7 @@ void CANReceiver()
                 }
                 break;
                 case ACK_EV_HW_VERSION: {
-                    //PRINTF_FUNC("Get EV HW = %s \n", frame.data);
+                    //log_info("Get EV HW = %s \n", frame.data);
                 }
                 break;
                 case ACK_GET_OUTPUT_REQ: {
@@ -2425,10 +2378,10 @@ void CANReceiver()
                         }
                     }
 
-                    //PRINTF_FUNC("EvBatterytargetVoltage = %f \n", _chargingData[targetGun]->EvBatterytargetVoltage);
-                    //PRINTF_FUNC("EvBatterytargetCurrent = %f \n", _chargingData[targetGun]->EvBatterytargetCurrent);
-                    //PRINTF_FUNC("BatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
-                    //PRINTF_FUNC("CurrentRequest = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
+                    //log_info("EvBatterytargetVoltage = %f \n", _chargingData[targetGun]->EvBatterytargetVoltage);
+                    //log_info("EvBatterytargetCurrent = %f \n", _chargingData[targetGun]->EvBatterytargetCurrent);
+                    //log_info("BatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
+                    //log_info("CurrentRequest = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
                 }
                 break;
                 case ACK_GET_EV_BATTERY_INFO: {
@@ -2441,9 +2394,9 @@ void CANReceiver()
                         ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
                         ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
 
-                        //PRINTF_FUNC("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
-                        //PRINTF_FUNC("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
-                        //PRINTF_FUNC("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
+                        //log_info("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
+                        //log_info("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
+                        //log_info("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
                     } else if (_chargingData[targetGun]->Type == _Type_GB) {
                         ShmGBTData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
                         ShmGBTData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
@@ -2471,11 +2424,17 @@ void CANReceiver()
                         }
                     }
 
-                    //PRINTF_FUNC("EvboardStatus = %x \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].EvboardStatus);
-                    //PRINTF_FUNC("ConnectorPlug locked = %x \n", frame.data[0]);
-                    //PRINTF_FUNC("ConnectorTemp 0= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureP);
-                    //PRINTF_FUNC("ConnectorTemp 1= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureN);
-                    //PRINTF_FUNC("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
+                    //log_info("EvboardStatus = %x \n",
+                    //         ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].EvboardStatus);
+                    //log_info("ConnectorPlug locked = %x \n",
+                    //         frame.data[0]);
+                    //if (targetGun == 1) {
+                    //    log_info("ConnectorTemp 0= %d\r\n",
+                    //             frame.data[1]);
+                    //    log_info("ConnectorTemp 1= %d\r\n",
+                    //             frame.data[2]);
+                    //}
+                    //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 }
                 break;
                 case ACK_EVSE_ISOLATION_STATUS: {}
@@ -2491,9 +2450,9 @@ void CANReceiver()
                             (_chargingData[targetGun]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                              _chargingData[targetGun]->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                         // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
-                        PRINTF_FUNC("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n",
-                                    targetGun,
-                                    frame.data[0]);
+                        log_info("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n",
+                                 targetGun,
+                                 frame.data[0]);
                         if (frame.data[0] == 0x02) {
                             if (AbnormalStopAnalysis(targetGun, frame.data + 1) == true) {
                                 _chargingData[targetGun]->StopChargeFlag = YES;
@@ -2508,7 +2467,7 @@ void CANReceiver()
                 }
                 break;
                 default:
-                    PRINTF_FUNC("EV board = %d, Ack none defined. intCmd = %d  \n", targetGun, intCmd);
+                    log_info("EV board = %d, Ack none defined. intCmd = %d  \n", targetGun, intCmd);
                     break;
                 }
             } else { //DS60-120 add
@@ -2552,8 +2511,8 @@ void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, stru
         (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)
     ) {
-        PRINTF_FUNC("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f\r\n",
-                    vol1 / 10, cur1 / 10, vol2 / 10, cur2 / 10);
+        log_info("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f\r\n",
+                 vol1 / 10, cur1 / 10, vol2 / 10, cur2 / 10);
 
         LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] = vol1;
         LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] = cur1;
@@ -2564,7 +2523,7 @@ void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, stru
     //        _outCur_1 != cur1 ||
     //        _outVol_2 != vol2 ||
     //        _outCur_2 != cur2) {
-    /*PRINTF_FUNC("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f \n",
+    /*log_info("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f \n",
         vol1, cur1, vol2, cur2);
     */
     //    _outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
@@ -2601,7 +2560,7 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
             maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
 
             if (maxCur * 10 <= cur1) {
-                //PRINTF_FUNC("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
+                //log_info("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
                 cur1 = maxCur * 10;
             }
         }
@@ -2626,7 +2585,7 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
             maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
 
             if (maxCur * 10 <= cur2) {
-                //PRINTF_FUNC("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
+                //log_info("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
                 cur2 = maxCur * 10;
             }
         }
@@ -2637,10 +2596,10 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
             (LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] <= cur1 - 5 || LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] >= cur1 + 5) ||
             (LogInfo[1][EV_LOG_OUTPUT_CAP_POW] <= pow2 - 5 || LogInfo[1][EV_LOG_OUTPUT_CAP_POW] >= pow2 + 5) ||
             (LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 || LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)) {
-        //PRINTF_FUNC("----------------------------------------------------- \n");
-        PRINTF_FUNC("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f\r\n",
-                    pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
-        //PRINTF_FUNC("----------------------------------------------------- \n");
+        //log_info("----------------------------------------------------- \n");
+        log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f\r\n",
+                 pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
+        //log_info("----------------------------------------------------- \n");
 
         LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
@@ -2660,7 +2619,7 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
             _cur_1 != cur1 ||
             _pow_2 != pow2 ||
             _cur_2 != cur2) {
-        PRINTF_FUNC("To EV (Real) Power_1 = %f, Cur_1 = %f, Power_2 = %f, Cur_2 = %f \n",
+        log_info("To EV (Real) Power_1 = %f, Cur_1 = %f, Power_2 = %f, Cur_2 = %f \n",
                     pow1, cur1, pow2, cur2);
         _pow_1 = pow1; _cur_1 = cur1; _pow_2 = pow2; _cur_2 = cur2;
         chargingData_1->RealMaxCurrent = _cur_1;
@@ -2682,7 +2641,7 @@ void Initialization()
         isPass = true;
         for (byte _index = 0; _index < gun_count; _index++) {
             if (!FindChargingInfoData(_index, &_chargingData[0])) {
-                DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
+                log_error("EvComm (main) : FindChargingInfoData false \n");
                 isPass = false;
                 break;
             }
@@ -2844,42 +2803,6 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
     return result;
 }
 
-#if defined METER_ENABLE
-void SendCommunicationOnly(byte index)
-{
-    byte targetID = _chargingData[index]->Evboard_id;
-
-    if (gun_count == 1 &&
-            _chargingData[index]->Type == _Type_CCS_2 &&
-            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-        targetID += 1;
-    }
-
-    SetChargingPermission(index, COMMUNICATION,
-                          _chargingData[index]->AvailableChargingPower,
-                          0,
-                          0,
-                          targetID);
-}
-
-void SendStopOnly(byte index)
-{
-    byte targetID = _chargingData[index]->Evboard_id;
-
-    if (gun_count == 1 &&
-            _chargingData[index]->Type == _Type_CCS_2 &&
-            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-        targetID += 1;
-    }
-
-    SetChargingPermission(index, STOP,
-                          _chargingData[index]->AvailableChargingPower,
-                          0,
-                          0,
-                          targetID);
-}
-#endif //defined METER_ENABLE
-
 void FormatVoltageAndCurrent()
 {
     char isLowCur = 0x00;
@@ -2979,48 +2902,11 @@ void FormatVoltageAndCurrent()
     }
 }
 
-// 如果是使用 Meter 計算的話
-void CalOutputPowerAndEnergy(int _index)
-{
-    if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-            ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-        //printf("(%d), totalChargingValue = %f \n", _index, ShmCsuMeterData->_meter[_index]._curTotalCharging / 100);
-#if defined METER_ENABLE
-        float totalChargingValue = ShmCsuMeterData->_meter[_index]._curTotalCharging / 100;
-
-        _chargingData[_index]->PresentChargedEnergy = totalChargingValue;
-        _chargingData[_index]->PowerConsumption = totalChargingValue;
-
-        if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
-            _chargingData[_index]->ChargingFee = totalChargingValue * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-        }
-#endif //METER_ENABLE
-    } else {
-        if (chargingTime[_index] == 0 ||
-                chargingTime[_index] > _chargingData[_index]->PresentChargedDuration) {
-            chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
-        } else {
-            int passTime = _chargingData[_index]->PresentChargedDuration - chargingTime[_index];
-
-            if (passTime > 0) {
-                float changingPow = (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
-                if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
-                    _chargingData[_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-                }
-
-                _chargingData[_index]->PresentChargedEnergy += changingPow;
-                _chargingData[_index]->PowerConsumption += changingPow;
-                chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
-            }
-        }
-    }
-}
-
 int main(int argc, char *argv[])
 {
     if (InitShareMemory() == FAIL) {
 #ifdef SystemLogMessage
-        DEBUG_ERROR("InitShareMemory NG\n");
+        log_error("InitShareMemory NG\n");
 #endif
         if (ShmStatusCodeData != NULL) {
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
@@ -3041,28 +2927,19 @@ int main(int argc, char *argv[])
 
     for (byte _index = 0; _index < gun_count; _index++) { //DS60-120 add
         if (_chargingData[_index]->Type == _Type_Chademo) {
-            PRINTF_FUNC("Conn %d (Chademo), MaxVol = %f, MaxCur = %f \n",
-                        _index, maxChargingVol[_index], maxChargingCur[_index]);
+            log_info("Conn %d (Chademo), MaxVol = %f, MaxCur = %f \n",
+                     _index, maxChargingVol[_index], maxChargingCur[_index]);
         } else if (_chargingData[_index]->Type == _Type_CCS_2) {
-            PRINTF_FUNC("Conn %d (CCS), MaxVol = %f, MaxCur = %f \n",
-                        _index, maxChargingVol[_index], maxChargingCur[_index]);
+            log_info("Conn %d (CCS), MaxVol = %f, MaxCur = %f \n",
+                     _index, maxChargingVol[_index], maxChargingCur[_index]);
         } else if (_chargingData[_index]->Type == _Type_GB) {
-            PRINTF_FUNC("Conn %d (GBT), MaxVol = %f, MaxCur = %f \n",
-                        _index, maxChargingVol[_index], maxChargingCur[_index]);
+            log_info("Conn %d (GBT), MaxVol = %f, MaxCur = %f \n",
+                     _index, maxChargingVol[_index], maxChargingCur[_index]);
         }
     }
 
     while (CanFd) {
         for (byte _index = 0; _index < gun_count; _index++) {
-            byte targetID = _chargingData[_index]->Evboard_id;
-
-#if defined METER_ENABLE //DS60-120 add
-            if (gun_count == 1 &&
-                    _chargingData[_index]->Type == _Type_CCS_2 &&
-                    ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                targetID += 1;
-            }
-#endif //defined METER_ENABLE
 
             if (priorityLow == 1) {
                 // 優先權較低 - 只要有回應即不會再詢問
@@ -3083,7 +2960,7 @@ int main(int argc, char *argv[])
                 }
 
                 // 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
-                //PRINTF_FUNC("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
+                //log_info("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
                 GetMiscellaneousInfo(_index,
                                      _chargingData[_index]->RelayK1K2Status,
                                      _chargingData[_index]->PresentChargedEnergy,
@@ -3096,24 +2973,6 @@ int main(int argc, char *argv[])
             case S_RESERVATION:
                 if (_chargingData[_index]->Type == _Type_Chademo) {
                     ClearAbnormalStatus_Chademo(_index);
-
-#if defined METER_ENABLE //DS60-120 add
-                    if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG) {
-                        if (!chkChademoPermission[_index]) {
-                            chkChademoPermission[_index] = true;
-                            gettimeofday(&_chk_chademo_permission_timeout[_index], NULL);
-                            SendCommunicationOnly(_index);
-                        } else {
-                            if (GetTimeoutValue(_chk_chademo_permission_timeout[_index]) / 1000 > 10000) {
-                                SendCommunicationOnly(_index);
-                                gettimeofday(&_chk_chademo_permission_timeout[_index], NULL);
-                            }
-                        }
-                    } else if (chkChademoPermission[_index]) {
-                        chkChademoPermission[_index] = false;
-                        SendStopOnly(_index);
-                    }
-#endif //defined METER_ENABLE
                 } else if (_chargingData[_index]->Type == _Type_GB) {
                     ClearAbnormalStatus_GB(_index);
                 } else if (_chargingData[_index]->Type == _Type_CCS_2) {
@@ -3146,21 +3005,6 @@ int main(int argc, char *argv[])
                     //maxChargingPow = (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
                     //DS60-120 add
                     SendErrorCount[_index] = 0;
-#if defined METER_ENABLE //DS60-120 add
-                    // 使用 Meter 狀況
-                    if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                            ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-                        if (ShmCsuMeterData->_meter[_index].isCalculation == NO) {
-                            if (ShmCsuMeterData->_meter[_index].curMeterValue != 0 ||
-                                    ShmCsuMeterData->_meter[_index]._chargingValue != 0 ||
-                                    ShmCsuMeterData->_meter[_index]._curTotalCharging != 0 ) {
-                                ShmCsuMeterData->_meter[_index].curMeterValue = 0;
-                                ShmCsuMeterData->_meter[_index]._chargingValue = 0;
-                                ShmCsuMeterData->_meter[_index]._curTotalCharging = 0;
-                            }
-                        }
-                    }
-#endif //defined METER_ENABLE
 
                     //maxChargingPow = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
                     // ShmPsuData->SystemAvailablePower 已是 * 10
@@ -3199,11 +3043,11 @@ int main(int argc, char *argv[])
                 // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
                 GetOutputReq(_index, _chargingData[_index]->Evboard_id);
 
-//                  PRINTF_FUNC("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
-//                  PRINTF_FUNC("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
-//                  PRINTF_FUNC("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
-//                  PRINTF_FUNC("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
-//                  PRINTF_FUNC("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
+//                  log_info("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
+//                  log_info("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
+//                  log_info("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
+//                  log_info("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
+//                  log_info("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
 
                 // 設定當前輸出
                 if (gun_count == 1) {
@@ -3226,10 +3070,10 @@ int main(int argc, char *argv[])
                         LogInfo[_index][EV_LOG_EVSE_MAX_VOL] = maxVol;
                         LogInfo[_index][EV_LOG_EVSE_MAX_CUR] = maxCur;
 
-                        PRINTF_FUNC("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f \n",
-                                    _index, maxVol / 10, maxCur / 10, _chargingData[_index]->AvailableChargingPower / 10);
+                        log_info("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f \n",
+                                 _index, maxVol / 10, maxCur / 10, _chargingData[_index]->AvailableChargingPower / 10);
                     }
-                    //PRINTF_FUNC("To EV_%d Max_Vol = %f, Cap_Cur = %f, Cap_Pow = %f \n",
+                    //log_info("To EV_%d Max_Vol = %f, Cap_Cur = %f, Cap_Pow = %f \n",
                     //            _index, maxVol, maxCur, _chargingData[_index]->AvailableChargingPower);
 
                     _chargingData[_index]->RealMaxVoltage = maxVol;
@@ -3274,12 +3118,12 @@ int main(int argc, char *argv[])
                 //DS60-120 add
                 if (LogInfo[_index][EV_LOG_MAX_BATT_VOL] != _chargingData[_index]->EvBatteryMaxVoltage) {
                     LogInfo[_index][EV_LOG_MAX_BATT_VOL] = _chargingData[_index]->EvBatteryMaxVoltage;
-                    PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", _index, _chargingData[_index]->EvBatteryMaxVoltage);
+                    log_info("index = %d, Ev Maximum Battery Voltage = %f \n", _index, _chargingData[_index]->EvBatteryMaxVoltage);
                 }
 
                 if (LogInfo[_index][EV_LOG_SOC] != _chargingData[_index]->EvBatterySoc) {
                     LogInfo[_index][EV_LOG_SOC] = _chargingData[_index]->EvBatterySoc;
-                    PRINTF_FUNC("index = %d, SOC = %d \n", _index, _chargingData[_index]->EvBatterySoc);
+                    log_info("index = %d, SOC = %d \n", _index, _chargingData[_index]->EvBatterySoc);
                 }
 
                 // 持續通知 Isolation 測試狀態
@@ -3288,7 +3132,7 @@ int main(int argc, char *argv[])
 //                      if (_chargingData[_index]->FireChargingVoltage >= 3500)
 //                          _chargingData[_index]->GroundFaultStatus = GFD_PASS;
 
-                    //PRINTF_FUNC("To EV_%d GFD = %d \n",   _index, _chargingData[_index]->GroundFaultStatus);
+                    //log_info("To EV_%d GFD = %d \n",   _index, _chargingData[_index]->GroundFaultStatus);
                     //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
                     {
                         //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
@@ -3306,15 +3150,15 @@ int main(int argc, char *argv[])
                             if (((GetTimeoutValue(_chk_ratingPower_timeout[_index]) / 1000) > 12000 &&
                                     _chargingData[_index]->RealRatingPower > 0) ||
                                     (GetTimeoutValue(_chk_ratingPower_timeout[_index]) / 1000) > 14000) {
-                                //PRINTF_FUNC("**********EvComm : _index= %d, RealRatingPower = %d \n",
+                                //log_info("**********EvComm : _index= %d, RealRatingPower = %d \n",
                                 //            _index, _chargingData[_index]->RealRatingPower);
                                 //_result = GFD_PASS;
 
                                 //DS60-120 add
                                 if (LogInfo[_index][EV_LOG_REAL_CAP_POW] != _chargingData[_index]->RealRatingPower) {
                                     LogInfo[_index][EV_LOG_REAL_CAP_POW] = _chargingData[_index]->RealRatingPower;
-                                    PRINTF_FUNC("Conn %d, RealRatingPower = %d \n",
-                                                _index, _chargingData[_index]->RealRatingPower);
+                                    log_info("Conn %d, RealRatingPower = %d \n",
+                                             _index, _chargingData[_index]->RealRatingPower);
 
                                 }
                             } else {
@@ -3336,8 +3180,6 @@ int main(int argc, char *argv[])
                 // 計算 Power
                 _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
 
-                //CalOutputPowerAndEnergy(_index); //DS60-120 add
-
                 //DS60-120 remove
                 if (chargingTime[_index] == 0 ||
                         chargingTime[_index] > _chargingData[_index]->PresentChargedDuration) {
@@ -3445,7 +3287,8 @@ int main(int argc, char *argv[])
                         maxCur = _chargingData[_index]->AvailableChargingCurrent;
 
                         GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
-                        SetChargingPermission(_index, STOP,
+                        SetChargingPermission(_index,
+                                              STOP,
                                               _chargingData[_index]->AvailableChargingPower,
                                               maxCur,
                                               maxVol,
@@ -3495,6 +3338,6 @@ int main(int argc, char *argv[])
         priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
         usleep(45000); //EV 小板通訊 (50 ms)
     }
-    DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
+    log_info("Module_EvComm : Can-bus port = %d \n", CanFd);
     return FAIL;
 }

+ 142 - 176
EVSE/Projects/DD360Audi/Apps/ReModule_InternalComm.c

@@ -122,10 +122,9 @@ struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
 bool _isOutputNoneMatch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-#if !defined METER_ENABLE
 bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-#endif //!defined METER_ENABLE
+
 bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 
@@ -1017,11 +1016,29 @@ void SetFanModuleSpeed()
     }
 }
 
+typedef struct StGunPNState {
+    uint8_t GunP: 1;
+    uint8_t GunN: 1;
+    uint8_t Reserved: 6;
+} GunPNState;
+
+typedef struct StPreCharginState {
+    uint8_t AcContactor : 1;     //bit 0
+    uint8_t CcsPrecharge : 1;    //bit 1
+    uint8_t Reserved: 6;
+} PreChargingState;
+
 //==========================================
 // Common Function
 //==========================================
 void SetK1K2RelayStatus(byte index)
 {
+    PreChargingState *pRegPreChargingState = NULL;
+    PreChargingState *pOutputPreChargingState = NULL;
+    GunPNState *pRegGunPNState = NULL;
+    GunPNState *pOutputGunPNState = NULL;
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)_chargingData[index];
+
     if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
         if (regRelay.relay_event.bits.Gun1_N == NO) {
             outputRelay.relay_event.bits.Gun1_N = YES;
@@ -1031,6 +1048,94 @@ void SetK1K2RelayStatus(byte index)
         return;
     }
 
+#if 1
+    pRegPreChargingState = (PreChargingState *)&regRelay.relay_event.relay_status[0];
+    pOutputPreChargingState = (PreChargingState *)&outputRelay.relay_event.relay_status[0];
+    if (index == 0) {
+        pRegGunPNState = (GunPNState *)&regRelay.relay_event.relay_status[1];
+        pOutputGunPNState = (GunPNState *)&outputRelay.relay_event.relay_status[1];
+    } else if (index == 1) {
+        pRegGunPNState = (GunPNState *)&regRelay.relay_event.relay_status[2];
+        pOutputGunPNState = (GunPNState *)&outputRelay.relay_event.relay_status[2];
+    }
+
+    switch (pDcChargingInfo->SystemStatus) {
+    case S_BOOTING:
+    case S_IDLE:
+    case S_AUTHORIZING:
+    case S_REASSIGN_CHECK:
+    case S_REASSIGN:
+    case S_PREPARNING:
+    case S_PREPARING_FOR_EV:
+        if (pRegGunPNState->GunP == YES) {
+            pOutputGunPNState->GunP = NO;
+        } else if (pRegGunPNState->GunN == YES) {
+            pOutputGunPNState->GunN = NO;
+        }
+
+        if (index == 1 && pDcChargingInfo->Type == _Type_CCS_2) {
+            if (pRegPreChargingState->CcsPrecharge == YES) {
+                pOutputPreChargingState->CcsPrecharge = NO;
+            }
+        }
+        break;
+
+    case S_PREPARING_FOR_EVSE:
+    case S_CHARGING:
+        //if (pDcChargingInfo->RelayWeldingCheck != YES) {
+        //    break;
+        //}
+
+        if (pRegGunPNState->GunN == NO) {
+            pOutputGunPNState->GunN = YES;
+        } else if (pRegGunPNState->GunP == NO) {
+            pOutputGunPNState->GunP = YES;
+        }
+        break;
+
+    case S_TERMINATING:
+    case S_COMPLETE:
+    case S_ALARM:
+        if ((pDcChargingInfo->PresentChargingCurrent * 10) <= SEFETY_SWITCH_RELAY_CUR) {
+            if (pRegGunPNState->GunP == YES) {
+                pOutputGunPNState->GunP = NO;
+            } else if (pRegGunPNState->GunN == YES) {
+                pOutputGunPNState->GunN = NO;
+            }
+        }
+        break;
+
+    case S_CCS_PRECHARGE_ST0:
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+        break;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+        if (pDcChargingInfo->Type == _Type_CCS_2 && index == 1) {
+            if (pRegPreChargingState->CcsPrecharge == NO) {
+                pOutputPreChargingState->CcsPrecharge = YES;
+            } else if (pRegPreChargingState->CcsPrecharge == YES) {
+                pRegGunPNState->GunP = NO;
+            }
+        }
+        break;
+
+    case S_CCS_PRECHARGE_ST1:
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+        break;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+        if (pDcChargingInfo->Type == _Type_CCS_2 && index == 1) {
+            if (pRegGunPNState->GunP == NO) {
+                pOutputGunPNState->GunP = YES;
+            } else if (pRegGunPNState->GunP == YES) {
+                pOutputPreChargingState->CcsPrecharge = NO;
+            }
+        }
+        break;
+    }
+#endif //0
+
+#if 0
     if (_chargingData[index]->SystemStatus < S_PREPARING_FOR_EVSE) {
         //if (_chargingData[index]->Evboard_id == 0x01) {
         if (index == 0) {
@@ -1061,10 +1166,7 @@ void SetK1K2RelayStatus(byte index)
         }
     } else if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
                 _chargingData[index]->SystemStatus <= S_CHARGING)) {
-#if !defined METER_ENABLE
-        if (_chargingData[index]->RelayWeldingCheck == YES)
-#endif //!defined METER_ENABLE
-        {
+        if (_chargingData[index]->RelayWeldingCheck == YES) {
             //if (_chargingData[index]->Evboard_id == 0x01) {
             if (index == 0) {
                 if (regRelay.relay_event.bits.Gun1_N == NO) {
@@ -1154,6 +1256,7 @@ void SetK1K2RelayStatus(byte index)
 #endif //!defined DD360 && !defined DD360Audi
         }
     }
+#endif //0
 }
 
 void CheckAcInputOvpStatus(byte index)
@@ -1204,8 +1307,12 @@ void CheckPhaseLossStatus(byte index)
     }
 }
 
-void SetParalleRelayStatus()
+void SetParalleRelayStatus(void)
 {
+#if defined  DD360 || defined DD360Audi || defined DD360ComBox
+    return;
+#endif //!defined  DD360 || !defined DD360Audi || !defined DD360ComBox
+
     // 之後雙槍單模機種,橋接都會上
     if (gunCount >= 2) {
         if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
@@ -1518,14 +1625,6 @@ int InitShareMemory()
         result = FAIL;
     }
 
-#if defined METER_ENABLE
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-#endif//defined METER_ENABLE
-
     return result;
 }
 
@@ -1643,32 +1742,6 @@ void Initialization()
     }
 }
 
-#if defined METER_ENABLE
-void StartCheckRelayInfo(byte _chkIndex, byte toState)
-{
-    if (ShmDcCommonData->RelayCheckStatus[_chkIndex] == STOP) {
-        gettimeofday(&_relayStateChkTimer[_chkIndex], NULL);
-        ShmDcCommonData->RelayCheckStatus[_chkIndex] = START;
-    } else {
-        if ((GetTimeoutValue(_relayStateChkTimer[_chkIndex]) / 1000) > RELAY_CHECK_TIME * 1000) {
-            //log_info ("relay welding or driving fault = %d \n", _chkIndex);
-            if (toState == 1) {
-                ShmDcCommonData->RelayCheckStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
-            } else {
-                ShmDcCommonData->RelayCheckStatus[_chkIndex] = RELAY_STATUS_ERROR_WELDING;
-            }
-        }
-    }
-}
-
-void StopCheckRelayInfo(byte _chkIndex)
-{
-    if (ShmDcCommonData->RelayCheckStatus[_chkIndex] != STOP) {
-        ShmDcCommonData->RelayCheckStatus[_chkIndex] = STOP;
-    }
-}
-#endif //defined METER_ENABLE
-
 bool IsNoneMatchRelayStatus()
 {
     bool result = false;
@@ -1691,24 +1764,31 @@ bool IsNoneMatchRelayStatus()
         /*if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
             log_info("AC Contact Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
             log_info("CCS Precharge Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
             log_info("SMR1:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
             log_info("SMR1:D- Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
             log_info("SMR2:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
             log_info("SMR2:D- Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
             log_info("Parallel:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
             log_info("Parallel:D- Relay none match. \n");
         }*/
@@ -1716,61 +1796,6 @@ bool IsNoneMatchRelayStatus()
         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, try to switch to %d \n", outputRelay.relay_event.bits.AC_Contactor);
-    }
-
-    if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
-        //log_info("CCS Precharge Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.CCS_Precharge);
-    }
-#endif //!defined DD360 && !defined DD360Audi
-
-    if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
-        //StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
-        //log_info("SMR1:D+ Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_P);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
-        //log_info("SMR1:D+ Release %d \n");
-    }
-
-    if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
-        //StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
-        //log_info("SMR1:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_N);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
-        //StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
-        //log_info("SMR2:D+ Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun2_P);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
-        //StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
-        //log_info("SMR2:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun2_N);
-    } else {
-        //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) {
-        //StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
-        //log_info("Parallel:D+ Relay none match, try to switch to %d \n", 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) {
-        //StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
-        //log_info("Parallel:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_Parallel_N);
-    } else {
-        //StopCheckRelayInfo(RELAY_PARA_N_STATUS);
-    }
-#endif //!defined DD360 && !defined DD360Audi
-
     return result;
 }
 
@@ -1924,7 +1949,6 @@ void CheckOutputVolNoneMatchFire(byte index)
 
 void CheckRelayWeldingStatus(byte index)
 {
-#if !defined METER_ENABLE
     if (!_isRelayWelding[index]) {
         if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
             gettimeofday(&_checkRelayWeldingTimer[index], NULL);
@@ -1949,7 +1973,6 @@ void CheckRelayWeldingStatus(byte index)
             _chargingData[index]->StopChargeFlag = YES;
         }
     }
-#endif //!defined METER_ENABLE
 }
 
 void GetPsuTempForFanSpeed()
@@ -2384,8 +2407,6 @@ void ResetDetAlarmStatus(byte gun)
 
 int main(void)
 {
-    byte relayMatchFlag = NO;
-
     if (InitShareMemory() == FAIL) {
         log_error("InitShareMemory NG\n");
         if (ShmStatusCodeData != NULL) {
@@ -2507,10 +2528,8 @@ int main(void)
 #endif //!defined DD360 && !defined DD360Audi
 
                 if (_chargingData[i]->SystemStatus == S_IDLE) {
-#if !defined METER_ENABLE
                     _chargingData[i]->RelayWeldingCheck = NO;
                     _isRelayWelding[i] = NO;
-#endif //!defined METER_ENABLE
                     _isOvpChkTimeFlag[i] = NO;
                     ResetDetAlarmStatus(i); //DS60-120 add
                 }
@@ -2524,14 +2543,14 @@ int main(void)
                     isCharging = true;
 
                     // 限定只有在槍類別為 GBT 的時候才做 relay welding 的判斷
-                    if (_chargingData[i]->Type == _Type_GB) {
-                        if (_chargingData[i]->SystemStatus >= S_PREPARING_FOR_EVSE &&
-                                _chargingData[i]->RelayWeldingCheck == NO) {
-                            CheckRelayWeldingStatus(i);
-                        }
-                    } else {
-                        _chargingData[i]->RelayWeldingCheck = YES;
-                    }
+                    //if (_chargingData[i]->Type == _Type_GB) {
+                    //    if (_chargingData[i]->SystemStatus >= S_PREPARING_FOR_EVSE &&
+                    //            _chargingData[i]->RelayWeldingCheck == NO) {
+                    //        CheckRelayWeldingStatus(i);
+                    //    }
+                    //} else {
+                    _chargingData[i]->RelayWeldingCheck = YES;
+                    //}
 
                     if (_chargingData[i]->SystemStatus == S_CHARGING) {
                         CheckOutputPowerOverCarReq(i);
@@ -2543,20 +2562,23 @@ int main(void)
                     _chargingData[i]->IsReadyToCharging = NO;
                 }
             }
+
             // Cable check (Get)
             GetGfdAdc();
 
             // 橋接 relay
-            //SetParalleRelayStatus();
+            SetParalleRelayStatus();
 
             // 搭上 AC Contactor
-//          if (isCharging)
-//              outputRelay.relay_event.bits.AC_Contactor = YES;
-//          else
-//              outputRelay.relay_event.bits.AC_Contactor = NO;
+            //if (isCharging) {
+            //    outputRelay.relay_event.bits.AC_Contactor = YES;
+            //} else {
+            //    outputRelay.relay_event.bits.AC_Contactor = NO;
+            //}
 
             if (isCharging ||
-                    (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)) {
+                    (ShmPsuData->Work_Step >= _TEST_MODE &&
+                     ShmPsuData->Work_Step <= _TEST_MODE)) {
                 isStopChargingCount = false;
                 outputRelay.relay_event.bits.AC_Contactor = YES;
             } else {
@@ -2564,7 +2586,8 @@ int main(void)
                     gettimeofday(&_close_ac_contactor, NULL);
                     isStopChargingCount = true;
                 } else {
-                    if ((outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
+                    if ((outputRelay.relay_event.bits.AC_Contactor == YES &&
+                            GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
                         outputRelay.relay_event.bits.AC_Contactor = NO;
                     }
                 }
@@ -2576,10 +2599,8 @@ int main(void)
 
             // 搭上/鬆開 Relay
             if (IsNoneMatchRelayStatus()) {
-                relayMatchFlag = NO;
                 if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay)) {
                     //regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-#if defined DD360 ||defined DD360Audi || defined DD360ComBox
                     regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
                     regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
                     regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
@@ -2587,7 +2608,7 @@ int main(void)
                     regRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_N;
                     regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
                     regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
-#endif //defined DD360 || defined DD360Audi
+
                     //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
                     //            regRelay.relay_event.bits.AC_Contactor,
                     //            regRelay.relay_event.bits.Gun1_P,
@@ -2600,61 +2621,6 @@ int main(void)
 
                 }
             }
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-            else if (relayMatchFlag == NO) {
-                relayMatchFlag = YES;
-                log_info("======== Relay Status Start========\n");
-                if (regRelay.relay_event.bits.AC_Contactor == YES) {
-                    log_info("AC Power : ON \n");
-                } else {
-                    log_info("AC Power : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_P == YES) {
-                    log_info("Conn1(+) : ON \n");
-                } else {
-                    log_info("Conn1(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_N == YES) {
-                    log_info("Conn1(-) : ON \n");
-                } else {
-                    log_info("Conn1(-) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun2_P == YES) {
-                    log_info("Conn2(+) : ON \n");
-                } else {
-                    log_info("Conn2(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun2_N == YES) {
-                    log_info("Conn2(-) : ON \n");
-                } else {
-                    log_info("Conn2(-) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.CCS_Precharge == YES) {
-                    log_info("Precharge : ON \n");
-                } else {
-                    log_info("Precharge : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_Parallel_P == YES) {
-                    log_info("Parallel(+) : ON \n");
-                } else {
-                    log_info("Parallel(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_Parallel_N == YES) {
-
-                    log_info("Parallel(-) : ON \n");
-                } else {
-                    log_info("Parallel(-) : OFF \n");
-                }
-                log_info("======== Relay Status End========\n");
-            }
-#endif //!defined DD360 && !defined DD360Audi
         }
 
 #if !defined NO_FAN_BOARD && !defined DD360ComBox
@@ -2681,7 +2647,7 @@ int main(void)
         }
 #endif //NO_FAN_BOARD
 
-#if defined DD360ComBox
+#if !defined DD360ComBox
         if (ShmLedModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000) {
                 if (gunCount == 1) {

+ 0 - 64
EVSE/Projects/DD360Audi/Apps/ReModule_PrimaryComm.c

@@ -60,9 +60,6 @@ typedef unsigned char       byte;
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 struct PrimaryMcuData           *ShmPrimaryMcuData;
-#if defined METER_ENABLE //DS60-120 add
-struct MeterInformation         *ShmCsuMeterData;
-#endif //defined METER_ENABLE
 
 void trim(char *s);
 int mystrcmp(char *p1, char *p2);
@@ -233,14 +230,6 @@ int InitShareMemory()
         result = FAIL;
     }
 
-#if defined METER_ENABLE //DS60-120 add
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-#endif //defined METER_ENABLE
-
     return result;
 }
 
@@ -373,48 +362,6 @@ void GetInputGpioStatus()
     }
 }
 
-#if defined METER_ENABLE //DS60-120 add
-void GetMeterConsumption(byte index)
-{
-    if (Query_Meter_value(Uart1Fd, Addr.IoExtend, &ShmCsuMeterData->_meter[index], &ShmCsuMeterData->isWorking, index) == PASS) {
-        // meter value (Resolution) : 10
-        if (!ShmCsuMeterData->isWorking) {
-            //ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = YES;
-            return;
-        }
-
-        if (ShmCsuMeterData->_meter[index].isCalculation == YES) {
-//          printf("Meter%d, Comsumption = %.1f, curMeterValue = %.1f \n",
-//                  index,
-//                  ShmCsuMeterData->_meter[index].newMeterValue,
-//                  ShmCsuMeterData->_meter[index].curMeterValue);
-
-            if (ShmCsuMeterData->_meter[index].curMeterValue == 0) {
-                ShmCsuMeterData->_meter[index].curMeterValue = ShmCsuMeterData->_meter[index].newMeterValue;
-            } else {
-                // 最大充時,兩個都會累加,但只輸出給一槍使用
-                ShmCsuMeterData->_meter[index]._chargingValue += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-
-                if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX ||
-                        (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER &&
-                         ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY_A_TO_M)) {
-                    for (byte subIndex = 0; subIndex < gun_count; subIndex++) {
-                        if (ChargingData[subIndex]->SystemStatus == S_CHARGING) {
-                            ShmCsuMeterData->_meter[subIndex]._curTotalCharging += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-                            break;
-                        }
-                    }
-                } else {
-                    ShmCsuMeterData->_meter[index]._curTotalCharging += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-                }
-
-                ShmCsuMeterData->_meter[index].curMeterValue = ShmCsuMeterData->_meter[index].newMeterValue;
-            }
-        }
-    }
-}
-#endif //defined METER_ENABLE
-
 static void checkChillerStatus(Gpio_out *gpio)
 {
     uint8_t gunIndex = 0;
@@ -673,17 +620,6 @@ int main(void)
             SetOutputGpio(ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0]);
 
             GetInputGpioStatus();
-
-#if defined METER_ENABLE //DS60-120 add
-            if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                    ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-                GetMeterConsumption(_count);
-                _count++;
-                if (_count >= gun_count) {
-                    _count = 0;
-                }
-            }
-#endif //defined METER_ENABLE
         }
 
         usleep(50000);

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


BIN
EVSE/Projects/DD360Audi/output/DoComm


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


BIN
EVSE/Projects/DD360Audi/output/Module_EvComm


BIN
EVSE/Projects/DD360Audi/output/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/output/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/output/Module_LcmControl


BIN
EVSE/Projects/DD360Audi/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Audi/output/ReadCmdline


BIN
EVSE/Projects/DD360Audi/output/main


+ 8 - 0
EVSE/Projects/DD360ComBox/Apps/FactoryConfig.c

@@ -229,6 +229,14 @@ int main(int argc, char *argv[])
         helpOutput();
     }
 
+    if (argc == 4) {
+        strcpy((char *)SysConfig.ModelName, argv[2]);
+        strcpy((char *)SysConfig.SerialNumber, argv[3]);
+    } else {
+        strcpy((char *)SysConfig.ModelName, "DDYC182V0UE2AD");
+        strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
+    }
+
     /*
      * Configuration bin file generate
     */

+ 71 - 145
EVSE/Projects/DD360ComBox/Apps/ReMain.c

@@ -102,11 +102,6 @@ int whileLoopTime = 10000; // 10 ms
 int wtdFd = -1;
 byte _authorizeIndex = NO_DEFINE;
 
-#if defined METER_ENABLE
-bool relayWeldingCheck = false;
-bool relayDrivingCheck = false;
-#endif //defined METER_ENABLE
-
 bool IsAuthorizingMode();
 void ClearAuthorizedFlag();
 bool isDetectPlugin();
@@ -160,11 +155,6 @@ struct ChargingInfoData         *ac_chargingInfo[AC_QUANTITY];
 struct timeb                    startChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeb                    endChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-#if defined METER_ENABLE
-struct MeterInformation         *ShmCsuMeterData;
-struct DcCommonInformation      *ShmDcCommonData;
-#endif //defined METER_ENABLE
-
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
 static AudiCustInfo             *gAudiCustInfo = NULL; //Jerry add
 #endif //defined DD360Audi
@@ -812,22 +802,6 @@ int CreateShareMemory()
     }
     // memset(ShmOCPP16Data,0,sizeof(struct OCPP16Data));
 
-#if defined METER_ENABLE
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-    memset(ShmCsuMeterData, 0, sizeof(struct MeterInformation));
-
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-    memset(ShmDcCommonData, 0, sizeof(struct DcCommonInformation));
-#endif //defined METER_ENABLE
-
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     //creat Audi customization info
     if ((MeterSMId = shmget(ShmAudiCustInfoKey, sizeof(AudiCustInfo), IPC_CREAT | 0777)) < 0) {
@@ -1617,10 +1591,6 @@ void InitialShareMemoryInfo()
     ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag = NO;
     ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag = NO;
 
-#if defined METER_ENABLE
-    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V015S0; //DS60-120
-#endif //defined METER_ENABLE
-
     log_info("3InitialShareMemoryInfo done...\r\n");
 }
 
@@ -3645,14 +3615,7 @@ bool CheckConnectorTypeStatus()
                 if (type == NO_DEFINE) {
                     type = chargingInfo[gunIndex]->Type;
                 }
-#if defined METER_ENABLE
-                else {
-                    // 雙槍都是同一個 type
-                    if (type == chargingInfo[gunIndex]->Type) {
-                        ShmDcCommonData->SysGunAreSameType = YES;
-                    }
-                }
-#endif //METER_ENABLE
+
                 if (chargingInfo[gunIndex]->Evboard_id == 0x00) {
                     result = false;
                 }
@@ -4244,7 +4207,7 @@ void GetSystemTime()
 //          date[12], date[13]);
 }
 
-void CheckFactoryConfigFunction()
+void CheckFactoryConfigFunction(void)
 {
     char Buf[256] = {0};
 
@@ -5717,10 +5680,7 @@ int main(void)
 
         if ((GetTimeoutValue(_cmdMainPriority_time) / 1000) > 5000) {
             CheckTask();
-#if defined METER_ENABLE
-            relayWeldingCheck = false;
-            relayDrivingCheck = false;
-#endif //defined METER_ENABLE
+
             for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++) {
                 //if (chargingInfo[_index]->SystemStatus == S_CHARGING) {
                 //    CheckSmartChargeProfile(_index);
@@ -5740,28 +5700,10 @@ int main(void)
                         _ocppProfileChkFlag++;
                     }
                 }
-
-#if defined METER_ENABLE
-                if (ShmDcCommonData->SysGunAreSameType == YES) {
-                    if (ShmDcCommonData->GunRelayWeldingOccur[_index] == YES) {
-                        relayWeldingCheck = true;
-                    }
-                    if (ShmDcCommonData->GunRelayDrivingOccur[_index] == YES) {
-                        relayDrivingCheck = true;
-                    }
-                }
-#endif //defined METER_ENABLE
             }
             gettimeofday(&_cmdMainPriority_time, NULL);
         }
 
-#if defined METER_ENABLE
-        if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-            CheckStatusOfMeter();
-        }
-#endif //defined METER_ENABLE
-
         for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++) {
             autoStartChargingForComBox(gun_index); //for DD360ComBox
 
@@ -5769,10 +5711,6 @@ int main(void)
             CheckErrorOccurStatus(gun_index);
             ChkOcppStatus(gun_index);
 
-#if defined METER_ENABLE
-            CheckRelayWeldingOrDrivingFault(gun_index);
-#endif //defined METER_ENABLE
-
             if ((chargingInfo[gun_index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
                     chargingInfo[gun_index]->SystemStatus <= S_CHARGING) ||
                     (chargingInfo[gun_index]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
@@ -5888,100 +5826,84 @@ int main(void)
                         ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
                     }
 
-#if defined METER_ENABLE
-                    if (PrecheckIsPass(gun_index)) {
-                        if (chargingInfo[gun_index]->SystemStatus == S_FAULT) {
-                            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-                            setChargerMode(gun_index, MODE_IDLE);
-                        }
-#endif //defined METER_ENABLE
-
-                        if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
-                            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                    if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
+                        if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
 #if defined DD360Audi
-                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
+                            ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
 #else
-                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
+                            ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
 #endif //
-                            }
-                        } else {
-                            // Idle 正常程序起點
-                            // 判斷是否有啟用檢查插槍
-                            if (isDetectPlugin()) {
-                                // 卡號驗證成功後,等待充電槍插入充電車
-                                if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
-                                    if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
-                                            chargingInfo[gun_index]->IsAvailable) {
-                                        PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
-                                        chargingInfo[gun_index]->RemoteStartFlag = NO;
-                                        chargingInfo[gun_index]->isRemoteStart = YES; //DS60-120
-                                        ChangeGunSelectByIndex(gun_index);
-                                        AddPlugInTimes(gun_index);
-                                        setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                        strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
-                                        ClearDetectPluginFlag();
-                                        continue;
-                                    }
-                                } else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE) {
-                                    if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
-                                            chargingInfo[gun_index]->IsAvailable &&
-                                            chargingInfo[gun_index]->SystemStatus == S_IDLE
+                        }
+                    } else {
+                        // Idle 正常程序起點
+                        // 判斷是否有啟用檢查插槍
+                        if (isDetectPlugin()) {
+                            // 卡號驗證成功後,等待充電槍插入充電車
+                            if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
+                                if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
+                                        chargingInfo[gun_index]->IsAvailable) {
+                                    PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
+                                    chargingInfo[gun_index]->RemoteStartFlag = NO;
+                                    chargingInfo[gun_index]->isRemoteStart = YES; //DS60-120
+                                    ChangeGunSelectByIndex(gun_index);
+                                    AddPlugInTimes(gun_index);
+                                    setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                    strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
+                                    ClearDetectPluginFlag();
+                                    continue;
+                                }
+                            } else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE) {
+                                if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
+                                        chargingInfo[gun_index]->IsAvailable &&
+                                        chargingInfo[gun_index]->SystemStatus == S_IDLE
 #if defined DD360Audi
-                                            && (waitRightGunPlugIt(gun_index) == PASS ||
-                                                waitLeftGunPlugIt(gun_index) == PASS)
+                                        && (waitRightGunPlugIt(gun_index) == PASS ||
+                                            waitLeftGunPlugIt(gun_index) == PASS)
 #endif //defined DD360Audi
-                                       ) {
-                                        PRINTF_FUNC("-----------------2----------------- \n");
-                                        ChangeGunSelectByIndex(gun_index);
-                                        AddPlugInTimes(gun_index);
-                                        strcpy((char *)chargingInfo[gun_index]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
-                                        PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
-                                        strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-                                        // 當前操作的槍號,進入 Preparing
-                                        setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                        ClearDetectPluginFlag();
-                                        continue;
-                                    }
-                                }
-
-                                if (!isCardScan) {
-                                    // LCM => Waiting for plugging
-                                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
-                                }
-                            } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION) {
-                                if (!isReservationExpired(gun_index)) {
-                                    chargingInfo[gun_index]->SystemStatus = S_IDLE;
-                                }
-                            } else if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
-                                       (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable)) {
-                                PRINTF_FUNC("-----------------3----------------- \n");
-                                bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
-
-                                if (isCanStartChargingFlag) {
+                                   ) {
+                                    PRINTF_FUNC("-----------------2----------------- \n");
                                     ChangeGunSelectByIndex(gun_index);
                                     AddPlugInTimes(gun_index);
+                                    strcpy((char *)chargingInfo[gun_index]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
+                                    PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
+                                    strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+                                    // 當前操作的槍號,進入 Preparing
                                     setChargerMode(gun_index, MODE_REASSIGN_CHECK);
                                     ClearDetectPluginFlag();
                                     continue;
                                 }
-                            } else {
-                                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                            }
+
+                            if (!isCardScan) {
+                                // LCM => Waiting for plugging
+                                ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_WAIT_FOR_PLUG;
+                            }
+                        } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION) {
+                            if (!isReservationExpired(gun_index)) {
+                                chargingInfo[gun_index]->SystemStatus = S_IDLE;
+                            }
+                        } else if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
+                                   (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable)) {
+                            PRINTF_FUNC("-----------------3----------------- \n");
+                            bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
+
+                            if (isCanStartChargingFlag) {
+                                ChangeGunSelectByIndex(gun_index);
+                                AddPlugInTimes(gun_index);
+                                setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                ClearDetectPluginFlag();
+                                continue;
+                            }
+                        } else {
+                            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
 #if defined DD360Audi
-                                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
+                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_SELECT_GUN;
 #else
-                                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
+                                ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
 #endif // defined DD360Audi
-                                }
                             }
-                        } // Idle 正常程序終點
-#if defined METER_ENABLE
-                    } else {
-                        setChargerMode(gun_index, MODE_FAULT);
-                        if (gun_index == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
-                            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_FIX;
                         }
-                    }
-#endif //defined METER_ENABLE
+                    } // Idle 正常程序終點
                 }
             }
             break;
@@ -6225,7 +6147,8 @@ int main(void)
                     }
                 } else if (chargingInfo[gun_index]->Type == _Type_GB) {
                     // 檢查樁端的 GFD 結果
-                    if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9) {
+                    //if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9) {
+                    if (isPrechargeStatus_gb(gun_index) > 9) {
                         setChargerMode(gun_index, MODE_CHARGING);
                     }
 
@@ -6428,7 +6351,10 @@ int main(void)
                     //    setChargerMode(gun_index, MODE_COMPLETE);
                     //}
                 } else if (chargingInfo[gun_index]->Type == _Type_GB) {
-                    log_info("************ GB lock Status = %d, status = %d \n", isEvStopCharging_gb(gun_index), isPrechargeStatus_gb(gun_index));
+                    //log_info("************ GB lock Status = %d, status = %d \n",
+                    //         isEvStopCharging_gb(gun_index),
+                    //         isPrechargeStatus_gb(gun_index));
+
                     // 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
                     //if (isEvStopCharging_chademo(gun_index) == YES) {
                     //    /*+++ 20200908, vern, disable it for DD360 +++*/

+ 3 - 155
EVSE/Projects/DD360ComBox/Apps/ReModule_EvComm.c

@@ -54,10 +54,6 @@ struct CHAdeMOData              *ShmCHAdeMOData;
 struct GBTData                  *ShmGBTData;
 struct CcsData                  *ShmCcsData;
 struct PsuData                  *ShmPsuData;
-#if defined METER_ENABLE //DS60-120 add
-struct MeterInformation         *ShmCsuMeterData;
-struct DcCommonInformation      *ShmDcCommonData;
-#endif //defined METER_ENABLE
 
 byte gun_count;
 int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
@@ -283,20 +279,6 @@ int InitShareMemory()
         }
     }
 
-#if defined METER_ENABLE //DS60-120 add
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        return FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        return FAIL;
-    }
-#endif //define METER_ENABLE
-
     return result;
 }
 
@@ -2248,7 +2230,6 @@ void CANReceiver()
             if (nbytes > 0) {
                 byte target;
                 byte targetGun = 0x00;
-                byte findIndex = 0x00; //DS60-120 add
                 intCmd = (int) (frame.can_id & CAN_EFF_MASK);
 
                 if (!isClearBuf) { //DS60-120 add
@@ -2256,25 +2237,15 @@ void CANReceiver()
                 }
 
                 if (intCmd == ADDRESS_REQ) {
-#if defined METER_ENABLE
-                    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
-#endif //defined METER_ENABLE
                     AddrAssignment(frame.data);
                     continue;
                 }
+
                 intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
 
                 target = ((byte) (frame.can_id & 0x000000FF));      // 0x01 or 0x02
 
                 for (byte _index = 0; _index < gun_count; _index++) {                    // 假設有找到回應的 Index
-                    findIndex = target;
-#if defined METER_ENABLE
-                    if (gun_count == 1 &&
-                            _chargingData[_index]->Type == _Type_CCS_2 &&
-                            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                        target -= 1;
-                    }
-#endif //defined METER_ENABLE
                     if (_chargingData[_index]->Evboard_id == target) {
                         targetGun = _index;
                         break;
@@ -2286,13 +2257,6 @@ void CANReceiver()
                     PRINTF_FUNC("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
                     continue;
                 }
-#if defined METER_ENABLE
-                else if (gun_count == 1 && targetGun == 0 && findIndex == 1 &&
-                         ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                    // 這樣的條件下~ 也是單槍 CCS 舊版本的狀況 : 因為舊版 CCS 不會 timeout, then send request id
-                    ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
-                }
-#endif //defined METER_ENABLE
 
                 if (intCmd == 256) {
                     continue;
@@ -2844,42 +2808,6 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
     return result;
 }
 
-#if defined METER_ENABLE
-void SendCommunicationOnly(byte index)
-{
-    byte targetID = _chargingData[index]->Evboard_id;
-
-    if (gun_count == 1 &&
-            _chargingData[index]->Type == _Type_CCS_2 &&
-            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-        targetID += 1;
-    }
-
-    SetChargingPermission(index, COMMUNICATION,
-                          _chargingData[index]->AvailableChargingPower,
-                          0,
-                          0,
-                          targetID);
-}
-
-void SendStopOnly(byte index)
-{
-    byte targetID = _chargingData[index]->Evboard_id;
-
-    if (gun_count == 1 &&
-            _chargingData[index]->Type == _Type_CCS_2 &&
-            ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-        targetID += 1;
-    }
-
-    SetChargingPermission(index, STOP,
-                          _chargingData[index]->AvailableChargingPower,
-                          0,
-                          0,
-                          targetID);
-}
-#endif //defined METER_ENABLE
-
 void FormatVoltageAndCurrent()
 {
     char isLowCur = 0x00;
@@ -2979,43 +2907,6 @@ void FormatVoltageAndCurrent()
     }
 }
 
-// 如果是使用 Meter 計算的話
-void CalOutputPowerAndEnergy(int _index)
-{
-    if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-            ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-        //printf("(%d), totalChargingValue = %f \n", _index, ShmCsuMeterData->_meter[_index]._curTotalCharging / 100);
-#if defined METER_ENABLE
-        float totalChargingValue = ShmCsuMeterData->_meter[_index]._curTotalCharging / 100;
-
-        _chargingData[_index]->PresentChargedEnergy = totalChargingValue;
-        _chargingData[_index]->PowerConsumption = totalChargingValue;
-
-        if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
-            _chargingData[_index]->ChargingFee = totalChargingValue * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-        }
-#endif //METER_ENABLE
-    } else {
-        if (chargingTime[_index] == 0 ||
-                chargingTime[_index] > _chargingData[_index]->PresentChargedDuration) {
-            chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
-        } else {
-            int passTime = _chargingData[_index]->PresentChargedDuration - chargingTime[_index];
-
-            if (passTime > 0) {
-                float changingPow = (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
-                if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
-                    _chargingData[_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-                }
-
-                _chargingData[_index]->PresentChargedEnergy += changingPow;
-                _chargingData[_index]->PowerConsumption += changingPow;
-                chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
-            }
-        }
-    }
-}
-
 int main(int argc, char *argv[])
 {
     if (InitShareMemory() == FAIL) {
@@ -3054,15 +2945,6 @@ int main(int argc, char *argv[])
 
     while (CanFd) {
         for (byte _index = 0; _index < gun_count; _index++) {
-            byte targetID = _chargingData[_index]->Evboard_id;
-
-#if defined METER_ENABLE //DS60-120 add
-            if (gun_count == 1 &&
-                    _chargingData[_index]->Type == _Type_CCS_2 &&
-                    ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                targetID += 1;
-            }
-#endif //defined METER_ENABLE
 
             if (priorityLow == 1) {
                 // 優先權較低 - 只要有回應即不會再詢問
@@ -3096,24 +2978,6 @@ int main(int argc, char *argv[])
             case S_RESERVATION:
                 if (_chargingData[_index]->Type == _Type_Chademo) {
                     ClearAbnormalStatus_Chademo(_index);
-
-#if defined METER_ENABLE //DS60-120 add
-                    if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG) {
-                        if (!chkChademoPermission[_index]) {
-                            chkChademoPermission[_index] = true;
-                            gettimeofday(&_chk_chademo_permission_timeout[_index], NULL);
-                            SendCommunicationOnly(_index);
-                        } else {
-                            if (GetTimeoutValue(_chk_chademo_permission_timeout[_index]) / 1000 > 10000) {
-                                SendCommunicationOnly(_index);
-                                gettimeofday(&_chk_chademo_permission_timeout[_index], NULL);
-                            }
-                        }
-                    } else if (chkChademoPermission[_index]) {
-                        chkChademoPermission[_index] = false;
-                        SendStopOnly(_index);
-                    }
-#endif //defined METER_ENABLE
                 } else if (_chargingData[_index]->Type == _Type_GB) {
                     ClearAbnormalStatus_GB(_index);
                 } else if (_chargingData[_index]->Type == _Type_CCS_2) {
@@ -3146,21 +3010,6 @@ int main(int argc, char *argv[])
                     //maxChargingPow = (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
                     //DS60-120 add
                     SendErrorCount[_index] = 0;
-#if defined METER_ENABLE //DS60-120 add
-                    // 使用 Meter 狀況
-                    if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                            ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-                        if (ShmCsuMeterData->_meter[_index].isCalculation == NO) {
-                            if (ShmCsuMeterData->_meter[_index].curMeterValue != 0 ||
-                                    ShmCsuMeterData->_meter[_index]._chargingValue != 0 ||
-                                    ShmCsuMeterData->_meter[_index]._curTotalCharging != 0 ) {
-                                ShmCsuMeterData->_meter[_index].curMeterValue = 0;
-                                ShmCsuMeterData->_meter[_index]._chargingValue = 0;
-                                ShmCsuMeterData->_meter[_index]._curTotalCharging = 0;
-                            }
-                        }
-                    }
-#endif //defined METER_ENABLE
 
                     //maxChargingPow = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
                     // ShmPsuData->SystemAvailablePower 已是 * 10
@@ -3336,8 +3185,6 @@ int main(int argc, char *argv[])
                 // 計算 Power
                 _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
 
-                //CalOutputPowerAndEnergy(_index); //DS60-120 add
-
                 //DS60-120 remove
                 if (chargingTime[_index] == 0 ||
                         chargingTime[_index] > _chargingData[_index]->PresentChargedDuration) {
@@ -3445,7 +3292,8 @@ int main(int argc, char *argv[])
                         maxCur = _chargingData[_index]->AvailableChargingCurrent;
 
                         GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
-                        SetChargingPermission(_index, STOP,
+                        SetChargingPermission(_index,
+                                              STOP,
                                               _chargingData[_index]->AvailableChargingPower,
                                               maxCur,
                                               maxVol,

+ 142 - 176
EVSE/Projects/DD360ComBox/Apps/ReModule_InternalComm.c

@@ -122,10 +122,9 @@ struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
 bool _isOutputNoneMatch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-#if !defined METER_ENABLE
 bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-#endif //!defined METER_ENABLE
+
 bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 
@@ -1017,11 +1016,29 @@ void SetFanModuleSpeed()
     }
 }
 
+typedef struct StGunPNState {
+    uint8_t GunP: 1;
+    uint8_t GunN: 1;
+    uint8_t Reserved: 6;
+} GunPNState;
+
+typedef struct StPreCharginState {
+    uint8_t AcContactor : 1;     //bit 0
+    uint8_t CcsPrecharge : 1;    //bit 1
+    uint8_t Reserved: 6;
+} PreChargingState;
+
 //==========================================
 // Common Function
 //==========================================
 void SetK1K2RelayStatus(byte index)
 {
+    PreChargingState *pRegPreChargingState = NULL;
+    PreChargingState *pOutputPreChargingState = NULL;
+    GunPNState *pRegGunPNState = NULL;
+    GunPNState *pOutputGunPNState = NULL;
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)_chargingData[index];
+
     if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
         if (regRelay.relay_event.bits.Gun1_N == NO) {
             outputRelay.relay_event.bits.Gun1_N = YES;
@@ -1031,6 +1048,94 @@ void SetK1K2RelayStatus(byte index)
         return;
     }
 
+#if 0
+    pRegPreChargingState = (PreChargingState *)&regRelay.relay_event.relay_status[0];
+    pOutputPreChargingState = (PreChargingState *)&outputRelay.relay_event.relay_status[0];
+    if (index == 0) {
+        pRegGunPNState = (GunPNState *)&regRelay.relay_event.relay_status[1];
+        pOutputGunPNState = (GunPNState *)&outputRelay.relay_event.relay_status[1];
+    } else if (index == 1) {
+        pRegGunPNState = (GunPNState *)&regRelay.relay_event.relay_status[2];
+        pOutputGunPNState = (GunPNState *)&outputRelay.relay_event.relay_status[2];
+    }
+
+    switch (pDcChargingInfo->SystemStatus) {
+    case S_BOOTING:
+    case S_IDLE:
+    case S_AUTHORIZING:
+    case S_REASSIGN_CHECK:
+    case S_REASSIGN:
+    case S_PREPARNING:
+    case S_PREPARING_FOR_EV:
+        if (pRegGunPNState->GunP == YES) {
+            pOutputGunPNState->GunP = NO;
+        } else if (pRegGunPNState->GunN == YES) {
+            pOutputGunPNState->GunN = NO;
+        }
+
+        if (index == 1 && pDcChargingInfo->Type == _Type_CCS_2) {
+            if (pRegPreChargingState->CcsPrecharge == YES) {
+                pOutputPreChargingState->CcsPrecharge = NO;
+            }
+        }
+        break;
+
+    case S_PREPARING_FOR_EVSE:
+    case S_CHARGING:
+        //if (pDcChargingInfo->RelayWeldingCheck != YES) {
+        //    break;
+        //}
+
+        if (pRegGunPNState->GunN == NO) {
+            pOutputGunPNState->GunN = YES;
+        } else if (pRegGunPNState->GunP == NO) {
+            pOutputGunPNState->GunP = YES;
+        }
+        break;
+
+    case S_TERMINATING:
+    case S_COMPLETE:
+    case S_ALARM:
+        if ((pDcChargingInfo->PresentChargingCurrent * 10) <= SEFETY_SWITCH_RELAY_CUR) {
+            if (pRegGunPNState->GunP == YES) {
+                pOutputGunPNState->GunP = NO;
+            } else if (pRegGunPNState->GunN == YES) {
+                pOutputGunPNState->GunN = NO;
+            }
+        }
+        break;
+
+    case S_CCS_PRECHARGE_ST0:
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+        break;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+        if (pDcChargingInfo->Type == _Type_CCS_2 && index == 1) {
+            if (pRegPreChargingState->CcsPrecharge == NO) {
+                pOutputPreChargingState->CcsPrecharge = YES;
+            } else if (pRegPreChargingState->CcsPrecharge == YES) {
+                pRegGunPNState->GunP = NO;
+            }
+        }
+        break;
+
+    case S_CCS_PRECHARGE_ST1:
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+        break;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+        if (pDcChargingInfo->Type == _Type_CCS_2 && index == 1) {
+            if (pRegGunPNState->GunP == NO) {
+                pOutputGunPNState->GunP = YES;
+            } else if (pRegGunPNState->GunP == YES) {
+                pOutputPreChargingState->CcsPrecharge = NO;
+            }
+        }
+        break;
+    }
+#endif //0
+
+#if 1
     if (_chargingData[index]->SystemStatus < S_PREPARING_FOR_EVSE) {
         //if (_chargingData[index]->Evboard_id == 0x01) {
         if (index == 0) {
@@ -1061,10 +1166,7 @@ void SetK1K2RelayStatus(byte index)
         }
     } else if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
                 _chargingData[index]->SystemStatus <= S_CHARGING)) {
-#if !defined METER_ENABLE
-        if (_chargingData[index]->RelayWeldingCheck == YES)
-#endif //!defined METER_ENABLE
-        {
+        if (_chargingData[index]->RelayWeldingCheck == YES) {
             //if (_chargingData[index]->Evboard_id == 0x01) {
             if (index == 0) {
                 if (regRelay.relay_event.bits.Gun1_N == NO) {
@@ -1154,6 +1256,7 @@ void SetK1K2RelayStatus(byte index)
 #endif //!defined DD360 && !defined DD360Audi
         }
     }
+#endif //0
 }
 
 void CheckAcInputOvpStatus(byte index)
@@ -1204,8 +1307,12 @@ void CheckPhaseLossStatus(byte index)
     }
 }
 
-void SetParalleRelayStatus()
+void SetParalleRelayStatus(void)
 {
+#if defined  DD360 || defined DD360Audi || defined DD360ComBox
+    return;
+#endif //!defined  DD360 || !defined DD360Audi || !defined DD360ComBox
+
     // 之後雙槍單模機種,橋接都會上
     if (gunCount >= 2) {
         if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
@@ -1518,14 +1625,6 @@ int InitShareMemory()
         result = FAIL;
     }
 
-#if defined METER_ENABLE
-    if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-#endif//defined METER_ENABLE
-
     return result;
 }
 
@@ -1643,32 +1742,6 @@ void Initialization()
     }
 }
 
-#if defined METER_ENABLE
-void StartCheckRelayInfo(byte _chkIndex, byte toState)
-{
-    if (ShmDcCommonData->RelayCheckStatus[_chkIndex] == STOP) {
-        gettimeofday(&_relayStateChkTimer[_chkIndex], NULL);
-        ShmDcCommonData->RelayCheckStatus[_chkIndex] = START;
-    } else {
-        if ((GetTimeoutValue(_relayStateChkTimer[_chkIndex]) / 1000) > RELAY_CHECK_TIME * 1000) {
-            //log_info ("relay welding or driving fault = %d \n", _chkIndex);
-            if (toState == 1) {
-                ShmDcCommonData->RelayCheckStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
-            } else {
-                ShmDcCommonData->RelayCheckStatus[_chkIndex] = RELAY_STATUS_ERROR_WELDING;
-            }
-        }
-    }
-}
-
-void StopCheckRelayInfo(byte _chkIndex)
-{
-    if (ShmDcCommonData->RelayCheckStatus[_chkIndex] != STOP) {
-        ShmDcCommonData->RelayCheckStatus[_chkIndex] = STOP;
-    }
-}
-#endif //defined METER_ENABLE
-
 bool IsNoneMatchRelayStatus()
 {
     bool result = false;
@@ -1691,24 +1764,31 @@ bool IsNoneMatchRelayStatus()
         /*if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
             log_info("AC Contact Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
             log_info("CCS Precharge Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
             log_info("SMR1:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
             log_info("SMR1:D- Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
             log_info("SMR2:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
             log_info("SMR2:D- Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
             log_info("Parallel:D+ Relay none match. \n");
         }
+
         if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
             log_info("Parallel:D- Relay none match. \n");
         }*/
@@ -1716,61 +1796,6 @@ bool IsNoneMatchRelayStatus()
         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, try to switch to %d \n", outputRelay.relay_event.bits.AC_Contactor);
-    }
-
-    if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
-        //log_info("CCS Precharge Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.CCS_Precharge);
-    }
-#endif //!defined DD360 && !defined DD360Audi
-
-    if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
-        //StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
-        //log_info("SMR1:D+ Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_P);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
-        //log_info("SMR1:D+ Release %d \n");
-    }
-
-    if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
-        //StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
-        //log_info("SMR1:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_N);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
-        //StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
-        //log_info("SMR2:D+ Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun2_P);
-    } else {
-        //StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
-    }
-
-    if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
-        //StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
-        //log_info("SMR2:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun2_N);
-    } else {
-        //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) {
-        //StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
-        //log_info("Parallel:D+ Relay none match, try to switch to %d \n", 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) {
-        //StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
-        //log_info("Parallel:D- Relay none match, try to switch to %d \n", outputRelay.relay_event.bits.Gun1_Parallel_N);
-    } else {
-        //StopCheckRelayInfo(RELAY_PARA_N_STATUS);
-    }
-#endif //!defined DD360 && !defined DD360Audi
-
     return result;
 }
 
@@ -1924,7 +1949,6 @@ void CheckOutputVolNoneMatchFire(byte index)
 
 void CheckRelayWeldingStatus(byte index)
 {
-#if !defined METER_ENABLE
     if (!_isRelayWelding[index]) {
         if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
             gettimeofday(&_checkRelayWeldingTimer[index], NULL);
@@ -1949,7 +1973,6 @@ void CheckRelayWeldingStatus(byte index)
             _chargingData[index]->StopChargeFlag = YES;
         }
     }
-#endif //!defined METER_ENABLE
 }
 
 void GetPsuTempForFanSpeed()
@@ -2384,8 +2407,6 @@ void ResetDetAlarmStatus(byte gun)
 
 int main(void)
 {
-    byte relayMatchFlag = NO;
-
     if (InitShareMemory() == FAIL) {
         log_error("InitShareMemory NG\n");
         if (ShmStatusCodeData != NULL) {
@@ -2507,10 +2528,8 @@ int main(void)
 #endif //!defined DD360 && !defined DD360Audi
 
                 if (_chargingData[i]->SystemStatus == S_IDLE) {
-#if !defined METER_ENABLE
                     _chargingData[i]->RelayWeldingCheck = NO;
                     _isRelayWelding[i] = NO;
-#endif //!defined METER_ENABLE
                     _isOvpChkTimeFlag[i] = NO;
                     ResetDetAlarmStatus(i); //DS60-120 add
                 }
@@ -2524,14 +2543,14 @@ int main(void)
                     isCharging = true;
 
                     // 限定只有在槍類別為 GBT 的時候才做 relay welding 的判斷
-                    if (_chargingData[i]->Type == _Type_GB) {
-                        if (_chargingData[i]->SystemStatus >= S_PREPARING_FOR_EVSE &&
-                                _chargingData[i]->RelayWeldingCheck == NO) {
-                            CheckRelayWeldingStatus(i);
-                        }
-                    } else {
-                        _chargingData[i]->RelayWeldingCheck = YES;
-                    }
+                    //if (_chargingData[i]->Type == _Type_GB) {
+                    //    if (_chargingData[i]->SystemStatus >= S_PREPARING_FOR_EVSE &&
+                    //            _chargingData[i]->RelayWeldingCheck == NO) {
+                    //        CheckRelayWeldingStatus(i);
+                    //    }
+                    //} else {
+                    _chargingData[i]->RelayWeldingCheck = YES;
+                    //}
 
                     if (_chargingData[i]->SystemStatus == S_CHARGING) {
                         CheckOutputPowerOverCarReq(i);
@@ -2543,20 +2562,23 @@ int main(void)
                     _chargingData[i]->IsReadyToCharging = NO;
                 }
             }
+
             // Cable check (Get)
             GetGfdAdc();
 
             // 橋接 relay
-            //SetParalleRelayStatus();
+            SetParalleRelayStatus();
 
             // 搭上 AC Contactor
-//          if (isCharging)
-//              outputRelay.relay_event.bits.AC_Contactor = YES;
-//          else
-//              outputRelay.relay_event.bits.AC_Contactor = NO;
+            //if (isCharging) {
+            //    outputRelay.relay_event.bits.AC_Contactor = YES;
+            //} else {
+            //    outputRelay.relay_event.bits.AC_Contactor = NO;
+            //}
 
             if (isCharging ||
-                    (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)) {
+                    (ShmPsuData->Work_Step >= _TEST_MODE &&
+                     ShmPsuData->Work_Step <= _TEST_MODE)) {
                 isStopChargingCount = false;
                 outputRelay.relay_event.bits.AC_Contactor = YES;
             } else {
@@ -2564,7 +2586,8 @@ int main(void)
                     gettimeofday(&_close_ac_contactor, NULL);
                     isStopChargingCount = true;
                 } else {
-                    if ((outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
+                    if ((outputRelay.relay_event.bits.AC_Contactor == YES &&
+                            GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000))) {
                         outputRelay.relay_event.bits.AC_Contactor = NO;
                     }
                 }
@@ -2576,10 +2599,8 @@ int main(void)
 
             // 搭上/鬆開 Relay
             if (IsNoneMatchRelayStatus()) {
-                relayMatchFlag = NO;
                 if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay)) {
                     //regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-#if defined DD360 ||defined DD360Audi || defined DD360ComBox
                     regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
                     regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
                     regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
@@ -2587,7 +2608,7 @@ int main(void)
                     regRelay.relay_event.bits.Gun2_N = outputRelay.relay_event.bits.Gun2_N;
                     regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
                     regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
-#endif //defined DD360 || defined DD360Audi
+
                     //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
                     //            regRelay.relay_event.bits.AC_Contactor,
                     //            regRelay.relay_event.bits.Gun1_P,
@@ -2600,61 +2621,6 @@ int main(void)
 
                 }
             }
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-            else if (relayMatchFlag == NO) {
-                relayMatchFlag = YES;
-                log_info("======== Relay Status Start========\n");
-                if (regRelay.relay_event.bits.AC_Contactor == YES) {
-                    log_info("AC Power : ON \n");
-                } else {
-                    log_info("AC Power : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_P == YES) {
-                    log_info("Conn1(+) : ON \n");
-                } else {
-                    log_info("Conn1(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_N == YES) {
-                    log_info("Conn1(-) : ON \n");
-                } else {
-                    log_info("Conn1(-) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun2_P == YES) {
-                    log_info("Conn2(+) : ON \n");
-                } else {
-                    log_info("Conn2(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun2_N == YES) {
-                    log_info("Conn2(-) : ON \n");
-                } else {
-                    log_info("Conn2(-) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.CCS_Precharge == YES) {
-                    log_info("Precharge : ON \n");
-                } else {
-                    log_info("Precharge : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_Parallel_P == YES) {
-                    log_info("Parallel(+) : ON \n");
-                } else {
-                    log_info("Parallel(+) : OFF \n");
-                }
-
-                if (regRelay.relay_event.bits.Gun1_Parallel_N == YES) {
-
-                    log_info("Parallel(-) : ON \n");
-                } else {
-                    log_info("Parallel(-) : OFF \n");
-                }
-                log_info("======== Relay Status End========\n");
-            }
-#endif //!defined DD360 && !defined DD360Audi
         }
 
 #if !defined NO_FAN_BOARD && !defined DD360ComBox
@@ -2681,7 +2647,7 @@ int main(void)
         }
 #endif //NO_FAN_BOARD
 
-#if defined DD360ComBox
+#if !defined DD360ComBox
         if (ShmLedModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000) {
                 if (gunCount == 1) {

+ 0 - 64
EVSE/Projects/DD360ComBox/Apps/ReModule_PrimaryComm.c

@@ -60,9 +60,6 @@ typedef unsigned char       byte;
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 struct PrimaryMcuData           *ShmPrimaryMcuData;
-#if defined METER_ENABLE //DS60-120 add
-struct MeterInformation         *ShmCsuMeterData;
-#endif //defined METER_ENABLE
 
 void trim(char *s);
 int mystrcmp(char *p1, char *p2);
@@ -233,14 +230,6 @@ int InitShareMemory()
         result = FAIL;
     }
 
-#if defined METER_ENABLE //DS60-120 add
-    if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-#endif //defined METER_ENABLE
-
     return result;
 }
 
@@ -373,48 +362,6 @@ void GetInputGpioStatus()
     }
 }
 
-#if defined METER_ENABLE //DS60-120 add
-void GetMeterConsumption(byte index)
-{
-    if (Query_Meter_value(Uart1Fd, Addr.IoExtend, &ShmCsuMeterData->_meter[index], &ShmCsuMeterData->isWorking, index) == PASS) {
-        // meter value (Resolution) : 10
-        if (!ShmCsuMeterData->isWorking) {
-            //ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = YES;
-            return;
-        }
-
-        if (ShmCsuMeterData->_meter[index].isCalculation == YES) {
-//          printf("Meter%d, Comsumption = %.1f, curMeterValue = %.1f \n",
-//                  index,
-//                  ShmCsuMeterData->_meter[index].newMeterValue,
-//                  ShmCsuMeterData->_meter[index].curMeterValue);
-
-            if (ShmCsuMeterData->_meter[index].curMeterValue == 0) {
-                ShmCsuMeterData->_meter[index].curMeterValue = ShmCsuMeterData->_meter[index].newMeterValue;
-            } else {
-                // 最大充時,兩個都會累加,但只輸出給一槍使用
-                ShmCsuMeterData->_meter[index]._chargingValue += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-
-                if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX ||
-                        (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER &&
-                         ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY_A_TO_M)) {
-                    for (byte subIndex = 0; subIndex < gun_count; subIndex++) {
-                        if (ChargingData[subIndex]->SystemStatus == S_CHARGING) {
-                            ShmCsuMeterData->_meter[subIndex]._curTotalCharging += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-                            break;
-                        }
-                    }
-                } else {
-                    ShmCsuMeterData->_meter[index]._curTotalCharging += ShmCsuMeterData->_meter[index].newMeterValue - ShmCsuMeterData->_meter[index].curMeterValue;
-                }
-
-                ShmCsuMeterData->_meter[index].curMeterValue = ShmCsuMeterData->_meter[index].newMeterValue;
-            }
-        }
-    }
-}
-#endif //defined METER_ENABLE
-
 static void checkChillerStatus(Gpio_out *gpio)
 {
     uint8_t gunIndex = 0;
@@ -673,17 +620,6 @@ int main(void)
             SetOutputGpio(ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0]);
 
             GetInputGpioStatus();
-
-#if defined METER_ENABLE //DS60-120 add
-            if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
-                    ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L') {
-                GetMeterConsumption(_count);
-                _count++;
-                if (_count >= gun_count) {
-                    _count = 0;
-                }
-            }
-#endif //defined METER_ENABLE
         }
 
         usleep(50000);

BIN
EVSE/Projects/DD360ComBox/Apps/UnsafetyOutputTask


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


BIN
EVSE/Projects/DD360ComBox/output/DoComm


BIN
EVSE/Projects/DD360ComBox/output/FactoryConfig


BIN
EVSE/Projects/DD360ComBox/output/Module_EvComm


BIN
EVSE/Projects/DD360ComBox/output/Module_EventLogging


BIN
EVSE/Projects/DD360ComBox/output/Module_InternalComm


BIN
EVSE/Projects/DD360ComBox/output/Module_LcmControl


BIN
EVSE/Projects/DD360ComBox/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360ComBox/output/ReadCmdline


BIN
EVSE/Projects/DD360ComBox/output/main