Jelajahi Sumber

[Improve][Modularization][Module_OcppBackend20]

2021.09.10 / Folus Wen

Actions:
1. ID_CpConfiguration logic fix.
2. handleRequestStartTransactionRequest() add connector status check logic.
3. TransactionEvent seqNo don't add when store temp TransactionEvent data.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 tahun lalu
induk
melakukan
df3d66cfd3

+ 246 - 60
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -7395,7 +7395,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*100))/100.0;
 				}
 			}
 
@@ -7416,7 +7416,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*100))/100.0;
 				}
 			}
 
@@ -7437,7 +7437,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*100))/100.0;
 				}
 			}
 
@@ -7451,7 +7451,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*100))/100.0;
 				}
 			}
 
@@ -7472,7 +7472,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*100))/100.0;
 				}
 			}
 
@@ -7508,7 +7508,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				{
 					if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 					{
-						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
+						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100))/100.0;
 					}
 				}
 
@@ -7529,7 +7529,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				{
 					if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 					{
-						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
+						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100))/100.0;
 					}
 				}
 
@@ -7550,7 +7550,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				{
 					if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 					{
-						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
+						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100))/100.0;
 					}
 				}
 
@@ -7565,7 +7565,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				{
 					if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 					{
-						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
+						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100))/100.0;
 					}
 				}
 
@@ -7586,7 +7586,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				{
 					if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 					{
-						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
+						ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100))/100.0;
 					}
 				}
 
@@ -7622,7 +7622,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100))/100.0;
 				}
 			} // END OF FOR CHAdeMO_QUANTITY
 
@@ -7643,7 +7643,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100))/100.0;
 				}
 			} // END OF CCS_QUANTITY
 
@@ -7664,7 +7664,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100))/100.0;
 				}
 			} // END OF GB_QUANTITY
 
@@ -7678,7 +7678,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100))/100.0;
 				}
 			}
 
@@ -7699,7 +7699,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100))/100.0;
 				}
 			 }
 
@@ -7735,7 +7735,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower*100))/100.0;
 				}
 			} // END OF FOR
 
@@ -7756,7 +7756,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower*100))/100.0;
 				}
 			}
 
@@ -7778,7 +7778,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
 				     //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
-				    ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
+				    ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower*100))/100.0;
 				}
 			}
 
@@ -7793,7 +7793,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
 				     //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
-				    ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
+				    ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower*100))/100.0;
 				}
 			}
 
@@ -7814,7 +7814,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-				    ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
+				    ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower*100))/100.0;
 				}
 			}
 
@@ -7850,7 +7850,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
+				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*100))/100.0;
 				}
 			}
 
@@ -7871,7 +7871,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
+				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*100))/100.0;
 				}
 			}
 
@@ -7892,7 +7892,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
+				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*100))/100.0;
 				}
 			}
 
@@ -7906,7 +7906,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
-				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
+				 	ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*100))/100.0;
 				}
 			}
 
@@ -7927,7 +7927,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*100))/100.0;
 				}
 			}
 
@@ -8040,7 +8040,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*100))/100.0;
 				}
 			}
 			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
@@ -8073,7 +8073,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*100))/100.0;
 				}
 			}
 			strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
@@ -8106,7 +8106,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*100))/100.0;
 				}
 			}
 
@@ -8140,7 +8140,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
+					ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*100))/100.0;
 				}
 			}
 
@@ -9596,7 +9596,7 @@ int sendTransactionEventRequest(int gun_index)
 				else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
