|
@@ -33,11 +33,12 @@
|
|
|
#include "MessageHandler.h"
|
|
|
#include "sqlite3.h"
|
|
|
|
|
|
+
|
|
|
+
|
|
|
#ifndef SPEC_LATEST_SUPPORTED
|
|
|
#define SPEC_LATEST_SUPPORTED 13
|
|
|
#endif
|
|
|
|
|
|
-
|
|
|
#define Debug
|
|
|
//#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
|
|
|
#define PASS 1
|
|
@@ -52,7 +53,6 @@ pthread_t pid;
|
|
|
extern int server_sign;
|
|
|
|
|
|
extern void CheckSystemValue(void);
|
|
|
-//extern int TransactionMessageAttemptsGet(void);
|
|
|
extern int FirstHeartBeatResponse(void);
|
|
|
extern void OCPP_get_TableAuthlocalAllData(void);
|
|
|
extern int TransactionMessageAttemptsGet(void);
|
|
@@ -101,6 +101,9 @@ static int TransactionQueueInterval = 10;//3;
|
|
|
static int TransactionQueueNum = 0;
|
|
|
static int OfflineTransactionQueueNum = 0; // Number of offline transactions
|
|
|
static int OfflineTransaction = 0;
|
|
|
+static int IsUsing = FALSE;
|
|
|
+static int IsFinished = FALSE;
|
|
|
+
|
|
|
int defaultWaitingTime = 10; //10 second
|
|
|
char OcppPath[160]={0};
|
|
|
char OcppProtocol[10]={0},OcppHost[50]={0}, OcppTempPath[50]={0};
|
|
@@ -865,24 +868,6 @@ if(fp == NULL) {
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
-#if 0
|
|
|
-if(fgetc(fp)==EOF)
|
|
|
-{
|
|
|
- //DEBUG_INFO("It is end of file");
|
|
|
- fclose(fp);
|
|
|
- memset(rmFileCmd, 0, sizeof rmFileCmd);
|
|
|
- if((access("/Storage/OCPP/TransactionRelatedQueue",F_OK))!=-1)
|
|
|
- {
|
|
|
- sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP/TransactionRelatedQueue");
|
|
|
- system(rmFileCmd);
|
|
|
- }
|
|
|
-
|
|
|
- result = FALSE;
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
if( fgets (str, 1200, fp)!=NULL ) {
|
|
|
/* writing content to stdout */
|
|
|
//DEBUG_INFO("str=%s",str);
|
|
@@ -1525,25 +1510,47 @@ void CheckTransactionPacket(char *uuid)
|
|
|
|
|
|
}
|
|
|
|
|
|
-/* type: 0 (showqueue ); type: 1(showfront); type: 2(delq) type: 3 (sentqueue) type: 4 (addq) type: 5(store queue to /Storage/OCPP/ )*/
|
|
|
+//---- type: 0 (showqueue ); type: 1(showfront); type: 2(delq) type: 3 (sentqueue) type: 4 (addq) type: 5(store queue to /Storage/OCPP/ ) ---//
|
|
|
int queue_operation(int type, char *frontUUID, char *frontData)
|
|
|
{
|
|
|
-
|
|
|
- pthread_mutex_unlock(&lock_sentData);
|
|
|
- pthread_mutex_lock(&lock_sentData);
|
|
|
int result=0;
|
|
|
- if(type == 0) // show items in queue
|
|
|
- result = showqueue();
|
|
|
- else if(type == 1) // show first item
|
|
|
- result = showfront(frontUUID, frontData);
|
|
|
- else if(type == 2) // delete item
|
|
|
- result = delq();
|
|
|
- else if(type == 3) // sent items in queue
|
|
|
- result = sentqueue();
|
|
|
- else if(type == 4) // add items to the queue
|
|
|
- result = addq(frontUUID, frontData);
|
|
|
-
|
|
|
- pthread_mutex_unlock(&lock_sentData);
|
|
|
+ while(1)
|
|
|
+ {
|
|
|
+ if (!IsUsing )
|
|
|
+ {
|
|
|
+ IsUsing = TRUE;
|
|
|
+ //pthread_mutex_unlock(&lock_sentData);
|
|
|
+ //pthread_mutex_lock(&lock_sentData);
|
|
|
+
|
|
|
+ if(type == 0) // show items in queue
|
|
|
+ {
|
|
|
+ result = showqueue();
|
|
|
+ }
|
|
|
+ else if(type == 1) // show first item
|
|
|
+ {
|
|
|
+ result = showfront(frontUUID, frontData);
|
|
|
+ }
|
|
|
+ else if(type == 2) // delete item
|
|
|
+ {
|
|
|
+ result = delq();
|
|
|
+ }
|
|
|
+ else if(type == 3) // sent items in queue
|
|
|
+ {
|
|
|
+ result = sentqueue();
|
|
|
+ }
|
|
|
+ else if(type == 4) // add items to the queue
|
|
|
+ {
|
|
|
+ result = addq(frontUUID, frontData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //pthread_mutex_unlock(&lock_sentData);
|
|
|
+
|
|
|
+ //IsFinished = TRUE;
|
|
|
+ IsUsing = FALSE;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //IsFinished = FALSE;
|
|
|
|
|
|
return result;
|
|
|
}
|