Просмотр исходного кода

2022-06-09 / Wendell

Actions
1. [add] MaxChargingSoc
2. [mod] trim number logic
3. [fix] ip address parsing logic
4. [fix] flash config changed logic
5. modify subVersion to 01

Files
1. As follow commit history

Image version : V2.02.XX.XXXX.XX
Wendell 2 лет назад
Родитель
Сommit
dc68c6eb46

+ 1 - 5
EVSE/Projects/DO360/Apps/Common.c

@@ -343,11 +343,7 @@ int Trim_String(char *string , int len)
             }
             else
             {
-                char temp[256];
-                memset(temp, 0x00, sizeof(temp));
-                memcpy(temp, &string[i + 1], len - i);
-
-                strncpy(&string[i], temp, len - i);
+                memmove(&string[i], &string[i + 1], len - i);
                 i -= 1;
                 len -= 1;
             }

+ 26 - 2
EVSE/Projects/DO360/Apps/Config.h

@@ -408,11 +408,12 @@ typedef union
         unsigned int Wifi4gResetEnable:1;           // 0: wifi/4g reset io disable, 1: wifi/4g reset io enable
         unsigned int PsuInit:1;                     // 0: no effect,                1: psu is initialized
         unsigned int Enable6ParallelRelay:1;        // 0: no effect,                1: enable 6 parallel relay
-        unsigned int WriteFlashEnable:1;            // 0: no effect,                1: flash content has changed
+        unsigned int FlashConfigChanged:1;          // 0: no effect,                1: flash content has changed
+        unsigned int WriteFlashEnable:1;            // 0: no effect,                1: enable write flash after timeout
         unsigned int WriteFlashBusy:1;              // 0: no effect,                1: flash is writing
         unsigned int WriteFlashImmediately:1;       // 0: no effect,                1: write flash immediately
         unsigned int WriteFlashAndReset:1;          // 0: no effect,                1: write flash and soft reset
-        unsigned int res:13;
+        unsigned int res:12;
     }bits;
 }SystemControl;
 
@@ -1291,6 +1292,27 @@ typedef struct
 {
     unsigned char Status;
 }ConnectorConfigAndStatus;
+
+typedef union
+{
+    unsigned int ErrorValue;
+    struct
+    {
+        unsigned int OutputRelayWelding:1;              // 0: no effect,    1: Welding
+        unsigned int OutputRelayDrivingFault:1;         // 0: no effect,    1: DrivingFault
+        unsigned int ParallelRelayWelding:1;            // 0: no effect,    1: Welding
+        unsigned int ParallelRelayDrivingFault:1;       // 0: no effect,    1: DrivingFault
+        unsigned int res:28;
+    }bits;
+}OutputError;
+
+typedef struct
+{
+    // system
+    int OfflineMaxChargingPower;                        // unit: W
+
+    int ManualGunLimitPower[MAX_GUN_QUANTITY];          // unit: W
+}OutputLimitation;
 // ************************************************************************************************* //
 
 typedef struct
@@ -1318,6 +1340,8 @@ typedef struct
     PriceReceiptInfoData PriceAndReceiptInfo;
     MeterValueInfoData MeterValue[MAX_GUN_QUANTITY];
     TimestampInfoData Timestamp[MAX_GUN_QUANTITY];
+    OutputError ConnectorError[MAX_GUN_QUANTITY];
+    OutputLimitation OutputLimit;
 }ChargerInfoData;
 
 #endif /* CONFIG_H_ */

+ 1 - 1
EVSE/Projects/DO360/Apps/Module_EvComm.c

@@ -2759,7 +2759,7 @@ BOOL CheckNewDispenserSequence(unsigned char index, unsigned char quantity)
         ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence = index + 1;
         ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity += quantity;
         ShmSysConfigAndInfo->SysConfig.WiringInfo.WiringSetting[index] = quantity;
-        ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
+        ShmChargerInfo->Control.SysCtrl.bits.FlashConfigChanged = true;
 
         ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity = ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence;
         ShmSysConfigAndInfo->SysInfo.DispenserInfo.TotalConnectorQuantity = ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity;

+ 51 - 9
EVSE/Projects/DO360/Apps/main.c

@@ -332,6 +332,7 @@ int Get_Ocpp_MaxProfileScheduleNumberPhases(int schedule_index);
 int Get_Ocpp_MaxProfileStartIndex(void);
 int Is_Ocpp_RemoteStartWaitReq(void);
 void Get_Ocpp_SessionTarget(int gunIndex, struct StructSessionTarget *sessionTarget);
+int Get_Ocpp_OffLineMaxChargingPower(void);
 
 void Set_Deduct_UserId(int gunIndex, char *userId);
 void Set_Deduct_TransactionId(int gunIndex, int transaction);
@@ -410,7 +411,7 @@ bool isModelNameMatch = true;
 //char* rfidPortName = "/dev/ttyS2";
 #if ENABLE_PCBA_TEST == 0
 char* fwVersion = "V2.02.00.0000.00";
-char* subVersion = "00";
+char* subVersion = "01";
 #else
 char* fwVersion = "PCBA.00.04";
 char* subVersion = "00";
