Quellcode durchsuchen

[Improve][AW-CCS][main]

2021.04.13 / Folus Wen

Actions:
1. Present charged energy separate to 24 periods data.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen vor 4 Jahren
Ursprung
Commit
520eb90fc7
2 geänderte Dateien mit 59 neuen und 12 gelöschten Zeilen
  1. 58 12
      EVSE/Projects/AW-CCS/Apps/main.c
  2. 1 0
      EVSE/Projects/AW-CCS/Apps/main.h

+ 58 - 12
EVSE/Projects/AW-CCS/Apps/main.c

@@ -2129,6 +2129,59 @@ int gpio_get_value(unsigned int gpio)
     return result;
 }
 
+int presentChargedEnergyClear(unsigned char gun_index)
+{
+	int result = FAIL;
+
+	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
+	memset(ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod, 0x00, ARRAY_SIZE(ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod)*sizeof(float));
+	result = PASS;
+
+	return result;
+}
+
+float presentChargedEnergyTotal(unsigned char gun_index)
+{
+	float result = 0.0f;
+
+	for(int idx=0;idx<ARRAY_SIZE(ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod);idx++)
+	{
+		result += ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod[idx];
+	}
+
+	return result;
+}
+
+int presentChargedEnergyUpdate(unsigned char gun_index)
+{
+	int result = FAIL;
+	time_t CurrentTime;
+	struct tm *tm;
+
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+
+	if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount==1)
+	{
+		// Resolution: 0.01 kwh
+		ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod[tm->tm_hour] += (((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/1000.0) - presentChargedEnergyTotal(gun_index);
+
+	}
+	else
+	{
+		// Resolution: 0.01 kwh
+		ShmCharger->gun_info[gun_index].presentChargedEnergyPeriod[tm->tm_hour] += ((((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/1000.0) +
+																				    (((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/1000.0) +
+																				    (((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/1000.0))
+																					- presentChargedEnergyTotal(gun_index);
+	}
+
+	// Resolution: 0.1 kwh
+	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = presentChargedEnergyTotal(gun_index)/10.0;
+
+	return result;
+}
+
 //===============================================
 // Get firmware version
 //===============================================
@@ -2161,7 +2214,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.48.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.49.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -3938,7 +3991,7 @@ int main(void)
 
 						ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode = 0x00;
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = 0;
-						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
+						presentChargedEnergyClear(gun_index);
 						ShmCharger->gun_info[gun_index].targetCurrent = 0xFF;
 						ocpp_set_unlocker_req(gun_index, OFF);
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId = -1;
@@ -4279,7 +4332,7 @@ int main(void)
 								if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
 								{
 									ocpp_set_unlocker_req(gun_index, OFF);
-									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
+									presentChargedEnergyClear(gun_index);
 									getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
 									ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption;
 									ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption;
@@ -4379,7 +4432,7 @@ int main(void)
 									(ShmCharger->gun_info[gun_index].isCCSStartTransation == ON))
 								{
 									ocpp_set_unlocker_req(gun_index, OFF);
-									ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
+									presentChargedEnergyClear(gun_index);
 									getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
 									ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption;
 									ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption;
@@ -4699,14 +4752,7 @@ int main(void)
 
 						ftime(&endChargingTime[gun_index]);
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
-						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount==1)
-							ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/100.0;
-						else
-						{
-							//ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy[0] = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/100.0;
-							//ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy[1] = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/100.0;
-							//ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy[2] = ((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/100.0;
-						}
+						presentChargedEnergyUpdate(gun_index);
 
 						// Response StartTransactionConf
 						ocpp_set_starttransaction_conf(gun_index, OFF);

+ 1 - 0
EVSE/Projects/AW-CCS/Apps/main.h

@@ -696,6 +696,7 @@ typedef struct GUN_INFO
 	Set_Aux_Power_Switch							setAuxPowerSwitch;
 	Gpio_in											GPIO_Input;
 	Ac_Ccs_Info										acCcsInfo;
+	float											presentChargedEnergyPeriod[24];		// Session present charged energy at each period, resolution: 0.01 KWH
 	uint8_t											ccsHandshakeState;
 	uint8_t											PreviousEVChargeProgress;
 	uint8_t											chargingMode;