Переглянути джерело

[Add][Modularization][Modudle_OcppBackend / Module_OcppBackendPH]

2022.02.05 / Folus Wen

Actions:
1. TCCI deduct info add amount and vemData column to local db.
2. TCCI data transfer with ID_CreditDeductResult add amount info.

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 3 роки тому
батько
коміт
9fb72cbe8a

+ 6 - 5
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -1301,13 +1301,13 @@ int OCPP_getPeriodEnergyToDataTransfer(int32_t transactionId)
 	return isSuccess;
 }
 
-int OCPP_insert_deduct_info(int txId, char *creditNo, uint8_t deductResult, uint8_t isDonateInvoice)
+int OCPP_insert_deduct_info(int txId, char *creditNo, uint8_t deductResult, uint8_t isDonateInvoice, double amount, char *vemData)
 {
 	int result = PASS;
 	char* errMsg = NULL;
 	char sqlStr[8192];
 
-	sprintf(sqlStr, "insert into report_deduct_info(txId, creditNo, deductResult, isDonateInvoice, isUploaded) values('%d', '%s', '%d', '%d', '0');", txId, creditNo, deductResult, isDonateInvoice);
+	sprintf(sqlStr, "insert into report_deduct_info(txId, creditNo, deductResult, isDonateInvoice, amount, vemData, isUploaded) values('%d', '%s', '%d', '%d', '%.2f', '%s', '0');", txId, creditNo, deductResult, isDonateInvoice, amount, vemData);
 
 	if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
 	{
@@ -1346,11 +1346,12 @@ int queryDeductCallBack(void *data, int columenCount, char **columnValue, char *
 {
 	sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 	sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId,"%s","ID_CreditDeductResult");
-	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, "{\\\"txId\\\":%d,\\\"creditNo\\\":\\\"%s\\\",\\\"deductResult\\\":%s,\\\"isDonateInvoice\\\":%s}",
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, "{\\\"txId\\\":%d,\\\"creditNo\\\":\\\"%s\\\",\\\"deductResult\\\":%s,\\\"isDonateInvoice\\\":%s,\\\"amount\\\":%s}",
 			atoi(columnValue[1]),
 			columnValue[2],
 			atoi(columnValue[3])==1?"true":"false",
-			atoi(columnValue[4])==1?"true":"false");
+			atoi(columnValue[4])==1?"true":"false",
+			columnValue[5]);
 
 	ShmOCPP16Data->CsMsg.bits[0].DataTransferReq = 1;
 
@@ -4505,7 +4506,7 @@ void CheckSystemValue(void)
 	//===============================
 	if(ShmOCPP16Data->TcciCustomData.ReportCreditDeductReq)
 	{
-		OCPP_insert_deduct_info(ShmOCPP16Data->TcciCustomData.DeductInfo.txId, (char*)ShmOCPP16Data->TcciCustomData.DeductInfo.creditNo, ShmOCPP16Data->TcciCustomData.DeductInfo.deductResult, ShmOCPP16Data->TcciCustomData.DeductInfo.isDonateInvoice);
+		OCPP_insert_deduct_info(ShmOCPP16Data->TcciCustomData.DeductInfo.txId, (char*)ShmOCPP16Data->TcciCustomData.DeductInfo.creditNo, ShmOCPP16Data->TcciCustomData.DeductInfo.deductResult, ShmOCPP16Data->TcciCustomData.DeductInfo.isDonateInvoice, ShmOCPP16Data->TcciCustomData.DeductInfo.amount, (char*)ShmOCPP16Data->TcciCustomData.DeductInfo.vemData);
 
 		ShmOCPP16Data->TcciCustomData.ReportCreditDeductReq = FALSE;
 	}

+ 2 - 0
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -104,6 +104,8 @@ static char *sqlReportDeduct = "create table if not exists report_deduct_info (
 							   "creditNo text,"
 							   "deductResult text,"
 							   "isDonateInvoice text,"
+							   "amount text,"
+							   "vemData text,"
 							   "isUploaded text);";
 
 //=================================

+ 6 - 5
EVSE/Modularization/ocppph/MessageHandler.c

@@ -808,13 +808,13 @@ int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg
 	return result;
 }
 