@@ -1201,7 +1202,7 @@ int isReachableInternet()
 				if (strstr(buf, "inet addr:") > 0)
 				{
 					sscanf(buf, "%*s%s", tmp);
-					substr(tmp, tmp, strspn(tmp, "addr:"), strlen(buf)-strspn(tmp, "addr:"));
+					substr(tmp, tmp, strspn(tmp, "addr:"), strlen(tmp)-strspn(tmp, "addr:"));
 
 					if (strcmp(tmp, (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress) != EQUAL)
 					{
@@ -5004,6 +5005,25 @@ void Get_Ocpp_SessionTarget(int gunIndex, struct StructSessionTarget *sessionTar
     }
 }
 
+//===============================================
+// Ocpp OffLineMaxChargingPower
+//===============================================
+int Get_Ocpp_OffLineMaxChargingPower(void)
+{
+    // unit: W
+    int maxChargingPower = 0;
+
+    if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+    {
+        maxChargingPower = atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OffLineMaxChargingPower].ItemData);
+    }
+    if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+    {
+        maxChargingPower = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OffLineMaxChargingPower].variableAttribute[0].value);
+    }
+    return maxChargingPower > 0 ? maxChargingPower : 0;
+}
+
 //===============================================
 // DeductResult
 //===============================================
@@ -6113,17 +6133,22 @@ void ExecuteWriteFlash(void)
 struct timespec _WiringInfo_time;
 int CheckFlashUpdate(void)
 {
-    if(ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable)
+    if(ShmChargerInfo->Control.SysCtrl.bits.FlashConfigChanged)
     {
-        ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = false;
+        ShmChargerInfo->Control.SysCtrl.bits.FlashConfigChanged = false;
         LOG_INFO("Flash Config Changed");
 
         GetClockTime(&_WiringInfo_time);
+        ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
+    }
 
+    if(ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable)
+    {
         // wait for 30s to write flash or write flash immediately
         if((GetTimeoutValue(_WiringInfo_time) / uSEC_VAL) >= WIRING_INFO_DELAY ||
             ShmChargerInfo->Control.SysCtrl.bits.WriteFlashImmediately)
         {
+            ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = false;
             LOG_INFO("Start Writing Flash");
 
             pid_t writePid = fork();
@@ -7476,7 +7501,7 @@ bool CheckBackendChargingTimeout(byte gunIndex)
 	{
 		if (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0)
 		{
-			if (chargingInfo[gunIndex]->PresentChargedDuration > (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration * 60))
+			if (chargingInfo[gunIndex]->PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration * 60))
 				result = true;
 		}
 	}
@@ -7485,7 +7510,7 @@ bool CheckBackendChargingTimeout(byte gunIndex)
 		// 隨插即充電的要看 offline
 		if (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0)
 		{
-			if (chargingInfo[gunIndex]->PresentChargedDuration > (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration * 60))
+			if (chargingInfo[gunIndex]->PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration * 60))
 				result = true;
 		}
 	}
@@ -7501,7 +7526,7 @@ bool CheckBackendChargingEnergy(byte gunIndex)
 	{
 		if (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0)
 		{
-			if (chargingInfo[gunIndex]->PresentChargedEnergy > ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)
+			if (chargingInfo[gunIndex]->PresentChargedEnergy >= ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)
 				result = true;
 		}
 	}
@@ -7510,7 +7535,7 @@ bool CheckBackendChargingEnergy(byte gunIndex)
 		// 隨插即充電的要看 offline
 		if (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy > 0)
 		{
-			if (chargingInfo[gunIndex]->PresentChargedEnergy > (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy))
+			if (chargingInfo[gunIndex]->PresentChargedEnergy >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy))
 				result = true;
 		}
 	}
@@ -7518,6 +7543,22 @@ bool CheckBackendChargingEnergy(byte gunIndex)
 	return result;
 }
 
+bool IsReachConfigMaxChargingSoc(byte gunIndex)
+{
+    bool result = false;
+
+    if(ShmSysConfigAndInfo->SysConfig.MaxChargingSoc > 0)
+    {
+        if(chargingInfo[gunIndex]->EvBatterySoc >= ShmSysConfigAndInfo->SysConfig.MaxChargingSoc)
+        {
+            LOG_INFO("Gun %d MaxChargingSoc: [%d%%] Stop", gunIndex + 1, ShmSysConfigAndInfo->SysConfig.MaxChargingSoc);
+            result = true;
+        }
+    }
+
+    return result;
+}
+
 bool CheckSessionTargetStop(byte gunIndex)
 {
     bool stop = false;
@@ -10196,7 +10237,8 @@ int main(void)
                         ChargingTerminalProcess(gun_index);
                     }
 					else if(CheckBackendChargingTimeout(gun_index) ||
-                        CheckBackendChargingEnergy(gun_index))
+                        CheckBackendChargingEnergy(gun_index) ||
+                        IsReachConfigMaxChargingSoc(gun_index))
 					{
 					    LOG_INFO("********** Gun %d Backend Stop (S_CHARGING) **********", gun_index + 1);
 						// 板端或後臺要求停止

BIN
EVSE/Projects/DO360/Images/FactoryDefaultConfig.bin


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


BIN
EVSE/rootfs/root/Module_PowerSharing