Browse Source

2022-02-09 / Simon Xue

Action
1. Add deduction info.
2. Modify flow

Files
As the commit history files

Image Version: v2.01.XX.XXXX.XX
Simon Xue 3 years ago
parent
commit
b10f80d246

+ 7 - 4
EVSE/Modularization/Module_Systex.c

@@ -39,7 +39,7 @@ unsigned char HOST_ID_eTicket_Polling[] = {0x35, 0x30};//
 // Transaction Type, offset = 2, length = 2 bytes , 
 //==================================
 //-------------尋卡---------------
-unsigned char TRANS_TYPE_Search[] = {0x30, 0x30};	//讀取卡片卡號 or 條碼資料
+unsigned char TRANS_TYPE_Search[] = {0x37, 0x32};	//讀取卡片卡號 or 條碼資料
 //--------------信用卡一般消費---------------
 unsigned char TRANS_TYPE_Sale[] = {0x31, 0x31};	//消費交易 : 信用卡,票證,掃碼支付
 unsigned char TRANS_TYPE_Void[] = {0x30, 0x35};//取消交易 : 信用卡,
@@ -353,7 +353,8 @@ int CreditCardPreAuth(int Fd, int PreCost,unsigned char *EVSEID, struct TransInf
 			strncpy(TransInfoReturn->TransDate,Buffer+56,6);	
 			strncpy(TransInfoReturn->TransTime,Buffer+62,6);	
 			strncpy(TransInfoReturn->StoreId,Buffer+97,18);
-			strncpy(TransInfoReturn->ApprovalNo,Buffer+12,12);
+			strncpy(TransInfoReturn->ROC,Buffer+12,12);
+			strncpy(TransInfoReturn->ApprovalNo,Buffer+115,9);
 			strncpy(TransInfoReturn->RRN,Buffer+124,12);
 			strncpy(TransInfoReturn->CardNo,Buffer+24,20);
 			strncpy(TransInfoReturn->VemData,Buffer+246,64);
@@ -415,7 +416,8 @@ int CreditCardPreAuthComplete(int Fd, int PreCost,unsigned char *EVSEID, unsigne
 			strncpy(TransInfoReturn->TransDate,Buffer+56,6);	
 			strncpy(TransInfoReturn->TransTime,Buffer+62,6);	
 			strncpy(TransInfoReturn->StoreId,Buffer+97,18);
-			strncpy(TransInfoReturn->ApprovalNo,Buffer+12,12);
+			strncpy(TransInfoReturn->ROC,Buffer+12,12);
+			strncpy(TransInfoReturn->ApprovalNo,Buffer+115,9);
 			strncpy(TransInfoReturn->RRN,Buffer+124,12);
 			strncpy(TransInfoReturn->CardNo,Buffer+24,20);
 			strncpy(TransInfoReturn->VemData,Buffer+246,64);
@@ -534,7 +536,8 @@ int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID, struct TransInfo *Tr
 			strncpy(TransInfoReturn->TransDate,Buffer+56,6);	
 			strncpy(TransInfoReturn->TransTime,Buffer+62,6);	
 			strncpy(TransInfoReturn->StoreId,Buffer+97,18);
-			strncpy(TransInfoReturn->ApprovalNo,Buffer+12,12);
+			strncpy(TransInfoReturn->ROC,Buffer+12,12);
+			strncpy(TransInfoReturn->ApprovalNo,Buffer+115,9);
 			strncpy(TransInfoReturn->RRN,Buffer+124,12);
 			strncpy(TransInfoReturn->CardNo,Buffer+24,20);
 			strncpy(TransInfoReturn->VemData,Buffer+246,64);

+ 2 - 1
EVSE/Modularization/Module_Systex.h

@@ -53,7 +53,8 @@ struct TransInfo
 {
 	unsigned char TransDate[6];	//交易日期
 	unsigned char TransTime[6];	//交易時間
-	unsigned char ApprovalNo[12];		//EDC簽單調閱編號或授權碼[信用卡退貨交易] (左靠右補空白)
+	unsigned char ROC[12];		//EDC簽單調閱編號 (左靠右補空白)
+	unsigned char ApprovalNo[9];		//授權碼[信用卡退貨交易] (左靠右補空白)
 	unsigned char StoreId[18];		//櫃號,機號,發票號碼(左靠右補空白)
 	unsigned char RRN[12];		//信用卡交易序號
 	unsigned char CardNo[20];		//卡號(左靠右補空白),卡號部份隱藏

+ 20 - 1
EVSE/Projects/DD360Tcci/Apps/CSU/Primary.c

@@ -24,14 +24,29 @@ void ChangeLCM(uint8_t page)
 // ***********************************
 // Enter LCM Page
 // ***********************************
-
 void CheckLeftButton()
 {
     pSysInfo->CurGunSelected = LEFT_GUN_NUM;
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+    if(pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
+    	pSysInfo->SystemPage = _PAGE_BILL;
+    	return;
+    }
+    if(pDcChargingInfo->SystemStatus == S_IDLE) {
+    	pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+    }
 }
 void CheckRightButton()
 {
     pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+    if(pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
+    	pSysInfo->SystemPage = _PAGE_BILL;
+    	return;
+    }
+    if(pDcChargingInfo->SystemStatus == S_IDLE) {
+		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+	}
 }
 void CheckPrimaryWarm(void)
 {
@@ -175,6 +190,10 @@ void ChkPrimaryStatus(void)
         return;
     // Press Left Button
     if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS && !leftBtnPush ) {
+    	if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_PLUGIN) {
+    		log_info("Authorize Process can't select gun");
+    		return;
+    	}
         leftBtnPush = true;
         CheckLeftButton();
         log_info("left btn down...............................%x %x %x",

+ 57 - 23
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -8,13 +8,15 @@
 #include "../Define/define.h"
 #include "../ShareMemory/shmMem.h"
 #include "../SelectGun/SelectGun.h"
+#include "../DataBase/DataBase.h"
 
 #include "main.h"
 #include "../timeout.h"
-static DcCommonInfo *ShmDcCommonData = NULL;
-static struct SysInfoData *pSysInfo = NULL;
-#define PREAUTHMONEY 2
-
+static DcCommonInfo *ShmDcCommonData 			= NULL;
+static SelectGunInfo *ShmSelectGunInfo          = NULL;
+static struct SysInfoData *pSysInfo 			= NULL;
+#define PREAUTHMONEY	1
+bool isDeductDb_ready;
 //------------------------------------------------------------------------------
 static char *rfidPortName = "/dev/ttyS2";
 
@@ -326,7 +328,17 @@ void ScannerCardProcess(void)
     }
 }
 
+void WritePayResult(int result ,uint8_t gunIndex)
+{
+	ShmDcCommonData->TransactionInfo[gunIndex].Amount = ShmDcCommonData->finalcost[gunIndex];
+	memcpy(ShmDcCommonData->TransactionInfo[gunIndex].ApprovalNo , ShmDcCommonData->pCreditCard[gunIndex].ApprovalNo,9);
+	memcpy(ShmDcCommonData->TransactionInfo[gunIndex].CardNo , ShmDcCommonData->pCreditCard[gunIndex].CardNo,20);
+	ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = result;
+	ShmDcCommonData->TransactionInfo[gunIndex].IsDonateInvoice = ShmDcCommonData->donate_flag[gunIndex];
+	ShmDcCommonData->TransactionInfo[gunIndex].TransactionId = ShmSelectGunInfo->PricesInfo[gunIndex].TransactionId;
+	memcpy(&ShmDcCommonData->TransactionInfo[gunIndex].VemData,&ShmDcCommonData->pCreditCard[gunIndex].VemData,64);
 
+}
 static int InitialRfidPort(void)
 {
     int fd = open(rfidPortName, O_RDWR);
@@ -369,7 +381,16 @@ void CreateRfidFork(void)
         fd = InitialRfidPort();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-
+        ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
+        int gunIndex;
+        if(DeductDB_Open() != PASS)
+        {
+        	isDeductDb_ready = false;
+        }
+        else
+        {
+        	isDeductDb_ready = true;
+        }
         //log_info("RFID fork Child's PID is %d", getpid());
         int result;
         while (isContinue) {
@@ -396,6 +417,7 @@ void CreateRfidFork(void)
             		pSysInfo->SystemPage = _PAGE_SENSING;
             		strcpy((char *)pSysConfig->UserId,"AutoStartCharging");
             		//strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
+            		log_info("Authorize card:%s",pSysConfig->UserId);
             	} else if (result < 0) {
             		//pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
             		log_info("No Card Scanning...");
@@ -407,38 +429,50 @@ void CreateRfidFork(void)
             		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));
-				}
-            } else if (pSysInfo->SystemPage == _PAGE_PAYING) {
-            	result = CreditCardPreAuthComplete(fd, 1/*ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]*/ ,"TCC Test",
-            	            	            			&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0],
-            	            							&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
-            	//result = 1;
-            	if (result > 0 ) {
-					log_info("Credit Card Spend Money:%d",ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]);
-					ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] = TRUE;
-					pSysInfo->SystemPage = _PAGE_COMPLETE;
-					/*
+					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");
-						*/
 
