Browse Source

2022-07-11 / Simon Xue

Action:
1. [Add] Power derating.
2. [Add] Set fan 7000 when start charging.
3. [Mod] Update memory using.
4. [Fix] LCM charging Energy bug.

Files
As the following commit history files

Image Version: V1.21.XX.XXXX.XX
Simon Xue 2 years ago
parent
commit
c46f2bd552
52 changed files with 1009 additions and 232 deletions
  1. 2 0
      EVSE/Projects/DD360/Apps/CSU/Ethernet.c
  2. 148 4
      EVSE/Projects/DD360/Apps/CSU/main.c
  3. 7 0
      EVSE/Projects/DD360/Apps/Config.h
  4. 192 43
      EVSE/Projects/DD360/Apps/Define/define.h
  5. 4 4
      EVSE/Projects/DD360/Apps/Log/log.h
  6. 11 0
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c
  7. 42 1
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c
  8. 1 1
      EVSE/Projects/DD360/Apps/ModuleEventLog/Module_EventLogging.c
  9. 3 3
      EVSE/Projects/DD360/Apps/ModuleInternalComm/Module_InternalComm.h
  10. 24 1
      EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c
  11. 9 7
      EVSE/Projects/DD360/Apps/ModuleLcmCtrl/Module_LcmControl.c
  12. 8 40
      EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c
  13. 18 1
      EVSE/Projects/DD360/Apps/ModuleUpdateFW/Module_UpdateFW.c
  14. BIN
      EVSE/Projects/DD360/Apps/Module_ChkSysTask
  15. BIN
      EVSE/Projects/DD360/Apps/Module_DoComm
  16. BIN
      EVSE/Projects/DD360/Apps/Module_EvComm
  17. BIN
      EVSE/Projects/DD360/Apps/Module_EventLogging
  18. BIN
      EVSE/Projects/DD360/Apps/Module_InternalComm
  19. BIN
      EVSE/Projects/DD360/Apps/Module_UpdateFW
  20. 19 11
      EVSE/Projects/DD360/Apps/ReadCmdline.c
  21. BIN
      EVSE/Projects/DD360/Apps/UnsafetyOutputTask
  22. BIN
      EVSE/Projects/DD360/Apps/main
  23. BIN
      EVSE/Projects/DD360/Images/ramdisk.gz
  24. BIN
      EVSE/Projects/DD360/output/FactoryConfig
  25. BIN
      EVSE/Projects/DD360/output/Module_ChkSysTask
  26. BIN
      EVSE/Projects/DD360/output/Module_DoComm
  27. BIN
      EVSE/Projects/DD360/output/Module_EvComm
  28. BIN
      EVSE/Projects/DD360/output/Module_EventLogging
  29. BIN
      EVSE/Projects/DD360/output/Module_InternalComm
  30. BIN
      EVSE/Projects/DD360/output/Module_LcmControl
  31. BIN
      EVSE/Projects/DD360/output/Module_PrimaryComm
  32. BIN
      EVSE/Projects/DD360/output/Module_UpdateFW
  33. BIN
      EVSE/Projects/DD360/output/ReadCmdline
  34. BIN
      EVSE/Projects/DD360/output/UnsafetyOutputTask
  35. BIN
      EVSE/Projects/DD360/output/main
  36. 2 0
      EVSE/Projects/DD360Audi/Apps/CSU/Ethernet.c
  37. 148 4
      EVSE/Projects/DD360Audi/Apps/CSU/main.c
  38. 7 0
      EVSE/Projects/DD360Audi/Apps/Config.h
  39. 192 43
      EVSE/Projects/DD360Audi/Apps/Define/define.h
  40. 4 4
      EVSE/Projects/DD360Audi/Apps/Log/log.h
  41. 11 0
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c
  42. 42 1
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c
  43. 1 1
      EVSE/Projects/DD360Audi/Apps/ModuleEventLog/Module_EventLogging.c
  44. 3 3
      EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/Module_InternalComm.h
  45. 24 1
      EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/RelayBoard.c
  46. 9 7
      EVSE/Projects/DD360Audi/Apps/ModuleLcmCtrl/Module_LcmControl.c
  47. 8 40
      EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c
  48. 18 1
      EVSE/Projects/DD360Audi/Apps/ModuleUpdateFW/Module_UpdateFW.c
  49. 19 11
      EVSE/Projects/DD360Audi/Apps/ReadCmdline.c
  50. BIN
      EVSE/rootfs/root/Module_Payment_Bazel8
  51. BIN
      EVSE/rootfs/root/Module_PowerSharing
  52. 33 0
      build_rootfs_copy.sh

+ 2 - 0
EVSE/Projects/DD360/Apps/CSU/Ethernet.c

@@ -186,6 +186,8 @@ void InitEthernet(void)
     log_info("%s",tmpbuf);
     system(tmpbuf);
 
+    system("/sbin/ifconfig lo up");
+
     //Run DHCP client if enabled
     system("killall udhcpc");
     system("rm -rf /etc/resolv.conf");

+ 148 - 4
EVSE/Projects/DD360/Apps/CSU/main.c

@@ -77,14 +77,16 @@ static ChillerTempErr gChillerTempErr = {0};
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 
+#define DERATING_TARGET_LEVEL 5
+
 // for initial index to check EV board type is correct
 uint8_t bd0_1_status = 0;
 uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "T1.21.00.0000.00"; // "V0.16.00.0000.00";
-char* DebugVersion = "T1.21.7";
+char *fwVersion = "V1.22.00.0000.00"; // "V0.16.00.0000.00";
+char* DebugVersion = "V1.22.0";
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -323,7 +325,7 @@ static void GetFirmwareVersion(void)
 {
     // Get CSU root file system version
     sprintf((char *)pSysInfo->CsuRootFsFwRev, fwVersion);
-
+    sprintf((char *)ShmDcCommonData->DebugVersion, DebugVersion);
     uint8_t count = 0, chademo = 0, ccs = 0, gb = 0;
     for (uint8_t idx = 0; idx < 3; idx++) {
         if (pSysConfig->ModelName[7 + idx] == 'J') {
@@ -4430,6 +4432,144 @@ void showversion()
     }
     log_info("\t================================ ");
 }
+
+
+void SetNatural300AGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetCurrent[0] = 5000;
+    deratingByConnOtp->deratingTargetCurrent[1] = 3000;
+    deratingByConnOtp->deratingTargetCurrent[2] = 1000;
+    deratingByConnOtp->deratingTargetCurrent[3] = 0;
+    deratingByConnOtp->deratingTargetCurrent[4] = 0;
+}
+void SetLiquidCoolGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetCurrent[0] = 5000;
+    deratingByConnOtp->deratingTargetCurrent[1] = 4000;
+    deratingByConnOtp->deratingTargetCurrent[2] = 3000;
+    deratingByConnOtp->deratingTargetCurrent[3] = 0;
+    deratingByConnOtp->deratingTargetCurrent[4] = 0;
+}
+
+void SetCHAdeMoTypeKOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetRate[0] = 1;
+    deratingByConnOtp->deratingTargetRate[1] = 0.8;
+    deratingByConnOtp->deratingTargetRate[2] = 0.8;
+    deratingByConnOtp->deratingTargetRate[3] = 0;
+    deratingByConnOtp->deratingTargetRate[4] = 0;
+
+    memset(&deratingByConnOtp->deratingTargetCurrent[0], 0, sizeof(deratingByConnOtp->deratingTargetCurrent));
+}
+
+void SetCHAdeMoTypeSJOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetCurrent[0] = 2000;
+    deratingByConnOtp->deratingTargetCurrent[1] = 1250;
+    deratingByConnOtp->deratingTargetCurrent[2] = 1250;
+    deratingByConnOtp->deratingTargetCurrent[3] = 0;
+    deratingByConnOtp->deratingTargetCurrent[4] = 0;
+}
+
+static void SetGunTypeOTPValue(void)
+{
+    //struct ChargingInfoData* chargingData_2 = NULL;
+    uint8_t Gun1Type = 0;
+    uint8_t Gun2Type = 0;
+    uint8_t Type;
+    int i,cnt;
+    if (pSysConfig->TotalConnectorCount == 1) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(0);
+        Gun1Type = pSysConfig->ModelName[7];
+        Gun2Type = pSysConfig->ModelName[7];
+
+        switch (Gun1Type) {
+
+        case 'K':
+            SetCHAdeMoTypeKOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+        case 'S':
+            SetCHAdeMoTypeSJOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+        case 'T':
+        case 'D':
+            SetNatural300AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+            // 水冷
+        case 'V':
+        case 'F':
+            SetLiquidCoolGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+        default:
+            pDcChargingInfo->deratingByConnOtp.isNeedDerating = NO;
+        }
+        if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
+            log_info("------------ Gun0 - Type:%c Derating info (OTP)-----------", Gun1Type);
+            if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[0] != 0) {
+                for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                    if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt] != 0) {
+                        log_info(" (Pwr) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt]);
+                    }
+                }
+            } else if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[0] != 0) {
+                for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                    if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt] != 0) {
+                        log_info(" (Cur) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt]);
+                    }
+                }
+            }
+        }
+
+    } else if (pSysConfig->TotalConnectorCount == 2) {
+        Gun1Type = pSysConfig->ModelName[7];
+        Gun2Type = pSysConfig->ModelName[9];
+        for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
+
+            switch (i == 0 ? Gun1Type : Gun2Type) {
+            case 'K':
+                SetCHAdeMoTypeKOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+            case 'S':
+                SetCHAdeMoTypeSJOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+                // 風冷300A
+            case 'T':
+            case 'D':
+                SetNatural300AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+                // 水冷
+            case 'V':
+            case 'F':
+                SetLiquidCoolGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+            default:
+                pDcChargingInfo->deratingByConnOtp.isNeedDerating = NO;
+            }
+            if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
+                log_info("------------ Gun%d - Type:%c Derating info (OTP)-----------",i, i == 0 ? Gun1Type : Gun2Type);
+                if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[0] != 0) {
+                    for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                        if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt] != 0) {
+                            log_info(" (Pwr) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt]);
+                        }
+                    }
+                } else if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[0] != 0) {
+                    for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                        if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt] != 0) {
+                            log_info(" (Cur) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt]);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
 int main(void)
 {
     bool isModelNameMatch = true;
@@ -4601,6 +4741,8 @@ int main(void)
 
     time_t ShowEVStatusTimer[2] = { 0 };
 
+    SetGunTypeOTPValue();
+
     for (;;) {
 
         CheckOcppStatus();
@@ -4720,7 +4862,9 @@ int main(void)
                     strcpy((char *)pDcChargingInfo->StopDateTime, "");
                     strcpy((char *)pDcChargingInfo->StartUserId, "");
                     strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "");
-                    
+                    if (pDcChargingInfo->deratingByConnOtp.deratingIndex != 0) {
+                        pDcChargingInfo->deratingByConnOtp.deratingIndex = 0;
+                    }
                     //Jerry add
                     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
                     memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));

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

@@ -293,6 +293,10 @@ enum _CREDITCARD_STATUS {
 	_CREDITCARD_SETTLEMENT,
 	_CREDITCARD_START,
 };
+enum _DERATING_TEMP {
+    STAGE1_GUN_DERATING_TEMP = 140,
+    STAGE2_GUN_DERATING_TEMP = 145,
+};
 //------------------------------------------------------------------------------
 //struct StructMeter {
 //    float curMeterValue;
@@ -489,6 +493,9 @@ typedef struct StDcCommonInfo {
     GunInfo pGunInfo[2];
     uint8_t showNetPackage;
     uint8_t showCanPackage;
+    time_t FanOnTime;
+    float TempVolt[4];
+    char DebugVersion[32];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 192 - 43
EVSE/Projects/DD360/Apps/Define/define.h

@@ -153,6 +153,15 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
+#elif defined Emulator
+    #define MAX_PSU_QUANTITY        62
+    #define CHAdeMO_QUANTITY        3
+    #define CCS_QUANTITY            3
+    #define GB_QUANTITY             3
+    #define AC_QUANTITY             3
+    #define GENERAL_GUN_QUANTITY    0
+    #define PSU_QUANTITY            2
+    #define ONE_CONNECTOR_USE       0
 #else
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        2
@@ -188,6 +197,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmRelay2BdKey			1013
 #define ShmYesCustomKey         1014
 #define ShmOcppPHModuleKey      1015
+#define ShmSmartBoxKey          1016
 
 #define FaultCodeLength         5
 #define AlarmCodeLength         20
@@ -332,6 +342,7 @@ enum CoreProfile {
      isEnableLocalPowerSharing,
      PowerSharingServerIP,
      EVCCID_PREFIX,
+     OffLineMaxChargingPower,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -370,7 +381,9 @@ struct WifiConfigData
 {
 	unsigned char		WifiMode;					//0: disable, 1: Infrastructure client, 2: Infrastructure server, 3: Ad-Hoc
 	unsigned char		WifiSsid[256];				//default: Null
-	unsigned char		WifiPassword[256];			//default: Null
+    unsigned char       WifiPassword[224];          //default: Null
+    unsigned char       WifiBroadcastSsid;          //the SSID broadcast configuration, 0: hidden   1: broadcast
+    unsigned char       WifiTargetBssidMac[31];     //Target connect SSID MAC address, default: Null
 	int					WifiRssi;					//dbm
 	unsigned char		WifiDhcpServer;				//0: enable, 1: disable
 	unsigned char		WifiDhcpClient;				//0: enable, 1: disable
@@ -385,7 +398,8 @@ struct TeleConfigData
 {
 	unsigned char		TelcomModelName[64];		//default: Null
 	unsigned char		TelcomSoftwareVer[64];		//default: Null
-	unsigned char		TelcomApn[256];				//default: Null
+    unsigned char       TelcomApn[255];             //default: Null
+    unsigned char       TelcomNetworkType;          //0: Auto   1: CDMA  2: WCDMA  3: LTE  4: TD-SCDMA  5: UMTS  6: CDMA  7: HDR  8: CDMA/HDR
 	int					TelcomRssi;					//dbm
 	unsigned char		TelcomChapPapId[256];		//default: Null
 	unsigned char		TelcomChapPapPwd[256];		//default: Null
@@ -484,7 +498,8 @@ typedef union
         unsigned int InvalidIdStop:1;               // 0: no effect,    1: invalid stop when StopTransactionOnInvalidId is true
         unsigned int RemoteStop:1;                  // 0: no effect,    1: remote stop
         unsigned int UnlockStop:1;                  // 0: no effect,    1: unlock stop
-        unsigned int res:23;
+        unsigned int SessionTargetStop:1;           // 0: no effect,    1: session target stop
+        unsigned int res:22;
     }bits;
 }ChargingStop;
 
@@ -591,6 +606,16 @@ struct SysConfigData
     unsigned char           MaintainServerSecurityProfile;      // Maintain server security profile 0~3
     unsigned char           MaintainServerSecurityPassword[41]; // Maintain server AuthorizationKey for security profile
     unsigned char           PowerSharingServerIP[512];          // Local power sharing server ip address
+    unsigned int            PowerSharingCapacityPower;          // Local power sharing capacity power
+    unsigned char           MaxChargingSoc;                     //0: unlimit, 1 ~ 100 percent
+};
+
+struct DERATING_BY_OTP
+{
+    unsigned char isNeedDerating;
+    unsigned char deratingIndex;        // Current used power or current
+    double deratingTargetRate[5];       // Reduce the output energy rate
+    double deratingTargetCurrent[5];    // derating target current
 };
 
 struct ChargingInfoData
@@ -626,6 +651,7 @@ struct ChargingInfoData
 	int EvBatterySoc;				// 0~100%
 	unsigned char ConnectorPlugIn;			//0: unplug, 1: Plug-in
 	unsigned char GunLocked;				//0: unlocked 1: locked
+	unsigned char InProgress;               //0: real idle, 1: session(transaction) in progress
 	float PilotVoltage;
 	unsigned char PilotState;//1:state A, 2:State B1, 3:State B2, 4:State C, 5:State D, 6:State E, 7:State F, 8: Pilot error
 	unsigned char PilotDuty;					// 0~100%
@@ -695,6 +721,9 @@ struct ChargingInfoData
     unsigned char       CCSGunType;
     struct timeval      PreChargeTimer;
     unsigned char       _SaftyDetect;
+    unsigned char       _TotalPsuCount;                 // Psu count for connector
+    unsigned char       _TakePsuGpCount;                // Get the used psu group count
+    struct DERATING_BY_OTP deratingByConnOtp;
 };
 
 typedef struct
@@ -878,6 +907,7 @@ struct ConnectorInfoData
     float                   CostDiscount;                   // connector user's Discount or couponPoint, unit: 1 point
     float                   EnergyCost;                     // connector user's energy cost, unit: 1 dollar
     float                   ParkingFee;                     // connector user's parking fee, unit: 1 dollar
+    float                   RemainAmount;                   // connector user's remain amount, unit: 1 dollar
 };
 
 typedef union
