Bläddra i källkod

[Improve][AW-Regular][main.c]
2022-06-08 / EASON YANG
Action
1. Improve: ocpp_set_starttransaction_req() function. Sending message to maintain server.
2, Improve: ocpp_set_starttransaction_conf() function. Sending message to maintain server.
3. Improve: ocpp_set_stoptransaction_req() function. Sending message to maintain server.
4. Improve: ocpp_set_stoptransaction_conf() function. Sending message to maintain server.
5. Improve: ocpp_copy_userid_to_starttransaction() function. Sending message to maintain server.
6. Improve: checkStopReason() function. Sending message to maintain server.
7. Improve: Created share memory. ShmOCPP16DataPH.

File
1. main.c
Action 1
Action 2
Action 3
Action 4
Action 5
Action 6
Action 7

FIRMWARE VERSION: V0.71.XX.XXXX.PX

8009 2 år sedan
förälder
incheckning
4f23bc4300
1 ändrade filer med 53 tillägg och 0 borttagningar
  1. 53 0
      EVSE/Projects/AW-Regular/Apps/main.c

+ 53 - 0
EVSE/Projects/AW-Regular/Apps/main.c

@@ -81,6 +81,7 @@ struct FanModuleData			*ShmFanModuleData;
 struct RelayModuleData			*ShmRelayModuleData;
 struct OCPP16Data				*ShmOCPP16Data;
 struct OCPP20Data				*ShmOCPP20Data;
+struct OCPP16Data				*ShmOCPP16DataPH;
 struct Charger					*ShmCharger;
 
 struct timeb					startTime[AC_QUANTITY][10];
@@ -811,6 +812,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)
@@ -825,6 +832,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)
@@ -839,6 +852,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)
@@ -857,6 +876,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)
@@ -869,6 +894,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)
@@ -1368,6 +1398,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
+	{}
+
     return result;
 }
 
@@ -3963,6 +4007,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()