-				} else {
-					log_info("PAYING FAIL");
-					ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] = FALSE;
-					pSysInfo->SystemPage = _PAGE_PAYFAIL;
 				}
-
             }
 
+			for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+				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",
+															&ShmDcCommonData->pCreditCard[gunIndex].VemData[0],
+															&ShmDcCommonData->pCreditCard[gunIndex]);
+					//result = 1;
+					if (result > 0 ) {
+						log_info("Credit Card Spend Money:%.1f",ShmDcCommonData->finalcost[gunIndex]);
+						pSysInfo->SystemPage = _PAGE_COMPLETE;
+						WritePayResult(TRUE,gunIndex);
+						ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
+					} else {
+						log_info("PAYING FAIL");
+						ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
+						pSysInfo->SystemPage = _PAGE_PAYFAIL;
+						WritePayResult(FALSE,gunIndex);
+					}
+					if (isDeductDb_ready == TRUE) {
+						InsertDeductInfo(gunIndex,&ShmDcCommonData->TransactionInfo[gunIndex]);
+					}
+					ShmDcCommonData->PayFinish[gunIndex] = TRUE;
+				}
+			} // for
+
+
             if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
             	ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test",
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],

+ 41 - 18
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -3511,7 +3511,9 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP == YES ||
             ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP == YES ||
             ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP == YES ||
