Procházet zdrojové kódy

2020-11-10 / Wendell
Actions
1. disable printf message
2. fix remote stop & unlock stop issue
3. fix gun type parsing issue
4. fix RunUnconditionalCharge issue

Files:
1. As follow by commit history

Image version : V0.05.XX.XXXX.XX

Wendell před 4 roky
rodič
revize
77a5221255

+ 6 - 0
EVSE/Projects/DO360/Apps/Config.h

@@ -80,6 +80,12 @@ enum _AC_SYSTEM_STATUS
 	AC_SYS_E
 };
 
+#define STR_GUN_TYPE_CHADEMO        "CHAdeMO"
+#define STR_GUN_TYPE_CCS            "CCS"
+#define STR_GUN_TYPE_GBT            "GBT"
+#define STR_GUN_TYPE_AC             "AC"
+#define STR_GUN_TYPE_UNKNOWN        "Unknown Type"
+
 enum _GUN_TYPE
 {
 	_Type_Chademo = 		0,

binární
EVSE/Projects/DO360/Apps/FactoryConfig


binární
EVSE/Projects/DO360/Apps/Module_EvComm


+ 26 - 13
EVSE/Projects/DO360/Apps/Module_EvComm.c

@@ -56,9 +56,9 @@ struct SysConfigAndInfo				*ShmSysConfigAndInfo;
 void PRINTF_FUNC(char *string, ...);
 
 int StoreLogMsg(const char *fmt, ...);
-#define DEBUG_INFO(format, args...) PRINTF_FUNC("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) PRINTF_FUNC("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) PRINTF_FUNC("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 
 int StoreLogMsg(const char *fmt, ...)
 {
@@ -103,7 +103,7 @@ void PRINTF_FUNC(char *string, ...)
 	vsnprintf(buffer, sizeof(buffer), string, args);
 	va_end(args);
 
-	printf("%s \n", buffer);
+	DEBUG_INFO("%s \n", buffer);
 }
 
 void ShowSocketData(struct PACKET_STRUCTURE *packet)
@@ -883,7 +883,7 @@ unsigned char ConnectorQuantityTypeParsing(unsigned char *modelName, unsigned ch
 
 	for(int i = 0; i < 3; i++)
 	{
-		if(IsAvalibleGunType(modelName[7 + i], type))
+		if(IsAvalibleGunType(modelName[7 + i], &type[quantity]))
 		{
 			if(quantity < 2)
 			{
@@ -1097,12 +1097,16 @@ BOOL FindConnectorID(unsigned char dispenserIndex, unsigned char id)
 
 void ConnectorTypeBindingHandler(unsigned char dispenserIndex, unsigned char *type)
 {
+    char *str_gun_type[] = {STR_GUN_TYPE_CHADEMO, STR_GUN_TYPE_CCS, STR_GUN_TYPE_GBT};
+
 	for(int i = 0; i < ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorQuantity; i++)
 	{
 		unsigned char gunIndex = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorID[i] - 1;
 		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].ParentDispensetIndex = dispenserIndex;
 		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].GeneralChargingData.Index = gunIndex;
 		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].GeneralChargingData.Type = type[i];
+
+		PRINTF_FUNC("Dispenser id %d Connector %d type %s", dispenserIndex + 1, gunIndex + 1, str_gun_type[type[i]]);
 	}
 }
 
@@ -1159,7 +1163,7 @@ void DispenserCheckInInfoUpdate(void)
 
 	if(change)
 	{
-		PRINTF_FUNC("Total Dispenser: %d, Total Connector: %d",
+		PRINTF_FUNC("Total Dispenser: %d, Total Connector: %d\n",
 			ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity,
 			ShmSysConfigAndInfo->SysInfo.DispenserInfo.TotalConnectorQuantity);
 	}
@@ -1212,9 +1216,7 @@ BOOL DispenserIdentificationHandler(struct PACKET_STRUCTURE *packet, unsigned ch
 
 			ConnectorTypeBindingHandler(dispenserIndex, connectorType);
 
-			PRINTF_FUNC("Dispenser id %d identified, Connector: %d, ID: %d, %d", dispenserIndex + 1, quantity,
-				ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorID[0],
-				ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorID[1]);
+			PRINTF_FUNC("Dispenser id %d identified, Connector quantity: %d\n", dispenserIndex + 1, quantity);
 
 			DispenserCheckInInfoUpdate();
 
@@ -1424,7 +1426,12 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
 	    switch(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].GeneralChargingData.SystemStatus)
 	    {
             case S_PREPARING_FOR_EV:
-                if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus >= _CRS_Preparing &&
+                if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.RemoteStopRequest ||
+                    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.UnlockStopRequest)
+                {
+                    permission = _DAS_NotAllowed;
+                }
+                else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus >= _CRS_Preparing &&
                     ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus <= _CRS_Charging)
                 {
                     if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.PermissionRequest)
@@ -1446,7 +1453,12 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
                 break;
 
             case S_CHARGING:
-                if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Preparing ||
+                if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.RemoteStopRequest ||
+                    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.UnlockStopRequest)
+                {
+                    permission = _DAS_NotAllowed;
+                }
+                else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Preparing ||
                     ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Charging)
                 {
                     permission = _DAS_Allowed;
@@ -1494,6 +1506,7 @@ void DisableConnector(unsigned char dispenserIndex)
 	{
 		unsigned char connector = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorID[i] - 1;
 		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connector].Enable = false;
+		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connector].Parameter.bits.TimeoutStopRequest = true;
 	}
 }
 