@@ -885,15 +915,11 @@ typedef union
     unsigned int SettingValue;
     struct
     {
-        unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
-        unsigned int FlashConfigChanged:1;      // 0: no effect, 1: flash config has changed
-        unsigned int EnableWriteFlash:1;        // 0: no effect, 1: enable to write flash after timeout
-        unsigned int CleanWiringInfo:1;         // 0: no effect, 1: clean wiring info
-        unsigned int res:28;
+        unsigned int res:32;
     }bits;
 }CabinetSettingFlag;
 
-typedef struct DC_METER_INFO
+struct DC_METER_INFO
 {
     double presetVoltage;                       // resolution: 1.000v
     double presentCurrent;                      // resolution: 1.000a
@@ -901,7 +927,61 @@ typedef struct DC_METER_INFO
     double totlizeImportEnergy;                 // resolution: 1.000kwh
     double totlizeExportEnergy;                 // resolution: 1.000kwh
     unsigned char LinkStatus;                   // 0 = unknow ,1 = link , 2 miss link
-}DC_Meter_Info;
+};
+
+typedef struct Bazel8Command
+{
+    unsigned char isReq:1;
+    unsigned char isRes:1;
+    unsigned char isWaitRes:1;
+    unsigned char isResultPass:1;
+} bazel8Command;
+
+typedef struct EventInfo
+{
+    int messageId;
+    char messageString[64];
+    unsigned char isGetOn:1;
+}eventInfo;
+
+typedef struct StartTxResp
+{
+    char statusCode[8];
+    char statusText[128];
+    char txnId[32];
+    unsigned char isGetOn:1;
+}startTxResp;
+
+struct BAZEL8
+{
+    eventInfo       event;
+    startTxResp     txResp;
+
+    bazel8Command   cmdPreAuth;
+};
+
+struct Enegate
+{
+    union
+    {
+        unsigned char OperationValue[CONNECTOR_QUANTITY];
+        struct
+        {
+            unsigned char isAuthorizing:1;
+            unsigned char isAuthorized:1;
+            unsigned char isAuthorizedPass:1;
+            unsigned char isSessionStopReq:1;
+            unsigned char isStopService:1;
+            unsigned char isAutoStartEnable:1;
+            unsigned char isConnectTimeout:1;
+            unsigned char :1;
+        } bits[CONNECTOR_QUANTITY];
+    }Operation;
+
+    unsigned char   serviceStartTimestamp[36];
+    unsigned char   serviceStopTimestamp[36];
+    unsigned char   isEnable:1;
+};
 
 struct SysInfoData
 {
@@ -996,10 +1076,12 @@ struct SysInfoData
     unsigned char           AuthorizedStatus;           // cabinet authorized status
     CabinetSettingFlag      CabinetSetting;
     struct LocalSharingInfo localSharingInfo;           // Local power sharing info structure
-    DC_Meter_Info DcMeterInfo[4];
+    struct DC_METER_INFO    DcMeterInfo[4];
     unsigned char           OTPTemp;                    // OTP Temperature
     unsigned char           OTPTempR;                   // OTP Recovery Temperature
     struct LCD_OVERRIDE     LcdOveride;                 // LCD override info (no use anymore)
+    struct BAZEL8           bazel8;                     // Bazel8 payment used
+    struct Enegate          enegate;                    // Enegate payment used
 };
 
 struct SysConfigAndInfo
@@ -1253,18 +1335,18 @@ char AlarmStatusCode[160][6]=
 	"012261",	//GB groundfault detection timeout (GFD)
 	"012262",	//Circuit Short L1
 	"012263",	// PSU Duplicate ID
-	"012264", 	// PSU Output Short Circuit
+	"012264", 	// Psu Fault : Infy => Output Short Circuit,UU => Abnormal discharge circuit
 	"012265", 	// PSU Discharge Abnormal
 	"012266", 	// PSU Dc Side ShutDown
 	"012267", 	// PSU Failure Alarm
 	"012268", 	// PSU Protection Alarm
-	"012269", 	// PSU FanFailure Alarm
+	"012269", 	// Psu Fault : Infy => Fan Fault,UU => Fan Fault
 	"012270", 	// PSU Input UVP
 	"012271",	// PSU Input OVP
 	"012272", 	// PSU WalkIn State
-	"012273", 	// PSU Power Limited State
-	"012274", 	// PSU Id Repeat
-	"012275", 	// PSU Severe Uneven Current
+	"012273", 	// Psu Fault : Infy => Power Limited State,UU => Dc OVP and shutdown
+	"012274", 	// Psu Fault : Infy => Id Repeat,UU => Id Repeat
+	"012275", 	// Psu Fault : Infy => Severe Uneven Current,UU => Pfc internal unbalance
 	"012276", 	// PSU Three Phase Input Inadequate
 	"012277", 	// PSU Three Phase Onput Imbalance
 	"012278", 	// PSU Ffc Side ShutDown
@@ -1296,18 +1378,18 @@ char AlarmStatusCode[160][6]=
 	"012304",   // connection disconnected from power cabinet
 	"012305",   // Meter communication timeout
 	"012306",   // The dip switch of the PSU may be incorrect
-    "012307",   // Psu Fuse Burn-Out
-    "012308",   // Psu Pfc And Dcdc Communication Fault
-    "012309",   // Psu Bus Voltage Unbalance
-    "012310",   // Psu Bus Over Voltage
-    "012311",   // Psu Bus Voltage Abnormal
-    "012312",   // Psu Bus Under Voltage
-    "012313",   // Psu Input Phase Loss
-    "012314",   // Psu Fan Full Speed
-    "012315",   // Psu Temperature Power Limit
-    "012316",   // Psu Ac Power Limit
-    "012317",   // Psu Dcdc Eeprom Fault
-    "012318",   // Psu Pfc Eeprom Fault
+    "012307",   // Psu Fault : Infy => Fuse Burn-Out,UU => Pfc internal OVP
+    "012308",   // Psu Fault : Infy => Pfc And Dcdc Communication Fault,UU => Pfc And Dcdc Communication Fault
+    "012309",   // Psu Fault : Infy => Bus Voltage Unbalance,UU => Dc output voltage unbalance
+    "012310",   // Psu Fault : Infy => Bus Over Voltage,UU => Ac site OVP
+    "012311",   // Psu Fault : Infy => Bus Voltage Abnormal,UU => Ac site UVP
+    "012312",   // Psu Fault : Infy => Bus Under Voltage,UU => Pfc internal UVP
+    "012313",   // Psu Fault : Infy => Input Phase Loss,UU => Dc to Dc don’t work
+    "012314",   // Psu Fault : Infy => Fan Full Speed,UU => Fan don’t work
+    "012315",   // Psu Fault : Infy => Temperature Power Limit,UU => env OTP、Pfc OTP、output relay broken、Dc OTP
+    "012316",   // Psu Fault : Infy => Ac Power Limit,UU => Ac OVP and shutdown
+    "012317",   // Psu Fault : Infy => Dcdc Eeprom Fault,UU => Dc to Dc broken
+    "012318",   // Psu Fault : Infy => Pfc Eeprom Fault,UU => Pfc broken
     "012319",   // Psu Dcdc Over Voltage
     "012320",   // System CHAdeMO output UCP
     "012321",   // System CCS output UCP
@@ -1316,13 +1398,13 @@ char AlarmStatusCode[160][6]=
     "012324",   // Connector 1 detects abnormal voltage on the output line
     "012325",   // Connector 2 detects abnormal voltage on the output line
     "012326",   // System task is lost
