浏览代码

2020.06.22 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/MessageHandler.c connector status change detection logic bug fixed.
2. EVSE/Modularization/ocppfiles/MessageHandler.c cancel unused variable.

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 4 年之前
父节点
当前提交
40c907ccdc
共有 1 个文件被更改,包括 42 次插入54 次删除
  1. 42 54
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 42 - 54
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -46,7 +46,7 @@ static int UnknownKeynum 			= 0;
 // Gun Total  Numbers
 //===============================
 static int gunTotalNumber			= 0;
-static unsigned char gunType[4] 	= {0};
+static uint8_t gunType[4] 			= {0};
 
 //===============================
 // Local List Version
@@ -59,7 +59,6 @@ static char idTagAuthorization[32]	= {0};
 //===============================
 static int server_sign				= FALSE;
 int server_pending 					= FALSE;
-int PRE_SYS_MODE[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY];
 static int BootNotificationInterval = 0;
 static int SystemInitial 			= 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;	// System Boot UP
 
@@ -81,19 +80,19 @@ static char CurrentChargingProfileScheduleStr[30]	= {0};
 //========================================
 // OCPP status/previous related variables
 //========================================
-static int GunStatusInterval 															= 10;
-static int statusModeChage[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY] 	= {FALSE};
-static int ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
-static int CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
-static int GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
-static int AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
-static int ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
-static int CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
-static int GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
-static int AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
-static int TransactionMessageAttemptsValue 		= 0;
-static int TransactionMessageRetryIntervalValue 	= 0;
-static int TempMeterValueInterval 			= 0;
+static int GunStatusInterval 																= 10;
+static uint8_t statusModeChage[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY] 	= {FALSE};
+static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
+static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
+static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
+static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
+static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
+static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
+static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
+static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
+static int TransactionMessageAttemptsValue 													= 0;
+static int TransactionMessageRetryIntervalValue 											= 0;
+static int TempMeterValueInterval 															= 0;
 static struct OCPPAuthLocalElemet
 {
 	int listVersionInt;
@@ -2254,22 +2253,20 @@ void CheckSystemValue(void)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[gun_index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[gun_index]) )
+					if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
 					{
-						//PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
-						ChademoPreviousSystemStatus[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
-						ChademoPreviousConnectorPlugIn[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
+						ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
+						ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
 						cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
 						statusModeChage[gun_index] = TRUE;
 					}
 
 			#if 1 // for TempStopTransaction
 					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
-										{
+					{
 						checkTempStopTransaction(gun_index);
 					}
 			#endif
-
 				}
 			}
 		}
@@ -2290,11 +2287,10 @@ void CheckSystemValue(void)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[gun_index]) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn != CcsPreviousConnectorPlugIn[gun_index]) )//if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
+					if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn != CcsPreviousConnectorPlugIn[index]) )//if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
 					{
-						//PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
-						CcsPreviousSystemStatus[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
-						CcsPreviousConnectorPlugIn[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
+						CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
+						CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
 						cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
 						statusModeChage[gun_index] = TRUE;
 					}
@@ -2305,7 +2301,6 @@ void CheckSystemValue(void)
 						checkTempStopTransaction(gun_index);
 					}
 			#endif
-
 				}
 			}
 		}
@@ -2326,11 +2321,10 @@ void CheckSystemValue(void)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[gun_index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[gun_index]) )
+					if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
 					{
-						//PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
-						GbPreviousSystemStatus[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
-						GbPreviousConnectorPlugIn[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
+						GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
+						GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
 						cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
 						statusModeChage[gun_index] = TRUE;
 					}
@@ -2341,7 +2335,6 @@ void CheckSystemValue(void)
 						checkTempStopTransaction(gun_index);
 					}
 		#endif
-
 				}
 			}
 