@@ -1541,7 +1554,7 @@ void DispenserSocketProcess(int socketFd, struct sockaddr_in clientInfo, unsigne
 	                            {
 	                                ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[index].DispenserIndex = dispenserIndex;
 	                                ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[index].Status = _CNS_DispenserMatched;
-	                                PRINTF_FUNC("Dispenser id %d check in, model name: %s", dispenserID, modelName);
+	                                PRINTF_FUNC("********** Dispenser id %d check in, model name: %s **********\n", dispenserID, modelName);
 	                                ackResult = _R_OK;
 	                            }
 	                            else
@@ -1804,7 +1817,7 @@ void tcpSocketServerStart(void)
 	while(1)
 	{
 		clientSockFd = accept(sockFd, (struct sockaddr*) &clientInfo, &addrlen);
-		PRINTF_FUNC("Client ip: %s is accepted at port: %d", inet_ntoa(clientInfo.sin_addr), clientInfo.sin_port);
+		PRINTF_FUNC("\nClient ip: %s is accepted at port: %d", inet_ntoa(clientInfo.sin_addr), clientInfo.sin_port);
 
 		connectIndex = FindFreeChannel();
 		if(connectIndex >= 0)

binární
EVSE/Projects/DO360/Apps/Module_EventLogging


binární
EVSE/Projects/DO360/Apps/Module_InternalComm


+ 2 - 2
EVSE/Projects/DO360/Apps/Module_InternalComm.c

@@ -278,14 +278,14 @@ void GetFwAndHwVersion_Fan()
 		strcpy((char *) ShmFanModuleData->version, ver.Version_FW);
 		// SystemInfo
 		strcpy((char *) ShmSysConfigAndInfo->SysInfo.FanModuleFwRev, ver.Version_FW);
-		//PRINTF_FUNC("GetFwAndHwVersion_Fan s1 = %s \n", ver.Version_FW);
+		PRINTF_FUNC("GetFwAndHwVersion_Fan s1 = %s \n", ver.Version_FW);
 	}
 
 	if (Query_HW_Ver(Uart5Fd, Addr.Fan, &ver) == PASS)
 	{
 		// SystemInfo
 		strcpy((char *) ShmSysConfigAndInfo->SysInfo.FanModuleHwRev, ver.Version_FW);
-		//PRINTF_FUNC("GetFwAndHwVersion_Fan s2 = %s \n", ver.Version_HW);
+		PRINTF_FUNC("GetFwAndHwVersion_Fan s2 = %s \n", ver.Version_HW);
 	}
 }
 