-    "012327",   // DC input ovp
-    "012328",   // DC input uvp
-    "012329",   // Psu Can Communication Fault
-    "012330",   // Psu Dc to Dc OTP
-    "012331",   // Psu Dc to Dc OVP
-    "012332",   // reserved
-    "012333",   // reserved
+    "012327",   // System DC input ovp
+    "012328",   // System DC input uvp
+    "012329",   // Psu Fault : Infy => Psu Can Communication Fault,UU =>
+    "012330",   // Psu Fault : Infy => Psu Dc to Dc OTP,UU => env UTP
+    "012331",   // Psu Fault : Infy => Psu Dc to Dc OVP,UU => Dc output OVP
+    "012332",   // Chiller Tube OTP
+    "012333",   // Psu Fault : Infy => DC input ovp (Phase OVP),UU => Dc output UVP
     "012334",   // reserved
     "012335",   // reserved
     "012336",   // reserved
@@ -1336,12 +1418,12 @@ char AlarmStatusCode[160][6]=
     "012344",   // AC: Meter IC communication timeout
     "012345",   // AC: Pilot negative error
     "012346",   // Psu Communication error with CSU
-    "012347",   // reserved
+    "012347",   // AC: Local power sharing communication error (Slave disconnect from Master)
     "012348",   // reserved
     "012349",   // reserved
     "012350",   // reserved
     "012351",   // reserved
-    "012352",   // reserved
+    "012352",   // Payment system communication timeout
     "012353",   // reserved
     "012354",   // reserved
     "012355",   // reserved
@@ -1508,16 +1590,20 @@ struct AlarmCodeData
             unsigned char PsuCanCommFault:1;                        //bit 1
             unsigned char PsuDcDcOtp:1;                             //bit 2
             unsigned char PsuDcDcOvp:1;                             //bit 3
-            unsigned char :4;                                       //reserved bit 4 ~ bit 7
+            unsigned char ChillerTubeOTP : 1;                       //bit 4
+            unsigned char PsuPhaseOvp:1;                            //bit 5
+            unsigned char :2;                                       //reserved bit 6 ~ bit 7
             //AlarmVal[17]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
             //AlarmVal[18]
             unsigned char MeterIcCommTimeout:1;                     //bit 0
             unsigned char PilotNegativeError:1;                     //bit 1
             unsigned char PsuComminicationErrWithCSU:1;             //bit 2
-            unsigned char :5;                                       //reserved bit 3 ~ bit 7
+            unsigned char LocalPowerSharingCommunicationError:1;    //bit 3
+            unsigned char :4;                                       //reserved bit 4 ~ bit 7
             //AlarmVal[19]
-            unsigned char :8;                                       //reserved bit 0 ~ bit 7
+            unsigned char PaymentCommTimeout:1;                     //Payment system communication timeout
+            unsigned char :7;                                       //reserved bit 1 ~ bit 7
 		}bits;
 	}AlarmEvents;
 };
@@ -1843,7 +1929,7 @@ char InfoStatusCode[384][6]=
     "023981",   // ERROR_CODE_CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT
     "023982",   // ERROR_CODE_CHADEMO_ADC_LESS_THAN_10V
     "023983",   // STOP by EV with unknow reason
-    "023984",   // Reserved
+    "023984",   // STOP by EVSE condition (Config or OCPP)
     "023985",   // Reserved
     "023986",   // Reserved
     "023987",   // Reserved
@@ -2190,7 +2276,8 @@ struct InfoCodeData
             unsigned char CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT:1; //bit 1
             unsigned char CHADEMO_ADC_LESS_THAN_10V:1;              //bit 2
             unsigned char Stop_by_EV_with_unknow_reason:1;          //bit 3
-            unsigned char :4;                                       //bit 4 ~ 7 reserved
+            unsigned char Stop_by_EVSE_condition:1;                 //bit 4
+            unsigned char :3;                                       //bit 5 ~ 7 reserved
 			//InfoVal[40]
 			unsigned char BackendDisconnectedViaEthernet:1;			//bit 0
 			unsigned char BackendDisconnectViaWiFi:1;				//bit 1
@@ -2267,6 +2354,8 @@ struct PsuModuleData
 	unsigned int 		AlarmCode;
 	unsigned int 		FaultCode;			//
 	unsigned int 		IAvailableCurrent;		            // unit: 0.1A
+    unsigned short  PresentMaxOutputVoltage;//abcd=abc.d volt
+    unsigned short  KwAvailablePower;       // unit: 0.1 kw
 };
 
 /*Following are the information for each PSU Group*/
@@ -2288,6 +2377,11 @@ struct PsuGroupData
     unsigned short          TempIAvailableCurrent;          // unit: 0.1A
     unsigned short          StableIAvailableCurrent;        // unit: 0.1A
     unsigned short          StableCurrentCounter;           // stable current counter
+    unsigned short          GroupMaxVoltage;                // unit: 0.1V
+    unsigned char           IsUsing;                        // 0 : none use
+    unsigned char           UsingTarget;                    // 0xFF : Check
+    unsigned char           PwSwitchStatus;
+    unsigned short          TotalRatingPower;               // unit: 1kW
 };
 
 /*Following is the information for system all PSU*/
@@ -2303,6 +2397,54 @@ struct PsuData
 	unsigned char           PsuStopChargeFlag;
 };
 
+struct SmartTimeChk
+{
+    struct timespec     FetchLoopTime;
+    unsigned char       IsFetchStart;
+
+    struct timespec     ReleaseLoopTime;
+    unsigned char       IsReleaseStart;
+};
+
+struct DynamicFetchCtrl
+{
+    unsigned char       ShareGroup;         // 255 : None
+    unsigned char       FetchLoopStep;      // 0 : None, 1 : Output Vol, 2 : RCB ON, 3 : Current sharing, 4 : Finish
+    unsigned short      ShareTargetCurrent; // 0.1A
+    unsigned char       TargetRelay;        // 255 : None
+};
+
+struct DynamicReleaseCtrl
+{
+    unsigned char       ReleaseGroup;       // 255 : None
+    unsigned char       ReleaseLoopStep;    // 0 : None, 1 : Limit Pwr, 2 : Pwr OFF, 3. RCB OFF, 4. Finish
+    float               CheckOutPwrIsStable;// 0.1kw
+    unsigned char       TargetRelay;        // 255 : None
+
+    float               LimitCurCap;        // Inform 0.1A
+    float               LimitPwrCap;        // Inform 0.1kw
+    float               LimitCur;           // Target 0.1A
+    float               LimitPwr;           // Target 0.1kw
+};
+
+struct ConnInfo
+{
+    unsigned char ConnectorStaus;
+    unsigned char NeedToFetch;
+};
+
+struct SmartBoxData
+{
+    struct ConnInfo     ConnectorStatus[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];     // Connector 1 / 2 Status : None, Wait, Using
+    struct ConnInfo     AnotherConnectorStatus[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    unsigned char       ConnectorUsingGroupCount[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; // Psu group for connector
+    struct SmartTimeChk SmartChk[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    struct DynamicFetchCtrl Dynamic4Fetch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    struct DynamicReleaseCtrl Dynamic4Release[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    unsigned char       ParallelRelayStatus[3];
+    unsigned char       RcbParallelStatus[3];
+};
+
 /************************************************************************************/
 /**************************CHAdeMO protocol Share memory*********************/
 /**************************************************************************************/
@@ -4449,6 +4591,7 @@ struct Triggers
                                                     // be used to trigger a meter value when vehicle stops charging or when vehicle charges at a high power that requires a
                                                     // different tariff.
                                                     // It is recommended to implement a hysteresis around this value to avoid repetitive triggers when the power fluctuates around this level.
+    unsigned char atCPStatus[100];
 };
 
 struct StrcutRunningCost
@@ -4469,6 +4612,10 @@ struct StrcutFinalCost
 {
     int             txId;
     unsigned char   description[1024];
+
+    float           cost;
+    unsigned char   priceText[1024];
+    unsigned char   qrCodeText[1024];
 };
 
 struct StructCost
@@ -4874,6 +5021,7 @@ enum OCPP20CtrlrVariable
 	ChargingStation_SystemUptimeSec,
 	ChargingStation_FreeVend,
 	ChargingStation_FreeVendIdtag,
+	ChargingStation_OffLineMaxChargingPower,
 	Connector_Available,
 	Connector_ConnectorType,
 	Connector_SupplyPhases,
@@ -6008,7 +6156,8 @@ struct OCPP20Data
 			unsigned char SecurityEventNotificationConf :1;
 			unsigned char SignCertificateReq :1;
 			unsigned char SignCertificateConf :1;
-			unsigned char :2;
+            unsigned char NotifyCustomerInformationReq :1;  //bit 6
+            unsigned char NotifyCustomerInformationConf :1; //bit 7
 
 		} bits;
 	} SpMsg;

+ 4 - 4
EVSE/Projects/DD360/Apps/Log/log.h

@@ -2,11 +2,11 @@
 #define _LOG_H_
 
 //------------------------------------------------------------------------------
-#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)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
-#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args) //DS60-120 add
+#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args) //DS60-120 add
 //------------------------------------------------------------------------------
 int StoreLogMsg(const char *fmt, ...);
 int StoreEventLogMsg(const char *fmt, ...);

+ 11 - 0
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -166,6 +166,7 @@ static void getChillerTemperature(ChillerTemp *chillerTemp)
     for (i = 0; i < 4; i++) {
         adcVoltage = 0.0;
         adcVoltage =  ReadAdcVolt(i);
+        ShmDcCommonData->TempVolt[i] = adcVoltage;
         if ((adcVoltage <= 0.9) && (adcVoltage >= 0.8)) { //0 ~ -40
             pChillerTemp->Temp[i] = ((adcVoltage - 0.908) * 500) + 60;
             //log_info("1 adcVoltage = %f", (adcVoltage - 0.9) * 500);
@@ -309,6 +310,7 @@ void CANReceiver(int fd)
         int len = 0;
         char _info[1024];
         int i;
+        unsigned char GunStatus[2];
 
         pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
@@ -515,6 +517,7 @@ void CANReceiver(int fd)
 
             case ACK_GET_OUTPUT_REQ:
                 //DS60-120 add
+
                 if ((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EV &&
                         pDcChargingInfo->SystemStatus <= S_CHARGING) ||
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
@@ -525,6 +528,14 @@ void CANReceiver(int fd)
                         pDcChargingInfo->EvBatteryStartSoc = frame.data[1];
                     }
 
+                    // 進入充電時重新更新電池電量
+                    if (GunStatus[targetGun] != pDcChargingInfo->SystemStatus && pDcChargingInfo->SystemStatus == S_CHARGING) {
+
+                        log_info("Reset Gun%d SoC:%d", targetGun, frame.data[1]);
+                        pDcChargingInfo->EvBatterySoc = frame.data[1];
+                        GunStatus[targetGun] = pDcChargingInfo->SystemStatus;
+                    }
+
                     if (frame.data[1] > pDcChargingInfo->EvBatterySoc) {
                         pDcChargingInfo->EvBatterySoc = frame.data[1];
                         log_info("Gun%d SOC:%d", targetGun,pDcChargingInfo->EvBatterySoc);

+ 42 - 1
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -55,7 +55,7 @@ static float LogInfo[2][10]; //DS60-120 add
 static int CanFd = -1;
 
 bool psuOutputReady[2] = {0, 0};
-
+uint8_t deratingIndex[2];
 //------------------------------------------------------------------------------
 extern void CANReceiver(int fd);
 extern void ClearAbnormalStatus_Chademo(uint8_t gun_index);
@@ -301,7 +301,33 @@ static void setCurrentOutput(void)
         }
     }
 }
+void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, float* cur)
+{
+    if (((chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
+        chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP) ||
+        (chargingData->ChillerTemp >= STAGE1_GUN_DERATING_TEMP &&
+            chargingData->ChillerTemp < STAGE2_GUN_DERATING_TEMP)) &&
+        chargingData->deratingByConnOtp.deratingIndex < 1)
+    {
+        chargingData->deratingByConnOtp.deratingIndex = 1;
+    } else if ((chargingData->ConnectorTemp >= STAGE2_GUN_DERATING_TEMP ||
+        chargingData->ChillerTemp >= STAGE2_GUN_DERATING_TEMP) &&
+        chargingData->ConnectorTemp != UNDEFINED_TEMP &&
+        chargingData->ChillerTemp != UNDEFINED_TEMP &&
+        chargingData->deratingByConnOtp.deratingIndex < 2)
+    {
+        chargingData->deratingByConnOtp.deratingIndex = 2;
+    }
 
+    if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
+    {
+        *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
+    } else if (chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex] != 0)
+    {
+        if (*cur > chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex])
+            *cur = chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex];
+    }
+}
 static void SetPresentChargingOutputCap(void)
 {
     float pow1 = 0, cur1 = 0;
@@ -346,6 +372,13 @@ static void SetPresentChargingOutputCap(void)
         }
     }
 