-            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure == YES
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure == YES ||
+			ShmSelectGunInfo->EthDevStatus.Backend == 0 ||
+			ShmSelectGunInfo->EthDevStatus.Backend == 2
        ) {
         pSysWarning->Level = WARN_LV_ER;
     } else {
@@ -3694,9 +3696,7 @@ static void checkPileEndGfdResult(uint8_t gunIndex, uint8_t gunType, uint8_t sys
     case _Type_Chademo:
         // 檢查樁端的 GFD 結果
         if (sysStatus == S_PREPARING_FOR_EVSE &&
-                isPrechargeStatus_chademo(gunIndex) > 6 &&
-                isPrechargeStatus_chademo(gunIndex) < 8
-           ) {
+                isPrechargeStatus_chademo(gunIndex) >= 6 ) {
             // 當前操作的槍號,進入 Charging
             setChargerMode(gunIndex, MODE_CHARGING);
         }
@@ -3723,7 +3723,7 @@ static void checkPileEndGfdResult(uint8_t gunIndex, uint8_t gunType, uint8_t sys
         // 檢查樁端的 GFD 結果
         //if (isPrechargeStatus_gb(gunIndex) > 5 && isPrechargeStatus_gb(gunIndex) < 9) {
         if (sysStatus == S_PREPARING_FOR_EVSE &&
-                isPrechargeStatus_gb(gunIndex) > 6) {
+                isPrechargeStatus_gb(gunIndex) >= 6) {
             setChargerMode(gunIndex, MODE_CHARGING);
         }
 
@@ -3844,6 +3844,7 @@ void ResetIdleData(uint8_t gunIndex)
     //Jerry add
     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
     memset(&ShmDcCommonData->pCreditCard[gunIndex], 0, sizeof(TransInfo));
+    memset(&ShmDcCommonData->TransactionInfo[gunIndex], 0, sizeof(RecordTransactionInfo));
     ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
     ShmDcCommonData->finalcost[gunIndex] = 0;
     ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
@@ -3857,7 +3858,7 @@ void ResetIdleData(uint8_t gunIndex)
     }
     //strcpy((char *)ShmOCPP16Data->StatusNotification[gunIndex].VendorErrorCode, "");
     ReleaseAlarmCode(gunIndex);
-    if (pSysInfo->SystemPage != _PAGE_SELECT_GUN)
+    if (pSysInfo->SystemPage != _PAGE_SELECT_GUN && pSysInfo->SystemPage != _PAGE_SELECT_PAY)
     	pSysInfo->SystemPage = _PAGE_IDLE;
 }
 void CheckErrorCode(uint8_t gunIndex)
@@ -3968,6 +3969,7 @@ int main(void)
     log_info(" ********************************************************");
     log_info(" ******************  Project:DD360Tcci  *****************");
     log_info(" ********************************************************");
+    int is_plugout[2];
     if (!InitialSystemDefaultConfig()) {
         log_error("InitialSystemDefaultConfig NG ");
         //StopProcessingLoop();
@@ -4138,6 +4140,7 @@ int main(void)
                 if (isModeChange(gunIndex)) {
                     log_info("============================= S_IDLE(%x) ============================= ", gunIndex);
                     ResetIdleData(gunIndex);
+                    is_plugout[gunIndex] = FALSE;
                 }
                 isChargingAverageState();
                 // For RemoteStart Using
@@ -4153,17 +4156,27 @@ int main(void)
                 ScannerCardProcess();
                 if (pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
                 	ShmDcCommonData->LineStatus[gunIndex] = 0;
+                	StopGunInfoTimeoutDet(gunIndex);
                 	StartSystemTimeoutDet(Timeout_ReturnViewPage);
 				}
                 if (pSysInfo->CurGunSelected == gunIndex){
+
                 	if(pSysInfo->SystemPage ==_PAGE_BILL) {
                 		StartSystemTimeoutDet(Timeout_AddLine);
                 		if (ShmDcCommonData->LineStatus[gunIndex] == 1 || ShmDcCommonData->LineStatus[gunIndex] == 2 )
                 			pSysInfo->SystemPage =_PAGE_ADD_FRIEND;
                 	} else if(pSysInfo->SystemPage ==_PAGE_ADD_FRIEND) {
+                		StopSystemTimeoutDet();
                 		StartGunInfoTimeoutDet(gunIndex, Timeout_LineReigster);
-                		if (ShmDcCommonData->LineStatus[gunIndex] == 3 || ShmDcCommonData->LineStatus[gunIndex] == 4 )
+                		if (ShmDcCommonData->LineStatus[gunIndex] == 3)  {
+                			pSysInfo->SystemPage =_PAGE_SELECT_PAY;
+                			ShmDcCommonData->donate_flag[gunIndex] = FALSE;
+                		}
+						if (ShmDcCommonData->LineStatus[gunIndex] == 4 ) {
                 			pSysInfo->SystemPage =_PAGE_SELECT_PAY;
+                			ShmDcCommonData->donate_flag[gunIndex] = TRUE;
+
+                		}
                 	}
                 }
                 goto CheckStatus;
@@ -4443,6 +4456,7 @@ CheckStatus:
                     ChangeStartOrStopDateTime(YES, gunIndex);
                     pDcChargingInfo->Replug_flag = FALSE;
                     ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
+                    ShmDcCommonData->StopCharge[gunIndex] = FALSE;
                 }
 
                 if (ShmOCPP16Data->CpMsg.bits[gunIndex].StartTransactionConf) {
@@ -4461,7 +4475,8 @@ CheckStatus:
                 		pSysInfo->SystemPage == _PAGE_STOP_CONFIRM_RIGHT)
                 	break;
                 // LCM => Charging
-                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_IDLE) {
+                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_IDLE &&
+                		pSysInfo->SystemPage != _PAGE_SELECT_GUN) {
                     pSysInfo->SystemPage = _PAGE_CHARGING;
                 }
                 break;
