|
@@ -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);
|