+    if (chargingData_1->deratingByConnOtp.isNeedDerating) {
+        GetOtpPwrOrCurMethod(chargingData_1, &pow1, &cur1);
+        if (deratingIndex[0] != chargingData_1->deratingByConnOtp.deratingIndex) {
+            log_info("Gun0 Derating Index Set %d", chargingData_1->deratingByConnOtp.deratingIndex);
+            deratingIndex[0] = chargingData_1->deratingByConnOtp.deratingIndex;
+        }
+    }
     pow2 = chargingData_2->AvailableChargingPower;
     cur2 = chargingData_2->AvailableChargingCurrent;
 
@@ -371,6 +404,14 @@ static void SetPresentChargingOutputCap(void)
         }
     }
 
+    if (chargingData_2->deratingByConnOtp.isNeedDerating) {
+        GetOtpPwrOrCurMethod(chargingData_2, &pow2, &cur2);
+        if (deratingIndex[1] != chargingData_2->deratingByConnOtp.deratingIndex) {
+            log_info("Gun1 Derating Index Set %d", chargingData_2->deratingByConnOtp.deratingIndex);
+            deratingIndex[1] = chargingData_2->deratingByConnOtp.deratingIndex;
+        }
+    }
+
     //DS60-120 add
     if ((LogInfo[0][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 5 ||
             LogInfo[0][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 5) ||

+ 1 - 1
EVSE/Projects/DD360/Apps/ModuleEventLog/Module_EventLogging.c

@@ -52,7 +52,7 @@ static struct FaultCodeData *pFaultCode      = NULL;
 //#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)
-#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args) //DS60-120 add
+#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args) //DS60-120 add
 
 /*
 int StoreLogMsg(const char *fmt, ...)

+ 3 - 3
EVSE/Projects/DD360/Apps/ModuleInternalComm/Module_InternalComm.h

@@ -85,9 +85,9 @@
 #define AC_ROTARY_SWITCH_FAULT                  (131072)
 #define AC_RELAY_DRIVE_FAULT                    (262144)
 
-#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)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
 //------------------------------------------------------------------------------
 

+ 24 - 1
EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c

@@ -1245,9 +1245,31 @@ static void GetFanSpeed(void)
 static void GetFanSpeedByFunction(void)
 {
     if (ShmDcCommonData->debugflag== YES) {
+        ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
         return;
     }
 
+    int gunIndex;
+    struct ChargingInfoData* pDcChargingInfo = NULL;
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
+        if ((pDcChargingInfo->SystemStatus > S_AUTHORIZING && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            ShmDcCommonData->FanOnTime = time((time_t*)NULL);
+            if (ShmFanModuleData->SetFan1Speed == 0) {
+                ShmFanModuleData->SetFan1Speed = 7000;
+                log_info("Set Fan speed 7000");
+            }
+        }
+    }
+
+    if ((time((time_t*)NULL) - ShmDcCommonData->FanOnTime) >= 600 &&
+        ShmFanModuleData->SetFan1Speed == 7000) {
+        ShmFanModuleData->SetFan1Speed = 0;
+        log_info("Close fan");
+    }
+
+    /*
     // 風控修改 :
     // ******************************************************* //
     //
@@ -1305,6 +1327,7 @@ static void GetFanSpeedByFunction(void)
     if (ShmFanModuleData->TestFanSpeed < 0) {
         ShmFanModuleData->TestFanSpeed = 0;
     }
+    */
 //
 //  printf("power = %f \n", power);
 //  printf("_maxPower = %d \n", _maxPower);
@@ -1406,7 +1429,7 @@ static void fanBoardPorcess(void)
 
         if (GetTimeoutValue(gFanBoardRunTimer) / 1000 >= 1000) {
             //GetPsuTempForFanSpeed();
-            //GetFanSpeedByFunction();
+            GetFanSpeedByFunction();
             GetFanSpeed();
             pSysInfo->SystemFanRotaSpeed = _setFanSpeed;
             gettimeofday(&gFanBoardRunTimer, NULL);

+ 9 - 7
EVSE/Projects/DD360/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -933,20 +933,22 @@ void ChangeRemainTime(int sec)
 
 void ChangeChargingEnergyValue(float energy)
 {
-    uint8_t cmd[10];
-    uint8_t value[10];
+    uint8_t cmd[20];
+    uint8_t value[20];
 
     memset(cmd, 0x00, sizeof(cmd));
 
     sprintf((char*)value, "%.4f kWh", energy);
+    if (energy > 0.00005)
+        energy -= 0.00005;
     string2ByteArray(value, cmd);
     DisplayValueToLcm(__present_energy, cmd, sizeof(cmd));
 }
 
 void ChangeChargingPowerValue(float pow)
 {
-    uint8_t cmd[10];
-    uint8_t value[10];
+    uint8_t cmd[20];
+    uint8_t value[20];
 
     memset(cmd, 0x00, sizeof(cmd));
 
@@ -1040,8 +1042,8 @@ void DisplayMoneyRate(float money)
 
 void DisplayMoneyCur(uint8_t *cur)
 {
-    uint8_t cmd[10] = {0};
-    uint8_t buf[10] = {0};
+    uint8_t cmd[20] = {0};
+    uint8_t buf[20] = {0};
     uint8_t len = 0;
 
     *(cur + 3) = '\0';
@@ -2085,7 +2087,7 @@ void ProcessPageInfo()
                     } else {
                         ChangeChargingPowerValue(0);
                     }
-
+                    
                     if (pDcChargingInfo->PresentChargedEnergy > 0 &&
                             pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
                         ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);

+ 8 - 40
EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -372,68 +372,36 @@ static void checkChillerStatus(Gpio_out *gpio)
         pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
 
         if((pDcChargingInfo->SystemStatus > S_IDLE && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
-            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1))
-        {
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
             pChillerInfo->ChillerSwitch = YES;
             pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-        }
-        else
-        {
-            if(pChillerInfo->ChillerSwitch == YES)
-            {
+        } else {
+            if(pChillerInfo->ChillerSwitch == YES) {
                 //10分鐘後停止
-                if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600)
-                {
+                if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600) {
                     pChillerInfo->ChillerSwitch = NO;
-                    ShmFanModuleData->SetFan1Speed = 0;
-                }
-            }
-            else
-            {
-                pChillerInfo->ChillerSwitch = NO;
-            }
-        }
-#if 0
-        if ((pDcChargingInfo->PresentChargingCurrent) >= 150) { //當前電壓於150A,打開水冷機
-            pChillerInfo->ChillerSwitch = YES;
-            pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-        } else {
-            if (pChillerInfo->ChillerSwitch == YES) {
-                if ((pDcChargingInfo->PresentChargingCurrent) >= 100) { //判斷如果還是大於100A不變動
-                    pChillerInfo->ChillerSwitch = YES;
-                    pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-                } else {
-                    if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600) { //5分鐘後停止
-                        pChillerInfo->ChillerSwitch = NO;
-                    } else {
-                        pChillerInfo->ChillerSwitch = YES;
-                    }
                 }
             } else {
                 pChillerInfo->ChillerSwitch = NO;
             }
         }
-#endif
     }
 
     uint8_t _chillerNeedOn = NO;
     for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++)
     {
         pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
-        if(pChillerInfo->ChillerSwitch == YES)
-        {
+        if(pChillerInfo->ChillerSwitch == YES) {
             _chillerNeedOn = YES;
-            if (chillerCount >= 2) {
-                ShmFanModuleData->SetFan1Speed = 7000;
-            }
         }
     }
 
+    /*
     if (ShmDcCommonData->debugflag == YES)
         _chillerNeedOn = ShmDcCommonData->chillerCtrl;
+    */
 
-    if(_chiller.ChillerSwitch != _chillerNeedOn)
-    {
+    if(_chiller.ChillerSwitch != _chillerNeedOn) {
         log_info("Chiller Need Turn %s", _chillerNeedOn == YES ? "ON" : "OFF");
     }
     _chiller.ChillerSwitch = _chillerNeedOn;

+ 18 - 1
EVSE/Projects/DD360/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -185,6 +185,13 @@ static int InitCanBus(void)
     return fd;
 }
 
+unsigned long long getAvailableMemory()
+{
+    long pages = sysconf(_SC_AVPHYS_PAGES);
+    long page_size = sysconf(_SC_PAGE_SIZE);
+    return pages * page_size;
+}
+
 static int CheckUpdateProcess(void)
 {
     //bool isPass = true;
@@ -205,6 +212,13 @@ static int CheckUpdateProcess(void)
     DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
 
+
+    if (getAvailableMemory() < (200 * 1024 * 1024))
+    {
+        log_info("Available memory (%.2f Bytes) less than 200 MBytes, free cache first.\n", getAvailableMemory() / (1024 * 1024.0));
+        system("echo 3 > /proc/sys/vm/drop_caches");
+    }
+
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     d = opendir("/mnt/");
     if (d) {
@@ -243,6 +257,8 @@ static int CheckUpdateProcess(void)
                         ((unsigned int)ptr[19]));
                 log_info("Typed...%x ", Type);
 
+                free(ptr);
+
                 switch (Type) {
                 case 0x10000001:
                 case 0x10000002:
@@ -396,9 +412,10 @@ static int CheckUpdateProcess(void)
                     //return isPass;
                     break;
                 }
+            } else {
+                free(ptr);
             }
             free(new_str);
-            free(ptr);
         }
     }
     free(dir);

BIN
EVSE/Projects/DD360/Apps/Module_ChkSysTask


BIN
EVSE/Projects/DD360/Apps/Module_DoComm


BIN
EVSE/Projects/DD360/Apps/Module_EvComm


BIN
EVSE/Projects/DD360/Apps/Module_EventLogging


BIN
EVSE/Projects/DD360/Apps/Module_InternalComm


BIN
EVSE/Projects/DD360/Apps/Module_UpdateFW


+ 19 - 11
EVSE/Projects/DD360/Apps/ReadCmdline.c

@@ -342,6 +342,7 @@ void GetFwVerProc(void)
 
     printf("ModelName = %s\r\n", pSysConfig->ModelName);
     printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
+    printf("DC Main Debug Version = %s \n", ShmDcCommonData->DebugVersion);
     printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
     printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
     printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
@@ -781,7 +782,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
 
                 printf ("[UnconditionalCharge - S_PREPARNIN]\n");
-
+                ShmFanModuleData->TestFanSpeed = 7000;
                 //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
                 printf ("wait find module\n");
 
@@ -939,7 +940,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 //無阻塞偵測 keybaord 結束
                 system(STTY_DEF TTY_PATH);
             }
-
+            pDcChargingInfo->ConnectorPlugIn = 0;
             pDcChargingInfo->SystemStatus = S_COMPLETE;
             break;
 
@@ -971,6 +972,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 
             if (stopChg == pSysConfig->TotalConnectorCount) {
                 ShmDcCommonData->debugflag = NO;
+                ShmFanModuleData->TestFanSpeed = 0;
                 system("/root/Module_EvComm &");
                 sleep(3);
 
@@ -1127,16 +1129,20 @@ static void resdGunAndChillerTemp(void)
 
                 pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
 
-                printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d, %3d, %3d, %3d\r\n",
+                printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d(%.3f), %3d(%.3f), %3d(%.3f), %3d(%.3f)\r\n",
                              i,
                              pDcChargingInfo->ConnectorTemp,
                              pDcChargingInfo->ChillerTemp,
                              ShmDcCommonData->ConnectorTemp[i][0],
                              ShmDcCommonData->ConnectorTemp[i][1],
                              ShmDcCommonData->SystemTemp[0],
+                             ShmDcCommonData->TempVolt[0],
                              ShmDcCommonData->SystemTemp[1],
+                             ShmDcCommonData->TempVolt[1],
                              ShmDcCommonData->SystemTemp[2],
-                             ShmDcCommonData->SystemTemp[3]);
+                             ShmDcCommonData->TempVolt[2],
+                             ShmDcCommonData->SystemTemp[3],
+                             ShmDcCommonData->TempVolt[3]);
             }//for
             ftime(&showTime);
         }