@@ -4525,8 +4540,12 @@ CheckStatus:
                 if (pSysInfo->SystemPage == _PAGE_MAINTAIN) {
                     break;
                 }
-
-                if (pDcChargingInfo->ConnectorPlugIn == NO ) {
+                if (pSysInfo->CurGunSelected == gunIndex && is_plugout[gunIndex] == TRUE) {
+                	pSysInfo->SystemPage = _PAGE_EXIT;
+                	break;
+                }
+                if (pDcChargingInfo->ConnectorPlugIn == NO) {
+                	is_plugout[gunIndex] = TRUE;
                     StartGunInfoTimeoutDet(gunIndex, Timeout_PlugOutGun);
                     if (pSysInfo->CurGunSelected == gunIndex) {
                     	pSysInfo->SystemPage = _PAGE_EXIT;
@@ -4534,8 +4553,7 @@ CheckStatus:
                     }
                 }
 
-                if (pSysInfo->CurGunSelected == gunIndex &&
-                		pSysInfo->SystemPage != _PAGE_PAYING) {
+                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_PAYING) {
                 	if (ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == TRUE)
 						pSysInfo->SystemPage = _PAGE_COMPLETE;
 					else
@@ -4560,9 +4578,10 @@ CheckStatus:
                 		ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
                 		ShmDcCommonData->PreAuth_Result = 0;
                     } else {
-						if(ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == FALSE) {
+						if(ShmDcCommonData->PayFinish[pSysInfo->CurGunSelected] == FALSE) {
 							pSysInfo->SystemPage = _PAGE_PAYING;
 						}
+						ShmDcCommonData->StopCharge[gunIndex] = TRUE;
                     }
                 }
 
@@ -4571,7 +4590,12 @@ CheckStatus:
 
 					continue;
 				}
