|
@@ -63,6 +63,8 @@ static int FirstHeartBeat = 0;
|
|
|
static int FirmwareStatusNotificationStatus = FIRMWARE_STATUS_IDLE; // Idle
|
|
|
static int DiagnosticsStatusNotificationStatus = DIAGNOSTIC_STATUS_IDLE; // Idle
|
|
|
static char CurrentChargingProfileScheduleStr[30] = {0};
|
|
|
+static float periousPeriodicPowerConsumption[CONNECTOR_QUANTITY] = {0};
|
|
|
+static float periousClockPowerConsumption[CONNECTOR_QUANTITY] = {0};
|
|
|
|
|
|
//========================================
|
|
|
// OCPP status/previous related variables
|
|
@@ -3985,6 +3987,15 @@ int ProcessShareMemory()
|
|
|
{
|
|
|
gunTotalNumber += 1;
|
|
|
gunType[gun_index] = GUN_TYPE_DO;
|
|
|
+ for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == gun_index)
|
|
|
+ {
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
|
|
|
+ DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
switch(modelnameInfo.ParsingInfo[gun_index].GunType)
|
|
|
{
|
|
@@ -4012,28 +4023,64 @@ int ProcessShareMemory()
|
|
|
{
|
|
|
gunTotalNumber += 1;
|
|
|
|
|
|
- switch(modelnameInfo.ParsingInfo[gun_index].GunType)
|
|
|
- {
|
|
|
- case Gun_Type_Chademo:
|
|
|
- gunType[gun_index] = GUN_TYPE_CHAdeMO;
|
|
|
- DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
|
|
|
- break;
|
|
|
- case Gun_Type_CCS_2:
|
|
|
- gunType[gun_index] = GUN_TYPE_CCS;
|
|
|
- DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
|
|
|
+ switch(modelnameInfo.ParsingInfo[gun_index].GunType)
|
|
|
+ {
|
|
|
+ case Gun_Type_Chademo:
|
|
|
+ gunType[gun_index] = GUN_TYPE_CHAdeMO;
|
|
|
+ DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
|
|
|
+ for(int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
|
|
|
+ {
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
|
|
|
+ DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption);
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
- case Gun_Type_GB:
|
|
|
- gunType[gun_index] = GUN_TYPE_GBT;
|
|
|
- DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
|
|
|
+ case Gun_Type_CCS_2:
|
|
|
+ gunType[gun_index] = GUN_TYPE_CCS;
|
|
|
+ DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
|
|
|
+ for (int index = 0; index < CCS_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
|
|
|
+ {
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
|
|
|
+ DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption);
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
- case Gun_Type_AC:
|
|
|
- gunType[gun_index] = GUN_TYPE_AC;
|
|
|
- DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
|
|
|
+ case Gun_Type_GB:
|
|
|
+ gunType[gun_index] = GUN_TYPE_GBT;
|
|
|
+ DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
|
|
|
+ for (int index = 0; index < GB_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
|
|
|
+ {
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
|
|
|
+ DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption);
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
- default:
|
|
|
- DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
|
|
|
- break;
|
|
|
- }
|
|
|
+ case Gun_Type_AC:
|
|
|
+ gunType[gun_index] = GUN_TYPE_AC;
|
|
|
+ DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
|
|
|
+ for (int index = 0; index < AC_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
|
|
|
+ {
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
|
|
|
+ DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -6181,27 +6228,6 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
//=================================
|
|
|
// Transaction_Begin
|
|
|
//=================================
|
|
|
- if(strstr((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData, "Energy.Active.Import.Interval") != NULL)
|
|
|
- {
|
|
|
- //============================================ Energy.Active.Import.Interval ================================
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.3f", 0.0); // MeterStart is 0~6553.5 kWh
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context,ReadingContextStr[ReadingContext_Transaction_Begin]);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format,ValueFormatStr[Raw]);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand,MeasurandStr[Energy_Active_Import_Interval]);//MeasurandStr[Energy_Active_Export_Interval/*Energy_Reactive_Export_Register*/]);
|
|
|
-
|
|
|
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
|
|
|
- if((gunType[gun_index] == GUN_TYPE_CHAdeMO)||(gunType[gun_index] == GUN_TYPE_CCS)||(gunType[gun_index] == GUN_TYPE_GBT)||(gunType[gun_index] == GUN_TYPE_DO))
|
|
|
- {
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase,PhaseStr[L3_N]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase,PhaseStr[L1_N]);
|
|
|
- }
|
|
|
-
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Location,LocationStr[Location_Outlet]);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Unit,UnitOfMeasureStr[UnitOfMeasure_kWh]);
|
|
|
- }
|
|
|
|
|
|
//=================================
|
|
|
// Transaction_End
|
|
@@ -6335,7 +6361,8 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
|
|
|
}
|
|
|
}// END OF CHAdeMO_QUANTITY
|
|
|
|
|
@@ -6357,7 +6384,8 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
|
|
|
}
|
|
|
}// END OF CCS_QUANTITY
|
|
|
|
|
@@ -6379,7 +6407,8 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
|
|
|
}
|
|
|
}// END OF GB_QUANTITY
|
|
|
|
|
@@ -6393,7 +6422,8 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -6415,7 +6445,8 @@ int sendStopTransactionRequest(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
|
|
|
}
|
|
|
}// END OF AC_QUANTITY
|
|
|
|
|
@@ -7310,7 +7341,20 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy );
|
|
|
+ if(dataType == ReadingContext_Sample_Clock)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]));
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else if(dataType == ReadingContext_Sample_Periodic)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "0.000");
|
|
|
+ }
|
|
|
}
|
|
|
} // END OF FOR CHAdeMO_QUANTITY
|
|
|
|
|
@@ -7331,7 +7375,20 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy );
|
|
|
+ if(dataType == ReadingContext_Sample_Clock)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]));
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else if(dataType == ReadingContext_Sample_Periodic)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "0.000");
|
|
|
+ }
|
|
|
}
|
|
|
} // END OF CCS_QUANTITY
|
|
|
|
|
@@ -7352,7 +7409,20 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy);
|
|
|
+ if(dataType == ReadingContext_Sample_Clock)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]));
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else if(dataType == ReadingContext_Sample_Periodic)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "0.000");
|
|
|
+ }
|
|
|
}
|
|
|
} // END OF GB_QUANTITY
|
|
|
|
|
@@ -7366,7 +7436,20 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy);
|
|
|
+ if(dataType == ReadingContext_Sample_Clock)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption - periousClockPowerConsumption[gun_index]));
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
|
|
|
+ }
|
|
|
+ else if(dataType == ReadingContext_Sample_Periodic)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption - periousPeriodicPowerConsumption[gun_index]));
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "0.000");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -7387,7 +7470,20 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy );
|
|
|
+ if(dataType == ReadingContext_Sample_Clock)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]));
|
|
|
+ periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else if(dataType == ReadingContext_Sample_Periodic)
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));
|
|
|
+ periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "0.000");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -14585,6 +14681,79 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
retriesInt--;
|
|
|
}while((isSuccess == 0)&&(retriesInt >= 0));
|
|
|
}
|
|
|
+ else if(strncmp(locationstr,"sftp", 4) == 0) // sftp
|
|
|
+ {
|
|
|
+ memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
+ memset(temp, 0, ARRAY_SIZE(temp));
|
|
|
+ //DEBUG_INFO("locationstr=%s\n",locationstr);
|
|
|
+ strcpy(ftpbuf, locationstr);
|
|
|
+ int ftppathlen=strlen(ftpbuf);
|
|
|
+ int i=1;
|
|
|
+ char filenametemp[50];
|
|
|
+ while(i < ftppathlen)
|
|
|
+ {
|
|
|
+ int len=ftppathlen-i;
|
|
|
+ if(ftpbuf[len]== 47) // '/' ascii code: 47
|
|
|
+ {
|
|
|
+ DEBUG_INFO(" compare '/' all right\n");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ i=i+1;
|
|
|
+ }
|
|
|
+
|
|
|
+ memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
|
|
|
+ strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
|
|
|
+ filenametemp[i+1] = 0;
|
|
|
+ strncpy(temp, ftpbuf, ftppathlen-i+1);
|
|
|
+
|
|
|
+ pch=strchr(temp,'@');
|
|
|
+ if(pch==NULL)
|
|
|
+ {
|
|
|
+ sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
|
|
|
+ protocol, host, &port, path);
|
|
|
+ strcpy(user,"anonymous");
|
|
|
+ strcpy(password,"");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sscanf(temp,"%[^:]:%*2[/]%[^@]@%[^:]:%i/%199[^\n]",
|
|
|
+ protocol, user, host, &port, path);
|
|
|
+ }
|
|
|
+
|
|
|
+ sscanf(host,"%[^/]%s",host1, path1);
|
|
|
+ sprintf(ftppath,"%s:/%s", host,path);
|
|
|
+
|
|
|
+ if(port == 0)
|
|
|
+ {
|
|
|
+ port = 21;
|
|
|
+ }
|
|
|
+
|
|
|
+ do
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloading]);
|
|
|
+ ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
+ sleep(1);
|
|
|
+
|
|
|
+ isSuccess = sftpDownLoadFile(host1, user, port, ftppath, filenametemp, locationstr);
|
|
|
+ if(!isSuccess)
|
|
|
+ {
|
|
|
+ //BulldogUtil.sleepMs(interval*1000);
|
|
|
+ DEBUG_INFO("Update firmware request and download file fail.\n");
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
|
|
|
+ ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
+ if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Idle]);
|
|
|
+ ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
+ ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
+ }
|
|
|
+ retriesInt--;
|
|
|
+ }while((!isSuccess)&&(retriesInt >= 0));
|
|
|
+ }
|
|
|
else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
|
|
|
{
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
@@ -19477,6 +19646,39 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+int sftpDownLoadFile(char *location, char *user, int port, char *path, char *filename,char *url)
|
|
|
+{
|
|
|
+ int result = TRUE;
|
|
|
+ char rmFileCmd[100]={0};
|
|
|
+ char FilePath[100]={0};
|
|
|
+ char ftpbuf[200];
|
|
|
+ int systemresult;
|
|
|
+
|
|
|
+ sprintf(FilePath,"/mnt/%s",filename);
|
|
|
+ system("ping 8.8.8.8 &");
|
|
|
+
|
|
|
+ if((access(FilePath,F_OK))!=-1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("filename=%s exist.\n",FilePath);
|
|
|
+ sprintf(rmFileCmd,"rm -f %s",FilePath);
|
|
|
+ system(rmFileCmd);
|
|
|
+ }
|
|
|
+
|
|
|
+ memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
+ sprintf(ftpbuf,"timeout -t 360 scp -i /root/.ssh/id_rsa_bear -P %d %s@%s%s /mnt/%s", port, user, path, filename, filename);
|
|
|
+ DEBUG_INFO("Download command: %s\n",ftpbuf);
|
|
|
+
|
|
|
+ systemresult = system(ftpbuf);
|
|
|
+ if(systemresult != 0)
|
|
|
+ {
|
|
|
+ DEBUG_WARN("scp error!\n");
|
|
|
+ result = FALSE;
|
|
|
+ }
|
|
|
+ system("pkill ping");
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
|
|
|
{
|
|
|
int result = TRUE;
|
|
@@ -20013,26 +20215,6 @@ void storeTempStopTransaction(int gun_index)
|
|
|
//1. Transaction_Begin
|
|
|
//=================================
|
|
|
//============================== Energy.Active.Import.Interval ===========================================
|
|
|
- if(strstr((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData, "Energy.Active.Import.Interval") != NULL)
|
|
|
- {
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.3f", 0.0); // MeterStart is 0~6553.5 kWh
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context,ReadingContextStr[ReadingContext_Transaction_Begin]);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format,ValueFormatStr[Raw]);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand,MeasurandStr[Energy_Active_Import_Interval]);//MeasurandStr[Energy_Active_Export_Interval/*Energy_Reactive_Export_Register*/]);
|
|
|
-
|
|
|
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
|
|
|
- if((gunType[gun_index] == GUN_TYPE_CHAdeMO)||(gunType[gun_index] == GUN_TYPE_CCS)||(gunType[gun_index] == GUN_TYPE_GBT)||(gunType[gun_index] == GUN_TYPE_DO))
|
|
|
- {
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase,PhaseStr[L3_N]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase,PhaseStr[L1_N]);
|
|
|
- }
|
|
|
-
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Location,LocationStr[Location_Outlet]);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Unit,UnitOfMeasureStr[UnitOfMeasure_kWh]);
|
|
|
- }
|
|
|
|
|
|
//=================================
|
|
|
//2. Transaction_End
|
|
@@ -20167,7 +20349,7 @@ void storeTempStopTransaction(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
}
|
|
|
}// END OF CHAdeMO_QUANTITY
|
|
|
|
|
@@ -20189,7 +20371,7 @@ void storeTempStopTransaction(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
}
|
|
|
}// END OF CCS_QUANTITY
|
|
|
|
|
@@ -20211,7 +20393,7 @@ void storeTempStopTransaction(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
}
|
|
|
}// END OF GB_QUANTITY
|
|
|
|
|
@@ -20225,7 +20407,7 @@ void storeTempStopTransaction(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -20247,7 +20429,7 @@ void storeTempStopTransaction(int gun_index)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy );// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.3f" ,(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]));// PresentChargedEnergy is 0~6553.5 kWh
|
|
|
}
|
|
|
}// END OF AC_QUANTITY
|
|
|
|