Przeglądaj źródła

2022-02-15/Jerry Wang
Action:
1. Cancel LineStatusPage structure.
2. Add new messageId [ID_ReaderStatus].

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 lat temu
rodzic
commit
6632ceb265

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

@@ -1378,6 +1378,36 @@ void OCPP_query_deduct_info()
     }
 }
 
+void reportReaderStatus(int gun_index)
+{
+	struct timeval tmnow;
+	struct tm *tm;
+	char buf[28];//, usec_buf[6];
+	gettimeofday(&tmnow, NULL);
+
+	time_t t;
+	t = time(NULL);
+	/*UTC time and date*/
+	tm = gmtime(&t);
+	strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
+	#if 0 // remove temporally
+		strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
+		strcat(buf,".");
+		sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
+		strcat(buf,usec_buf);
+	#endif
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId,"%s","ID_ReaderStatus");
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, "{\\\"connectorId\\\":%d,\\\"readerStatus\\\":%d,\\\"timestamp\\\":\\\"%s\\\",\\\"SerialNo\\\":\\\"%s\\\",\\\"creditNo\\\":\\\"%s\\\"}",
+			(gun_index+1),
+			ShmOCPP16Data->TcciCustomData.ReaderStatus[gun_index].readerStatus,
+			buf,
+			ShmOCPP16Data->TcciCustomData.SerialNo[gun_index],
+			ShmOCPP16Data->TcciCustomData.ReaderStatus[gun_index].creditNo);
+
+	ShmOCPP16Data->CsMsg.bits[0].DataTransferReq = 1;
+}
+
 //==========================================
 // Check time passed since today
 //==========================================
@@ -5016,6 +5046,15 @@ void CheckSystemValue(void)
 			refreshStartTimer(&clientTime.StatusNotification[gun_index]);
 		}
 
+		//==============================================
+		// TCCI reader status report
+		//==============================================
+		if(ShmOCPP16Data->TcciCustomData.ReaderStatus[gun_index].ReportReaderStatusReq == 1)
+		{
+			reportReaderStatus(gun_index);
+			ShmOCPP16Data->TcciCustomData.ReaderStatus[gun_index].ReportReaderStatusReq = 0;
+		}
+
 		//==============================================
 		// CSU Trigger Smart Charging Profile
 	    //==============================================
@@ -10765,7 +10804,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 
 				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")));
+					sprintf((char *)ShmOCPP16Data->TcciCustomData.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)
@@ -11053,7 +11092,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 							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, "SerialNo", json_object_new_string((char*)ShmOCPP16Data->TcciCustomData.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)));
 						}

+ 42 - 3
EVSE/Modularization/ocppph/MessageHandler.c

@@ -885,6 +885,36 @@ void OCPP_query_deduct_info()
     }
 }
 
+void reportReaderStatus(int gun_index)
+{
+	struct timeval tmnow;
+	struct tm *tm;
+	char buf[28];//, usec_buf[6];
+	gettimeofday(&tmnow, NULL);
+
+	time_t t;
+	t = time(NULL);
+	/*UTC time and date*/
+	tm = gmtime(&t);
+	strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
+	#if 0 // remove temporally
+		strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
+		strcat(buf,".");
+		sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
+		strcat(buf,usec_buf);
+	#endif
+	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].MessageId,"%s","ID_ReaderStatus");
+	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].Data, "{\\\"connectorId\\\":%d,\\\"readerStatus\\\":%d,\\\"timestamp\\\":\\\"%s\\\",\\\"SerialNo\\\":\\\"%s\\\",\\\"creditNo\\\":\\\"%s\\\"}",
+			(gun_index+1),
+			ShmOCPP16DataPH->TcciCustomData.ReaderStatus[gun_index].readerStatus,
+			buf,
+			ShmOCPP16DataPH->TcciCustomData.SerialNo[gun_index],
+			ShmOCPP16DataPH->TcciCustomData.ReaderStatus[gun_index].creditNo);
+
+	ShmOCPP16DataPH->CsMsg.bits[0].DataTransferReq = 1;
+}
+
 //==========================================
 // Check time passed since today
 //==========================================
@@ -4538,7 +4568,16 @@ void CheckSystemValue(void)
 		}
 
 		//==============================================
-		// CSU Trigger Smart Charging Profilw
+		// TCCI reader status report
+		//==============================================
+		if(ShmOCPP16DataPH->TcciCustomData.ReaderStatus[gun_index].ReportReaderStatusReq == 1)
+		{
+			reportReaderStatus(gun_index);
+			ShmOCPP16DataPH->TcciCustomData.ReaderStatus[gun_index].ReportReaderStatusReq = 0;
+		}
+
+		//==============================================
+		// CSU Trigger Smart Charging Profile
 	    //==============================================
 	    if(ShmOCPP16DataPH->CSUMsg.bits[gun_index].ChargingProfileReq == 1)
 	    {
@@ -10303,7 +10342,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 
 				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")));
+					sprintf((char *)ShmOCPP16DataPH->TcciCustomData.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)
@@ -10547,7 +10586,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
 								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, "SerialNo", json_object_new_string((char*)ShmOCPP16DataPH->TcciCustomData.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)));
 							}

+ 9 - 6
EVSE/Projects/define.h

@@ -4583,11 +4583,6 @@ struct StructWeatherInfo
     float temperature;
 };
 
-struct StructLineStatusPage
-{
-    unsigned char SerialNo[CONNECTOR_QUANTITY][37];
-};
-
 struct StructCreditDeductResult
 {
     int txId;
@@ -4602,13 +4597,21 @@ struct StructCreditDeductResult
     unsigned char isDonateInvoice:1;
 };
 
+struct StructReaderStatus
+{
+	int readerStatus;
+	unsigned char creditNo[64];
+    unsigned char ReportReaderStatusReq:1;
+};
+
 struct StructTcciCustomData
 {
     struct StructChargerInfo ChargerInfo;
     struct StructWeatherInfo WeatherInfo;
     struct StructCreditDeductResult DeductInfo;
-    struct StructLineStatusPage LineStatusPage;
+    struct StructReaderStatus ReaderStatus[CONNECTOR_QUANTITY];
     unsigned char TriggerReaderReq[3];
+    unsigned char SerialNo[CONNECTOR_QUANTITY][37];
 
     unsigned char ReportCreditDeductReq:1;
     unsigned char ChargerInfoReq:1;