binární
EVSE/Projects/DO360/Apps/Module_LcmControl


binární
EVSE/Projects/DO360/Apps/Module_PrimaryComm


binární
EVSE/Projects/DO360/Apps/Module_PsuComm


binární
EVSE/Projects/DO360/Apps/ReadCmdline


+ 12 - 10
EVSE/Projects/DO360/Apps/ReadCmdline.c

@@ -880,20 +880,20 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 
                 //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
                 //確定模組己升壓完成
-    		    if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x01 ||
-    		        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x03)
-    		    {
-    		        printf ("First Ground Fault State (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
+    		    //if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x01 ||
+    		    //    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x03)
+    		    //{
+    		        //printf ("First Ground Fault State (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
     		        printf ("Wait K1K2 = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
     		        sleep(5);
     		        //EV done
     		        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_CHARGING;
-    		    }
-    		    else if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus > 0x02)
-    		    {
-    		        printf ("First Ground Fault check Fail (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
-    		        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
-    		    }
+    		    //}
+    		    //else if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus > 0x02)
+    		    //{
+    		    //    printf ("First Ground Fault check Fail (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
+    		    //    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
+    		    //}
 
     		}
     		break;
@@ -964,7 +964,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
     	get_char(word);
 
     	if (strlen(word) == 0)
+    	{
     		continue;
+    	}
 
     	j=0; ctr=0;
     	strcpy(newString[1], "-1");

binární
EVSE/Projects/DO360/Apps/UnsafetyOutputTask


binární
EVSE/Projects/DO360/Apps/main


+ 81 - 49
EVSE/Projects/DO360/Apps/main.c

@@ -126,9 +126,9 @@ void StartDispenserDhcpServer(void);
 void _SelfTestTimeout(void);
 void CheckConnectionTimeout(void);
 
-#define DEBUG_INFO_MSG(format, args...) PRINTF_FUNC("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN_MSG(format, args...) PRINTF_FUNC("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR_MSG(format, args...) PRINTF_FUNC("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_INFO_MSG(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_WARN_MSG(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define DEBUG_ERROR_MSG(format, args...) StoreLogMsg_1("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
@@ -168,7 +168,7 @@ bool isModelNameMatch = true;
 
 //int rfidFd = -1;
 //char* rfidPortName = "/dev/ttyS2";
-char* fwVersion = "D0.04.00.0000.00";
+char* fwVersion = "D0.05.00.0000.00";
 
 sqlite3 *localDb;
 bool isDb_ready;
@@ -375,7 +375,7 @@ void PRINTF_FUNC(char *string, ...)
 	vsnprintf(buffer, sizeof(buffer), string, args);
 	va_end(args);
 
-	printf("%s \n", buffer);
+	DEBUG_INFO_MSG("%s \n", buffer);
 }
 
 long long DiffTimebWithNow(struct timeb ST)
@@ -1472,6 +1472,8 @@ int Initialization()
 	for (byte count = 0; count < CONNECTOR_QUANTITY; count++)
 	{
 		chargingInfo[count]->RemoteStartFlag = NO;
+		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[count].Parameter.bits.RemoteStartRequest = false;
+		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[count].Parameter.bits.RemoteStopRequest = false;
 //
 //		if (chargingInfo[count]->Type == _Type_Chademo)
 //		{
@@ -1498,16 +1500,16 @@ int Initialization()
 		strcpy((char *)ShmOCPP16Data->StatusNotification[count].ErrorCode, "NoError");
 	}
 
