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

2022-02-10 / Simon Xue

Action
1. ReUpload Transction id pass.
2. RePreAuthComplete pass.

Files
As the commit history files

Image Version: V2.01.XX.XXXX
Simon Xue 3 жил өмнө
parent
commit
8628050b03

+ 84 - 34
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -274,6 +274,7 @@ void AuthorizeToCharge()
     SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
     struct ChargingInfoData *pDcChargingInfo = NULL;
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+    ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
     if(isAuthorizedComplete())
     {
        // StopSystemTimeoutDet();
@@ -287,6 +288,8 @@ void AuthorizeToCharge()
                 //pSysInfo->SystemPage = _PAGE_PLUGIN;
                 //log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
                 DetectPluginStart();
+                if (ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] == TRUE)
+                	pSysInfo->SystemPage = _PAGE_PLUGIN;
                 //log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
                 //        ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
             } else {
@@ -306,7 +309,8 @@ void ScannerCardProcess(void)
     struct ChargingInfoData *pDcChargingInfo = NULL;
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
 
-    if (!isDetectPlugin() && pSysInfo->SystemPage == _PAGE_SENSING &&
+    if (!isDetectPlugin() && (pSysInfo->SystemPage == _PAGE_SENSING ||
+    		pSysInfo->SystemPage == _PAGE_AUTHORIZE ) &&
     		pDcChargingInfo->SystemStatus == S_IDLE &&
             pSysWarning->Level != WARN_LV_ER /*&&
             pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
@@ -378,11 +382,16 @@ void CreateRfidFork(void)
         int fd = -1;
         int isContinue = 1;
         RFID rfid = {0};
+        RecordTransactionInfo deduct;
         fd = InitialRfidPort();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
         ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
+        struct ChargingInfoData *pDcChargingInfo = NULL;
+        ShmDcCommonData->reupload_deduct_status = 0;
         int gunIndex;
+        int uploadIndex = 0;
+        int ReAuthComplete_Index = 0;
         if(DeductDB_Open() != PASS)
         {
         	isDeductDb_ready = false;
@@ -393,64 +402,64 @@ void CreateRfidFork(void)
         }
         //log_info("RFID fork Child's PID is %d", getpid());
         int result;
+        int is_idle = FALSE;
         while (isContinue) {
         	result = 0;
             usleep(500000);
             ftime(&SeqEndTime);
             SeqEndTime.time = time(NULL);
             tm = localtime(&SeqEndTime.time);
-
+            // 每日結帳
             if (tm->tm_hour == 23 && tm->tm_min == 00 && tm->tm_sec == 0) {
 				result = CreditCardUnionSettlement(fd,"TCC Test",&ShmDcCommonData->pCreditCard[0]);
 				if (result > 0) {
 					log_info("CreditCardUnionSettlement OK");
-					log_info("Get Money:%s",ShmDcCommonData->pCreditCard[0].TransAmount);
 				} else
 					log_info("CreditCardUnionSettlement FAIL");
 			}
 
-            if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
-            	//result = CreditCardSearch(fd,"TCC Test",&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
-            	result = 1;
+			if (tm->tm_min%2 == 0 && pSysInfo->SystemPage == _PAGE_IDLE) {
+				if(ShmDcCommonData->reupload_deduct_status == 0) {
+					// 嘗試傳送未上傳成功到後台ID
+					if (DB_GetReUploadDeduct(&uploadIndex,&ShmDcCommonData->UploadRedectInfo) == PASS) {
+						ShmDcCommonData->reupload_deduct_status = 1;
+						//log_info("deduct uploading");
+					} else {
+						//log_info("no deduct upload");
+					}
+				} else if (ShmDcCommonData->reupload_deduct_status == 2) {
+					UpdateDeductInfoStatus(&uploadIndex,&ShmDcCommonData->UploadRedectInfo);
+					ShmDcCommonData->reupload_deduct_status = 0;
+				}
+			}
+
+            if (pSysInfo->SystemPage == _PAGE_AUTHORIZE && ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] == FALSE) {
+            	result = CreditCardSearch(fd,"TCC Test",&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
+            	//result = 1;
             	StartSystemTimeoutDet(Timeout_ScanCard);
             	if (result > 0) {
-            		pSysInfo->SystemPage = _PAGE_SENSING;
-            		strcpy((char *)pSysConfig->UserId,"AutoStartCharging");
-            		//strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
+            		//strcpy((char *)pSysConfig->UserId,"AutoStartCharging");
+            		strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
             		log_info("Authorize card:%s",pSysConfig->UserId);
+            		StopSystemTimeoutDet();
+            		ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] = TRUE;
+
             	} else if (result < 0) {
             		//pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
             		log_info("No Card Scanning...");
             	}
-            } else if (pSysInfo->SystemPage == _PAGE_SENSING) {
-            	result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
-            	//result = 1;
-            	if (result > 0) {
-            		ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE;
-					pSysInfo->SystemPage = _PAGE_PLUGIN;
-					//strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
-					log_info("PreAuth OK");
-				} else if (result < 0) {
-					pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
-					ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
-					memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
-					log_info("PreAuth Fail");
-
-					result = CreditCardUnionSettlement(fd,"TCC Test",&ShmDcCommonData->pCreditCard[0]);
-					if (result > 0) {
-						log_info("CreditCardUnionSettlement OK");
-						log_info("Get Money:%s",ShmDcCommonData->pCreditCard[0].TransAmount);
-					} else
-						log_info("CreditCardUnionSettlement FAIL");
-
-				}
             }
-
+            is_idle = FALSE;
 			for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+				pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+				if (pDcChargingInfo->SystemStatus == S_IDLE) {
+					is_idle = TRUE;
+				}
+
 				if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && ShmDcCommonData->finalcost_flag[gunIndex]) {
 					ShmDcCommonData->StopCharge[gunIndex] = FALSE;
 					StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost
-					result = CreditCardPreAuthComplete(fd, 1/*(int)ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]*/ ,"TCC Test",
+					result = CreditCardPreAuthComplete(fd,1 /*(int)ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]*/ ,"TCC Test",
 															&ShmDcCommonData->pCreditCard[gunIndex].VemData[0],
 															&ShmDcCommonData->pCreditCard[gunIndex]);
 					//result = 1;
@@ -459,6 +468,7 @@ void CreateRfidFork(void)
 						pSysInfo->SystemPage = _PAGE_COMPLETE;
 						WritePayResult(TRUE,gunIndex);
 						ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
+
 					} else {
 						log_info("PAYING FAIL");
 						ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
@@ -470,9 +480,30 @@ void CreateRfidFork(void)
 					}
 					ShmDcCommonData->PayFinish[gunIndex] = TRUE;
 				}
-			} // for
 