-					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
+					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
 					if((access(TempStopTransaction,F_OK))!=-1)
 					{
@@ -9712,7 +9712,7 @@ int sendTransactionEventRequest(int gun_index)
 				else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
-					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
+					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
 					if((access(TempStopTransaction,F_OK))!=-1)
 					{
@@ -9827,7 +9827,7 @@ int sendTransactionEventRequest(int gun_index)
 				else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
-					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
+					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
 					if((access(TempStopTransaction,F_OK))!=-1)
 					{
@@ -9935,7 +9935,7 @@ int sendTransactionEventRequest(int gun_index)
 				else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
-					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
+					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
 					if((access(TempStopTransaction,F_OK))!=-1)
 					{
@@ -10049,7 +10049,7 @@ int sendTransactionEventRequest(int gun_index)
 				else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
-					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
+					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
 					sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
 					if((access(TempStopTransaction,F_OK))!=-1)
 					{
@@ -13009,6 +13009,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			if(!is_error(data))
 			{
 				strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
+				sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, " ");
 
 				if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
 				{
@@ -14228,9 +14229,11 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 	mtrace();
 	int result = FAIL;
 	int8_t gun_index = -1;
+	uint8_t tempIndex;
 	uint8_t isPeriodOverMax = FALSE;
 	uint8_t isProfileOverMax = FALSE;
 	uint8_t isTxProfile = TRUE;
+	uint8_t isAllowStart = TRUE;
 	uint8_t existProfileQuantity = 0;
 	uint8_t filename[128]={0};
 	uint8_t word[2048]={0};
@@ -14338,10 +14341,215 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 				if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
 					isProfileOverMax = TRUE;
 			}
+
+			//check Transaction active
+			if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
+			{
+				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 )
+					{
+
+						if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
+						}
+						else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
+							isAllowStart = FALSE;
+						}
+						else
+						{
+							if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
+								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) 	//S_PRECHARGE
+								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) 	//S_PREPARING_FOR_EV
+								&& (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE ))   // S_PREPARING_FOR_EVSE
+							{
+								DEBUG_WARN("CHAdeMO connector not allow start\n.");
+								isAllowStart = FALSE;
+							}
+						}//END FOR ELSE
+					}
+				}// END FOR CHAdeMO_QUANTITY
+			}
+			else if(gunType[gun_index] == GUN_TYPE_CCS)
+			{
+				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)
+					{
+						if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
+						}
+						else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
+							isAllowStart = FALSE;
+						}
+						else
+						{
+							if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE)          //S_IDLE
+								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING)   	//S_PRECHARGE
+								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)   	//S_PREPARING_FOR_EV
+								&& (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 	// S_PREPARING_FOR_EVSE
+							{
+								DEBUG_WARN("CCS connector not allow start\n.");
+								isAllowStart = FALSE;
+							}
+
+						}// END FOR ELSE
+					}
+				}// END FOR CCS_QUANTITY
+			}
+			else if(gunType[gun_index] == GUN_TYPE_GBT)
+			{
+				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 )
+					{
+						if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
+						}
+						else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
+							isAllowStart = FALSE;
+						}
+						else
+						{
+							if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
+								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
+								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
+								&& (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+							{
+								DEBUG_WARN("GB connector not allow start\n.");
+								isAllowStart = FALSE;
+							}
+
+						}// END FOR ELSE
+					}
+				} // END FOR GB_QUANTITY
+
+			}
+			else if(gunType[gun_index] == GUN_TYPE_DO)
+			{
+				tempIndex = gun_index;
+
+				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
+				{
+					if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
+					{
+						if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
+						}
+						else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
+							isAllowStart = FALSE;
+						}
+						else
+						{
+							if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE)         	//S_IDLE
+								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING)		//S_PRECHARGE
+								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV)		//S_PREPARING_FOR_EV
+								&& (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) 		// S_PREPARING_FOR_EVSE
+							{
+								DEBUG_WARN("GB connector not allow start\n.");
+								isAllowStart = FALSE;
+							}
+
+						}// END FOR ELSE
+					}
+				} // END FOR GB_QUANTITY
+
+			}
+			else
+			{
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
+				{
+					tempIndex = 2;
+				}
+				else
+				{
+					tempIndex = gun_index;
+				}
+
+				for (int index = 0; index < AC_QUANTITY; index++)
+				{
+					if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
+					{
+
+						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
+						}
+						else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
+						{
+							//Reserved
+							DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
+							isAllowStart = FALSE;
+						}
+						else
+						{
+							if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE)				//S_IDLE
+								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) 	//S_PRECHARGE
+								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) 	//S_PREPARING_FOR_EV
+								&& (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE))   // S_PREPARING_FOR_EVSE
+							{
+								DEBUG_WARN("AC connector not allow start\n.");
+								isAllowStart = FALSE;
+							}
+
+						}//END FOR ELSE
+					}
+				}// END FOR AC_QUANTITY
+			}
 		}
 
+
+
 		// Profile replace or add info
-		if((gun_index >= 0) && !isPeriodOverMax && !isProfileOverMax && isTxProfile)
+		if((gun_index >= 0) && !isPeriodOverMax && !isProfileOverMax && isTxProfile && isAllowStart)
 		{
 			if(strlen((char*)filename) > 0)
 			{
@@ -14374,6 +14582,9 @@ int handleRequestStartTransactionRequest(char *uuid, char *payload)
 			if(!isTxProfile)
 				DEBUG_WARN("Profile purpose is not TxProfile.\n");
 
+			if(!isAllowStart)
+				DEBUG_WARN("Target connector does not allow start.\n");
+
 			sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index<0?0:gun_index)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
 		}
 	}
@@ -17628,11 +17839,6 @@ void storeTempStopTransaction(int gun_index)
 			{
 				getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
 
-				if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
-				else
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
-
 				ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
 
 				ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
@@ -17738,11 +17944,6 @@ void storeTempStopTransaction(int gun_index)
 			{
 				getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
 
-				if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
-				else
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
-
 				ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
 
 				ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
@@ -17847,11 +18048,6 @@ void storeTempStopTransaction(int gun_index)
 			{
 				getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
 
-				if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
-				else
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
-
 				ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
 
 				ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
@@ -17874,11 +18070,6 @@ void storeTempStopTransaction(int gun_index)
 			{
 				getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
 
-				if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
-				else
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
-
 				ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
 
 				ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
@@ -17907,11 +18098,6 @@ void storeTempStopTransaction(int gun_index)
 			{
 				getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
 
-				if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
-				else
-					ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
-
 				ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
 
 				ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);

+ 1 - 1
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -695,10 +695,10 @@ int delq()
 	}
 
 	// open file for writing
+	strcpy(filename, "/Storage/OCPP/TransactionRelatedQueue20");
 	infile = fopen ("/Storage/OCPP/TransactionRelatedQueue20", "r");
 	outfile = fopen (tempfile, "w");
 
-	/*检测到文件结束标识返回1,否则返回0。*/
 	//DEBUG_INFO("feof(infile) =%d\n",feof(infile));
 	int c;
 	c = fgetc(infile);

+ 1 - 1
EVSE/Projects/define.h

@@ -5132,7 +5132,7 @@ struct UnitOfMeasureType
 
 struct SampledValueType
 {
-	float value;													// Required. Indicates the measured value.
+	double value;													// Required. Indicates the measured value.
 	unsigned char context[32];										// Optional. Type of detail value: start, end or sample. Default = "Sample.Periodic"
 	unsigned char measurand[32];									// Optional. Type of measurement. Default = "Energy.Active.Import.Register"
 	unsigned char phase[8];											// Optional. Indicates how the measured value is to be interpreted.