Эх сурвалжийг харах

2022-02-09/Jerry Wang
Action:
1. Modify messageId [ID_DisplayLCDPage] to [ID_LineStatusPage] and add new item 'SerialNo'.
2. Add new messageId [ID_GetTxUserInfo].

File:
1. EVSE/Modularization/ocppfiles/MessageHandler.c
--> Action 1,2
2. EVSE/Modularization/ocppph/MessageHandler.c
--> Action 1,2
3. define.h
--> Action 1,2

Jerry Wang 3 жил өмнө
parent
commit
8bad4bd072

+ 55 - 2
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -10744,7 +10744,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
 			json_object_put(response);
 		}
-		else if(strstr(tempmessageId, "ID_DisplayLcdPage") != NULL)
+		else if(strstr(tempmessageId, "ID_LineStatusPage") != NULL)
 		{
 			json_object *data;
 			data = json_tokener_parse(tempdata);
@@ -10754,7 +10754,12 @@ int handleDataTransferRequest(char *uuid, char *payload)
 
 				if(json_object_object_get(data, "ConnectorId") != NULL)
 				{
-                                        ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
+					ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
+				}
+
+				if(json_object_object_get(data, "SerialNo") != NULL)
+				{
+					sprintf((char *)ShmOCPP16Data->TcciCustomData.LineStatusPage.SerialNo[(ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId-1)], "%s", json_object_get_string(json_object_object_get(data,"SerialNo")));
 				}
 
 				if(json_object_object_get(data, "Page_Index") != NULL)
@@ -11025,6 +11030,54 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
 			json_object_put(response);
 		}
+		else if(strstr(tempmessageId, "ID_GetTxUserInfo") != NULL)
+		{
+			json_object *data;
+			data = json_tokener_parse(tempdata);
+			if(!is_error(data))
+			{
+				if((json_object_object_get(data, "ConnectorId") != NULL) && (json_object_object_get(data, "txId") != NULL))
+				{
+					int gun_index = json_object_get_int(json_object_object_get(data, "ConnectorId"))-1;
+					json_object_object_add(response, "status", json_object_new_string("Accepted"));
+					if(gun_index < gunTotalNumber)
+					{
+						if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == json_object_get_int(json_object_object_get(data, "txId")))
+						{
+							json_object *responsedata = json_object_new_object();
+							json_object_object_add(responsedata, "txId", json_object_new_int(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId));
+							json_object_object_add(responsedata, "ConnectorId", json_object_new_int(gun_index+1));
+							json_object_object_add(responsedata, "SerialNo", json_object_new_string((char*)ShmOCPP16Data->TcciCustomData.LineStatusPage.SerialNo[gun_index]));
+							json_object_object_add(responsedata, "StartTime", json_object_new_string((char*)ShmOCPP16Data->StartTransaction[gun_index].Timestamp));
+							json_object_object_add(response, "data", json_object_new_string(json_object_to_json_string_ext(responsedata, JSON_C_TO_STRING_PLAIN)));
+						}
+						else
+						{
+							json_object_object_add(response, "status", json_object_new_string("Rejected"));
+							json_object_object_add(response, "data", json_object_new_string("txId doesn't match the current transactionId."));
+						}
+					}
+					else
+					{
+						json_object_object_add(response, "status", json_object_new_string("Rejected"));
+						json_object_object_add(response, "data", json_object_new_string("ConnectorId is invalid."));
+					}
+				}
+				else
+				{
+					json_object_object_add(response, "status", json_object_new_string("Rejected"));
+					json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
+				}
+			}
+			else
+			{
+				json_object_object_add(response, "status", json_object_new_string("Rejected"));
+				json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
+			}
+
+			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
+			json_object_put(response);
+		}
 		else
 		{
 			// Can not find valid message id

+ 55 - 2
EVSE/Modularization/ocppph/MessageHandler.c

@@ -10282,7 +10282,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 			sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
 			json_object_put(response);
 		}
