Browse Source

2020-05-26 / Kathy Yeh
1. modify meter value: Energy.Active.Import.Register
2. modify: 不同卡片停止充電, QueuTransactionId issue
3. remove updateSetting()

Kathy_Yeh 4 years ago
parent
commit
dedb3db494

+ 189 - 61
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -131,6 +131,7 @@ extern char OcppPath[160];
 extern char OcppProtocol[10];
 extern char OcppHost[50];
 extern char OcppTempPath[50];
+extern char StartTransactionIdTagTemp[20];
 static int OcppPort=0;
 
 //===============================
@@ -2486,7 +2487,7 @@ int sendStopTransactionRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 			{
-				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
+				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
 			}
 		}// END OF CHAdeMO_QUANTITY
 	}
@@ -2505,7 +2506,7 @@ int sendStopTransactionRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 			{
-				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
+				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
 			}
 		}// END OF CCS_QUANTITY
 
@@ -2525,7 +2526,7 @@ int sendStopTransactionRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 			{
-				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
+				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
 			}
 		}// END OF GB_QUANTITY
 	}
@@ -3167,7 +3168,8 @@ int sendStopTransactionRequest(int gun_index)
 	}
 
 	//----------------------------replace queue StopTransaction TransactionId ---------------------------//
-	int gettransactionId = GetTransactionId(gun_index+1, ShmOCPP16Data->StopTransaction[gun_index].IdTag);
+	//int gettransactionId = GetTransactionId(gun_index+1, ShmOCPP16Data->StopTransaction[gun_index].IdTag);
+	int gettransactionId = GetTransactionId(gun_index+1, ShmOCPP16Data->StartTransaction[gun_index].IdTag);
 
 	if((ShmOCPP16Data->StopTransaction[gun_index].TransactionId != 0) && (gettransactionId != 0))
 	{
@@ -3328,6 +3330,103 @@ int sendMeterValuesRequest(int gun_index)
 
 
 	//idx_sample=1;
+	//********************************(2)Energy.Active.Import.Register ************************************************/
+	//J: CHAdeMO  U: CCS1 combo  E: CCS2 combo  G: GBT DC
+
+	if(gunType[gun_index] == 'J')
+	{
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+			{
+				tempIndex = ((gun_index==2) ? 1: 0);
+			}
+			else
+			{
+				tempIndex = gun_index;
+			}
+
+			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
+			{
+				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
+				{
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption );
+				}
+			}
+
+			strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
+	}
+	else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
+	{
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+			{
+				tempIndex = ((gun_index==2) ? 1: 0);
+			}
+			else
+			{
+				tempIndex = gun_index;
+			}
+
+			for (int index = 0; index < CCS_QUANTITY; index++)
+			{
+				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
+				{
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption );
+				}
+			}
+
+			strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
+	}
+	else if(gunType[gun_index] == 'G')
+	{
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+			{
+				tempIndex = ((gun_index==2) ? 1: 0);
+			}
+			else
+			{
+				tempIndex = gun_index;
+			}
+
+			for (int index = 0; index < GB_QUANTITY; index++)
+			{
+				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
+				{
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption );
+				}
+			}
+
+			strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
+	}
+	else
+	{
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
+			{
+				tempIndex = 2;
+			}
+			else
+			{
+				tempIndex = gun_index;
+			}
+
+			for (int index = 0; index < AC_QUANTITY; index++)
+			{
+				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
+				{
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption );
+				}
+			}
+
+			strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L1_N]);
+	}
+
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format, ValueFormatStr[Raw]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand, MeasurandStr[Energy_Active_Import_Register]);
+	//strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase, PhaseStr[L1_N]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location, LocationStr[Location_Outlet]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit,UnitOfMeasureStr[UnitOfMeasure_kWh]);
+
+
+	//idx_sample=2;
 	//****************************************************(3)Energy.Active.Export.Interval*********************************************/
 	//J: CHAdeMO  U: CCS1 combo  E: CCS2 combo  G: GBT DC
 
@@ -3346,11 +3445,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 			{
-				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy );
+				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy );
 			}
 		} // END OF FOR CHAdeMO_QUANTITY
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
 	}
 	else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
 	{
@@ -3369,11 +3468,11 @@ int sendMeterValuesRequest(int gun_index)
 			if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 			{
 			   //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy = 100.0;
-			   sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy );
+			   sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy );
 			}
 		} // END OF CCS_QUANTITY
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
 	}
 	else if(gunType[gun_index] == 'G')
 	{
@@ -3390,11 +3489,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 			{
-				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy);
+				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy);
 			}
 		} // END OF GB_QUANTITY
 