-                if (pDcChargingInfo->ConnectorPlugIn == NO ) {
+                if (pSysInfo->CurGunSelected == gunIndex && is_plugout[gunIndex] == TRUE) {
+                	pSysInfo->SystemPage = _PAGE_EXIT;
+                	break;
+                }
+                if (pDcChargingInfo->ConnectorPlugIn == NO) {
+                	is_plugout[gunIndex] = TRUE;
 					if (pDcChargingInfo->Replug_flag == TRUE) {
 						pSysInfo->SystemPage = _PAGE_SELECT_GUN;
 						pDcChargingInfo->SystemStatus = S_IDLE;
@@ -4582,11 +4606,10 @@ CheckStatus:
 					}
 					break;
 				}
-                if (pSysInfo->SystemPage == _PAGE_PAYING)
-                	break;
+                //if (pSysInfo->SystemPage == _PAGE_PAYING)
+                //	break;
 
-                if (pSysInfo->CurGunSelected == gunIndex &&
-                		pSysInfo->SystemPage != _PAGE_PAYING) {
+                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_PAYING) {
                 	if (pDcChargingInfo->Replug_flag == TRUE)
                 		pSysInfo->SystemPage = _PAGE_PLUGOUT;
                 	else {

+ 19 - 2
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -409,7 +409,8 @@ typedef struct stTransInfo
 {
 	unsigned char TransDate[6];	//交易日期
 	unsigned char TransTime[6];	//交易時間
-	unsigned char ApprovalNo[12];		//EDC簽單調閱編號或授權碼[信用卡退貨交易] (左靠右補空白)
+	unsigned char ROC[12];		//EDC簽單調閱編號 (左靠右補空白)
+	unsigned char ApprovalNo[9];		//授權碼[信用卡退貨交易] (左靠右補空白)
 	unsigned char StoreId[18];		//櫃號,機號,發票號碼(左靠右補空白)
 	unsigned char RRN[12];		//信用卡交易序號
 	unsigned char CardNo[20];		//卡號(左靠右補空白),卡號部份隱藏
@@ -417,6 +418,19 @@ typedef struct stTransInfo
 	unsigned char VemData[64];		//無人自助設備交易資訊 交易別31/32 (預授權完成/預授權取消) 必要欄位 資訊來源為交易別13 (預授權)的回傳
 }TransInfo;
 
+typedef struct stRecordTransactionInfo
+{
+	int TransactionId;
+    unsigned char DeductResult;                     // 0: Fail, 1: Pass
+    unsigned char IsDonateInvoice;                  // 0: Do not donate, 1: Donate
+    unsigned char ApprovalNo[9];
+    unsigned char CardNo[20];		//卡號(左靠右補空白),卡號部份隱藏
+    unsigned char VemData[64];
+    float Amount;
+    unsigned char IsUpload; // 0: not upload, 1: uploaded
+    unsigned char res;
+}RecordTransactionInfo;
+
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
     uint8_t CcsVersion;
@@ -457,7 +471,7 @@ typedef struct StDcCommonInfo {
     char PresentTime[128];
     TransInfo pCreditCard[2];
     int runningcost[2];
-    int finalcost[2];
+    float finalcost[2];
     unsigned int finalcost_flag[2];
     float ChargingRate;
     int PreAuth_Config;
@@ -467,6 +481,9 @@ typedef struct StDcCommonInfo {
     int ConnectorID[2];
     unsigned int AuthPass_flag[2];
     unsigned int PayPass_flag[2];
+    unsigned int PayFinish[2];
+    unsigned int StopCharge[2];
+    RecordTransactionInfo TransactionInfo[2];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 159 - 0
EVSE/Projects/DD360Tcci/Apps/DataBase/DataBase.c

@@ -11,9 +11,11 @@
 
 //------------------------------------------------------------------------------
 #define DB_FILE                                 "/Storage/ChargeLog/localCgargingRecord.db"
+#define DEDUCT_FILE                 			"/Storage/ChargeLog/localDeductRecord.db"
 
 //------------------------------------------------------------------------------
 static sqlite3 *localDb;
+static sqlite3 *deductDb;
 
 //------------------------------------------------------------------------------
 //===============================================
@@ -324,3 +326,160 @@ int InsertEventRecord(uint8_t *statusCode)
 
     return result;
 }
+
+
+int DeductDB_Open(void)
+{
+	int result = PASS;
+	char* errMsg = NULL;
+	char* createDeductInfoSql="CREATE TABLE IF NOT EXISTS deduct_record("
+					      	  "idx integer primary key AUTOINCREMENT, "
+							  "gunIndex text, "
+						  	  "transactionId text, "
+						  	  "deductResult text, "
+						  	  "isDonate text, "
+						  	  "approvalNo text, "
+						  	  "cardNo text,"
+						  	  "vemData text, "
+						  	  "amount text, "
+						  	  "isUpload text"
+						  	  ");";
+
+	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("Deduct database open successfully.");
+
+		if (sqlite3_exec(deductDb, createDeductInfoSql, 0, 0, &errMsg) != SQLITE_OK)
+		{
+			result = FAIL;
+			log_info("Create deduct info table error message: %s", errMsg);
+		}
+		else
+		{
+			log_info("Opened deduct info table successfully");
+		}
+
+		sqlite3_close(deductDb);
+	}
+
+	return result;
+}
+/*
+int InsertDeductInfo(uint8_t gunIndex, RecordTransactionInfo *deductInfo)
+{
+    int result = PASS;
+    char *errMsg = NULL;
+    char sqlStr[1024] = {0};
+
+	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,
+				    deductInfo->ApprovalNo,
+				    deductInfo->CardNo,
+				    deductInfo->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;
+        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");
+        }
+
+        sqlite3_close(deductDb);
+    }
+
+    return result;
+}
+*/
+int InsertDeductInfo(uint8_t 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');",
+			gunIndex,
+			deductInfo->TransactionId,
+			deductInfo->DeductResult,
+			deductInfo->IsDonateInvoice,
+			approNo,
+			carNo,
+			vemData,
+			deductInfo->Amount,
+			deductInfo->IsUpload);
+
+
+
+	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");
+		}
+
+		sqlite3_close(deductDb);
+	}
+
+
+
+	return result;
+}

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

@@ -1,6 +1,6 @@
 #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);
@@ -11,4 +11,7 @@ int DB_Reboot_Record(void);
 int CreateEventRecord(void);
 int InsertEventRecord(uint8_t *statusCode);
 
+int DeductDB_Open(void);
+int InsertDeductInfo(uint8_t gunIndex, RecordTransactionInfo *deductInfo);
+
 #endif /* _DATA_BASE_H_ */

+ 66 - 30
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -891,15 +891,23 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
     ShmSelectGunInfo->PricesInfo[plugNum].UserPrices = transPricesUnit(ntohl(pAccountInfo->UserPrices));
     pDcChargingInfo->ChargingFee                     = transPricesUnit(ntohl(pAccountInfo->TotalCost));
     ShmSelectGunInfo->PricesInfo[plugNum].Balance    = transPricesUnit(ntohl(pAccountInfo->Balance));