-		else if(strstr(tempmessageId, "ID_DisplayLcdPage") != NULL)
+		else if(strstr(tempmessageId, "ID_LineStatusPage") != NULL)
 		{
 			json_object *data;
 			data = json_tokener_parse(tempdata);
@@ -10292,7 +10292,12 @@ int handleDataTransferRequest(char *uuid, char *payload)
 
 				if(json_object_object_get(data, "ConnectorId") != NULL)
 				{
-                                        ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
+                    ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
+				}
+
+				if(json_object_object_get(data, "SerialNo") != NULL)
+				{
+					sprintf((char *)ShmOCPP16DataPH->TcciCustomData.LineStatusPage.SerialNo[(ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId-1)], "%s", json_object_get_string(json_object_object_get(data,"SerialNo")));
 				}
 
 				if(json_object_object_get(data, "Page_Index") != NULL)
@@ -10519,6 +10524,54 @@ int handleDataTransferRequest(char *uuid, char *payload)
 				sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
 				json_object_put(response);
 			}
+			else if(strstr(tempmessageId, "ID_GetTxUserInfo") != NULL)
+			{
+				json_object *data;
+				data = json_tokener_parse(tempdata);
+				if(!is_error(data))
+				{
+					if((json_object_object_get(data, "ConnectorId") != NULL) && (json_object_object_get(data, "txId") != NULL))
+					{
+						int gun_index = json_object_get_int(json_object_object_get(data, "ConnectorId"))-1;
+						json_object_object_add(response, "status", json_object_new_string("Accepted"));
+						if(gun_index < gunTotalNumber)
+						{
+							if(ShmOCPP16DataPH->StartTransaction[gun_index].ResponseTransactionId == json_object_get_int(json_object_object_get(data, "txId")))
+							{
+								json_object *responsedata = json_object_new_object();
+								json_object_object_add(responsedata, "txId", json_object_new_int(ShmOCPP16DataPH->StartTransaction[gun_index].ResponseTransactionId));
+								json_object_object_add(responsedata, "ConnectorId", json_object_new_int(gun_index+1));
+								json_object_object_add(responsedata, "SerialNo", json_object_new_string((char*)ShmOCPP16DataPH->TcciCustomData.LineStatusPage.SerialNo[gun_index]));
+								json_object_object_add(responsedata, "StartTime", json_object_new_string((char*)ShmOCPP16DataPH->StartTransaction[gun_index].Timestamp));
+								json_object_object_add(response, "data", json_object_new_string(json_object_to_json_string_ext(responsedata, JSON_C_TO_STRING_PLAIN)));
+							}
+							else
+							{
+								json_object_object_add(response, "status", json_object_new_string("Rejected"));
+								json_object_object_add(response, "data", json_object_new_string("txId doesn't match the current transactionId."));
+							}
+						}
+						else
+						{
+							json_object_object_add(response, "status", json_object_new_string("Rejected"));
+							json_object_object_add(response, "data", json_object_new_string("ConnectorId is invalid."));
+						}
+					}
+					else
+					{
+						json_object_object_add(response, "status", json_object_new_string("Rejected"));
+						json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
+					}
+				}
+				else
+				{
+					json_object_object_add(response, "status", json_object_new_string("Rejected"));
+					json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
+				}
+
+				sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
+				json_object_put(response);
+			}
 			else
 			{
 				json_object_object_add(response, "status", json_object_new_string("Rejected"));

+ 6 - 0
EVSE/Projects/define.h

@@ -4589,6 +4589,11 @@ struct StructWeatherInfo
     float temperature;
 };
 
+struct StructLineStatusPage
+{
+	unsigned char SerialNo[CONNECTOR_QUANTITY][37];
+};
+
 struct StructCreditDeductResult
 {
     int txId;
@@ -4608,6 +4613,7 @@ struct StructTcciCustomData
     struct StructChargerInfo ChargerInfo;
     struct StructWeatherInfo WeatherInfo;
     struct StructCreditDeductResult DeductInfo;
+	struct StructLineStatusPage LineStatusPage;
     unsigned char TriggerReaderReq[3];
 
     unsigned char ReportCreditDeductReq:1;