-		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
+		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
 	}
 	else
 	{
@@ -3411,21 +3510,21 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 			{
-				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy );
+				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy );
 			}
 		 }
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L1_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L1_N]);
 	}
 
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format, ValueFormatStr[Raw]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand, MeasurandStr[Energy_Active_Import_Interval]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format, ValueFormatStr[Raw]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand, MeasurandStr[Energy_Active_Import_Interval]);
 	//strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L1_N]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location, LocationStr[Location_Outlet]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit,UnitOfMeasureStr[UnitOfMeasure_kWh]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location, LocationStr[Location_Outlet]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit,UnitOfMeasureStr[UnitOfMeasure_kWh]);
 
-	//idx_sample=2;
+	//idx_sample=3;
 	//********************************(4)Power.Active.Export************************************************/
 	//J : CHAdeMO   U: CCS1 combo   E: CCS2 combo   G: GBT DC
 
@@ -3444,11 +3543,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 			{
-				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower);
+				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower);
 			}
 		} // END OF FOR
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
 	}
 	else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
 	{
@@ -3465,11 +3564,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 			{
-				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower);
+				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower);
 			}
 		}
 
-		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
+		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
 	}
 	else if(gunType[gun_index] == 'G')
 	{
@@ -3487,11 +3586,11 @@ int sendMeterValuesRequest(int gun_index)
 			if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 			{
 			     //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
-			    sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower);
+			    sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower);
 			}
 		}
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
 	}
 	else
 	{
@@ -3508,21 +3607,22 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 			{
-			    sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower);
+			    sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower);
 			}
 		}
 
-		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L1_N]);
+		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L1_N]);
 	}
 
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format, ValueFormatStr[Raw]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand, MeasurandStr[Power_Active_Import]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format, ValueFormatStr[Raw]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand, MeasurandStr[Power_Active_Import]);
 	//strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L1_N]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location, LocationStr[Location_Outlet]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit,UnitOfMeasureStr[UnitOfMeasure_kW]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location, LocationStr[Location_Outlet]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit,UnitOfMeasureStr[UnitOfMeasure_kW]);
 
-	//idx_sample=3;
+
+	//idx_sample=4;
 	//***********************************************(5)VOLTAGE******************************************************/
 	//J : CHAdeMO   U: CCS1 combo   E: CCS2 combo   G: GBT DC
 
@@ -3541,11 +3641,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 			{
-			 	sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage );
+			 	sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage );
 			}
 		}
 
-		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
+		 strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase, PhaseStr[L3_N]);
 	}
 	else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
 	{
@@ -3562,11 +3662,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 			{
-			 	sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage );
+			 	sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage );
 			}
 		}
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase, PhaseStr[L3_N]);
 	}
 	else if(gunType[gun_index] == 'G')
 	{
@@ -3583,11 +3683,11 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 			{
-			 	sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage );
+			 	sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage );
 			}
 		}
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase, PhaseStr[L3_N]);
 	}
 	else
 	{
@@ -3604,23 +3704,24 @@ int sendMeterValuesRequest(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 			{
-				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage );
+				sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage );
 			}
 		}
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L1_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase, PhaseStr[L1_N]);
 	}
 
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format, ValueFormatStr[Raw]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand, MeasurandStr[Voltage]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format, ValueFormatStr[Raw]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand, MeasurandStr[Voltage]);
 	// strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L1_N]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location, LocationStr[Location_Outlet]);
-	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit,UnitOfMeasureStr[UnitOfMeasure_V]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location, LocationStr[Location_Outlet]);
+	strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit,UnitOfMeasureStr[UnitOfMeasure_V]);
+
 
 	if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
 	{
-		//idx_sample=4;
+		//idx_sample=5;
 		//sampledValue = NULL;
 		//***********************************************(6)SOC******************************************************/
 		if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
@@ -3640,7 +3741,7 @@ int sendMeterValuesRequest(int gun_index)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );
 				}
 			}
 		}
@@ -3652,7 +3753,7 @@ int sendMeterValuesRequest(int gun_index)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc );
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc );
 				}
 			}
 
@@ -3665,24 +3766,24 @@ int sendMeterValuesRequest(int gun_index)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					 sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc );
+					 sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc );
 				}
 			}
 
 		}
 
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format, ValueFormatStr[Raw]);
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand, MeasurandStr[SoC]);
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase, PhaseStr[L3_N]);
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location, LocationStr[Location_Outlet]);
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit,UnitOfMeasureStr[UnitOfMeasure_Percent]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Format, ValueFormatStr[Raw]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Measurand, MeasurandStr[SoC]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Phase, PhaseStr[L3_N]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Location, LocationStr[Location_Outlet]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Unit,UnitOfMeasureStr[UnitOfMeasure_Percent]);
 	}
 
 
 	if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
 	{
-		 sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
+		 sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
 		 	 			,MESSAGE_TYPE_CALL
 		 	 			,guid
 		 	 			,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
@@ -3723,12 +3824,19 @@ int sendMeterValuesRequest(int gun_index)
 		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase
 		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location
 		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Value
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Context
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Format
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Measurand
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Phase
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Location
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Unit
 
 		 	 );
 	 }
 	 else
 	 {
-		 sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
+		 sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
 		 	 			,MESSAGE_TYPE_CALL
 		 	 			,guid
 		 	 			,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
@@ -3762,6 +3870,13 @@ int sendMeterValuesRequest(int gun_index)
 		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase
 		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location
 		 				,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location
+						,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit
 
 		 	 );
 	}
