Browse Source

2020-054-21 / Kathy Yeh
1. modify offline TempStopTransaction logic
2. modify SetTransactionIdZero logic

Kathy_Yeh 4 years ago
parent
commit
b258308329
1 changed files with 28 additions and 3 deletions
  1. 28 3
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 28 - 3
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -178,6 +178,7 @@ static int GbPreviousConnectorPlugIn[GB_QUANTITY];
 static int AcPreviousConnectorPlugIn[AC_QUANTITY];
 static int TransactionMessageAttemptsValue = 0;
 static int TransactionMessageRetryIntervalValue = 0;
+static int TempMeterValueInterval = 0;
 static struct OCPPAuthLocalElemet
 {
 	int listVersionInt;
@@ -1051,7 +1052,10 @@ int InitShareMemory()
 	ShmOCPP16Data->GetConfiguration.ResponseUnknownKey = staticResponseUnknownKey;
 	ShmOCPP16Data->SendLocalList.LocalAuthorizationList = staticLocalAuthorizationList;
 
-    return result;
+	//offline MeterValue Interval
+	TempMeterValueInterval = 0;
+
+	return result;
 }
 
 
@@ -1126,6 +1130,27 @@ char * stringtrimspace( char * s )
 	return (s);
 }
 
+int isOFFline(void)
+{
+	if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
+	{
+		if(TempMeterValueInterval >=  (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 )  )
+		{
+			TempMeterValueInterval = 0;
+			return TRUE;
+		}
+		else
+		{
+			TempMeterValueInterval = TempMeterValueInterval+ 1;
+			return FALSE;
+		}
+	}
+	else
+	{
+		return FALSE;
+	}
+}
+
 //---------------------------------------------
 //  new:
 //  enum SYSTEM_STATUS
@@ -1395,7 +1420,7 @@ void CheckSystemValue(void)
 	//==============================================
 	// Meter report
 	//==============================================
-	if(/*(server_sign == TRUE) &&*/  ((time((time_t*)NULL) - clientTime.MeterValues[gun_index])> (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 ) ) )
+	if(/*(server_sign == TRUE) &&*/(isOFFline() == TRUE) || ((time((time_t*)NULL) - clientTime.MeterValues[gun_index])> (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 ) ) )
 	{
 		//check Transaction active
 		if(gunType[gun_index] == 'J')
@@ -15995,7 +16020,7 @@ void SetTransactionIdZero(int transactionId)
     			temptransactionId = atoi(revbuf[2]);
     			if(transactionId != temptransactionId)
     			{
-    			   fprintf(fptr2, "%s", strtemp);
+    			   fprintf(fptr2, "%s\n", strtemp);
     			}
 
     		}