@@ -1312,15 +1318,17 @@ static void writeGunAndChillerTemp(void)
         }
 
         if (strcmp(newString[0], "chiller") == 0) {//修改水冷機溫度值
-            if (_GunIndex >= 1) {
-                _GunIndex = 0; //只會有一個水冷機
+            if (ShmDcCommonData->pGunInfo[_GunIndex].withChiller) {
+                pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_GunIndex);
+                memset((char*)ShmDcCommonData->SystemTemp, atoi(newString[2]), sizeof(ShmDcCommonData->SystemTemp));
+                pDcChargingInfo->ChillerTemp = atoi(newString[2]);
+                printf("set %d chiller temperature = %d\r\n",
+                    _GunIndex,
+                    pDcChargingInfo->ChillerTemp);
+            } else {
+                printf("This Gun without Chiller");
             }
 
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-            pDcChargingInfo->ChillerTemp = atoi(newString[2]);
-            printf("set %d chiller temperature = %d\r\n",
-                   _GunIndex,
-                   pDcChargingInfo->ChillerTemp);
         } else if (strcmp(newString[0], "conn") == 0) {//修改槍頭溫度值
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
 

BIN
EVSE/Projects/DD360/Apps/UnsafetyOutputTask


BIN
EVSE/Projects/DD360/Apps/main


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


BIN
EVSE/Projects/DD360/output/FactoryConfig


BIN
EVSE/Projects/DD360/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360/output/Module_DoComm


BIN
EVSE/Projects/DD360/output/Module_EvComm


BIN
EVSE/Projects/DD360/output/Module_EventLogging


BIN
EVSE/Projects/DD360/output/Module_InternalComm


BIN
EVSE/Projects/DD360/output/Module_LcmControl


BIN
EVSE/Projects/DD360/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360/output/Module_UpdateFW


BIN
EVSE/Projects/DD360/output/ReadCmdline


BIN
EVSE/Projects/DD360/output/UnsafetyOutputTask


BIN
EVSE/Projects/DD360/output/main


+ 2 - 0
EVSE/Projects/DD360Audi/Apps/CSU/Ethernet.c

@@ -186,6 +186,8 @@ void InitEthernet(void)
     log_info("%s",tmpbuf);
     system(tmpbuf);
 
+    system("/sbin/ifconfig lo up");
+
     //Run DHCP client if enabled
     system("killall udhcpc");
     system("rm -rf /etc/resolv.conf");

+ 148 - 4
EVSE/Projects/DD360Audi/Apps/CSU/main.c

@@ -77,14 +77,16 @@ static ChillerTempErr gChillerTempErr = {0};
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 
+#define DERATING_TARGET_LEVEL 5
+
 // for initial index to check EV board type is correct
 uint8_t bd0_1_status = 0;
 uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "T1.21.00.0000.00"; // "V0.16.00.0000.00";
-char* DebugVersion = "T1.21.7";
+char *fwVersion = "V1.22.00.0000.00"; // "V0.16.00.0000.00";
+char* DebugVersion = "V1.22.0";
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -323,7 +325,7 @@ static void GetFirmwareVersion(void)
 {
     // Get CSU root file system version
     sprintf((char *)pSysInfo->CsuRootFsFwRev, fwVersion);
-
+    sprintf((char *)ShmDcCommonData->DebugVersion, DebugVersion);
     uint8_t count = 0, chademo = 0, ccs = 0, gb = 0;
     for (uint8_t idx = 0; idx < 3; idx++) {
         if (pSysConfig->ModelName[7 + idx] == 'J') {
@@ -4430,6 +4432,144 @@ void showversion()
     }
     log_info("\t================================ ");
 }
+
+
+void SetNatural300AGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetCurrent[0] = 5000;
+    deratingByConnOtp->deratingTargetCurrent[1] = 3000;
+    deratingByConnOtp->deratingTargetCurrent[2] = 1000;
+    deratingByConnOtp->deratingTargetCurrent[3] = 0;
+    deratingByConnOtp->deratingTargetCurrent[4] = 0;
+}
+void SetLiquidCoolGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetCurrent[0] = 5000;
+    deratingByConnOtp->deratingTargetCurrent[1] = 4000;
+    deratingByConnOtp->deratingTargetCurrent[2] = 3000;
+    deratingByConnOtp->deratingTargetCurrent[3] = 0;
+    deratingByConnOtp->deratingTargetCurrent[4] = 0;
+}
+
+void SetCHAdeMoTypeKOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetRate[0] = 1;
+    deratingByConnOtp->deratingTargetRate[1] = 0.8;
+    deratingByConnOtp->deratingTargetRate[2] = 0.8;
+    deratingByConnOtp->deratingTargetRate[3] = 0;
+    deratingByConnOtp->deratingTargetRate[4] = 0;
+
+    memset(&deratingByConnOtp->deratingTargetCurrent[0], 0, sizeof(deratingByConnOtp->deratingTargetCurrent));
+}
+
+void SetCHAdeMoTypeSJOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
+{
+    deratingByConnOtp->isNeedDerating = YES;
+    deratingByConnOtp->deratingTargetCurrent[0] = 2000;
+    deratingByConnOtp->deratingTargetCurrent[1] = 1250;
+    deratingByConnOtp->deratingTargetCurrent[2] = 1250;
+    deratingByConnOtp->deratingTargetCurrent[3] = 0;
+    deratingByConnOtp->deratingTargetCurrent[4] = 0;
+}
+
+static void SetGunTypeOTPValue(void)
+{
+    //struct ChargingInfoData* chargingData_2 = NULL;
+    uint8_t Gun1Type = 0;
+    uint8_t Gun2Type = 0;
+    uint8_t Type;
+    int i,cnt;
+    if (pSysConfig->TotalConnectorCount == 1) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(0);
+        Gun1Type = pSysConfig->ModelName[7];
+        Gun2Type = pSysConfig->ModelName[7];
+
+        switch (Gun1Type) {
+
+        case 'K':
+            SetCHAdeMoTypeKOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+        case 'S':
+            SetCHAdeMoTypeSJOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+        case 'T':
+        case 'D':
+            SetNatural300AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+            // 水冷
+        case 'V':
+        case 'F':
+            SetLiquidCoolGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+            break;
+        default:
+            pDcChargingInfo->deratingByConnOtp.isNeedDerating = NO;
+        }
+        if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
+            log_info("------------ Gun0 - Type:%c Derating info (OTP)-----------", Gun1Type);
+            if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[0] != 0) {
+                for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                    if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt] != 0) {
+                        log_info(" (Pwr) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt]);
+                    }
+                }
+            } else if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[0] != 0) {
+                for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                    if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt] != 0) {
+                        log_info(" (Cur) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt]);
+                    }
+                }
+            }
+        }
+
+    } else if (pSysConfig->TotalConnectorCount == 2) {
+        Gun1Type = pSysConfig->ModelName[7];
+        Gun2Type = pSysConfig->ModelName[9];
+        for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
+
+            switch (i == 0 ? Gun1Type : Gun2Type) {
+            case 'K':
+                SetCHAdeMoTypeKOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+            case 'S':
+                SetCHAdeMoTypeSJOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+                // 風冷300A
+            case 'T':
+            case 'D':
+                SetNatural300AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+                // 水冷
+            case 'V':
+            case 'F':
+                SetLiquidCoolGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
+                break;
+            default:
+                pDcChargingInfo->deratingByConnOtp.isNeedDerating = NO;
+            }
+            if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
+                log_info("------------ Gun%d - Type:%c Derating info (OTP)-----------",i, i == 0 ? Gun1Type : Gun2Type);
+                if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[0] != 0) {
+                    for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                        if (pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt] != 0) {
+                            log_info(" (Pwr) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetRate[cnt]);
+                        }
+                    }
+                } else if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[0] != 0) {
+                    for (cnt = 0; cnt < DERATING_TARGET_LEVEL; cnt++) {
+                        if (pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt] != 0) {
+                            log_info(" (Cur) count = %d, valut = %.1f ", cnt, pDcChargingInfo->deratingByConnOtp.deratingTargetCurrent[cnt]);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
 int main(void)
 {
     bool isModelNameMatch = true;
@@ -4601,6 +4741,8 @@ int main(void)
 
     time_t ShowEVStatusTimer[2] = { 0 };
 
+    SetGunTypeOTPValue();
+
     for (;;) {
 
         CheckOcppStatus();
@@ -4720,7 +4862,9 @@ int main(void)
                     strcpy((char *)pDcChargingInfo->StopDateTime, "");
                     strcpy((char *)pDcChargingInfo->StartUserId, "");
                     strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "");
-                    
+                    if (pDcChargingInfo->deratingByConnOtp.deratingIndex != 0) {
+                        pDcChargingInfo->deratingByConnOtp.deratingIndex = 0;
+                    }
                     //Jerry add
                     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
                     memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));

+ 7 - 0
EVSE/Projects/DD360Audi/Apps/Config.h

@@ -293,6 +293,10 @@ enum _CREDITCARD_STATUS {
 	_CREDITCARD_SETTLEMENT,
 	_CREDITCARD_START,
 };
+enum _DERATING_TEMP {
+    STAGE1_GUN_DERATING_TEMP = 140,
+    STAGE2_GUN_DERATING_TEMP = 145,
+};
 //------------------------------------------------------------------------------
 //struct StructMeter {
 //    float curMeterValue;
@@ -489,6 +493,9 @@ typedef struct StDcCommonInfo {
     GunInfo pGunInfo[2];
     uint8_t showNetPackage;
     uint8_t showCanPackage;
+    time_t FanOnTime;
+    float TempVolt[4];
+    char DebugVersion[32];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 192 - 43
EVSE/Projects/DD360Audi/Apps/Define/define.h

@@ -153,6 +153,15 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
+#elif defined Emulator
+    #define MAX_PSU_QUANTITY        62
+    #define CHAdeMO_QUANTITY        3
+    #define CCS_QUANTITY            3
+    #define GB_QUANTITY             3
+    #define AC_QUANTITY             3
+    #define GENERAL_GUN_QUANTITY    0
+    #define PSU_QUANTITY            2
+    #define ONE_CONNECTOR_USE       0
 #else
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        2
@@ -188,6 +197,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmRelay2BdKey			1013
 #define ShmYesCustomKey         1014
 #define ShmOcppPHModuleKey      1015
+#define ShmSmartBoxKey          1016
 
 #define FaultCodeLength         5
 #define AlarmCodeLength         20
@@ -332,6 +342,7 @@ enum CoreProfile {
      isEnableLocalPowerSharing,
      PowerSharingServerIP,
      EVCCID_PREFIX,
+     OffLineMaxChargingPower,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -370,7 +381,9 @@ struct WifiConfigData
 {
 	unsigned char		WifiMode;					//0: disable, 1: Infrastructure client, 2: Infrastructure server, 3: Ad-Hoc
 	unsigned char		WifiSsid[256];				//default: Null
-	unsigned char		WifiPassword[256];			//default: Null
+    unsigned char       WifiPassword[224];          //default: Null
+    unsigned char       WifiBroadcastSsid;          //the SSID broadcast configuration, 0: hidden   1: broadcast
+    unsigned char       WifiTargetBssidMac[31];     //Target connect SSID MAC address, default: Null
 	int					WifiRssi;					//dbm
 	unsigned char		WifiDhcpServer;				//0: enable, 1: disable
 	unsigned char		WifiDhcpClient;				//0: enable, 1: disable
@@ -385,7 +398,8 @@ struct TeleConfigData
 {
 	unsigned char		TelcomModelName[64];		//default: Null
 	unsigned char		TelcomSoftwareVer[64];		//default: Null
-	unsigned char		TelcomApn[256];				//default: Null
+    unsigned char       TelcomApn[255];             //default: Null
+    unsigned char       TelcomNetworkType;          //0: Auto   1: CDMA  2: WCDMA  3: LTE  4: TD-SCDMA  5: UMTS  6: CDMA  7: HDR  8: CDMA/HDR
 	int					TelcomRssi;					//dbm
 	unsigned char		TelcomChapPapId[256];		//default: Null
 	unsigned char		TelcomChapPapPwd[256];		//default: Null
@@ -484,7 +498,8 @@ typedef union
         unsigned int InvalidIdStop:1;               // 0: no effect,    1: invalid stop when StopTransactionOnInvalidId is true
         unsigned int RemoteStop:1;                  // 0: no effect,    1: remote stop
         unsigned int UnlockStop:1;                  // 0: no effect,    1: unlock stop
-        unsigned int res:23;
+        unsigned int SessionTargetStop:1;           // 0: no effect,    1: session target stop
+        unsigned int res:22;
     }bits;
 }ChargingStop;
 
@@ -591,6 +606,16 @@ struct SysConfigData
     unsigned char           MaintainServerSecurityProfile;      // Maintain server security profile 0~3
     unsigned char           MaintainServerSecurityPassword[41]; // Maintain server AuthorizationKey for security profile
     unsigned char           PowerSharingServerIP[512];          // Local power sharing server ip address
+    unsigned int            PowerSharingCapacityPower;          // Local power sharing capacity power
+    unsigned char           MaxChargingSoc;                     //0: unlimit, 1 ~ 100 percent
+};
+
+struct DERATING_BY_OTP
+{
+    unsigned char isNeedDerating;
+    unsigned char deratingIndex;        // Current used power or current
+    double deratingTargetRate[5];       // Reduce the output energy rate
+    double deratingTargetCurrent[5];    // derating target current
 };
 
 struct ChargingInfoData
@@ -626,6 +651,7 @@ struct ChargingInfoData
 	int EvBatterySoc;				// 0~100%
 	unsigned char ConnectorPlugIn;			//0: unplug, 1: Plug-in
 	unsigned char GunLocked;				//0: unlocked 1: locked
+	unsigned char InProgress;               //0: real idle, 1: session(transaction) in progress
 	float PilotVoltage;
 	unsigned char PilotState;//1:state A, 2:State B1, 3:State B2, 4:State C, 5:State D, 6:State E, 7:State F, 8: Pilot error
 	unsigned char PilotDuty;					// 0~100%
@@ -695,6 +721,9 @@ struct ChargingInfoData
     unsigned char       CCSGunType;
     struct timeval      PreChargeTimer;
     unsigned char       _SaftyDetect;
+    unsigned char       _TotalPsuCount;                 // Psu count for connector
+    unsigned char       _TakePsuGpCount;                // Get the used psu group count
+    struct DERATING_BY_OTP deratingByConnOtp;
 };
 
 typedef struct
@@ -878,6 +907,7 @@ struct ConnectorInfoData
     float                   CostDiscount;                   // connector user's Discount or couponPoint, unit: 1 point
     float                   EnergyCost;                     // connector user's energy cost, unit: 1 dollar
     float                   ParkingFee;                     // connector user's parking fee, unit: 1 dollar
+    float                   RemainAmount;                   // connector user's remain amount, unit: 1 dollar
 };
 
 typedef union