+    ShmSelectGunInfo->PricesInfo[plugNum].Discount   = transPricesUnit(ntohl(pAccountInfo->Discount));
+    ShmSelectGunInfo->PricesInfo[plugNum].TransactionId = ntohl(pAccountInfo->Transaction);
 
     if ((pricesInfo[plugNum].UserPrices != ShmSelectGunInfo->PricesInfo[plugNum].UserPrices) ||
-            (pricesInfo[plugNum].Balance != ShmSelectGunInfo->PricesInfo[plugNum].Balance)) {
+            (pricesInfo[plugNum].Balance != ShmSelectGunInfo->PricesInfo[plugNum].Balance) ||
+			(pricesInfo[plugNum].Discount != ShmSelectGunInfo->PricesInfo[plugNum].Discount) ||
+			(pricesInfo[plugNum].TransactionId != ShmSelectGunInfo->PricesInfo[plugNum].TransactionId)) {
         pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
         pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
+        pricesInfo[plugNum].Discount = ShmSelectGunInfo->PricesInfo[plugNum].Discount;
+        pricesInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
 
-        log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
+        log_info("id = %d, transaction id = %d, user prices = %.2f, Discount = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
                  plugNum,
+				 ShmSelectGunInfo->PricesInfo[plugNum].TransactionId,
                  ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
+				 ShmSelectGunInfo->PricesInfo[plugNum].Discount,
                  pDcChargingInfo->ChargingFee,
                  ShmSelectGunInfo->PricesInfo[plugNum].Balance,
                  (uint8_t *)GetCurrency(pSysConfig->BillingData.Currency)
@@ -1305,6 +1313,9 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         break;
 
     case REG_DEDUCT_INFO:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
         break;
 
     default:
@@ -1426,30 +1437,41 @@ static int readChargerStationInfo(int fd)
     return ret;
 }
 
-static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex)
+static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactionInfo *transactionInfo)
 {
     int ret = PASS;
-    uint8_t dataBuf[6] = {0};
-    DeductInfoVar DeductInfo;
-
-    DeductInfo.Amount = ShmDcCommonData->finalcost[gunIndex];
-    DeductInfo.DeductResult = ShmDcCommonData->PayPass_flag[gunIndex];
-    DeductInfo.IsDonateInvoice = ShmDcCommonData->donate_flag[gunIndex];
-
-    dataBuf[0] = DeductInfo.DeductResult;
-    dataBuf[1] = DeductInfo.IsDonateInvoice;
-    dataBuf[2] = (DeductInfo.Amount >> 24) & 0xFF;
-    dataBuf[3] = (DeductInfo.Amount >> 16) & 0xFF;
-    dataBuf[4] = (DeductInfo.Amount >> 8) & 0xFF;
-    dataBuf[5] = (DeductInfo.Amount & 0xFF);
-
+    uint8_t dataBuf[22] = {0};
+    int i;
+
+    memset((char *)dataBuf, 0x00, sizeof(dataBuf));
+    dataBuf[0] = transactionInfo->DeductResult;
+    dataBuf[1] = transactionInfo->IsDonateInvoice;
+    dataBuf[2] = (transactionInfo->TransactionId >> 24) & 0xFF;
+    dataBuf[3] = (transactionInfo->TransactionId >> 16) & 0xFF;
+    dataBuf[4] = (transactionInfo->TransactionId >> 8) & 0xFF;
+    dataBuf[5] = (transactionInfo->TransactionId & 0xFF);
+
+    int amount = (int)(transactionInfo->Amount * 100);
+
+    dataBuf[6] = (amount >> 24) & 0xFF;
+    dataBuf[7] = (amount >> 16) & 0xFF;
+    dataBuf[8] = (amount >> 8) & 0xFF;
+    dataBuf[9] = (amount & 0xFF);
+    memcpy((char *)&dataBuf[10], transactionInfo->ApprovalNo,9);
+    /*
+    for(i=0;i<22;i++) {
+    	log_info("dataBuf[%d]:0x%x",i,dataBuf[i]);
+    }
+    */
+    log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f",
+    		gunIndex,transactionInfo->TransactionId,transactionInfo->DeductResult,transactionInfo->IsDonateInvoice,transactionInfo->Amount);
     // copy deduct result to dataBuf here
 
     if ((ret = composeSocketData(fd,
                                  id,
                                  OP_WRITE_DATA,
                                  REG_DEDUCT_INFO,
-                                 6,
+                                 22,
                                  &dataBuf[0])) == FAIL) {
         return ret;
     }
@@ -2026,12 +2048,13 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         case REG_CHARGING_CAP:
             if(gMoreInfoReq[plugNum].bits.FinalCostReq)
             {
-                readChargingCapability(fd, gunID);
-                gMoreInfoReq[plugNum].bits.FinalCostReq = false;
-                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
-                ShmDcCommonData->finalcost[plugNum] = (int)pDcChargingInfo->ChargingFee;
-                ShmDcCommonData->finalcost_flag[plugNum] = TRUE;
-                log_info("Gun %d get final cost", plugNum);
+                if (readChargingCapability(fd, gunID) == PASS) {
+					gMoreInfoReq[plugNum].bits.FinalCostReq = false;
+					pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
+					ShmDcCommonData->finalcost[plugNum] = pDcChargingInfo->ChargingFee;
+					ShmDcCommonData->finalcost_flag[plugNum] = TRUE;
+					log_info("Gun %d get final cost", plugNum);
+                }
             }
             curReg = REG_PLUG_IN_STATE;
             break;
