瀏覽代碼

2022-01-07/Jerry Wang
Action:
1. Fix the problem that there is no status value in RemoteStartTransaction.conf when backend doesn't choose any connector for remote start.
2. Fix the problem that EVSE cannot send out all of the Aligned-Clock MeterValue for each connector.
3. Fix the problem that EVSE cannot record the Transaction related messages queue when EVSE can connect to server but no OCPP message feedback.

File:
1. /EVSE/Modularization/ocppfiles/MessageHandler.c
-->Action 1,2
2. /EVSE/Modularization/ocppfiles/Module_OcppBackend.c
-->Action 3
3. /EVSE/Modularization/ocppph/MessageHandler.c
-->Action 1,2
4. /EVSE/Modularization/ocppph/Module_OcppBackend.c
-->Action 3

Jerry Wang 3 年之前
父節點
當前提交
e8a25877fe

+ 115 - 101
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -90,6 +90,12 @@ static struct OCPPAuthLocalElemet
 	char idTagstatus[16];
 }idTagQuery;
 
+//============================================
+// OCPP MeterValue request flag
+//============================================
+uint8_t reqSampleMeter[CONNECTOR_QUANTITY]={0};
+uint8_t reqClockAlignMeter[CONNECTOR_QUANTITY]={0};
+
 //=============================================
 // OCPP HeartBeat Response Not Receive Counts
 //============================================
@@ -4403,9 +4409,6 @@ end:
 
 void CheckSystemValue(void)
 {
-	uint8_t reqSampleMeter[CONNECTOR_QUANTITY]={0};
-	uint8_t reqClockAlignMeter[CONNECTOR_QUANTITY]={0};
-
 	char filenmae[100]={0};
 	char str[100]={0};
 	int tempIndex = 0;
@@ -4423,6 +4426,107 @@ void CheckSystemValue(void)
 		HeartBeatWithNOResponse += 1;
 	}
 
+	for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
+	{
+		// ClockAlign MeterValue
+		if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData) > 0)?((getTimePassSinceToday(gun_index)%(atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData)))==0):FALSE))
+		{
+			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++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}// End for CHAdeMO
+			}
+			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++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				} // End for CCS
+			}
+			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++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}// End for GB
+			}
+			else if(gunType[gun_index] == GUN_TYPE_DO)
+			{
+				tempIndex = gun_index;
+
+				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}
+			}
+			else
+			{
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
+				{
+					tempIndex = 2;
+				}
+				else
+				{
+					tempIndex = gun_index;
+				}
+
+				for (int index = 0; index < AC_QUANTITY; index++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}//End for AC
+			}
+		}
+	}
+
 	for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
 	{
 		//==========================================
@@ -4827,104 +4931,7 @@ void CheckSystemValue(void)
 			cpinitateMsg.bits[gun_index].TriggerMeterValue = 0;
 		}
 
-		// ClockAlign MeterValue
-		if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData) > 0)?((getTimePassSinceToday(gun_index)%(atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData)))==0):FALSE))
-		{
-			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++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}// End for CHAdeMO
-			}
-			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++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				} // End for CCS
-			}
-			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++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}// End for GB
-			}
-			else if(gunType[gun_index] == GUN_TYPE_DO)
-			{
-				tempIndex = gun_index;
-
-				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}
-			}
-			else
-			{
-				if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
-				{
-					tempIndex = 2;
-				}
-				else
-				{
-					tempIndex = gun_index;
-				}
-
-				for (int index = 0; index < AC_QUANTITY; index++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}//End for AC
-			}
-		}
-
+		// Clock-aligned Meter value
 		if(isWebsocketSendable && (reqClockAlignMeter[gun_index] == 1))
 		{
 			sendMeterValuesRequest(gun_index, ReadingContext_Sample_Clock);
@@ -5050,6 +5057,7 @@ void CheckSystemValue(void)
 					sendMeterValuesRequest(gun_index, ReadingContext_Sample_Periodic);
 
 				storeTempStopTransaction(gun_index);
+				reqSampleMeter[gun_index] = 0;
 			}
 
 			refreshStartTimer(&clientTime.MeterValues[gun_index]);
@@ -12236,6 +12244,12 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						 strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
 					 }
 				 }
+				 else
+				 {
+					 refreshStartTimer(&clientTime.RemoteStartWait);
+					 ShmOCPP16Data->MsMsg.bits.isRemoteStartWaitReq = 1;
+					 strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
+				 }
 			 }
 			 else
 			 {

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

@@ -1521,6 +1521,9 @@ int main(void)
 				refreshStartTimer(&startTime.bootNotification);
 			}
 
+			// Check System Value
+			CheckSystemValue();
+
 			// On line operation
 			if(GetServerSign() == TRUE)
 			{
@@ -1532,9 +1535,6 @@ int main(void)
 					queueOpInfo.PreTransactionMessageResend = queueOpInfo.TransactionMessageResend;
 				}
 
