Prechádzať zdrojové kódy

[Improve][Modularization][Module_OcppBackendPH]

2022.03.15 / Folus Wen

Actions:
1. define.h add share memory key for maintain server.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 rokov pred
rodič
commit
83d7d23a3e

+ 1 - 1
EVSE/Modularization/ocppph/MessageHandler.c

@@ -3924,7 +3924,7 @@ int InitShareMemory()
 	{}
 
    	//creat ShmOCPP16DataPH
-   	if ((MeterSMId = shmget(3001, sizeof(struct OCPP16Data),  IPC_CREAT|0777)) < 0)
+   	if ((MeterSMId = shmget(ShmOcppPHModuleKey, sizeof(struct OCPP16Data),  IPC_CREAT|0777)) < 0)
 	{
 		DEBUG_ERROR("shmget ShmOCPP16DataPH NG\n");
 		result = FAIL;

+ 56 - 1
EVSE/Projects/AX80/Apps/main.c

@@ -91,6 +91,7 @@ struct FanModuleData			*ShmFanModuleData;
 struct RelayModuleData			*ShmRelayModuleData;
 struct OCPP16Data				*ShmOCPP16Data;
 struct OCPP20Data				*ShmOCPP20Data;
+struct OCPP16Data				*ShmOCPP16DataPH;
 struct Charger					*ShmCharger;
 struct DISPENSER				*ShmDispenser;
 
@@ -1056,6 +1057,12 @@ void ocpp_set_starttransaction_req(uint8_t gun_index, uint8_t status)
 		if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq != status)
 			ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = status;
 	}
+
+	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
+	{
+		if(ShmOCPP16DataPH->CpMsg.bits[gun_index].StartTransactionReq != status)
+			ShmOCPP16DataPH->CpMsg.bits[gun_index].StartTransactionReq = status;
+	}
 }
 
 void ocpp_set_starttransaction_conf(uint8_t gun_index, uint8_t status)
@@ -1070,6 +1077,12 @@ void ocpp_set_starttransaction_conf(uint8_t gun_index, uint8_t status)
 		if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf != status)
 			ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = status;
 	}
+
+	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
+	{
+		if(ShmOCPP16DataPH->CpMsg.bits[gun_index].StartTransactionConf != status)
+			ShmOCPP16DataPH->CpMsg.bits[gun_index].StartTransactionConf = status;
+	}
 }
 
 void ocpp_set_stoptransaction_req(uint8_t gun_index, uint8_t status)
@@ -1084,6 +1097,12 @@ void ocpp_set_stoptransaction_req(uint8_t gun_index, uint8_t status)
 		if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq != status)
 			ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = status;
 	}
+
+	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
+	{
+		if(ShmOCPP16DataPH->CpMsg.bits[gun_index].StopTransactionReq != status)
+			ShmOCPP16DataPH->CpMsg.bits[gun_index].StopTransactionReq = status;
+	}
 }
 
 void ocpp_set_stoptransaction_conf(uint8_t gun_index, uint8_t status)
@@ -1102,6 +1121,12 @@ void ocpp_set_stoptransaction_conf(uint8_t gun_index, uint8_t status)
 			ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = status;
 		}
 	}
+
+	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
+	{
+		if(ShmOCPP16DataPH->CpMsg.bits[gun_index].StopTransactionConf != status)
+			ShmOCPP16DataPH->CpMsg.bits[gun_index].StopTransactionConf = status;
+	}
 }
 
 void ocpp_copy_userid_to_starttransaction(uint8_t gun_index)
@@ -1114,6 +1139,11 @@ void ocpp_copy_userid_to_starttransaction(uint8_t gun_index)
 	{
 		memcpy((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId));
 	}
+
+	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
+	{
+		memcpy((char*)ShmOCPP16DataPH->StartTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16DataPH->StartTransaction[gun_index].IdTag));
+	}
 }
 
 uint8_t ocpp_get_starttransaction_result(uint8_t gun_index)
@@ -1541,6 +1571,20 @@ int CreatShareMemory()
    	}
    	memset(ShmCharger,0,sizeof(struct Charger));
 
+   	//creat ShmOCPP16DataPH
+   	if ((MeterSMId = shmget(ShmOcppPHModuleKey, sizeof(struct OCPP16Data),  IPC_CREAT|0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16DataPH NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16DataPH = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16DataPH NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
 	//creat ShmDispenser
    	if ((MeterSMId = shmget(ShmDispenserKey, sizeof(struct DISPENSER), IPC_CREAT | 0777)) < 0)
     {
@@ -4524,7 +4568,7 @@ void checkChargingProfileLimit(uint8_t gun_index)
 				   ((idx_period == 0) || (ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod > 0))
 				  )
 				{
-					ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingRateUnit,"W")==PASS?ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].limit/(220*ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].numberPhases):ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].limit);
+					targetMaxCurrent = (mystrcmp((char*)ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingRateUnit,"W")==PASS?ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].limit/(220*ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].numberPhases):ShmOCPP20Data->MaxChargingProfile.chargingSchedule[0].chargingSchedulePeriod[idx_period].limit);
 					//DEBUG_INFO("targetMaxCurrent on period[%d]: %d\n", idx_period, targetMaxCurrent);
 				}
 				else
@@ -4587,6 +4631,7 @@ void checkStopReason(uint8_t gun_index)
 		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
 		{
 			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+			memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
 		}
 		else if(ShmOCPP16Data->MsMsg.bits.ResetReq)
 		{
@@ -4644,6 +4689,7 @@ void checkStopReason(uint8_t gun_index)
 		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
 		{
 			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EVDisconnected");
+			memcpy((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId));
 		}
 		else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
 		{
@@ -4697,6 +4743,15 @@ void checkStopReason(uint8_t gun_index)
 		
 		ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
 	}
+
+	// Maintain server
+	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
+	{
+		memcpy(ShmOCPP16DataPH->StopTransaction[gun_index].StopReason, ShmOCPP16Data->StopTransaction[gun_index].StopReason, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].StopReason));
+		memcpy(ShmOCPP16DataPH->StopTransaction[gun_index].IdTag, ShmOCPP16Data->StopTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
+
+		ShmOCPP16DataPH->CpMsg.bits[gun_index].StopTransactionReq = ON;
+	}
 }
 
 void checkRemoteUpgradeStatus()

+ 1 - 0
EVSE/Projects/define.h

@@ -187,6 +187,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
 #define ShmYesCustomKey         1014
+#define ShmOcppPHModuleKey		1015
 
 #define FaultCodeLength         5
 #define AlarmCodeLength         20