@@ -15781,7 +15896,7 @@ void OCPP_deleteIdTag(char idTag[])
 
 int GetOcppServerURL()
 {
-    int result = FALSE;
+	int result = FALSE;
 	memset(OcppProtocol, 0, sizeof(OcppProtocol));
 	memset(OcppHost, 0, sizeof(OcppHost));
 	memset(OcppTempPath, 0, sizeof(OcppTempPath));
@@ -15897,6 +16012,12 @@ void SetHeartBeatWithNOResponse(void)
 	HeartBeatWithNOResponse = 0;
 }
 
+void GetStartTransactionIdTag(int gun_index)
+{
+	memset(StartTransactionIdTagTemp, 0 ,sizeof(StartTransactionIdTagTemp));
+	strcpy(StartTransactionIdTagTemp, (const char *)ShmOCPP16Data->StartTransaction[gun_index].IdTag);
+}
+
 void splitstring(char *src,const char *separator,char **dest,int *num) {
 	/*
 		src 源字串的首地址(buf的地址)
@@ -15927,6 +16048,12 @@ int GetTransactionId(int gunindex, unsigned char idTag[])
 	char str[100]={0};
 
 	temptransactionId = 0;
+
+	if((strcmp((const char*)idTag, "")==0)||(idTag[0]=='\0'))
+	{
+		return temptransactionId;
+	}
+
 	/*------ Read the file ----------------*/
 	fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
 	if (!fptr1)
@@ -17716,6 +17843,7 @@ void GetChargingProfileRequest(int gunindex)
 
 }
 
+//Note: It is not real StopTransaction. It is temporary StopTransaction.
 void storeTempStopTransaction(int gun_index)
 {
 	//int result = FAIL;
@@ -17745,7 +17873,7 @@ void storeTempStopTransaction(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 			{
-				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
+				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
 			}
 		}// END OF CHAdeMO_QUANTITY
 	}
@@ -17764,7 +17892,7 @@ void storeTempStopTransaction(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 			{
-				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
+				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
 			}
 		}// END OF CCS_QUANTITY
 
@@ -17784,7 +17912,7 @@ void storeTempStopTransaction(int gun_index)
 		{
 			if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 			{
-				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
+				ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
 			}
 		}// END OF GB_QUANTITY
 	}

+ 1 - 0
EVSE/Modularization/ocppfiles/MessageHandler.h

@@ -135,6 +135,7 @@ int GetBootNotificationInterval(void);
 void InitialSystemValue(void);
 void checkTempStopTransaction(int gun_index);
 void storeTempStopTransaction(int gun_index);
+void GetStartTransactionIdTag(int gun_index);
  //===============================================
  // sqlite related routine
  //===============================================

+ 7 - 3
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -108,7 +108,7 @@ static int IsUsing = FALSE;
 int defaultWaitingTime = 10; //10 second
 char OcppPath[160]={0};
 char OcppProtocol[10]={0},OcppHost[50]={0}, OcppTempPath[50]={0};
-
+unsigned char StartTransactionIdTagTemp[20]={0};
 //===============================
 // OCPP SentQueue TransactionId
 //===============================
@@ -1370,7 +1370,7 @@ if( fgets (str, 1200, fp)!=NULL ) {
 		else
 		{
 			hashmap_operation(0, guid, tempdata);
-            FillStartTransaction(tempconnectorId, IdtagStr, tempmeterStart, tempreservationId, timestampStr);
+			FillStartTransaction(tempconnectorId, IdtagStr, tempmeterStart, tempreservationId, timestampStr);
 			//DEBUG_INFO("\n 2. sent queue guid=%s\n",guid);
 		}
 	}
@@ -1393,9 +1393,13 @@ if( fgets (str, 1200, fp)!=NULL ) {
 		sstr[c] = '\0';
 		temptransactionId = atoi(sstr);
 
-		gettransactionId = GetTransactionId(tempconnectorId, IdtagStr);
+		//gettransactionId = GetTransactionId(tempconnectorId, IdtagStr);
+		GetStartTransactionIdTag(tempconnectorId);
+		gettransactionId = GetTransactionId(tempconnectorId, StartTransactionIdTagTemp);
+
 		if((gettransactionId != 0)&&(temptransactionId != gettransactionId))
 		{
+			//replace transactionId of metervalue or stopTransaction
 			strncpy(strcomposite,str, (loc-str)+2+strlen("transactionId"));
 			sprintf(strcomposite+((loc-str)+2+strlen("transactionId")),"%d",gettransactionId);
 			strcat(strcomposite, loc+strlen("transactionId")+2+c);