-				// Check System Value
-				CheckSystemValue();
-
 				// PING packet
 				if(isWebsocketSendable && (0 < GetWebSocketPingInterval()) && ((GetWebSocketPingInterval()+counterPingSend) <= getDiffSecNow(startTime.pingOn)))
 				{

+ 115 - 101
EVSE/Modularization/ocppph/MessageHandler.c

@@ -91,6 +91,12 @@ static struct OCPPAuthLocalElemet
 	char idTagstatus[16];
 }idTagQuery;
 
+//============================================
+// OCPP MeterValue request flag
+//============================================
+uint8_t reqSampleMeter[CONNECTOR_QUANTITY]={0};
+uint8_t reqClockAlignMeter[CONNECTOR_QUANTITY]={0};
+
 //=============================================
 // OCPP HeartBeat Response Not Receive Counts
 //============================================
@@ -3922,9 +3928,6 @@ end:
 
 void CheckSystemValue(void)
 {
-	uint8_t reqSampleMeter[CONNECTOR_QUANTITY]={0};
-	uint8_t reqClockAlignMeter[CONNECTOR_QUANTITY]={0};
-
 	char filenmae[100]={0};
 	char str[100]={0};
 	int tempIndex = 0;
@@ -3942,6 +3945,107 @@ void CheckSystemValue(void)
 		HeartBeatWithNOResponse += 2;
 	}
 
+	for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
+	{
+		// ClockAlign MeterValue
+		if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData) > 0)?((getTimePassSinceToday(gun_index)%(atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData)))==0):FALSE))
+		{
+			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++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}// End for CHAdeMO
+			}
+			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++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				} // End for CCS
+			}
+			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++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}// End for GB
+			}
+			else if(gunType[gun_index] == GUN_TYPE_DO)
+			{
+				tempIndex = gun_index;
+
+				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}
+			}
+			else
+			{
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
+				{
+					tempIndex = 2;
+				}
+				else
+				{
+					tempIndex = gun_index;
+				}
+
+				for (int index = 0; index < AC_QUANTITY; index++)
+				{
+					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
+					{
+						reqClockAlignMeter[gun_index] = 1;
+					}
+				}//End for AC
+			}
+		}
+	}
+
 	for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
 	{
 		//==========================================
@@ -4347,104 +4451,7 @@ void CheckSystemValue(void)
 			cpinitateMsg.bits[gun_index].TriggerMeterValue = 0;
 		}
 
-		// ClockAlign MeterValue
-		if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData) > 0)?((getTimePassSinceToday(gun_index)%(atoi((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData)))==0):FALSE))
-		{
-			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++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}// End for CHAdeMO
-			}
-			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++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				} // End for CCS
-			}
-			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++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}// End for GB
-			}
-			else if(gunType[gun_index] == GUN_TYPE_DO)
-			{
-				tempIndex = gun_index;
-
-				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}
-			}
-			else
-			{
-				if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
-				{
-					tempIndex = 2;
-				}
-				else
-				{
-					tempIndex = gun_index;
-				}
-
-				for (int index = 0; index < AC_QUANTITY; index++)
-				{
-					// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
-					{
-						reqClockAlignMeter[gun_index] = 1;
-					}
-				}//End for AC
-			}
-		}
-
+		// Clock-aligned Meter value
 		if(isWebsocketSendable && (reqClockAlignMeter[gun_index] == 1))
 		{
 			sendMeterValuesRequest(gun_index, ReadingContext_Sample_Clock);
@@ -4570,6 +4577,7 @@ void CheckSystemValue(void)
 					sendMeterValuesRequest(gun_index, ReadingContext_Sample_Periodic);
 
 				//storeTempStopTransaction(gun_index);
+				reqSampleMeter[gun_index] = 0;
 			}
 
 			refreshStartTimer(&clientTime.MeterValues[gun_index]);
@@ -11742,6 +11750,12 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 						 strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
 					 }
 				 }
+				 else
+				 {
+					 refreshStartTimer(&clientTime.RemoteStartWait);
+					 ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq = 1;
+					 strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
+				 }
 			 }
 			 else
 			 {

+ 3 - 3
EVSE/Modularization/ocppph/Module_OcppBackend.c

@@ -1510,6 +1510,9 @@ int main(void)
 				refreshStartTimer(&startTime.bootNotification);
 			}
 
+			// Check System Value
+			CheckSystemValue();
+
 			// On line operation
 			if(GetServerSign() == TRUE)
 			{
@@ -1521,9 +1524,6 @@ int main(void)
 					queueOpInfo.PreTransactionMessageResend = queueOpInfo.TransactionMessageResend;
 				}
 
-				// Check System Value
-				CheckSystemValue();
-
 				if(isWebsocketSendable && (0 < GetWebSocketPingInterval()) && ((GetWebSocketPingInterval()+counterPingSend) <= getDiffSecNow(startTime.pingOn)))
 				{
 					lws_callback_on_writable(wsi_client);