-	for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.AcConnectorCount; count++)
-	{
-		ac_chargingInfo[count]->RemoteStartFlag = NO;
+//	for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.AcConnectorCount; count++)
+//	{
+//		ac_chargingInfo[count]->RemoteStartFlag = NO;
 
-		if (ac_chargingInfo[count]->Type == _Type_AC)
-		{
-			ac_chargingInfo[count]->SelfTest_Comp = NO;
-			strcpy((char *)ShmOCPP16Data->StatusNotification[count + ShmSysConfigAndInfo->SysConfig.TotalConnectorCount].ErrorCode, "NoError");
-		}
-	}
+//		if (ac_chargingInfo[count]->Type == _Type_AC)
+//		{
+//			ac_chargingInfo[count]->SelfTest_Comp = NO;
+//			strcpy((char *)ShmOCPP16Data->StatusNotification[count + ShmSysConfigAndInfo->SysConfig.TotalConnectorCount].ErrorCode, "NoError");
+//		}
+//	}
 
 	PRINTF_FUNC("Initialization OK \n");
 	return PASS;
@@ -3137,6 +3139,8 @@ void AuthorizingSettingInitial(unsigned char index, unsigned char AuthorizeSrc)
             memset(ShmOCPP16Data->RemoteStartTransaction[index].IdTag, 0x00, 20);
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus = _AuthorizeStatus_Idle;
             ShmOCPP16Data->CsMsg.bits[index].RemoteStartTransactionReq = false;