@@ -2362,17 +2355,16 @@ void CheckSystemValue(void)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[gun_index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[gun_index]) )
+					if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
 					{
-						//PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
-						AcPreviousSystemStatus[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
-						AcPreviousConnectorPlugIn[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
+						AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
+						AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
 						cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
 						statusModeChage[gun_index] = TRUE;
 					}
 
 			#if 1 // for TempStopTransaction
-					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
+					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
 					{
 						checkTempStopTransaction(gun_index);
 					}
@@ -2384,11 +2376,10 @@ void CheckSystemValue(void)
 
 
 	if(isWebsocketSendable &&
-	   (((server_sign == TRUE) && (SystemInitial > 0)) ||
-	   ((server_sign == TRUE) && ((statusModeChage[gun_index] == TRUE) || ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > (server_cycle_Status + (GunStatusInterval*gun_index))) || ((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 30))))) )
+	   ((server_sign == TRUE) && ((statusModeChage[gun_index] == TRUE) || ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > (server_cycle_Status + (GunStatusInterval*gun_index))) || ((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 30)))) )
 	{
 		if(SystemInitial > 0)
-			SystemInitial = SystemInitial -1;
+			SystemInitial -= 1;
 
 		sendStatusNotificationRequest(gun_index);
 		clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
@@ -3642,7 +3633,7 @@ int sendStopTransactionRequest(int gun_index)
 	//=================================
 	//============================================ Energy.Active.Import.Interval ================================
     //idx_sample=0;
-	sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.1f", 0); // MeterStart is 0~6553.5 kWh
+	sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.1f", 0.0); // MeterStart is 0~6553.5 kWh
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context,ReadingContextStr[ReadingContext_Transaction_Begin]);
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format,ValueFormatStr[Raw]);
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand,MeasurandStr[Energy_Active_Import_Interval]);//MeasurandStr[Energy_Active_Export_Interval/*Energy_Reactive_Export_Register*/]);
@@ -15433,7 +15424,7 @@ void storeTempStopTransaction(int gun_index)
 	//=================================
 	//============================== Energy.Active.Import.Interval ===========================================
     //idx_sample=0;
-	sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.1f", 0); // MeterStart is 0~6553.5 kWh
+	sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.1f", 0.0); // MeterStart is 0~6553.5 kWh
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context,ReadingContextStr[ReadingContext_Transaction_Begin]);
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format,ValueFormatStr[Raw]);
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand,MeasurandStr[Energy_Active_Import_Interval]);//MeasurandStr[Energy_Active_Export_Interval/*Energy_Reactive_Export_Register*/]);
@@ -16353,16 +16344,16 @@ void InitialSystemValue(void)
 	DiagnosticsStatusNotificationStatus = DIAGNOSTIC_STATUS_IDLE; // Idle
 
 	memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
-	memset(statusModeChage, 0, sizeof(statusModeChage));
-	memset(ChademoPreviousSystemStatus, 0, sizeof(ChademoPreviousSystemStatus));
-	memset(CcsPreviousSystemStatus, 0, sizeof(CcsPreviousSystemStatus));
-	memset(GbPreviousSystemStatus, 0, sizeof(GbPreviousSystemStatus));
-	memset(AcPreviousSystemStatus, 0, sizeof(AcPreviousSystemStatus));
-	memset(ChademoPreviousConnectorPlugIn, 0, sizeof(ChademoPreviousConnectorPlugIn));
-	memset(CcsPreviousConnectorPlugIn, 0, sizeof(CcsPreviousConnectorPlugIn));
-	memset(GbPreviousConnectorPlugIn, 0, sizeof(GbPreviousConnectorPlugIn));
-	memset(AcPreviousConnectorPlugIn, 0, sizeof(AcPreviousConnectorPlugIn));
-	memset(gunType, 0, sizeof(gunType));
+	memset(statusModeChage, 0, ARRAY_SIZE(statusModeChage));
+	memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
+	memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
+	memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
+	memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
+	memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
+	memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
+	memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
+	memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
+	memset(gunType, 0, ARRAY_SIZE(gunType));
 
  	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
 	{
@@ -16445,9 +16436,6 @@ void InitialSystemValue(void)
 		clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
 	}
 
-	// Charger PRE_SYS_MODE
-	memset(PRE_SYS_MODE, 0, sizeof(PRE_SYS_MODE));
-
 	memset( (void *)unknownkey, 0, sizeof(unknownkey));
 
 	clientTime.Heartbeat=time((time_t*)NULL);