+			} // for
+			if (is_idle == TRUE && tm->tm_min%2 == 0 &&
+					pSysInfo->SystemPage == _PAGE_IDLE && ShmDcCommonData->reupload_deduct_status == 0) {
+				if (DB_GetReDeductInfo(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete) == PASS ) {
 
+					result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->ReAuthComplete.Amount ,"TCC Test",
+															&ShmDcCommonData->ReAuthComplete.VemData[0],
+															&ShmDcCommonData->pCreditCard[0]);
+					if (result > 0) {
+						ShmDcCommonData->ReAuthComplete.DeductResult = YES;
+						ShmDcCommonData->ReAuthComplete.IsUpload = NO;
+						UpdateDeductInfoStatus(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete);
+						log_info("PreAuthComplete OK");
+					} else if ( result < 0) {
+						log_info("Backgroud ID:%d Amount:%d VemData:%s PreAuthComplete fail",
+								ShmDcCommonData->ReAuthComplete.TransactionId,
+								(int)ShmDcCommonData->ReAuthComplete.Amount,
+								ShmDcCommonData->ReAuthComplete.VemData);
+					}
+				} else {
+					log_info("DB_GetReDeductInfo Fail");
+				}
+			}
             if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
             	ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test",
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],
@@ -488,6 +519,25 @@ void CreateRfidFork(void)
 
 				}
 				ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