+            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.RemoteStartRequest = false;
+            chargingInfo[index]->RemoteStartFlag = false;
 
             if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType != _AuthorizeSrc_None)
             {
@@ -3203,6 +3207,7 @@ void SetConnectorAuthorizeOK(unsigned char index, unsigned char AuthorizeSrc)
             {
                 ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_Remote;
                 memcpy(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, 32);
+                ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.RemoteStartRequest = true;
                 PRINTF_FUNC("*********** Connector id %d RemoteAuthorize OK***********", index + 1);
             }
             break;
@@ -3282,6 +3287,7 @@ void PowerCabinetAuthorizeProcess(void)
             {
                 SetAuthorizingTarget(index, _AuthorizeSrc_Remote);
                 ShmOCPP16Data->CsMsg.bits[index].RemoteStartTransactionReq = false;
+                chargingInfo[index]->RemoteStartFlag = true;
                 FindRemoteStartRequest = true;
                 break;
             }
@@ -4389,16 +4395,9 @@ void OcppStartTransation(byte gunIndex)
 {
 	byte _OcppGunIndex = gunIndex;
 
-	// 如果有 AC 槍,而現在是 DC 第二把槍進入充電
-//	if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount == 1 && gunIndex == 1)
-//		_OcppGunIndex = 2;
-
-	if(strcmp((char *)chargingInfo[gunIndex]->StartUserId, "") == EQUAL)
-		strcpy((char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag, (char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
-	else
-		strcpy((char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
+	strcpy((char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
 
-	PRINTF_FUNC("Gun: %d, OCPP Start Transation Index: %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
+	PRINTF_FUNC("Gun index %d, OCPP Start Transation Index %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
 	ShmOCPP16Data->CpMsg.bits[_OcppGunIndex].StartTransactionReq = YES;
 }
 
@@ -4406,19 +4405,14 @@ void OcppStopTransation(byte gunIndex)
 {
 	byte _OcppGunIndex = gunIndex;
 
-	// 如果有 AC 槍,而現在是 DC 第二把槍進入充電
-//	if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount == 1 && gunIndex == 1)
-//		_OcppGunIndex = 2;
-
-	if(strcmp((char *)chargingInfo[gunIndex]->StartUserId, "") == EQUAL)
-		strcpy((char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag, (char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
-	else
-		strcpy((char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
+	strcpy((char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
 
-	PRINTF_FUNC("OCPP Start Transation Index: %d, IdTag = %s \n", _OcppGunIndex, ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
+	PRINTF_FUNC("Gun index %d, OCPP Stop Transation Index %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
 	ShmOCPP16Data->CpMsg.bits[_OcppGunIndex].StopTransactionReq = YES;
 }
 
+
+// no use
 bool OcppRemoteStop(byte gunIndex)
 {
 	byte acDirIndex = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
@@ -4584,16 +4578,36 @@ void ChkOcppStatus(byte gunIndex)
 	if (ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorReq == YES)
 	{
 		ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorReq = NO;
-		if (chargingInfo[gunIndex]->SystemStatus >= S_REASSIGN_CHECK &&
-				chargingInfo[gunIndex]->SystemStatus <= S_CHARGING)
+
+        if(chargingInfo[gunIndex]->SystemStatus == S_PREPARNING ||
+                chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EV ||
+                chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EVSE ||
+                chargingInfo[gunIndex]->SystemStatus == S_CHARGING)
 		{
 			// 充電中,需停止充電
 			strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "UnlockCommand");
-			ChargingTerminalProcess(gunIndex);
+			ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].Parameter.bits.UnlockStopRequest = true;
+			PRINTF_FUNC("********** OcppUnlockStop Gun %d **********\n", gunIndex);
 		}
+
 		strcpy((char *)ShmOCPP16Data->UnlockConnector[gunIndex].ResponseStatus, "Unlocked");
 		ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorConf = YES;
 	}
+
+    if (ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq == YES)
+    {
+        ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq = NO;
+
+        if(chargingInfo[gunIndex]->SystemStatus == S_PREPARNING ||
+                chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EV ||
+                chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EVSE ||
+                chargingInfo[gunIndex]->SystemStatus == S_CHARGING)
+        {
+            strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "Remote");
+            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].Parameter.bits.RemoteStopRequest = true;
+            PRINTF_FUNC("********** OcppRemoteStop Gun %d **********\n", gunIndex);
+        }
+    }
 }
 
 bool CheckBackendChargingTimeout(byte gunIndex)
@@ -5440,10 +5454,10 @@ int main(void)
 
 			gettimeofday(&_cmdMainPriority_time, NULL);
 
-			PRINTF_FUNC("Gun 1(%d): %d(%s), Gun 2(%d): %d(%s), OCPP: %s",
-                chargingInfo[0]->Index, chargingInfo[0]->SystemStatus, chargingInfo[0]->IsAvailable ? "Operative" : "Inoperative",
-                chargingInfo[1]->Index, chargingInfo[1]->SystemStatus, chargingInfo[1]->IsAvailable ? "Operative" : "Inoperative",
-                ShmOCPP16Data->OcppConnStatus ? "On" : "Off");
+//			PRINTF_FUNC("Gun 1(%d): %d(%s), Gun 2(%d): %d(%s), OCPP: %s",
+//                chargingInfo[0]->Index, chargingInfo[0]->SystemStatus, chargingInfo[0]->IsAvailable ? "Operative" : "Inoperative",
+//                chargingInfo[1]->Index, chargingInfo[1]->SystemStatus, chargingInfo[1]->IsAvailable ? "Operative" : "Inoperative",
+//                ShmOCPP16Data->OcppConnStatus ? "On" : "Off");
 
 //			PRINTF_FUNC("Gun 1: %d(%d), Gun 2: %d(%d), Gun 3: %d(%d), Gun 4: %d(%d)",
 //                chargingInfo[0]->Index, chargingInfo[0]->Type,
@@ -5481,9 +5495,17 @@ int main(void)
 			CheckErrorOccurStatus(gun_index);
 			ChkOcppStatus(gun_index);
 
-			if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable == false)
+			if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.TimeoutStopRequest)
 			{
-				setChargerMode(gun_index, MODE_IDLE);
+			    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.TimeoutStopRequest = false;
+
+			    if(chargingInfo[gun_index]->SystemStatus == S_PREPARNING ||
+                    chargingInfo[gun_index]->SystemStatus == S_PREPARING_FOR_EV ||
+                    chargingInfo[gun_index]->SystemStatus == S_PREPARING_FOR_EVSE ||
+                    chargingInfo[gun_index]->SystemStatus == S_CHARGING)
+			    {
+			        ChargingTerminalProcess(gun_index);
+			    }
 			}
 
 			//PRINTF_FUNC("index = %d, ErrorCode = %s \n", gun_index, ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
@@ -5496,6 +5518,8 @@ int main(void)
 				{
 					// clean PermissionRequest flag
 					ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PermissionRequest = false;
+					ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.RemoteStopRequest = false;
+					ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = true;
 
 					if (chargingInfo[gun_index]->SystemStatus == S_IDLE &&
 							isModeChange(gun_index))
@@ -5690,6 +5714,7 @@ int main(void)
 						if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
 							ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
 						StopSystemTimeoutDet();
+						ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = false;
 					}
 
 					bool isRessign = false;
@@ -5792,10 +5817,10 @@ int main(void)
 						setChargerMode(gun_index, MODE_PREPARE_FOR_EV);
 					}
 
-					if (isEvBoardStopChargeFlag(gun_index) == YES || OcppRemoteStop(gun_index) == YES)
+					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端或後臺要求停止
-					    PRINTF_FUNC("EvBoardStop: %d, OcppStop: %d \n", isEvBoardStopChargeFlag(gun_index), OcppRemoteStop(gun_index));
+					    PRINTF_FUNC("********** EvBoardStop Gun %d (S_PREPARNING)**********\n", gun_index);
 						ChargingTerminalProcess(gun_index);
 					}
 
@@ -5843,10 +5868,10 @@ int main(void)
 						setChargerMode(gun_index, MODE_CHARGING);
 					}
 
-					if (isEvBoardStopChargeFlag(gun_index) == YES  ||
-							OcppRemoteStop(gun_index) == YES)
+					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端或後臺要求停止
+					    PRINTF_FUNC("********** EvBoardStop Gun %d (S_PREPARING_FOR_EV)**********\n", gun_index);
 						ChargingTerminalProcess(gun_index);
 					}
 
@@ -5924,8 +5949,7 @@ int main(void)
 						}
 					}
 
-					if (isEvBoardStopChargeFlag(gun_index) == YES ||
-							OcppRemoteStop(gun_index) == YES)
+					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端或後臺要求停止
 						ChargingTerminalProcess(gun_index);
@@ -6041,7 +6065,6 @@ int main(void)
 					}
 
 					if (isEvBoardStopChargeFlag(gun_index) ||
-							OcppRemoteStop(gun_index) ||
 							CheckBackendChargingTimeout(gun_index) ||
 							CheckBackendChargingEnergy(gun_index) ||
 							strcmp((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid") == EQUAL)
@@ -6175,8 +6198,17 @@ int main(void)
 						ChangeStartOrStopDateTime(NO, gun_index);
 					}
 
-					//if(chargingInfo[gun_index]->ConnectorPlugIn == NO &&
 					if(GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 10000000)
+					{
+					    if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
+					    {
+					        PRINTF_FUNC ("********** Gun %d psu is releasable **********\n", gun_index);
+					        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = true;
+					    }
+					}
+
+					if(chargingInfo[gun_index]->ConnectorPlugIn == NO &&
+                        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
 					{
 						setChargerMode(gun_index, MODE_IDLE);
 					}

binární
EVSE/Projects/DO360/Images/ramdisk.gz


+ 4 - 1
EVSE/Projects/define.h

@@ -616,7 +616,10 @@ typedef union
         unsigned int  PermissionRequest:1;              // 0: no request,    1: dispenser request to charging
         unsigned int  RemoteStartRequest:1;             // 0: no request,    1: remote start
         unsigned int  RemoteStopRequest:1;              // 0: no request,    1: remote stop
-        unsigned int  res:25;
+        unsigned int  UnlockStopRequest:1;              // 0: no request,    1: Unlock stop
+        unsigned int  TimeoutStopRequest:1;             // 0: no request,    1: ethernet timeout stop
+        unsigned int  PsuReleasable:1;
+        unsigned int  res:22;
     }bits;
 }ConnectorParameter;