@@ -885,15 +915,11 @@ typedef union
     unsigned int SettingValue;
     struct
     {
-        unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
-        unsigned int FlashConfigChanged:1;      // 0: no effect, 1: flash config has changed
-        unsigned int EnableWriteFlash:1;        // 0: no effect, 1: enable to write flash after timeout
-        unsigned int CleanWiringInfo:1;         // 0: no effect, 1: clean wiring info
-        unsigned int res:28;
+        unsigned int res:32;
     }bits;
 }CabinetSettingFlag;
 
-typedef struct DC_METER_INFO
+struct DC_METER_INFO
 {
     double presetVoltage;                       // resolution: 1.000v
     double presentCurrent;                      // resolution: 1.000a
@@ -901,7 +927,61 @@ typedef struct DC_METER_INFO
     double totlizeImportEnergy;                 // resolution: 1.000kwh
     double totlizeExportEnergy;                 // resolution: 1.000kwh
     unsigned char LinkStatus;                   // 0 = unknow ,1 = link , 2 miss link
-}DC_Meter_Info;
+};
+
+typedef struct Bazel8Command
+{
+    unsigned char isReq:1;
+    unsigned char isRes:1;
+    unsigned char isWaitRes:1;
+    unsigned char isResultPass:1;
+} bazel8Command;
+
+typedef struct EventInfo
+{
+    int messageId;
+    char messageString[64];
+    unsigned char isGetOn:1;
+}eventInfo;
+
+typedef struct StartTxResp
+{
+    char statusCode[8];
+    char statusText[128];
+    char txnId[32];
+    unsigned char isGetOn:1;
+}startTxResp;
+
+struct BAZEL8
+{
+    eventInfo       event;
+    startTxResp     txResp;
+
+    bazel8Command   cmdPreAuth;
+};
+
+struct Enegate
+{
+    union
+    {
+        unsigned char OperationValue[CONNECTOR_QUANTITY];
+        struct
+        {
+            unsigned char isAuthorizing:1;
+            unsigned char isAuthorized:1;
+            unsigned char isAuthorizedPass:1;
+            unsigned char isSessionStopReq:1;
+            unsigned char isStopService:1;
+            unsigned char isAutoStartEnable:1;
+            unsigned char isConnectTimeout:1;
+            unsigned char :1;
+        } bits[CONNECTOR_QUANTITY];
+    }Operation;
+
+    unsigned char   serviceStartTimestamp[36];
+    unsigned char   serviceStopTimestamp[36];
+    unsigned char   isEnable:1;
+};
 
 struct SysInfoData
 {
@@ -996,10 +1076,12 @@ struct SysInfoData
     unsigned char           AuthorizedStatus;           // cabinet authorized status
     CabinetSettingFlag      CabinetSetting;
     struct LocalSharingInfo localSharingInfo;           // Local power sharing info structure
-    DC_Meter_Info DcMeterInfo[4];
+    struct DC_METER_INFO    DcMeterInfo[4];
     unsigned char           OTPTemp;                    // OTP Temperature
     unsigned char           OTPTempR;                   // OTP Recovery Temperature
     struct LCD_OVERRIDE     LcdOveride;                 // LCD override info (no use anymore)
+    struct BAZEL8           bazel8;                     // Bazel8 payment used
+    struct Enegate          enegate;                    // Enegate payment used
 };
 
 struct SysConfigAndInfo
@@ -1253,18 +1335,18 @@ char AlarmStatusCode[160][6]=
 	"012261",	//GB groundfault detection timeout (GFD)
 	"012262",	//Circuit Short L1
 	"012263",	// PSU Duplicate ID
-	"012264", 	// PSU Output Short Circuit
+	"012264", 	// Psu Fault : Infy => Output Short Circuit,UU => Abnormal discharge circuit
 	"012265", 	// PSU Discharge Abnormal
 	"012266", 	// PSU Dc Side ShutDown
 	"012267", 	// PSU Failure Alarm
 	"012268", 	// PSU Protection Alarm
-	"012269", 	// PSU FanFailure Alarm
+	"012269", 	// Psu Fault : Infy => Fan Fault,UU => Fan Fault
 	"012270", 	// PSU Input UVP
 	"012271",	// PSU Input OVP
 	"012272", 	// PSU WalkIn State
-	"012273", 	// PSU Power Limited State
-	"012274", 	// PSU Id Repeat
-	"012275", 	// PSU Severe Uneven Current
+	"012273", 	// Psu Fault : Infy => Power Limited State,UU => Dc OVP and shutdown
+	"012274", 	// Psu Fault : Infy => Id Repeat,UU => Id Repeat
+	"012275", 	// Psu Fault : Infy => Severe Uneven Current,UU => Pfc internal unbalance
 	"012276", 	// PSU Three Phase Input Inadequate
 	"012277", 	// PSU Three Phase Onput Imbalance
 	"012278", 	// PSU Ffc Side ShutDown
@@ -1296,18 +1378,18 @@ char AlarmStatusCode[160][6]=
 	"012304",   // connection disconnected from power cabinet
 	"012305",   // Meter communication timeout
 	"012306",   // The dip switch of the PSU may be incorrect
-    "012307",   // Psu Fuse Burn-Out
-    "012308",   // Psu Pfc And Dcdc Communication Fault
-    "012309",   // Psu Bus Voltage Unbalance
-    "012310",   // Psu Bus Over Voltage
-    "012311",   // Psu Bus Voltage Abnormal
-    "012312",   // Psu Bus Under Voltage
-    "012313",   // Psu Input Phase Loss
-    "012314",   // Psu Fan Full Speed
-    "012315",   // Psu Temperature Power Limit
-    "012316",   // Psu Ac Power Limit
-    "012317",   // Psu Dcdc Eeprom Fault
-    "012318",   // Psu Pfc Eeprom Fault
+    "012307",   // Psu Fault : Infy => Fuse Burn-Out,UU => Pfc internal OVP
+    "012308",   // Psu Fault : Infy => Pfc And Dcdc Communication Fault,UU => Pfc And Dcdc Communication Fault
+    "012309",   // Psu Fault : Infy => Bus Voltage Unbalance,UU => Dc output voltage unbalance
+    "012310",   // Psu Fault : Infy => Bus Over Voltage,UU => Ac site OVP
+    "012311",   // Psu Fault : Infy => Bus Voltage Abnormal,UU => Ac site UVP
+    "012312",   // Psu Fault : Infy => Bus Under Voltage,UU => Pfc internal UVP
+    "012313",   // Psu Fault : Infy => Input Phase Loss,UU => Dc to Dc don’t work
+    "012314",   // Psu Fault : Infy => Fan Full Speed,UU => Fan don’t work
+    "012315",   // Psu Fault : Infy => Temperature Power Limit,UU => env OTP、Pfc OTP、output relay broken、Dc OTP
+    "012316",   // Psu Fault : Infy => Ac Power Limit,UU => Ac OVP and shutdown
+    "012317",   // Psu Fault : Infy => Dcdc Eeprom Fault,UU => Dc to Dc broken
+    "012318",   // Psu Fault : Infy => Pfc Eeprom Fault,UU => Pfc broken
     "012319",   // Psu Dcdc Over Voltage
     "012320",   // System CHAdeMO output UCP
     "012321",   // System CCS output UCP
@@ -1316,13 +1398,13 @@ char AlarmStatusCode[160][6]=
     "012324",   // Connector 1 detects abnormal voltage on the output line
     "012325",   // Connector 2 detects abnormal voltage on the output line
     "012326",   // System task is lost
-    "012327",   // DC input ovp
-    "012328",   // DC input uvp
-    "012329",   // Psu Can Communication Fault
-    "012330",   // Psu Dc to Dc OTP
-    "012331",   // Psu Dc to Dc OVP
-    "012332",   // reserved
-    "012333",   // reserved
+    "012327",   // System DC input ovp
+    "012328",   // System DC input uvp
+    "012329",   // Psu Fault : Infy => Psu Can Communication Fault,UU =>
+    "012330",   // Psu Fault : Infy => Psu Dc to Dc OTP,UU => env UTP
+    "012331",   // Psu Fault : Infy => Psu Dc to Dc OVP,UU => Dc output OVP
+    "012332",   // Chiller Tube OTP
+    "012333",   // Psu Fault : Infy => DC input ovp (Phase OVP),UU => Dc output UVP
     "012334",   // reserved
     "012335",   // reserved
     "012336",   // reserved
@@ -1336,12 +1418,12 @@ char AlarmStatusCode[160][6]=
     "012344",   // AC: Meter IC communication timeout
     "012345",   // AC: Pilot negative error
     "012346",   // Psu Communication error with CSU
-    "012347",   // reserved
+    "012347",   // AC: Local power sharing communication error (Slave disconnect from Master)
     "012348",   // reserved
     "012349",   // reserved
     "012350",   // reserved
     "012351",   // reserved
-    "012352",   // reserved
+    "012352",   // Payment system communication timeout
     "012353",   // reserved
     "012354",   // reserved
     "012355",   // reserved
@@ -1508,16 +1590,20 @@ struct AlarmCodeData
             unsigned char PsuCanCommFault:1;                        //bit 1
             unsigned char PsuDcDcOtp:1;                             //bit 2
             unsigned char PsuDcDcOvp:1;                             //bit 3
-            unsigned char :4;                                       //reserved bit 4 ~ bit 7
+            unsigned char ChillerTubeOTP : 1;                       //bit 4
+            unsigned char PsuPhaseOvp:1;                            //bit 5
+            unsigned char :2;                                       //reserved bit 6 ~ bit 7
             //AlarmVal[17]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
             //AlarmVal[18]
             unsigned char MeterIcCommTimeout:1;                     //bit 0
             unsigned char PilotNegativeError:1;                     //bit 1
             unsigned char PsuComminicationErrWithCSU:1;             //bit 2
-            unsigned char :5;                                       //reserved bit 3 ~ bit 7
+            unsigned char LocalPowerSharingCommunicationError:1;    //bit 3
+            unsigned char :4;                                       //reserved bit 4 ~ bit 7
             //AlarmVal[19]