+            } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) {
+        		result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
+				//result = 1;
+				if (result > 0) {
+					ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE;
+					//pSysInfo->SystemPage = _PAGE_PLUGIN;
+					//strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
+					log_info("PreAuth OK");
+				} else if (result < 0) {
+				    struct ChargingInfoData *pDcChargingInfo = NULL;
+				    //pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+					pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
+					//pDcChargingInfo->SystemStatus = S_IDLE;
+					ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
+					memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
+					log_info("PreAuth Fail");
+					ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
+				}
+				ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
             }
             /*
             // 刷卡判斷

+ 6 - 4
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -3847,8 +3847,9 @@ void ResetIdleData(uint8_t gunIndex)
     memset(&ShmDcCommonData->TransactionInfo[gunIndex], 0, sizeof(RecordTransactionInfo));
     ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
     ShmDcCommonData->finalcost[gunIndex] = 0;
-    ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
-    ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] = FALSE;
+    ShmDcCommonData->AuthPass_flag[gunIndex] = FALSE;
+    ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
+    ShmDcCommonData->GetCardNo[gunIndex] = FALSE;
 
     ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
     destroySelGun(gunIndex);
@@ -4282,7 +4283,8 @@ CheckStatus:
                     }
 
                     if (!GetIsCardScan() && pSysInfo->CurGunSelected == gunIndex &&
-                    		pSysInfo->SystemPage != _PAGE_AUTHORIZE_FAIL) {
+                    		pSysInfo->SystemPage != _PAGE_AUTHORIZE_FAIL &&
+                    		pSysInfo->SystemPage != _PAGE_SENSING) {
                         pSysInfo->SystemPage = _PAGE_PLUGIN;
                     }
                 }
@@ -4578,7 +4580,7 @@ CheckStatus:
                 		ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
                 		ShmDcCommonData->PreAuth_Result = 0;
                     } else {
-						if(ShmDcCommonData->PayFinish[pSysInfo->CurGunSelected] == FALSE) {
+						if(ShmDcCommonData->PayFinish[gunIndex] == FALSE) {
 							pSysInfo->SystemPage = _PAGE_PAYING;
 						}
 						ShmDcCommonData->StopCharge[gunIndex] = TRUE;

+ 4 - 0
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -483,7 +483,11 @@ typedef struct StDcCommonInfo {
     unsigned int PayPass_flag[2];
     unsigned int PayFinish[2];
     unsigned int StopCharge[2];
+    unsigned int GetCardNo[2];
+    int reupload_deduct_status;		// 0:Not ReUpload 1:ReUpload 2:ReUpload finish
     RecordTransactionInfo TransactionInfo[2];
+    RecordTransactionInfo UploadRedectInfo;
+    RecordTransactionInfo ReAuthComplete;
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 138 - 64
EVSE/Projects/DD360Tcci/Apps/DataBase/DataBase.c

@@ -370,37 +370,36 @@ int DeductDB_Open(void)
 
 	return result;
 }
-/*
-int InsertDeductInfo(uint8_t gunIndex, RecordTransactionInfo *deductInfo)
+
+int InsertDeductInfo(int gunIndex, RecordTransactionInfo *deductInfo)
 {
     int result = PASS;
     char *errMsg = NULL;
     char sqlStr[1024] = {0};
+    char approNo[13];
+    char carNo[21];
+    char vemData[65];
+
+    memset(approNo, 0x00, sizeof(approNo));
+    memset(carNo, 0x00, sizeof(carNo));
+    memset(vemData, 0x00, sizeof(vemData));
+
+    memcpy(approNo, (char *)&deductInfo->ApprovalNo, sizeof(deductInfo->ApprovalNo));
+    memcpy(carNo, (char *)&deductInfo->CardNo, sizeof(deductInfo->CardNo));
+    memcpy(vemData, (char *)&deductInfo->VemData, sizeof(deductInfo->VemData));
 
 	sprintf(sqlStr, "insert into deduct_record(gunIndex, transactionId, deductResult, isDonate, approvalNo, cardNo, vemData, amount, isUpload) "
-				    "values('%d', '%d', '%d', '%d', '%s', '%s', '%s' , '%f', '%d');",
+				    "values('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%f', '%d');",
 				    gunIndex,
 				    deductInfo->TransactionId,
 				    deductInfo->DeductResult,
 				    deductInfo->IsDonateInvoice,
-				    deductInfo->ApprovalNo,
-				    deductInfo->CardNo,
-				    deductInfo->VemData,
+					approNo,
+					carNo,
+					vemData,
 				    deductInfo->Amount,
 				    deductInfo->IsUpload);
 
-	log_info( "insert into charging_record(gunIndex, transactionId, deductResult, isDonate, approvalNo, cardNo, vemData, amount, isReport) "
-				    "values('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%d', '%f', '%d');",
-				    gunIndex,
-				    deductInfo->TransactionId,
-				    deductInfo->DeductResult,
-				    deductInfo->IsDonateInvoice,
-				    deductInfo->ApprovalNo,
-				    deductInfo->CardNo,
-				    deductInfo->VemData,
-				    deductInfo->Amount,
-				    deductInfo->IsReportTransactionInfo);
-
     if (sqlite3_open(DEDUCT_FILE, &deductDb))
     {
         result = FAIL;
@@ -425,61 +424,136 @@ int InsertDeductInfo(uint8_t gunIndex, RecordTransactionInfo *deductInfo)
 
     return result;
 }
-*/
-int InsertDeductInfo(uint8_t gunIndex, RecordTransactionInfo *deductInfo)
+
+int UpdateDeductInfoStatus(int gunIndex, RecordTransactionInfo *deductInfo)
 {
-	int result = PASS;
-	char *errMsg = NULL;
-	char sqlStr[1024] = {0};
-	char approNo[13];
-	char carNo[21];
-	char vemData[65];
+    int result = PASS;
+    char *errMsg = NULL;
+    char sqlStr[1024] = {0};
 
-	memset(approNo, 0x00, sizeof(approNo));
-	memset(carNo, 0x00, sizeof(carNo));
-	memset(vemData, 0x00, sizeof(vemData));
+    sprintf(sqlStr, "update deduct_record set deductResult = %d, isUpload = %d where transactionId = %d;",
+                    deductInfo->DeductResult,
+                    deductInfo->IsUpload,
+                    deductInfo->TransactionId);
 
-	memcpy(approNo, (char *)&deductInfo->ApprovalNo, sizeof(deductInfo->ApprovalNo));
-	memcpy(carNo, (char *)&deductInfo->CardNo, sizeof(deductInfo->CardNo));
-	memcpy(vemData, (char *)&deductInfo->VemData, sizeof(deductInfo->VemData));
+    if (sqlite3_open(DEDUCT_FILE, &deductDb))
+    {
+        result = FAIL;
+        log_info( "Can't open deduct database: %s", sqlite3_errmsg(deductDb));
+        sqlite3_close(deductDb);
+    }
+    else
+    {
+        //log_info( "Local event record database open successfully.");
+        if (sqlite3_exec(deductDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
+        {
+            result = FAIL;
+            log_info( "update deduct record error message: %s", errMsg);
+        }
+        else
+        {
+            //log_info( "update deduct record successfully");
+        }
 
-	sprintf(sqlStr, "insert into deduct_record(gunIndex, transactionId, deductResult, isDonate, approvalNo, cardNo, vemData, amount, isUpload) "
-			"values('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%f', '%d');",
-			gunIndex,
-			deductInfo->TransactionId,
-			deductInfo->DeductResult,
-			deductInfo->IsDonateInvoice,
-			approNo,
-			carNo,
-			vemData,
-			deductInfo->Amount,
-			deductInfo->IsUpload);
+        sqlite3_close(deductDb);
+    }
 
+    return result;
+}
 
+int DB_GetDeductInfo(int deductResult, int uploadState, int *gunIndex, RecordTransactionInfo *deductInfo)
+{
+    int result = PASS;
+    char *errMsg = NULL;
+    char sqlStr[1024];
+    char **rs;
+    int rows, cols;
 
-	if (sqlite3_open(DEDUCT_FILE, &deductDb))
-	{
-		result = FAIL;
-		log_info( "Can't open deduct database: %s", sqlite3_errmsg(deductDb));
-		sqlite3_close(deductDb);
-	}
-	else
-	{
-		//log_info( "Local event record database open successfully.");
-		if (sqlite3_exec(deductDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
-		{
-		result = FAIL;
-		log_info( "Insert deduct record error message: %s", errMsg);
-		}
-		else
-		{
-			//log_info( "Insert local event record successfully");
-		}
+    if(deductResult >= 0 && uploadState >= 0)
+    {
+        sprintf(sqlStr, "select * from deduct_record where deductResult = %d and isUpload = %d;", deductResult > 0 ? 1 : 0, uploadState > 0 ? 1 : 0);
+    }
+    else if(deductResult >= 0 && uploadState < 0)
+    {
+        sprintf(sqlStr, "select * from deduct_record where deductResult = %d;", deductResult > 0 ? 1 : 0);
+    }
+    else if(deductResult < 0 && uploadState >= 0)
+    {
+        sprintf(sqlStr, "select * from deduct_record where isUpload = %d;", uploadState > 0 ? 1 : 0);
+    }
+    else
+    {
+        sprintf(sqlStr, "select * from deduct_record;");
+    }
 
-		sqlite3_close(deductDb);
-	}
+    if (sqlite3_open(DEDUCT_FILE, &deductDb))
+    {
+        result = FAIL;
+        log_info("Can't open deduct database: %s", sqlite3_errmsg(deductDb));
+        sqlite3_close(deductDb);
+    }
+    else
+    {
+        sqlite3_get_table(deductDb, sqlStr, &rs, &rows, &cols, &errMsg);
+
+        if (rows > 0)
+        {
+            for (int idxRow = 1; idxRow <= rows; idxRow++)
+            {
+                *gunIndex = atoi(rs[(idxRow * cols) + 1]);
+                deductInfo->TransactionId = atoi(rs[(idxRow * cols) + 2]);
+                deductInfo->DeductResult = atoi(rs[(idxRow * cols) + 3]);
+                deductInfo->IsDonateInvoice = atoi(rs[(idxRow * cols) + 4]);
+                strcpy((char *)&deductInfo->ApprovalNo, rs[(idxRow * cols) + 5]);
+                strcpy((char *)&deductInfo->CardNo, rs[(idxRow * cols) + 6]);
+                strcpy((char *)&deductInfo->VemData, rs[(idxRow * cols) + 7]);
+                deductInfo->Amount = atoi(rs[(idxRow * cols) + 8]);
+                deductInfo->IsUpload = atoi(rs[(idxRow * cols) + 9]);
+                break;
+            }
+        }
+        else
+        {
+            result = FAIL;
+        }
+        sqlite3_free_table(rs);
+        sqlite3_close(deductDb);
+    }
 
+    return result;
+}
 
+int DB_GetReDeductInfo(int *gunIndex, RecordTransactionInfo *deductInfo)
+{
+    int result = PASS;
 
-	return result;
+    if(DB_GetDeductInfo(0, -1, gunIndex, deductInfo) == PASS)
+    {
+        //log_info("GetReDeductInfo OK");
+    }
+    else
+    {
+        result = FAIL;
+        //log_info("GetReDeductInfo NG");
+    }
+
+    return result;
 }
+
+int DB_GetReUploadDeduct(int *gunIndex, RecordTransactionInfo *deductInfo)
+{
+    int result = PASS;
+
+    if(DB_GetDeductInfo(-1, 0, gunIndex, deductInfo) == PASS)
+    {
+        //log_info("GetReUploadDeduct OK");
+    }
+    else
+    {
+        result = FAIL;
+        //log_info("GetReUploadDeduct NG");
+    }
+
+    return result;
+}
+

+ 7 - 1
EVSE/Projects/DD360Tcci/Apps/DataBase/DataBase.h

@@ -1,6 +1,8 @@
 #ifndef _DATA_BASE_H_
 #define _DATA_BASE_H_
+
 #include "../Config.h"
+
 int DB_Open(void);
 int DB_Insert_Record(int gunIndex);
 int DB_Update_Operactive(uint8_t gunIndex, uint8_t IsAvailable);
@@ -12,6 +14,10 @@ int CreateEventRecord(void);
 int InsertEventRecord(uint8_t *statusCode);
 
 int DeductDB_Open(void);
-int InsertDeductInfo(uint8_t gunIndex, RecordTransactionInfo *deductInfo);
+int InsertDeductInfo(int gunIndex, RecordTransactionInfo *deductInfo);
+int UpdateDeductInfoStatus(int gunIndex, RecordTransactionInfo *deductInfo);
+int DB_GetDeductInfo(int deductResult, int uploadState, int *gunIndex, RecordTransactionInfo *deductInfo);
+int DB_GetReDeductInfo(int *gunIndex, RecordTransactionInfo *deductInfo);
+int DB_GetReUploadDeduct(int *gunIndex, RecordTransactionInfo *deductInfo);
 
 #endif /* _DATA_BASE_H_ */

+ 10 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -27,6 +27,7 @@
 #include "../Config.h"
 #include "../SelectGun/SelectGun.h"
 #include "../timeout.h"
+#include "../DataBase/DataBase.h"
 #include "DoComm.h"
 
 //------------------------------------------------------------------------------
@@ -1957,7 +1958,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
         ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
     }
 #else
-    gunID = ID_REGISTER;
+    gunID = gDoCommGblData.ConnectorID[plugNum];;
 
     ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0; //非Audi 不需要等待主櫃回報餘額
 #endif // DD360Audi
@@ -2300,6 +2301,14 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             break;
         }
 
+
+        if (ShmDcCommonData->reupload_deduct_status == 1) {
+        	if (writeDeductInfo(fd, 0xff,plugNum, &ShmDcCommonData->UploadRedectInfo) == PASS) {
+        		ShmDcCommonData->UploadRedectInfo.IsUpload = YES;
+        		ShmDcCommonData->reupload_deduct_status = 2;
+        	}
+        }
+
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
                 DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) < 0

+ 3 - 0
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h

@@ -141,6 +141,9 @@
 #define ST_NO_UPDATE_FIRMWARE                   (0x02)
 
 #define LCM_PAGE_REMOTE_START_NO_ID             (0x0001)
+
+#define UPLOAD_DEDUCT_DB						(0x5656)
+
 //#define LCM_PAGE_JOIN_LINE                      (0x0002)
 //#define LCM_PAGE_PAYMENT_SWITCH                 (0x0003)
 

+ 16 - 8
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -205,9 +205,10 @@ void CheckReturnPress()
 	//pDcChargingInfo->SystemStatus = S_IDLE;
 	StopSystemTimeoutDet();
 	if ( pDcChargingInfo->SystemStatus == S_AUTHORIZING ) {
-		if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
+		if (pSysInfo->SystemPage == _PAGE_AUTHORIZE || pSysInfo->SystemPage == _PAGE_PLUGIN ) {
 			pSysInfo->SystemPage = _PAGE_SELECT_PAY;
 		}
+		pDcChargingInfo->SystemStatus = S_IDLE;
 		ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
 		ShmDcCommonData->PreAuth_Result = 0;
 		for(i=0;i<=30;i++) {
@@ -216,7 +217,7 @@ void CheckReturnPress()
 			sleep(1);
 		}
 		ShmDcCommonData->PreAuth_Result = 0;
-		pDcChargingInfo->SystemStatus = S_IDLE;
+
 		strcpy((char *)pSysConfig->UserId, "");
 		return;
 	}
@@ -900,10 +901,8 @@ void ChangeCarBonValue(float data)
     memset(cmd, 0x00, sizeof(cmd));
     _carbon = (data*9)/10*2.36 - data*0.637;
     //log_info("Carbon:%d",(int)_carbon);
-    if (_carbon < 10)
-    	sprintf((char *) value, "%.1f", _carbon);
-    else
-    	sprintf((char *) value, "%d", (int)_carbon);
+
+	sprintf((char *) value, "%d", (int)_carbon);
     string2ByteArray(value, cmd);
     DisplayValueToLcm(_String_Carbon, cmd, sizeof(cmd));
 }
