瀏覽代碼

2020.07.01 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/Module_OcppBackend.c if queue file size over 500MB only insert start/stop transaction to queue.

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 年之前
父節點
當前提交
b32535b700

+ 30 - 1
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -460,6 +460,30 @@ end:
 	pthread_exit(NULL/*(void *) fname*/);
 }
 
+int isQueueOverSize()
+{
+	FILE *fp;
+	uint32_t file_size;
+	uint8_t result = FALSE;
+
+	fp = fopen("/Storage/OCPP/TransactionRelatedQueue" , "r");
+	if(fp != NULL)
+	{
+		fseek(fp, 0L, SEEK_END);
+		file_size = ftell(fp);
+
+		if(file_size > (500*1024*1024))
+		{
+			result = TRUE;
+
+			DEBUG_WARN("Queue file over size.\n");
+		}
+		fclose(fp);
+	}
+
+	return result;
+}
+
 int showfront(char *uuid, char *data)
 {
 	FILE *fp;
@@ -1210,6 +1234,7 @@ void CheckTransactionPacket(char *uuid)
 int queue_operation(int type, char *frontUUID, char *frontData)
 {
 	int result=0;
+
 	while(1)
 	{
 		if (!IsUsing )
@@ -1234,7 +1259,11 @@ int queue_operation(int type, char *frontUUID, char *frontData)
 			}
 			else if(type == QUEUE_OPERATION_ADD)         		// add items to the queue
 			{
-				result = addq(frontUUID, frontData);
+				// If queue file over size only add start * stop transaction message
+				if(!isQueueOverSize() || (strstr(frontData, "MeterValues") == NULL))
+				{
+					result = addq(frontUUID, frontData);
+				}
 			}
 
 			IsUsing = FALSE;

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

@@ -89,6 +89,7 @@ extern int InitShareMemory();
 extern int ProcessShareMemory();
 extern void CheckSystemValue(void);
 
+extern int isQueueOverSize();
 extern int showfront(char *uuid, char *data);
 extern int addq(char *uuid, char *data) ;
 extern int delq();