@@ -2303,12 +2326,14 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
         }
         if(!DeductResultReq[plugNum] && pDcChargingInfo->SystemStatus == S_ALARM &&
-        		ShmDcCommonData->finalcost_flag[plugNum] == TRUE)
+        		ShmDcCommonData->PayFinish[plugNum] == TRUE)
         {
             DeductResultReq[plugNum] = YES;
             log_info("Write Gun %d Deduct Result", plugNum);
-            writeDeductInfo(fd, gunID,plugNum);
+            writeDeductInfo(fd, gunID,plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
             ShmDcCommonData->finalcost_flag[plugNum] = FALSE;
+            ShmDcCommonData->PayFinish[plugNum] = FALSE;
+            log_info("writeDeductInfo finish");
         }
         break;
 
@@ -2462,6 +2487,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             writePresentChargingInfo(fd, plugNum, gunID);
             ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
         }
+        if(!DeductResultReq[plugNum] &&
+				pDcChargingInfo->SystemStatus == S_TERMINATING &&
+				ShmDcCommonData->PayFinish[plugNum] == TRUE)
+		{
+			DeductResultReq[plugNum] = YES;
+			log_info("Write Gun %d Deduct Result", plugNum);
+			writeDeductInfo(fd, gunID,plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
+			ShmDcCommonData->finalcost_flag[plugNum] = FALSE;
+			ShmDcCommonData->PayFinish[plugNum] = FALSE;
+			log_info("writeDeductInfo finish");
+		}
         break;
 
     case S_COMPLETE:
@@ -2475,14 +2511,14 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
         }
         if(!DeductResultReq[plugNum] &&
-        		(pDcChargingInfo->SystemStatus == S_COMPLETE ||
-					pDcChargingInfo->SystemStatus == S_TERMINATING) &&
-        		ShmDcCommonData->finalcost_flag[plugNum] == TRUE)
+				ShmDcCommonData->PayFinish[plugNum] == TRUE)
         {
             DeductResultReq[plugNum] = YES;
             log_info("Write Gun %d Deduct Result", plugNum);
-            writeDeductInfo(fd, gunID,plugNum);
+            writeDeductInfo(fd, gunID,plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
             ShmDcCommonData->finalcost_flag[plugNum] = FALSE;
+            ShmDcCommonData->PayFinish[plugNum] = FALSE;
+            log_info("writeDeductInfo finish");
         }
         break;
 

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

@@ -151,7 +151,9 @@
 typedef struct StDeductInfoVar {
     unsigned char DeductResult;                     // 0: Fail, 1: Pass
     unsigned char IsDonateInvoice;                  // 0: Do not donate, 1: Donate
+    int TransactionId;								// transaction id
     int Amount;                                     // unit = 0.01 dollar
+    char ApprovalNumber[12];						// approval number
 } DeductInfoVar;
 
 /*
@@ -294,6 +296,8 @@ typedef struct StAccountInfo {
     int UserPrices;
     int TotalCost;
     int Balance;
+    int Discount;
+    int Transaction;
     uint8_t Reserved[3];
 } AccountInfo;
 

+ 61 - 42
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -20,6 +20,7 @@
 #include "../timeout.h"
 
 #define uSEC_VAL                                (1000000)
+
 //------------------------------------------------------------------------------
 //struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 //struct StatusCodeData           *ShmStatusCodeData;
@@ -204,6 +205,9 @@ void CheckReturnPress()
 	//pDcChargingInfo->SystemStatus = S_IDLE;
 	StopSystemTimeoutDet();
 	if ( pDcChargingInfo->SystemStatus == S_AUTHORIZING ) {
+		if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
+			pSysInfo->SystemPage = _PAGE_SELECT_PAY;
+		}
 		ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
 		ShmDcCommonData->PreAuth_Result = 0;
 		for(i=0;i<=30;i++) {
@@ -239,6 +243,7 @@ void CheckStopConfirmPress()
 	pDcChargingInfo->SystemStatus = S_TERMINATING;
 	pSysInfo->SystemPage = _PAGE_PAYING;
 	is_stop = FALSE;
+	ShmDcCommonData->StopCharge[pSysInfo->CurGunSelected] = TRUE;
 	StartGunInfoTimeoutDet(pSysInfo->CurGunSelected,Timeout_FinalCost);
 	/*
 	ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
@@ -322,18 +327,18 @@ void CheckTouchPress(short id)
 				log_info("LCM left Gun down...............................%x %x %x",
 						pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
 			}
-        	/*
-        	if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE) {
+
+        	if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
+        			pSysInfo->SystemPage == _PAGE_PAYFAIL) {
 				StopSystemTimeoutDet();
 				StartSystemTimeoutDet(Timeout_ReturnViewPage);
-        	}*/
+        	}
             break;
         case _Touch_Show_Right:
-        	if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
-				log_info("Authorize Page can't select gun");
-				return;
-			}
-
+        	if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_PLUGIN) {
+        		log_info("Authorize Process can't select gun");
+        		return;
+        	}
 			// Show log
 			if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
 				pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
@@ -344,14 +349,17 @@ void CheckTouchPress(short id)
 				log_info("LCM Right Gun down...............................%x %x %x",
 						pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
 			}
-			/*
-        	if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE) {
+
+        	if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
+        			pSysInfo->SystemPage == _PAGE_PAYFAIL) {
 				StopSystemTimeoutDet();
 				StartSystemTimeoutDet(Timeout_ReturnViewPage);
         	}
-        	*/
+
             break;
         case _Touch_Return:
