瀏覽代碼

Merge branch 'master' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x

ct_chen 3 年之前
父節點
當前提交
3a17d64068

+ 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;

+ 4 - 1
EVSE/Projects/AW-Regular/Apps/main.c

@@ -2715,10 +2715,12 @@ int isMatchStartUser(unsigned char gun_index)
 		}
 	}
 
+	/*
 	DEBUG_INFO("==== isMatchStartUser ==== \n");
 	DEBUG_INFO("tmpUser : %s \n", tmpUser);
 	DEBUG_INFO("StartUserId : %s \n", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
 	DEBUG_INFO("========================== \n");
+	*/
 
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId)==0)?YES:NO);
 }
@@ -3629,7 +3631,8 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 		{
 			// Absolute profile
 			if((mystrcmp((char*)ShmOCPP16Data->MaxChargingProfile.ChargingProfileKind, "Absolute") == PASS))
-			{		
+			{
+				// Checking limitation
 				for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.ChargingSchedulePeriod);idx_period++)
 				{
 					if((getMaxScheduleStart() >= ShmOCPP16Data->MaxChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&

+ 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