Browse Source

2020-06-05 / Kathy Yeh
1. modify TempStopTransaction error
2. modify delete QueueTransactionId logic
3. remove the logic of MeterValue

Kathy_Yeh 4 years ago
parent
commit
d8a91aa67f

+ 9 - 7
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -4575,6 +4575,7 @@ int sendMeterValuesRequest(int gun_index)
 	DEBUG_INFO("sendMeterValuesRequest ...\n");
 	//DEBUG_ERROR("gun_index =%d\n",gun_index);
 
+	/*
 	if((ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == 0)&&(ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq == 0)) // no TransactionId
 	{
 		DEBUG_INFO("NOT SENT METER Vlaue\n");
@@ -4583,6 +4584,7 @@ int sendMeterValuesRequest(int gun_index)
 
 		return result;
 	}
+	*/
 
 	if(ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq == 1)
 	{
@@ -15024,7 +15026,7 @@ void SetHeartBeatWithNOResponse(void)
 void GetStartTransactionIdTag(int gun_index)
 {
 	memset(StartTransactionIdTagTemp, 0 ,sizeof(StartTransactionIdTagTemp));
-	strcpy(StartTransactionIdTagTemp, (const char *)ShmOCPP16Data->StartTransaction[gun_index].IdTag);
+	strcpy((char *)StartTransactionIdTagTemp, (const char *)ShmOCPP16Data->StartTransaction[gun_index].IdTag);
 	DEBUG_INFO("gun_index=%d StartTransactionIdTagTemp=%s\n",gun_index,StartTransactionIdTagTemp);
 }
 
@@ -15734,7 +15736,7 @@ void storeTempStopTransaction(int gun_index)
 	{
 		sprintf(queuedata,"%d,[%d,\"%s\",\"StopTransaction\",{\"idTag\":\"%s\",\"meterStop\":%d,\"timestamp\":\"%s\",\"transactionId\":%d,\"reason\":\"%s\",\"transactionData\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
 
-							,gun_index
+							,gun_index + 1
 							,MESSAGE_TYPE_CALL
 							,guid
 							,ShmOCPP16Data->StopTransaction[gun_index].IdTag
@@ -15791,7 +15793,7 @@ void storeTempStopTransaction(int gun_index)
 	{
 		sprintf(queuedata,"%d,[%d,\"%s\",\"StopTransaction\",{\"idTag\":\"%s\",\"meterStop\":%d,\"timestamp\":\"%s\",\"transactionId\":%d,\"reason\":\"%s\",\"transactionData\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
 
-							,gun_index
+							,gun_index + 1
 							,MESSAGE_TYPE_CALL
 							,guid
 							,ShmOCPP16Data->StopTransaction[gun_index].IdTag
@@ -15908,20 +15910,20 @@ void checkTempStopTransaction(int gun_index)
 
 			//TempStopTransaction格式: 槍號,StopTransaction封包
 			strncpy(connectorStr, str, 1);
-			if(atoi(connectorStr) != gun_index)
+			if(atoi(connectorStr) != (gun_index+1))
 			{
 				DEBUG_INFO("atoi(connectorStr)=%d\n",atoi(connectorStr));
 				return ;
 			}
 
 	    //random_uuid(guid);
-			strncpy(guid, str+4, 36); //copy guid
+			strncpy(guid, str+6, 36); //copy guid
 	    sprintf(tempdata, "StopTransaction,%d", (gun_index));
 	    if(hashmap_operation(0, guid, tempdata) == 1)
 	    {
 	    	DEBUG_INFO("StopTransaction mapitem pass\n");
 	    }
-	    queue_operation(4, guid, str+2 );//addq(guid, queuedata); ---> remove temporally
+	    queue_operation(4, guid, str);//addq(guid, queuedata); ---> remove temporally
 
 	    memset(str,0,sizeof str);
 		}
@@ -16118,4 +16120,4 @@ void LWS_Send(char * str)
 
 	lws_callback_on_writable(wsi_client);
 	lws_service(context, 100);//timeout_ms
-}
+}

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

@@ -36,7 +36,7 @@ int defaultWaitingTime = 10; //10 second
 char OcppPath[160]={0};
 char OcppProtocol[10]={0},OcppHost[50]={0}, OcppTempPath[50]={0};
 int OcppPort=0;
-char StartTransactionIdTagTemp[20]={0};
+unsigned char StartTransactionIdTagTemp[20]={0};
 
 sqlite3 *db;
 char *errMsg = NULL;
@@ -462,7 +462,6 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			break;
 	}
 
-
 	return 0;
 }
 
@@ -1159,9 +1158,10 @@ if( fgets (str, 1200, fp)!=NULL ) {
 		else
 		{
 			LWS_Send(str+2);  // skip 2 bytes字串->  槍號,
+			gettransactionId=temptransactionId;
 		}
 
-		if((IsStopTransaction == TRUE)&&(gettransactionId != 0))
+		if(IsStopTransaction == TRUE)//if((IsStopTransaction == TRUE)&&(gettransactionId != 0))
 		{
 			SetTransactionIdZero(gettransactionId);
 		}

+ 2 - 2
EVSE/Modularization/ocppfiles/Module_OcppBackend.h

@@ -1,7 +1,7 @@
 /*
  * Sample_OCPP_Task.h
  *
- *  Created on: 2020¦~5¤ë26¤é
+ *  Created on: 2020�~5��26��
  *      Author: foluswen
  */
 
@@ -111,5 +111,5 @@ extern char 						OcppProtocol[10];
 extern char 						OcppHost[50];
 extern char 						OcppTempPath[50];
 extern int 							OcppPort;
-extern char 						StartTransactionIdTagTemp[20];
+extern unsigned char 		StartTransactionIdTagTemp[20];
 #endif /* HEADER_MODULE_OCPPBACKEND_H_ */