+        	if (pSysInfo->SystemPage == _PAGE_AUTHORIZE)
+        		pSysInfo->SystemPage = _PAGE_SELECT_PAY;
         	CheckReturnPress();
         	break;
         case _Touch_IDLE:
@@ -465,6 +473,7 @@ void CheckLCMPressed()
     } // if pid
     log_info("Create LCM fork:%d",Pid);
 }
+
 void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
 {
     read(_port, msg, readLen);
@@ -691,7 +700,7 @@ void string2ByteArray(uint8_t *input, uint8_t *output)
 
 void RefreshProgressAnimation()
 {
-	_everyPageRollChange >= 20 ? _everyPageRollChange = 0 : _everyPageRollChange++;
+	_everyPageRollChange >= 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
 }
 
 //================================================
@@ -830,6 +839,35 @@ void ChangeRemainTime(int sec)
     DisplayValueToLcm(_Text_Time, cmd, sizeof(cmd));
 }
 */
+void ShowSelectGun()
+{
+	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
+	if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
+			pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
+		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS1);
+
+	} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
+			pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
+		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS2);
+
+	} else if (pDcChargingInfo->Type == _Type_Chademo) {
+		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CHAdeMo);
+
+	}
+	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
+	if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
+			pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
+		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS1);
+
+	} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
+			pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
+		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS2);
+
+	} else if (pDcChargingInfo->Type == _Type_Chademo) {
+		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CHAdeMo);
+
+	}
+}
 void ChangeChargingPowerValue(float pow)
 {
     uint8_t cmd[10];
@@ -861,7 +899,11 @@ void ChangeCarBonValue(float data)
     float _carbon = 0;
     memset(cmd, 0x00, sizeof(cmd));
     _carbon = (data*9)/10*2.36 - data*0.637;
-    sprintf((char *) value, "%d", (int)_carbon);
+    //log_info("Carbon:%d",(int)_carbon);
+    if (_carbon < 10)
+    	sprintf((char *) value, "%.1f", _carbon);
+    else
+    	sprintf((char *) value, "%d", (int)_carbon);
     string2ByteArray(value, cmd);
     DisplayValueToLcm(_String_Carbon, cmd, sizeof(cmd));
 }
@@ -1047,13 +1089,14 @@ void ProcessPageInfo()
 
             	break;
             case _PAGE_SELECT_PAY:
-            	if (ShmDcCommonData->donate_flag == TRUE) {
+            	if (ShmDcCommonData->donate_flag[i] == TRUE) {
             		ChangeDisplay2Value(_Icon_WordAddFriend,_ICON_Empty);
             	} else
             		ChangeDisplay2Value(_Icon_WordAddFriend,_TCC_SelectPayMode);
             	StartSystemTimeoutDet(Timeout_SelectPayMode);
             	break;
             case _PAGE_SELECT_GUN:
+            	ShowSelectGun();
             	ClearQR_flag[i] = FALSE;
 				break;
             case _PAGE_BILL:
@@ -1115,7 +1158,7 @@ void ProcessPageInfo()
                 	ChangeTimeValue(0);
                 }
                 ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
-                //StartSystemTimeoutDet(Timeout_ReturnViewPage);
+                StartSystemTimeoutDet(Timeout_ReturnViewPage);
                 break;
             case _PAGE_COMPLETE:
             case _PAGE_PAYFAIL:
@@ -1129,7 +1172,7 @@ void ProcessPageInfo()
                 if ( ShmDcCommonData->finalcost[i] >= 0 && ShmDcCommonData->finalcost_flag[i] == TRUE) {
                 	StopGunInfoTimeoutDet(i);
 					ChangeChargingFeeValue(ShmDcCommonData->finalcost[i]);
-					ShmDcCommonData->finalcost_flag[i] = FALSE;
+					//ShmDcCommonData->finalcost_flag[i] = FALSE;
                 }
                 ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy);
                 ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
@@ -1332,6 +1375,7 @@ void InformationShow()
     }
 }
 */
+
 void DefautLayOut()
 {
 	int i;
@@ -1344,32 +1388,7 @@ void DefautLayOut()
 	ChangeDisplay2Value(_Icon_CardPay,0);
 	ChangeDisplay2Value(0x5000,1);
 
-	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
-	if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
-			pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
-		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS1);
-
-	} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
-			pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
-		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS2);
-
-	} else if (pDcChargingInfo->Type == _Type_Chademo) {
-		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CHAdeMo);
-
-	}
-	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
-	if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
-			pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
-		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS1);
-
-	} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
-			pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
-		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS2);
-
-	} else if (pDcChargingInfo->Type == _Type_Chademo) {
-		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CHAdeMo);
-
-	}
+	ShowSelectGun();
 }
 /*
 static int InitialRfidPort(void)

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/SelectGun/SelectGun.h

@@ -60,6 +60,8 @@ typedef struct StPricesInfo {
     //float TotalCost;            //unit = 0.01 dollar, value / 100
     float Balance;              //unit = 0.01 dollar, value / 100
     //float DefaultPrices;        //unit = 0.01 dollar, value / 100
+    float Discount;
+    int TransactionId;
     uint8_t Reserved[4];
 } PricesInfo;
 

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