-int OCPP_insert_deduct_info(int txId, char *creditNo, uint8_t deductResult, uint8_t isDonateInvoice)
+int OCPP_insert_deduct_info(int txId, char *creditNo, uint8_t deductResult, uint8_t isDonateInvoice, double amount, char *vemData)
 {
 	int result = PASS;
 	char* errMsg = NULL;
 	char sqlStr[8192];
 
-	sprintf(sqlStr, "insert into report_deduct_info(txId, creditNo, deductResult, isDonateInvoice, isUploaded) values('%d', '%s', '%d', '%d', '0');", txId, creditNo, deductResult, isDonateInvoice);
+	sprintf(sqlStr, "insert into report_deduct_info(txId, creditNo, deductResult, isDonateInvoice, amount, vemData, isUploaded) values('%d', '%s', '%d', '%d', '%.2f', '%s', '0');", txId, creditNo, deductResult, isDonateInvoice, amount, vemData);
 
 	if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
 	{
@@ -853,11 +853,12 @@ int queryDeductCallBack(void *data, int columenCount, char **columnValue, char *
 {
 	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].MessageId,"%s","ID_CreditDeductResult");
-	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].Data, "{\\\"txId\\\":%d,\\\"creditNo\\\":\\\"%s\\\",\\\"deductResult\\\":%s,\\\"isDonateInvoice\\\":%s}",
+	sprintf((char*)ShmOCPP16DataPH->DataTransfer[0].Data, "{\\\"txId\\\":%d,\\\"creditNo\\\":\\\"%s\\\",\\\"deductResult\\\":%s,\\\"isDonateInvoice\\\":%s,\\\"amount\\\":%s}",
 			atoi(columnValue[1]),
 			columnValue[2],
 			atoi(columnValue[3])==1?"true":"false",
-			atoi(columnValue[4])==1?"true":"false");
+			atoi(columnValue[4])==1?"true":"false",
+			columnValue[5]);
 
 	ShmOCPP16DataPH->CsMsg.bits[0].DataTransferReq = 1;
 
@@ -4025,7 +4026,7 @@ void CheckSystemValue(void)
 	//===============================
 	if(ShmOCPP16DataPH->TcciCustomData.ReportCreditDeductReq)
 	{
-		OCPP_insert_deduct_info(ShmOCPP16DataPH->TcciCustomData.DeductInfo.txId, (char*)ShmOCPP16DataPH->TcciCustomData.DeductInfo.creditNo, ShmOCPP16DataPH->TcciCustomData.DeductInfo.deductResult, ShmOCPP16DataPH->TcciCustomData.DeductInfo.isDonateInvoice);
+		OCPP_insert_deduct_info(ShmOCPP16DataPH->TcciCustomData.DeductInfo.txId, (char*)ShmOCPP16DataPH->TcciCustomData.DeductInfo.creditNo, ShmOCPP16DataPH->TcciCustomData.DeductInfo.deductResult, ShmOCPP16DataPH->TcciCustomData.DeductInfo.isDonateInvoice, ShmOCPP16DataPH->TcciCustomData.DeductInfo.amount, (char*)ShmOCPP16DataPH->TcciCustomData.DeductInfo.vemData);
 
 		ShmOCPP16DataPH->TcciCustomData.ReportCreditDeductReq = FALSE;
 	}

+ 2 - 0
EVSE/Modularization/ocppph/Module_OcppBackend.c

@@ -99,6 +99,8 @@ static char *sqlReportDeduct = "create table if not exists report_deduct_info (
 							   "creditNo text,"
 							   "deductResult text,"
 							   "isDonateInvoice text,"
+							   "amount text,"
+							   "vemData text,"
 							   "isUploaded text);";
 
 //=================================

+ 2 - 0
EVSE/Projects/define.h

@@ -4582,6 +4582,8 @@ struct StructCreditDeductResult
 {
     int txId;
     unsigned char creditNo[64];
+    unsigned char vemData[80];
+    double		  amount;
     unsigned char deductResult:1;
     unsigned char isDonateInvoice:1;
 };