-            unsigned char :8;                                       //reserved bit 0 ~ bit 7
+            unsigned char PaymentCommTimeout:1;                     //Payment system communication timeout
+            unsigned char :7;                                       //reserved bit 1 ~ bit 7
 		}bits;
 	}AlarmEvents;
 };
@@ -1843,7 +1929,7 @@ char InfoStatusCode[384][6]=
     "023981",   // ERROR_CODE_CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT
     "023982",   // ERROR_CODE_CHADEMO_ADC_LESS_THAN_10V
     "023983",   // STOP by EV with unknow reason
-    "023984",   // Reserved
+    "023984",   // STOP by EVSE condition (Config or OCPP)
     "023985",   // Reserved
     "023986",   // Reserved
     "023987",   // Reserved
@@ -2190,7 +2276,8 @@ struct InfoCodeData
             unsigned char CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT:1; //bit 1
             unsigned char CHADEMO_ADC_LESS_THAN_10V:1;              //bit 2
             unsigned char Stop_by_EV_with_unknow_reason:1;          //bit 3
-            unsigned char :4;                                       //bit 4 ~ 7 reserved
+            unsigned char Stop_by_EVSE_condition:1;                 //bit 4
+            unsigned char :3;                                       //bit 5 ~ 7 reserved
 			//InfoVal[40]
 			unsigned char BackendDisconnectedViaEthernet:1;			//bit 0
 			unsigned char BackendDisconnectViaWiFi:1;				//bit 1
@@ -2267,6 +2354,8 @@ struct PsuModuleData
 	unsigned int 		AlarmCode;
 	unsigned int 		FaultCode;			//
 	unsigned int 		IAvailableCurrent;		            // unit: 0.1A
+    unsigned short  PresentMaxOutputVoltage;//abcd=abc.d volt
+    unsigned short  KwAvailablePower;       // unit: 0.1 kw
 };
 
 /*Following are the information for each PSU Group*/
@@ -2288,6 +2377,11 @@ struct PsuGroupData
     unsigned short          TempIAvailableCurrent;          // unit: 0.1A
     unsigned short          StableIAvailableCurrent;        // unit: 0.1A
     unsigned short          StableCurrentCounter;           // stable current counter
+    unsigned short          GroupMaxVoltage;                // unit: 0.1V
+    unsigned char           IsUsing;                        // 0 : none use
+    unsigned char           UsingTarget;                    // 0xFF : Check
+    unsigned char           PwSwitchStatus;
+    unsigned short          TotalRatingPower;               // unit: 1kW
 };
 
 /*Following is the information for system all PSU*/
@@ -2303,6 +2397,54 @@ struct PsuData
 	unsigned char           PsuStopChargeFlag;
 };
 
+struct SmartTimeChk
+{
+    struct timespec     FetchLoopTime;
+    unsigned char       IsFetchStart;
+
+    struct timespec     ReleaseLoopTime;
+    unsigned char       IsReleaseStart;
+};
+
+struct DynamicFetchCtrl
+{
+    unsigned char       ShareGroup;         // 255 : None
+    unsigned char       FetchLoopStep;      // 0 : None, 1 : Output Vol, 2 : RCB ON, 3 : Current sharing, 4 : Finish
+    unsigned short      ShareTargetCurrent; // 0.1A
+    unsigned char       TargetRelay;        // 255 : None
+};
+
+struct DynamicReleaseCtrl
+{
+    unsigned char       ReleaseGroup;       // 255 : None
+    unsigned char       ReleaseLoopStep;    // 0 : None, 1 : Limit Pwr, 2 : Pwr OFF, 3. RCB OFF, 4. Finish
+    float               CheckOutPwrIsStable;// 0.1kw
+    unsigned char       TargetRelay;        // 255 : None
+
+    float               LimitCurCap;        // Inform 0.1A
+    float               LimitPwrCap;        // Inform 0.1kw
+    float               LimitCur;           // Target 0.1A
+    float               LimitPwr;           // Target 0.1kw
+};
+
+struct ConnInfo
+{
+    unsigned char ConnectorStaus;
+    unsigned char NeedToFetch;
+};
+
+struct SmartBoxData
+{
+    struct ConnInfo     ConnectorStatus[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];     // Connector 1 / 2 Status : None, Wait, Using
+    struct ConnInfo     AnotherConnectorStatus[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    unsigned char       ConnectorUsingGroupCount[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; // Psu group for connector
+    struct SmartTimeChk SmartChk[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    struct DynamicFetchCtrl Dynamic4Fetch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    struct DynamicReleaseCtrl Dynamic4Release[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    unsigned char       ParallelRelayStatus[3];
+    unsigned char       RcbParallelStatus[3];
+};
+
 /************************************************************************************/
 /**************************CHAdeMO protocol Share memory*********************/
 /**************************************************************************************/
@@ -4449,6 +4591,7 @@ struct Triggers
                                                     // be used to trigger a meter value when vehicle stops charging or when vehicle charges at a high power that requires a
                                                     // different tariff.
                                                     // It is recommended to implement a hysteresis around this value to avoid repetitive triggers when the power fluctuates around this level.
+    unsigned char atCPStatus[100];
 };
 
 struct StrcutRunningCost
@@ -4469,6 +4612,10 @@ struct StrcutFinalCost
 {
     int             txId;
     unsigned char   description[1024];
+
+    float           cost;
+    unsigned char   priceText[1024];
+    unsigned char   qrCodeText[1024];
 };
 
 struct StructCost
@@ -4874,6 +5021,7 @@ enum OCPP20CtrlrVariable
 	ChargingStation_SystemUptimeSec,
 	ChargingStation_FreeVend,
 	ChargingStation_FreeVendIdtag,
+	ChargingStation_OffLineMaxChargingPower,
 	Connector_Available,
 	Connector_ConnectorType,
 	Connector_SupplyPhases,
@@ -6008,7 +6156,8 @@ struct OCPP20Data
 			unsigned char SecurityEventNotificationConf :1;
 			unsigned char SignCertificateReq :1;
 			unsigned char SignCertificateConf :1;
-			unsigned char :2;
+            unsigned char NotifyCustomerInformationReq :1;  //bit 6
+            unsigned char NotifyCustomerInformationConf :1; //bit 7
 
 		} bits;
 	} SpMsg;

+ 4 - 4
EVSE/Projects/DD360Audi/Apps/Log/log.h

@@ -2,11 +2,11 @@
 #define _LOG_H_
 
 //------------------------------------------------------------------------------
-#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)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
-#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args) //DS60-120 add
+#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args) //DS60-120 add
 //------------------------------------------------------------------------------
 int StoreLogMsg(const char *fmt, ...);
 int StoreEventLogMsg(const char *fmt, ...);

+ 11 - 0
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -166,6 +166,7 @@ static void getChillerTemperature(ChillerTemp *chillerTemp)
     for (i = 0; i < 4; i++) {
         adcVoltage = 0.0;
         adcVoltage =  ReadAdcVolt(i);
+        ShmDcCommonData->TempVolt[i] = adcVoltage;
         if ((adcVoltage <= 0.9) && (adcVoltage >= 0.8)) { //0 ~ -40
             pChillerTemp->Temp[i] = ((adcVoltage - 0.908) * 500) + 60;
             //log_info("1 adcVoltage = %f", (adcVoltage - 0.9) * 500);
@@ -309,6 +310,7 @@ void CANReceiver(int fd)
         int len = 0;
         char _info[1024];
         int i;
+        unsigned char GunStatus[2];
 
         pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
@@ -515,6 +517,7 @@ void CANReceiver(int fd)
 
             case ACK_GET_OUTPUT_REQ:
                 //DS60-120 add
+
                 if ((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EV &&
                         pDcChargingInfo->SystemStatus <= S_CHARGING) ||
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
@@ -525,6 +528,14 @@ void CANReceiver(int fd)
                         pDcChargingInfo->EvBatteryStartSoc = frame.data[1];
                     }
 
+                    // 進入充電時重新更新電池電量
+                    if (GunStatus[targetGun] != pDcChargingInfo->SystemStatus && pDcChargingInfo->SystemStatus == S_CHARGING) {
+
+                        log_info("Reset Gun%d SoC:%d", targetGun, frame.data[1]);
+                        pDcChargingInfo->EvBatterySoc = frame.data[1];
+                        GunStatus[targetGun] = pDcChargingInfo->SystemStatus;
+                    }
+
                     if (frame.data[1] > pDcChargingInfo->EvBatterySoc) {
                         pDcChargingInfo->EvBatterySoc = frame.data[1];
                         log_info("Gun%d SOC:%d", targetGun,pDcChargingInfo->EvBatterySoc);

+ 42 - 1
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -55,7 +55,7 @@ static float LogInfo[2][10]; //DS60-120 add
 static int CanFd = -1;
 
 bool psuOutputReady[2] = {0, 0};
-
+uint8_t deratingIndex[2];
 //------------------------------------------------------------------------------
 extern void CANReceiver(int fd);
 extern void ClearAbnormalStatus_Chademo(uint8_t gun_index);
@@ -301,7 +301,33 @@ static void setCurrentOutput(void)
         }
     }
 }
+void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, float* cur)
+{
+    if (((chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
+        chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP) ||
+        (chargingData->ChillerTemp >= STAGE1_GUN_DERATING_TEMP &&
+            chargingData->ChillerTemp < STAGE2_GUN_DERATING_TEMP)) &&
+        chargingData->deratingByConnOtp.deratingIndex < 1)
+    {
+        chargingData->deratingByConnOtp.deratingIndex = 1;
+    } else if ((chargingData->ConnectorTemp >= STAGE2_GUN_DERATING_TEMP ||
+        chargingData->ChillerTemp >= STAGE2_GUN_DERATING_TEMP) &&
+        chargingData->ConnectorTemp != UNDEFINED_TEMP &&
+        chargingData->ChillerTemp != UNDEFINED_TEMP &&
+        chargingData->deratingByConnOtp.deratingIndex < 2)
+    {
+        chargingData->deratingByConnOtp.deratingIndex = 2;
+    }
 
+    if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
+    {
+        *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
+    } else if (chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex] != 0)
+    {
+        if (*cur > chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex])
+            *cur = chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex];
+    }
+}
 static void SetPresentChargingOutputCap(void)
 {
     float pow1 = 0, cur1 = 0;
@@ -346,6 +372,13 @@ static void SetPresentChargingOutputCap(void)
         }
     }
 
+    if (chargingData_1->deratingByConnOtp.isNeedDerating) {
+        GetOtpPwrOrCurMethod(chargingData_1, &pow1, &cur1);
+        if (deratingIndex[0] != chargingData_1->deratingByConnOtp.deratingIndex) {
+            log_info("Gun0 Derating Index Set %d", chargingData_1->deratingByConnOtp.deratingIndex);
+            deratingIndex[0] = chargingData_1->deratingByConnOtp.deratingIndex;
+        }
+    }
     pow2 = chargingData_2->AvailableChargingPower;
     cur2 = chargingData_2->AvailableChargingCurrent;
 
@@ -371,6 +404,14 @@ static void SetPresentChargingOutputCap(void)
         }
     }
 