@@ -923,8 +922,10 @@ void ChangeChargingEnergyValue(float energy)
     	ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0+100);
     else
     	ChangeDisplay2Value(_Icon_ChargeBar,(int)energy+_TCC_Charging_Bar0);
-
-    sprintf((char *) value, "%.1f", energy);
+    if (energy < 10)
+    	sprintf((char *) value, "%.1f", energy);
+    else
+    	sprintf((char *) value, "%d", (int)energy);
     string2ByteArray(value, cmd);
     DisplayValueToLcm(_Strting_Energy, cmd, sizeof(cmd));
 }
@@ -1116,6 +1117,13 @@ void ProcessPageInfo()
 				}*/
             	//ChangeDisplay2Value(_Icon_Precharge,0);
             	//ChangeDisplay2Value(_Icon_Precharge,1);
+            	if (ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] == TRUE &&
+            			ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] != TRUE) {
+            		ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH;
+            		ShmDcCommonData->PreAuth_Result = 0;
+            		sleep(3);
+            		pSysInfo->SystemPage = _PAGE_SENSING;
+            	}
             	_Text_Running_Count = 1;
                 break;
             case _PAGE_PLUGIN:

BIN
EVSE/Projects/DD360Tcci/Images/ramdisk.gz


BIN
EVSE/Projects/DD360Tcci/output/FactoryConfig


BIN
EVSE/Projects/DD360Tcci/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360Tcci/output/Module_DoComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EvComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EventLogging


BIN
EVSE/Projects/DD360Tcci/output/Module_InternalComm


BIN
EVSE/Projects/DD360Tcci/output/Module_LcmControl


BIN
EVSE/Projects/DD360Tcci/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Tcci/output/Module_UpdateFW


BIN
EVSE/Projects/DD360Tcci/output/ReadCmdline


BIN
EVSE/Projects/DD360Tcci/output/main


BIN
EVSE/Projects/DD360Tcci/output/simulation