+    if (chargingData_2->deratingByConnOtp.isNeedDerating) {
+        GetOtpPwrOrCurMethod(chargingData_2, &pow2, &cur2);
+        if (deratingIndex[1] != chargingData_2->deratingByConnOtp.deratingIndex) {
+            log_info("Gun1 Derating Index Set %d", chargingData_2->deratingByConnOtp.deratingIndex);
+            deratingIndex[1] = chargingData_2->deratingByConnOtp.deratingIndex;
+        }
+    }
+
     //DS60-120 add
     if ((LogInfo[0][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 5 ||
             LogInfo[0][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 5) ||

+ 1 - 1
EVSE/Projects/DD360Audi/Apps/ModuleEventLog/Module_EventLogging.c

@@ -52,7 +52,7 @@ static struct FaultCodeData *pFaultCode      = NULL;
 //#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)
-#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args) //DS60-120 add
+#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args) //DS60-120 add
 
 /*
 int StoreLogMsg(const char *fmt, ...)

+ 3 - 3
EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/Module_InternalComm.h

@@ -85,9 +85,9 @@
 #define AC_ROTARY_SWITCH_FAULT                  (131072)
 #define AC_RELAY_DRIVE_FAULT                    (262144)
 
-#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)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
 //------------------------------------------------------------------------------
 

+ 24 - 1
EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/RelayBoard.c

@@ -1245,9 +1245,31 @@ static void GetFanSpeed(void)
 static void GetFanSpeedByFunction(void)
 {
     if (ShmDcCommonData->debugflag== YES) {
+        ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
         return;
     }
 
+    int gunIndex;
+    struct ChargingInfoData* pDcChargingInfo = NULL;
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
+        if ((pDcChargingInfo->SystemStatus > S_AUTHORIZING && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            ShmDcCommonData->FanOnTime = time((time_t*)NULL);
+            if (ShmFanModuleData->SetFan1Speed == 0) {
+                ShmFanModuleData->SetFan1Speed = 7000;
+                log_info("Set Fan speed 7000");
+            }
+        }
+    }
+
+    if ((time((time_t*)NULL) - ShmDcCommonData->FanOnTime) >= 600 &&
+        ShmFanModuleData->SetFan1Speed == 7000) {
+        ShmFanModuleData->SetFan1Speed = 0;
+        log_info("Close fan");
+    }
+
+    /*
     // 風控修改 :
     // ******************************************************* //
     //
@@ -1305,6 +1327,7 @@ static void GetFanSpeedByFunction(void)
     if (ShmFanModuleData->TestFanSpeed < 0) {
         ShmFanModuleData->TestFanSpeed = 0;
     }
+    */
 //
 //  printf("power = %f \n", power);
 //  printf("_maxPower = %d \n", _maxPower);
@@ -1406,7 +1429,7 @@ static void fanBoardPorcess(void)
 
         if (GetTimeoutValue(gFanBoardRunTimer) / 1000 >= 1000) {
             //GetPsuTempForFanSpeed();
-            //GetFanSpeedByFunction();
+            GetFanSpeedByFunction();
             GetFanSpeed();
             pSysInfo->SystemFanRotaSpeed = _setFanSpeed;
             gettimeofday(&gFanBoardRunTimer, NULL);

+ 9 - 7
EVSE/Projects/DD360Audi/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -933,20 +933,22 @@ void ChangeRemainTime(int sec)
 
 void ChangeChargingEnergyValue(float energy)
 {
-    uint8_t cmd[10];
-    uint8_t value[10];
+    uint8_t cmd[20];
+    uint8_t value[20];
 
     memset(cmd, 0x00, sizeof(cmd));
 
     sprintf((char*)value, "%.4f kWh", energy);
+    if (energy > 0.00005)
+        energy -= 0.00005;
     string2ByteArray(value, cmd);
     DisplayValueToLcm(__present_energy, cmd, sizeof(cmd));
 }
 
 void ChangeChargingPowerValue(float pow)
 {
-    uint8_t cmd[10];
-    uint8_t value[10];
+    uint8_t cmd[20];
+    uint8_t value[20];
 
     memset(cmd, 0x00, sizeof(cmd));
 
@@ -1040,8 +1042,8 @@ void DisplayMoneyRate(float money)
 
 void DisplayMoneyCur(uint8_t *cur)
 {
-    uint8_t cmd[10] = {0};
-    uint8_t buf[10] = {0};
+    uint8_t cmd[20] = {0};
+    uint8_t buf[20] = {0};
     uint8_t len = 0;
 
     *(cur + 3) = '\0';
@@ -2085,7 +2087,7 @@ void ProcessPageInfo()
                     } else {
                         ChangeChargingPowerValue(0);
                     }
-
+                    
                     if (pDcChargingInfo->PresentChargedEnergy > 0 &&
                             pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
                         ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);

+ 8 - 40
EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -372,68 +372,36 @@ static void checkChillerStatus(Gpio_out *gpio)
         pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
 
         if((pDcChargingInfo->SystemStatus > S_IDLE && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
-            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1))
-        {
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
             pChillerInfo->ChillerSwitch = YES;
             pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-        }
-        else
-        {
-            if(pChillerInfo->ChillerSwitch == YES)
-            {
+        } else {
+            if(pChillerInfo->ChillerSwitch == YES) {
                 //10分鐘後停止
-                if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600)
-                {
+                if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600) {
                     pChillerInfo->ChillerSwitch = NO;
-                    ShmFanModuleData->SetFan1Speed = 0;
-                }
-            }
-            else
-            {
-                pChillerInfo->ChillerSwitch = NO;
-            }
-        }
-#if 0
-        if ((pDcChargingInfo->PresentChargingCurrent) >= 150) { //當前電壓於150A,打開水冷機
-            pChillerInfo->ChillerSwitch = YES;
-            pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-        } else {
-            if (pChillerInfo->ChillerSwitch == YES) {
-                if ((pDcChargingInfo->PresentChargingCurrent) >= 100) { //判斷如果還是大於100A不變動
-                    pChillerInfo->ChillerSwitch = YES;
-                    pChillerInfo->ChillerOnTime = time((time_t *)NULL);
-                } else {
-                    if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600) { //5分鐘後停止
-                        pChillerInfo->ChillerSwitch = NO;
-                    } else {
-                        pChillerInfo->ChillerSwitch = YES;
-                    }
                 }
             } else {
                 pChillerInfo->ChillerSwitch = NO;
             }
         }
-#endif
     }
 
     uint8_t _chillerNeedOn = NO;
     for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++)
     {
         pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
-        if(pChillerInfo->ChillerSwitch == YES)
-        {
+        if(pChillerInfo->ChillerSwitch == YES) {
             _chillerNeedOn = YES;
-            if (chillerCount >= 2) {
-                ShmFanModuleData->SetFan1Speed = 7000;
-            }
         }
     }
 
+    /*
     if (ShmDcCommonData->debugflag == YES)
         _chillerNeedOn = ShmDcCommonData->chillerCtrl;
+    */
 
-    if(_chiller.ChillerSwitch != _chillerNeedOn)
-    {
+    if(_chiller.ChillerSwitch != _chillerNeedOn) {
         log_info("Chiller Need Turn %s", _chillerNeedOn == YES ? "ON" : "OFF");
     }
     _chiller.ChillerSwitch = _chillerNeedOn;

+ 18 - 1
EVSE/Projects/DD360Audi/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -185,6 +185,13 @@ static int InitCanBus(void)
     return fd;
 }
 
+unsigned long long getAvailableMemory()
+{
+    long pages = sysconf(_SC_AVPHYS_PAGES);
+    long page_size = sysconf(_SC_PAGE_SIZE);
+    return pages * page_size;
+}
+
 static int CheckUpdateProcess(void)
 {
     //bool isPass = true;
@@ -205,6 +212,13 @@ static int CheckUpdateProcess(void)
     DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
 
+
+    if (getAvailableMemory() < (200 * 1024 * 1024))
+    {
+        log_info("Available memory (%.2f Bytes) less than 200 MBytes, free cache first.\n", getAvailableMemory() / (1024 * 1024.0));
+        system("echo 3 > /proc/sys/vm/drop_caches");
+    }
+
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     d = opendir("/mnt/");
     if (d) {
@@ -243,6 +257,8 @@ static int CheckUpdateProcess(void)
                         ((unsigned int)ptr[19]));
                 log_info("Typed...%x ", Type);
 
+                free(ptr);
+
                 switch (Type) {
                 case 0x10000001:
                 case 0x10000002:
@@ -396,9 +412,10 @@ static int CheckUpdateProcess(void)
                     //return isPass;
                     break;
                 }
+            } else {
+                free(ptr);
             }
             free(new_str);
-            free(ptr);
         }
     }
     free(dir);

+ 19 - 11
EVSE/Projects/DD360Audi/Apps/ReadCmdline.c

@@ -342,6 +342,7 @@ void GetFwVerProc(void)
 
     printf("ModelName = %s\r\n", pSysConfig->ModelName);
     printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
+    printf("DC Main Debug Version = %s \n", ShmDcCommonData->DebugVersion);
     printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
     printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
     printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
@@ -781,7 +782,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
 
                 printf ("[UnconditionalCharge - S_PREPARNIN]\n");
-
+                ShmFanModuleData->TestFanSpeed = 7000;
                 //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
                 printf ("wait find module\n");
 
@@ -939,7 +940,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 //無阻塞偵測 keybaord 結束
                 system(STTY_DEF TTY_PATH);
             }
-
+            pDcChargingInfo->ConnectorPlugIn = 0;
             pDcChargingInfo->SystemStatus = S_COMPLETE;
             break;
 
@@ -971,6 +972,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 
             if (stopChg == pSysConfig->TotalConnectorCount) {
                 ShmDcCommonData->debugflag = NO;
+                ShmFanModuleData->TestFanSpeed = 0;
                 system("/root/Module_EvComm &");
                 sleep(3);
 
@@ -1127,16 +1129,20 @@ static void resdGunAndChillerTemp(void)
 
                 pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
 
-                printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d, %3d, %3d, %3d\r\n",
+                printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d(%.3f), %3d(%.3f), %3d(%.3f), %3d(%.3f)\r\n",
                              i,
                              pDcChargingInfo->ConnectorTemp,
                              pDcChargingInfo->ChillerTemp,
                              ShmDcCommonData->ConnectorTemp[i][0],
                              ShmDcCommonData->ConnectorTemp[i][1],
                              ShmDcCommonData->SystemTemp[0],
+                             ShmDcCommonData->TempVolt[0],
                              ShmDcCommonData->SystemTemp[1],
+                             ShmDcCommonData->TempVolt[1],
                              ShmDcCommonData->SystemTemp[2],
-                             ShmDcCommonData->SystemTemp[3]);
+                             ShmDcCommonData->TempVolt[2],
+                             ShmDcCommonData->SystemTemp[3],
+                             ShmDcCommonData->TempVolt[3]);
             }//for
             ftime(&showTime);
         }
@@ -1312,15 +1318,17 @@ static void writeGunAndChillerTemp(void)
         }
 
         if (strcmp(newString[0], "chiller") == 0) {//修改水冷機溫度值
-            if (_GunIndex >= 1) {
-                _GunIndex = 0; //只會有一個水冷機
+            if (ShmDcCommonData->pGunInfo[_GunIndex].withChiller) {
+                pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_GunIndex);
+                memset((char*)ShmDcCommonData->SystemTemp, atoi(newString[2]), sizeof(ShmDcCommonData->SystemTemp));
+                pDcChargingInfo->ChillerTemp = atoi(newString[2]);
+                printf("set %d chiller temperature = %d\r\n",
+                    _GunIndex,
+                    pDcChargingInfo->ChillerTemp);
+            } else {
+                printf("This Gun without Chiller");
             }
 
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-            pDcChargingInfo->ChillerTemp = atoi(newString[2]);
-            printf("set %d chiller temperature = %d\r\n",
-                   _GunIndex,
-                   pDcChargingInfo->ChillerTemp);
         } else if (strcmp(newString[0], "conn") == 0) {//修改槍頭溫度值
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
 

BIN
EVSE/rootfs/root/Module_Payment_Bazel8


BIN
EVSE/rootfs/root/Module_PowerSharing


+ 33 - 0
build_rootfs_copy.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+echo $SCRIPTPATH
+
+ProjectPath="/opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects"
+
+
+sudo rm /dev/ram*
+sleep 3
+sudo cp -r /mnt/d/Phihong/Project/DD360Audi/Apps/* $ProjectPath/DD360Audi/Apps/
+rm -rf $ProjectPath/DD360/Apps/;
+cp -r $ProjectPath/DD360Audi/Apps/ $ProjectPath/DD360/Apps;
+cp -r $ProjectPath/DD360Audi/ModelNameList.txt  $ProjectPath/DD360/ModelNameList.txt;
+sudo make DD360-rootfs
+cp $ProjectPath/DD360/Images/* /mnt/d/Image/DD360/
+
+#rm -rf $ProjectPath/DD360ComBox/Apps/;
+#cp -r $ProjectPath/DD360Audi/Apps/ $ProjectPath/DD360ComBox/Apps;
+#cp -r $ProjectPath/DD360Audi/ModelNameList.txt $ProjectPath/DD360ComBox/ModelNameList.txt;
+#sudo cp -r /mnt/d/Phihong/Project/DD360Tcci/Apps/* $ProjectPath/DD360Tcci/Apps/
+#sudo make DD360Audi-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Audi/Images/* /mnt/e/Image/DD360Audi/
+#sudo make DD360Tcci-rootfs
+#cp $ProjectPath/DD360Tcci/Images/* /mnt/d/Image/DD360Tcc/
+#sudo make DD360ComBox-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360ComBox/Images/* /mnt/e/Image/DD360ComBox/
+#sudo make DD360UCar-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360UCar/Images/* /mnt/d/Image/DD360UCar/
+