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

2022-02-07 / Simon Xue

Action:
1. Charge flow OK.
2. Credit Card Reader AuthPre, AuthComplete, AuthCancel OK.

Files
As the commit history files

Image Version: V2.01.XX.XXXX.XX
Simon Xue 3 жил өмнө
parent
commit
94c8f2d726
25 өөрчлөгдсөн 1163 нэмэгдсэн , 559 устгасан
  1. 74 14
      EVSE/Modularization/Module_Systex.c
  2. 2 0
      EVSE/Modularization/Module_Systex.h
  3. 70 55
      EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c
  4. 117 30
      EVSE/Projects/DD360Tcci/Apps/CSU/main.c
  5. 7 1
      EVSE/Projects/DD360Tcci/Apps/CSU/main.h
  6. 21 33
      EVSE/Projects/DD360Tcci/Apps/Config.h
  7. 69 60
      EVSE/Projects/DD360Tcci/Apps/Define/define.h
  8. 247 31
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c
  9. 31 2
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h
  10. 364 279
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c
  11. 155 54
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h
  12. 6 0
      EVSE/Projects/DD360Tcci/Apps/timeout.h
  13. BIN
      EVSE/Projects/DD360Tcci/Images/ramdisk.gz
  14. BIN
      EVSE/Projects/DD360Tcci/output/FactoryConfig
  15. BIN
      EVSE/Projects/DD360Tcci/output/Module_ChkSysTask
  16. BIN
      EVSE/Projects/DD360Tcci/output/Module_DoComm
  17. BIN
      EVSE/Projects/DD360Tcci/output/Module_EvComm
  18. BIN
      EVSE/Projects/DD360Tcci/output/Module_EventLogging
  19. BIN
      EVSE/Projects/DD360Tcci/output/Module_InternalComm
  20. BIN
      EVSE/Projects/DD360Tcci/output/Module_LcmControl
  21. BIN
      EVSE/Projects/DD360Tcci/output/Module_PrimaryComm
  22. BIN
      EVSE/Projects/DD360Tcci/output/Module_UpdateFW
  23. BIN
      EVSE/Projects/DD360Tcci/output/ReadCmdline
  24. BIN
      EVSE/Projects/DD360Tcci/output/main
  25. BIN
      EVSE/Projects/DD360Tcci/output/simulation

+ 74 - 14
EVSE/Modularization/Module_Systex.c

@@ -38,15 +38,18 @@ 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_Sale[] = {0x31, 0x31};	//消費交易 : 信用卡,票證,掃碼支付
 unsigned char TRANS_TYPE_Void[] = {0x30, 0x35};//取消交易 : 信用卡,
 unsigned char TRANS_TYPE_Refund[] = {0x31, 0x32};//退貨交易 : 信用卡,票證,掃碼支付
-
+//--------------信用卡預授權---------------
 unsigned char TRANS_TYPE_Pre_Auth[] = {0x31, 0x33};	//預授權交易 : 信用卡
 unsigned char TRANS_TYPE_Pre_Auth_Complete[] = {0x33, 0x31};	//預授權完成交易 : 信用卡 
 unsigned char TRANS_TYPE_Pre_Auth_Cancel[] = {0x33, 0x32};	//取消預授權交易 : 信用卡 
-
-unsigned char TRANS_TYPE_UnionSettlement[] = {0x35, 0x41};	//批次結帳請款
+//--------------連動結帳---------------
+unsigned char TRANS_TYPE_UnionSettlement[] = {0x35, 0x41};	//連動結帳請款
 
 
 //==================================
@@ -146,6 +149,7 @@ int SendRequest(int uart, unsigned char* cmd, int length)
 					else
 					{
 						DEBUG_INFO_1("SendRequest: not recv ACKACK(%x, %x)\n", SendBuffer[0],SendBuffer[1]);
+						read(uart, SendBuffer, RequestLength);
 						return -1;
 					}			
 				}
@@ -219,10 +223,10 @@ reRecv:
 					memcpy(tmpBuf,RecvBuffer+1,8 );
 					if((strstr(tmpBuf,"00000000")==NULL)&&(strstr(tmpBuf,"000000TD")==NULL))
 					{
+						DEBUG_INFO_1("RecvResponse: Response Code failed (%s)\n", tmpBuf);
 						memset(tmpBuf,0,sizeof(tmpBuf));
 						tmpBuf[0]=tmpBuf[1]=0x06;
 						Rtn=write(uart, tmpBuf, 2);
-						DEBUG_INFO_1("RecvResponse: Response Code failed (%s)\n", tmpBuf);
 						return -1;
 					}
 					memset(tmpBuf,0,sizeof(tmpBuf));
@@ -243,6 +247,65 @@ reRecv:
 	}
 }
 
+//==========================================
+// CreditCardSearch
+// Input :
+//		
+// Output :
+//==========================================
+int CreditCardSearch(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoReturn)
+{
+	unsigned char Buffer[RequestLength], *ptr, tmpbuf[12];
+	
+	memset(Buffer,0x20,RequestLength);
+	ptr=Buffer;
+	strncpy(ptr,HOST_ID_CreditCard,2);//Host ID
+	ptr+=2;
+	strncpy(ptr,TRANS_TYPE_Search,2);//Transaction type
+	ptr+=2;
+	/*memset(tmpbuf,0,sizeof(tmpbuf));
+	sprintf(tmpbuf,"%d", PreCost);
+	if(strlen(tmpbuf)>12)
+	{
+		DEBUG_INFO_1("CreditCardPreAuthCancel: Wrong PreCost (PreCost=%d)\n", PreCost);
+		return -1;
+	}	
+	memset(ptr,0x30,12);
+	strncpy(ptr+12-(strlen(tmpbuf)+2),tmpbuf,strlen(tmpbuf));//Trans Amount
+	*/
+	ptr+=12;//Trans Amount
+	//strncpy(ptr,ApprovalNo, strlen(ApprovalNo));
+	ptr+=12;//Approval No
+	//strncpy(ptr,CardNum, strlen(CardNum));
+	ptr+=20;//Card No
+	strncpy(ptr,EVSEID, strlen(EVSEID));
+	ptr+=18;//Store Id	
+	//ptr+=2;//Period
+	if(SendRequest(Fd, Buffer, RequestLength)>0)
+	{
+		memset(Buffer,0,RequestLength);
+		if(RecvResponse(Fd,Buffer)>0)
+		{
+			strncpy(TransInfoReturn->TransDate,Buffer+56,6);	
+			strncpy(TransInfoReturn->TransTime,Buffer+62,6);	
+			strncpy(TransInfoReturn->CardNo,Buffer+24,20);
+			return 1;
+		}	
+		else
+		{
+			DEBUG_INFO_1("CreditCardUnionSettlement: RecvResponse failed\n");
+			return -1;
+		}	
+	}	
+	else
+	{
+		DEBUG_INFO_1("CreditCardUnionSettlement: SendRequest failed\n");
+		return -1;
+	}	
+}
+
+
+
 //==========================================
 // CreditCardPreAuth
 // Input :
@@ -429,15 +492,12 @@ int CreditCardPreAuthCancel(int Fd, int PreCost,unsigned char *EVSEID, unsigned
 }
 
 //==========================================
-// CreditCardPreAuthCancel
+// CreditCardUnionSettlement
 // Input :
-//		PreCost : 預扣金額*100, e.g., $1234 = 123400, $1234.56=123456
-//		EVSEID: EVSE ID, max length is 18
-//		ApprovalNo: max length is 12
-//		CardNum :  max length is 20
+//		
 // Output :
 //==========================================
-int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID,struct TransInfo *TransInfoReturn)
+int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoReturn)
 {
 	unsigned char Buffer[RequestLength], *ptr, tmpbuf[12];
 	
@@ -548,19 +608,19 @@ int main(int argc, char *argv[])
 	
 	
 	sleep(20);
-	if(CreditCardPreAuthCancel(UartFd, 1000,"TCC EVSE", &ReturnTransInfo.ApprovalNo, &ReturnTransInfo.CardNo,&ReturnTransInfo.VemData)<=0)
+	/*if(CreditCardPreAuthCancel(UartFd, 1000,"TCC EVSE", &ReturnTransInfo.ApprovalNo, &ReturnTransInfo.CardNo,&ReturnTransInfo.VemData)<=0)
 	{
 		printf("CreditCardPreAuthCancel NG\n");
 		//return;
-	}	
-	/*
+	}	*/
+	
 	printf("CreditCardPreAuthComplete......\n");
 	 if(CreditCardPreAuthComplete(UartFd, 500,"TCC EVSE", &ReturnTransInfo.VemData, &ReturnTransInfo)<=0)
 	{
 		printf("CreditCardPreAuthComplete NG\n");
 		return;
 	}	
-	*/
+	
 	
 	sleep(15);
 	if(CreditCardUnionSettlement(UartFd,"TCC EVSE",&ReturnTransInfo)<=0)

+ 2 - 0
EVSE/Modularization/Module_Systex.h

@@ -61,8 +61,10 @@ struct TransInfo
 	unsigned char VemData[64];		//無人自助設備交易資訊 交易別31/32 (預授權完成/預授權取消) 必要欄位 資訊來源為交易別13 (預授權)的回傳
 };
 
+int CreditCardSearch(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoReturn);
 int CreditCardPreAuth(int Fd, int PreCost,unsigned char *EVSEID, struct TransInfo *TransInfoReturn);
 int CreditCardPreAuthComplete(int Fd, int PreCost,unsigned char *EVSEID, unsigned char *VemData,struct TransInfo *TransInfoReturn);
 int CreditCardPreAuthCancel(int Fd, int PreCost,unsigned char *EVSEID, unsigned char *ApprovalNo, unsigned char *CardNum,unsigned char *VemData);
 int CreditCardUnionSettlement(int Fd,unsigned char *EVSEID,struct TransInfo *TransInfoReturn);
+
 #endif

+ 70 - 55
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -13,7 +13,7 @@
 #include "../timeout.h"
 static DcCommonInfo *ShmDcCommonData = NULL;
 static struct SysInfoData *pSysInfo = NULL;
-#define PREAUTHMONEY 2000
+#define PREAUTHMONEY 2
 
 //------------------------------------------------------------------------------
 static char *rfidPortName = "/dev/ttyS2";
@@ -234,22 +234,16 @@ static void UserScanFunction(void)
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                    pDcChargingInfo->SystemStatus == S_AUTHORIZING) {*/
-    if (pSysInfo->SystemPage == _PAGE_AUTHORIZE && pDcChargingInfo->SystemStatus == S_IDLE) {
+    if ( (pSysInfo->SystemPage == _PAGE_AUTHORIZE ||
+    		pSysInfo->SystemPage == _PAGE_SENSING) &&
+    		pDcChargingInfo->SystemStatus == S_IDLE) {
             log_info("// LCM => Authorizing");
             confirmSelGun(pSysInfo->CurGunSelected);
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
             StartSystemTimeoutDet(Timeout_Authorizing);
-            if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) {
-            	if (ShmDcCommonData->PreAuth_Result > 0) {
-            		pDcChargingInfo->SystemStatus = S_AUTHORIZING;
-            		AuthorizingStart();
-            		ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
-            	} else if (ShmDcCommonData->PreAuth_Result < 0) {
-            		pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
-            		ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
-            		ShmDcCommonData->PreAuth_Result = 0;
-            	}
-            }
+
+			pDcChargingInfo->SystemStatus = S_AUTHORIZING;
+			AuthorizingStart();
 
             // LCM => Authorizing
             //pSysInfo->SystemPage = _PAGE_AUTHORIZE;
@@ -287,12 +281,12 @@ void AuthorizeToCharge()
             // 判斷後台回覆狀態
             if (canStartCharging()) {
             // LCM => Authorize complete
-            	pDcChargingInfo->SystemStatus = S_AUTHORIZING;
-                pSysInfo->SystemPage = _PAGE_PLUGIN;
-                log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
+            	//pDcChargingInfo->SystemStatus = S_AUTHORIZING;
+                //pSysInfo->SystemPage = _PAGE_PLUGIN;
+                //log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
                 DetectPluginStart();
-                log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
-                        ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
+                //log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
+                //        ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
             } else {
                 log_info("LCM => Authorize fail");
                 //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
@@ -310,7 +304,7 @@ void ScannerCardProcess(void)
     struct ChargingInfoData *pDcChargingInfo = NULL;
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
 
-    if (!isDetectPlugin() && pSysInfo->SystemPage == _PAGE_AUTHORIZE &&
+    if (!isDetectPlugin() && pSysInfo->SystemPage == _PAGE_SENSING &&
     		pDcChargingInfo->SystemStatus == S_IDLE &&
             pSysWarning->Level != WARN_LV_ER /*&&
             pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
@@ -320,7 +314,7 @@ void ScannerCardProcess(void)
         UserScanFunction();
     }
 
-    if (pDcChargingInfo->SystemStatus == S_AUTHORIZING && pSysInfo->SystemPage == _PAGE_AUTHORIZE ) {
+    if (pDcChargingInfo->SystemStatus == S_AUTHORIZING && pSysInfo->SystemPage == _PAGE_SENSING ) {
         AuthorizeToCharge();
     } else if (pSysInfo->SystemPage == _PAGE_AUTHORIZE_FAIL) {
         StartSystemTimeoutDet(Timeout_VerifyFail);
@@ -341,7 +335,7 @@ static int InitialRfidPort(void)
 
     if (fd != FAIL) {
         ioctl (fd, TCGETS, &tios);
-        tios.c_cflag = B19200 | CS8 | CLOCAL | CREAD;
+        tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
         tios.c_lflag = 0;
         tios.c_iflag = 0;
         tios.c_oflag = 0;
@@ -377,14 +371,15 @@ void CreateRfidFork(void)
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
         //log_info("RFID fork Child's PID is %d", getpid());
-        int result = 0;
+        int result;
         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 && result == 0) {
+            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");
@@ -392,39 +387,59 @@ void CreateRfidFork(void)
 				} else
 					log_info("CreditCardUnionSettlement FAIL");
 			}
-            if (ShmDcCommonData->PreAuth_Result != 0 && ShmDcCommonData->PreAuth_Config != _CREDITCARD_IDLE)
-            	continue;
-
-            switch(ShmDcCommonData->PreAuth_Config) {
-            case _CREDITCARD_IDLE:
-            	ShmDcCommonData->PreAuth_Result = 0;
-            	break;
-            case _CREDITCARD_PREAUTH:
-				ShmDcCommonData->PreAuth_Result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
-				ShmDcCommonData->PreAuth_Result = 1;
-				if (ShmDcCommonData->PreAuth_Result > 0 ) {
-					//strncpy((char *)pSysConfig->UserId, (char *)ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
-					strcpy((char *)pSysConfig->UserId,"Ph Test");
-					log_info("Credit Card Pass card number:%s",ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo);
 
-				} else if (ShmDcCommonData->PreAuth_Result < 0) {
-					log_info("Credit Card Fail");
+            if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
+            	//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);
+            	} 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);
+
+				} 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;
+					/*
+					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;
 				}
 
-            	break;
-            case _CREDITCARD_PREAUTHCOMPLETE:
-            	ShmDcCommonData->PreAuth_Result = CreditCardPreAuthComplete(fd, ShmDcCommonData->finalcost[pSysInfo->CurGunSelected] ,"TCC Test",
-            	            			&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0],
-            							&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
-            	if (ShmDcCommonData->PreAuth_Result > 0 ) {
-            		log_info("Credit Card Spend Money:%d",ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]);
-            	} else {
-            		log_info("PAYING FAIL");
-            	}
-            	pSysInfo->SystemPage = _PAGE_COMPLETE;
-            	break;
-            case _CREDITCARD_CANCEL:
+            }
+
+            if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
             	ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test",
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo[0],
@@ -433,12 +448,12 @@ void CreateRfidFork(void)
 				if (ShmDcCommonData->PreAuth_Result > 0 ) {
 					strcpy((char *)pSysConfig->UserId,"");
 					log_info("Card Reader Stop");
-
+					memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
 				} else if (ShmDcCommonData->PreAuth_Result < 0) {
 					log_info("Car Reader Stop Fail");
-				}
 
-            	break;
+				}
+				ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
             }
             /*
             // 刷卡判斷

+ 117 - 30
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -81,8 +81,8 @@ uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "V2.00.00.0000.00"; // Phihong version
-char* DebugVersion = "v2.00.00";      // Software debug version
+char *fwVersion = "V2.01.00.0000.00"; // Phihong version
+char* DebugVersion = "v2.01.00";      // Software debug version
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -809,9 +809,7 @@ void CheckHwSlotStatusLog(uint8_t index)
 //=================================
 void ChangeLcmByIndex(uint8_t page_index)
 {
-    if (pSysWarning->Level != WARN_LV_ER ||
-            page_index == _PAGE_REFUND_COMPLETE ||
-            page_index == _PAGE_ERROR
+    if (pSysWarning->Level != WARN_LV_ER
        ) {
         pSysInfo->PageIndex = page_index;
         //log_info("LCM index:%d",pSysInfo->PageIndex);
@@ -1471,7 +1469,9 @@ void _AutoReturnTimeout(void)
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
         pDcChargingInfo->SystemStatus = S_ALARM;
         //pSysInfo->SystemPage = _LCM_ERROR;
-        pSysInfo->SystemPage = _PAGE_COMPLETE;
+        pSysInfo->SystemPage = _PAGE_PLUGOUT;
+        //pSysInfo->SystemPage = _PAGE_PAYING;
+        //StartGunInfoTimeoutDet(pSysInfo->CurGunSelected,Timeout_FinalCost);
         ClearDetectPluginFlag();
     }
 }
@@ -1506,10 +1506,21 @@ void _AuthorizedTimeout(void)
 
 void _DetectPlugInTimeout(uint8_t gunIndex)
 {
+	int i;
     log_info("*********** _DetectPlugInTimeout *********** ");
     strcpy((char *)pSysConfig->UserId, "");
     //StopSystemTimeoutDet();
     StopGunInfoTimeoutDet(gunIndex);
+
+	ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
+	ShmDcCommonData->PreAuth_Result = 0;
+	for(i=0;i<=30;i++) {
+		if(ShmDcCommonData->PreAuth_Result != 0)
+			break;
+		sleep(1);
+	}
+	ShmDcCommonData->PreAuth_Result = 0;
+
     if (pSysInfo->CurGunSelected == gunIndex)
     	pSysInfo->SystemPage = _PAGE_IDLE;
     ClearDetectPluginFlag();
@@ -2563,6 +2574,14 @@ void CreateTimeoutFork(void)
                     pSysInfo->SystemPage = _PAGE_SELECT_GUN;
                 }
                 break;
+            case Timeout_ScanCard:
+				if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_SCANCARD_TIMEOUT) {
+					strcpy((char *)pSysConfig->UserId, "");
+					ClearAuthorizedFlag();
+					StopSystemTimeoutDet();
+					pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+				}
+				break;
             case Timeout_Terminating:
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TERMINATING_TIMEOUT) {
                     StopSystemTimeoutDet();
@@ -2571,8 +2590,27 @@ void CreateTimeoutFork(void)
                     setChargerMode(pSysInfo->CurGunSelected, S_COMPLETE);
                 }
                 break;
+            case Timeout_AddLine:
+            	if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_ADDLINE_TIMEOUT) {
+            		StopSystemTimeoutDet();
+            		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+            	}
+            	break;
 
+            case Timeout_DonateComfirm:
+            	if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_DONATECOMFIRM_TIMEOUT) {
+            		StopSystemTimeoutDet();
+            		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+            	}
+            	break;
+            case Timeout_SelectPayMode:
+            	if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= TCC_SELECTPAY_TIMEOUT) {
+            		StopSystemTimeoutDet();
+            		pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+            	}
+            	break;
             }
+
             // 各槍
             for (uint8_t gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
                 pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
@@ -2646,7 +2684,22 @@ void CreateTimeoutFork(void)
                         systemPageRestoreInit();
                     }
                     break;
-
+                case Timeout_FinalCost:
+                	if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= TCC_FINALCOST_TIMEOUT) {
+                		StopGunInfoTimeoutDet(gunIndex);
+                		if (ShmDcCommonData->finalcost_flag[gunIndex] == FALSE) {
+                			ShmDcCommonData->finalcost[gunIndex] = pDcChargingInfo->PresentChargedEnergy * ShmDcCommonData->ChargingRate;
+                			ShmDcCommonData->finalcost_flag[gunIndex] = TRUE;
+                		}
+                	}
+                	break;
+                case Timeout_LineReigster:
+                	if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= TCC_LINEREGISTER_TIMEOUT) {
+                		StopGunInfoTimeoutDet(gunIndex);
+                		pSysInfo->SystemPage = _PAGE_SELECT_PAY;
+                		ShmDcCommonData->donate_flag[gunIndex] = TRUE;
+                	}
+                	break;
                     /*
                 case Timeout_SelectGun: //Jerry add
                     if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
@@ -3707,7 +3760,7 @@ static void checkPileEndGfdResult(uint8_t gunIndex, uint8_t gunType, uint8_t sys
             ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSGfdWarning = NO;
         } else if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
             // GFD 警告
-            //RecordAlarmCode(gunIndex, "012297");
+            RecordAlarmCode(gunIndex, "012297");
             ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSGfdTrip = NO;
             ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSGfdWarning = YES;
         }
@@ -3791,6 +3844,10 @@ void ResetIdleData(uint8_t gunIndex)
     //Jerry add
     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
     memset(&ShmDcCommonData->pCreditCard[gunIndex], 0, sizeof(TransInfo));
+    ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
+    ShmDcCommonData->finalcost[gunIndex] = 0;
+    ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
+    ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] = FALSE;
 
     ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
     destroySelGun(gunIndex);
@@ -3809,14 +3866,16 @@ void CheckErrorCode(uint8_t gunIndex)
 
     if (gunIndex == pSysInfo->CurGunSelected) {
         pSysInfo->SystemPage = _PAGE_MAINTAIN;
-        if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton)
-            pSysInfo->SystemPage = _PAGE_ERROR;
+
     } else if (pSelectedDcChargingInfo->SystemStatus != S_IDLE &&
             pSelectedDcChargingInfo->SystemStatus != S_RESERVATION &&
             pSelectedDcChargingInfo->SystemStatus != S_MAINTAIN &&
             pSelectedDcChargingInfo->SystemStatus != S_FAULT) {
         if (pSelectedDcChargingInfo->SystemStatus == S_CHARGING) {
-            pSysInfo->SystemPage = _PAGE_COMPLETE;
+        	if(ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == FALSE)
+        		pSysInfo->SystemPage = _PAGE_PAYING;
+        	else
+        		pSysInfo->SystemPage = _PAGE_COMPLETE;
         } else {
             systemPageRestoreInit();
         }
@@ -4091,10 +4150,22 @@ int main(void)
                 }
 
                 // 讀卡邏輯
-                //ScannerCardProcess();
-                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_IDLE) {
+                ScannerCardProcess();
+                if (pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
+                	ShmDcCommonData->LineStatus[gunIndex] = 0;
                 	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) {
+                		StartGunInfoTimeoutDet(gunIndex, Timeout_LineReigster);
+                		if (ShmDcCommonData->LineStatus[gunIndex] == 3 || ShmDcCommonData->LineStatus[gunIndex] == 4 )
+                			pSysInfo->SystemPage =_PAGE_SELECT_PAY;
+                	}
+                }
                 goto CheckStatus;
                 break;
             case S_RESERVATION:
@@ -4124,8 +4195,6 @@ CheckStatus:
                 if (pSysWarning->Level == WARN_LV_ER) {
                     CheckErrorCode(gunIndex);
                     pSysInfo->SystemPage = _PAGE_MAINTAIN;
-                    if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton)
-                        pSysInfo->SystemPage = _PAGE_ERROR;
                     continue;
                 }
                 if (PrecheckIsPass(gunIndex) == false) {
@@ -4141,22 +4210,18 @@ CheckStatus:
                     systemPageRestoreInit();
                     setChargerMode(gunIndex, MODE_IDLE);
                 }
-                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_SELECT_GUN) {
-					pSysInfo->SystemPage = _PAGE_IDLE;
-				}
                 break;
 
             case S_AUTHORIZING:
                 if (isModeChange(gunIndex)) {
                     log_info("============================= S_AUTHORIZING(%x) ============================= ", gunIndex);
                     StartSystemTimeoutDet(Timeout_AuthorizingForStop);
-                    pDcChargingInfo->Replug_flag = TRUE;
                 }
-
 				ScannerCardProcess();
                 // 隨插即充
                 //autoStartCharging(gunIndex);
                 if (pSysInfo->SystemPage == _PAGE_PLUGIN) {
+                	pDcChargingInfo->Replug_flag = TRUE;
                 	StopSystemTimeoutDet();
                 	StartGunInfoTimeoutDet(gunIndex,Timeout_WaitPlug);
                 }
@@ -4182,6 +4247,7 @@ CheckStatus:
                         if (pDcChargingInfo->ConnectorPlugIn == YES &&
                                 pDcChargingInfo->IsAvailable &&
                                 pDcChargingInfo->SystemStatus == S_AUTHORIZING &&
+								ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] == TRUE &&
                                 //waitSelectGunPlugIt(gunIndex)
                                 (waitRightGunPlugIt(gunIndex) == PASS ||
                                  waitLeftGunPlugIt(gunIndex) == PASS)
@@ -4215,7 +4281,7 @@ CheckStatus:
                     if (pSysInfo->OrderCharging != NO_DEFINE) {
                         pSysInfo->OrderCharging = NO_DEFINE;
                         pDcChargingInfo->_SaftyDetect = FALSE;
-
+                        pDcChargingInfo->Replug_flag = TRUE;
                     }
                     StopSystemTimeoutDet();
                     StopGunInfoTimeoutDet(gunIndex);
@@ -4376,6 +4442,7 @@ CheckStatus:
                     strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].ResponseIdTagInfo.Status, ""); //DS60-120 add
                     ChangeStartOrStopDateTime(YES, gunIndex);
                     pDcChargingInfo->Replug_flag = FALSE;
+                    ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
                 }
 
                 if (ShmOCPP16Data->CpMsg.bits[gunIndex].StartTransactionConf) {
@@ -4394,7 +4461,7 @@ CheckStatus:
                 		pSysInfo->SystemPage == _PAGE_STOP_CONFIRM_RIGHT)
                 	break;
                 // LCM => Charging
-                if (pSysInfo->CurGunSelected == gunIndex) {
+                if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_IDLE) {
                     pSysInfo->SystemPage = _PAGE_CHARGING;
                 }
                 break;
@@ -4436,7 +4503,10 @@ CheckStatus:
 					break;
                 }
                 if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_PAYING) {
-                    pSysInfo->SystemPage = _PAGE_COMPLETE;
+                	if (ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == TRUE)
+                		pSysInfo->SystemPage = _PAGE_COMPLETE;
+                	else
+                		pSysInfo->SystemPage = _PAGE_PAYFAIL;
                 }
                 break;
 
@@ -4445,6 +4515,7 @@ CheckStatus:
                     log_info ("============================= S_COMPLETE(%x) ============================= ", gunIndex);
                     if (strcmp((char *)pDcChargingInfo->StartDateTime, "") != EQUAL) {
                         OcppStopTransation(gunIndex);
+
                     }
                     TheEndCharging(gunIndex);
                     StopSystemTimeoutDet();
@@ -4463,8 +4534,12 @@ CheckStatus:
                     }
                 }
 
-                if (pSysInfo->CurGunSelected == gunIndex) {
-					pSysInfo->SystemPage = _PAGE_COMPLETE;
+                if (pSysInfo->CurGunSelected == gunIndex &&
+                		pSysInfo->SystemPage != _PAGE_PAYING) {
+                	if (ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == TRUE)
+						pSysInfo->SystemPage = _PAGE_COMPLETE;
+					else
+						pSysInfo->SystemPage = _PAGE_PAYFAIL;
                 }
 
                 break;
@@ -4481,12 +4556,19 @@ CheckStatus:
                     }
                     TheEndCharging(gunIndex);
                     StopGunInfoTimeoutDet(gunIndex);
+                    if (pDcChargingInfo->Replug_flag == TRUE) {
+                		ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
+                		ShmDcCommonData->PreAuth_Result = 0;
+                    } else {
+						if(ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == FALSE) {
+							pSysInfo->SystemPage = _PAGE_PAYING;
+						}
+                    }
                 }
 
                 if (pSysWarning->Level == WARN_LV_ER) {
 					pSysInfo->SystemPage = _PAGE_MAINTAIN;
-					if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton)
-						pSysInfo->SystemPage = _PAGE_ERROR;
+
 					continue;
 				}
                 if (pDcChargingInfo->ConnectorPlugIn == NO ) {
@@ -4503,11 +4585,16 @@ CheckStatus:
                 if (pSysInfo->SystemPage == _PAGE_PAYING)
                 	break;
 
-                if (pSysInfo->CurGunSelected == gunIndex) {
+                if (pSysInfo->CurGunSelected == gunIndex &&
+                		pSysInfo->SystemPage != _PAGE_PAYING) {
                 	if (pDcChargingInfo->Replug_flag == TRUE)
                 		pSysInfo->SystemPage = _PAGE_PLUGOUT;
-                	else
-                		pSysInfo->SystemPage = _PAGE_COMPLETE;
+                	else {
+                		if (ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] == TRUE)
+							pSysInfo->SystemPage = _PAGE_COMPLETE;
+						else
+							pSysInfo->SystemPage = _PAGE_PAYFAIL;
+                	}
 				}
                 break;
             case S_MAINTAIN:

+ 7 - 1
EVSE/Projects/DD360Tcci/Apps/CSU/main.h

@@ -28,7 +28,7 @@
 #define uSEC_VAL                                (1000000)
 #define SELFTEST_TIMEOUT                        (60)//45
 #define RETURN_VIEWPAGE_TIMEOUT                 (30)
-#define AUTHORIZE_TIMEOUT                       (30)//30
+#define AUTHORIZE_TIMEOUT                       (60)//30
 #define BALANCE_TIMEOUT                         (15)//15
 #define AUTHORIZE_FAIL_TIMEOUT                  (5)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
@@ -46,6 +46,12 @@
 #define WHILE_LOOP_TIME                         (10000)
 #define PRECHARGING_TTIMEOUT                    (60)
 #define PLUGOUTGUN_TIMEOUT                      (30)
+#define TCC_ADDLINE_TIMEOUT						(60)
+#define TCC_LINEREGISTER_TIMEOUT				(60)
+#define TCC_DONATECOMFIRM_TIMEOUT				(180)
+#define TCC_SELECTPAY_TIMEOUT					(180)
+#define TCC_FINALCOST_TIMEOUT					(30)
+#define TCC_SCANCARD_TIMEOUT					(60)
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 21 - 33
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -147,38 +147,26 @@ enum _PAGE_TCC_INDEX {
 	// Face 1
     _PAGE_NONE                   = 0x00,
     _PAGE_IDLE,
+	_PAGE_SELECT_GUN,
+	_PAGE_BILL,
+	_PAGE_ADD_FRIEND,
+	_PAGE_DONATE_LEFT,
+	_PAGE_SELECT_PAY,
     _PAGE_AUTHORIZE,
+	_PAGE_SENSING,
     _PAGE_PLUGIN,
     _PAGE_PRECHARGE,
     _PAGE_CHARGING,
+	_PAGE_STOP_CONFIRM_LEFT,
+	_PAGE_PAYING,
     _PAGE_COMPLETE,
-	_PAGE_PLUGOUT,
 	_PAGE_EXIT,
+	_PAGE_PLUGOUT,
 	_PAGE_AUTHORIZE_FAIL,
-	_PAGE_SELECT_GUN,
-	_PAGE_PAYING,
-	_PAGE_STOP_CONFIRM_LEFT = 13,
+	_PAGE_DONATE_RIGHT,
 	_PAGE_STOP_CONFIRM_RIGHT,
-	_PAGE_SENSING,
-	// Face 2
-    _PAGE_FUNCTION_SELECT,
-    _PAGE_REFUND_SENSEING,
-    _PAGE_REFUNDING,
-    _PAGE_REFUND_COMPLETE,
-    _PAGE_REFUND_NONE,
-    _PAGE_MEMBER_SELECT,
-    _PAGE_MEMBER_QR,
-    _PAGE_DONATE,
-    _PAGE_DONATE_SELECT,
-    _PAGE_PAY_SENSING,
-    _PAGE_PAY_ETICKET_SUCCESS,
-    _PAGE_PAY_MPAY_SUCCESS,
-    _PAGE_PAY_FAIL,
+	_PAGE_PAYFAIL,
     _PAGE_MAINTAIN = 30,
-    _PAGE_ERROR,
-
-    __SHOW_CABIENT_VERSION,
-    __SHOW_DISPENSER_VERASION,
 };
 enum _SELF_TEST_SEQ {
     _STEST_VERSION      = 0x00,
@@ -461,24 +449,24 @@ typedef struct StDcCommonInfo {
     // PSU Version
     uint8_t PSU_Number;
     PsuVerInfo PsuVer[12];
-    // Touch press
-    uint8_t TouchId;
-    // TCC Using
-    uint8_t _ChangeLCMRequest;
-    uint8_t _RefundRequest;
-    uint8_t _RefundCancel;
-    uint8_t _InvoiceRequest;
-    // TCC Payment fail
-    int                 PaymentFailId;
-    unsigned char       PaymentFailString[32];
+
 
     int WeatherID;
     float Temperature;
+    int Location;
     char PresentTime[128];
     TransInfo pCreditCard[2];
+    int runningcost[2];
     int finalcost[2];
+    unsigned int finalcost_flag[2];
+    float ChargingRate;
     int PreAuth_Config;
     int PreAuth_Result;
+    int LineStatus[2];
+    int donate_flag[2];
+    int ConnectorID[2];
+    unsigned int AuthPass_flag[2];
+    unsigned int PayPass_flag[2];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 69 - 60
EVSE/Projects/DD360Tcci/Apps/Define/define.h

@@ -186,6 +186,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmLedBdKey				1011
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
+#define ShmYesCustomKey         1014
 
 #define FaultCodeLength         5
 #define AlarmCodeLength         20
@@ -323,6 +324,8 @@ enum CoreProfile {
      FreeVend,
      OcppServer,
      MaintainServer,
+     StatusNotificationPeriodically,
+     StatusNotificationInterval,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -464,7 +467,9 @@ typedef union
         unsigned int HardResetStop:1;               // 0: no effect,    1: hard reset stop
         unsigned int SoftResetStop:1;               // 0: no effect,    1: soft reset stop
         unsigned int InvalidIdStop:1;               // 0: no effect,    1: invalid stop when StopTransactionOnInvalidId is true
-        unsigned int res:25;
+        unsigned int RemoteStop:1;                  // 0: no effect,    1: remote stop
+        unsigned int UnlockStop:1;                  // 0: no effect,    1: unlock stop
+        unsigned int res:23;
     }bits;
 }ChargingStop;
 
@@ -672,24 +677,8 @@ struct ChargingInfoData
     unsigned char       Replug_flag;
     unsigned char       isEVCCIDVerify;
     unsigned char       CCSGunType;
-    //Reservation
-    int                 ReservationTrigger;
-    // TCC
     struct timeval      PreChargeTimer;
     unsigned char       _SaftyDetect;
-    // TCC Change LCM Page
-    int                 ChangeLcmPage;
-    // TCC Refund
-    unsigned char       RefundDate[32];
-    float               Prepayment;
-    float               ActualCost;
-    float               RefundAmount;
-    // TCC Prepayment
-    unsigned char       CardType;                       // EasyCard or i-pass or icash
-    float               TopupMoney;
-    float               AccountAmount;
-    float               Balance;
-
 };
 
 typedef struct
@@ -715,26 +704,12 @@ typedef union
         unsigned int MiscNeedAnnouncement:1;            // 0: no need,      1: need send misc command
         unsigned int NeedDispenserVerInfo:1;            // 0: no need,      1: need dispenser to report it's version info
         unsigned int AuthorizeRequest:1;                // 0: idle,         1: requesting                           ( dispenser -> cabinet)
-        unsigned int ConnectorTimeoutConfigRequest:1;   // 0: no request,   1: connector timeout setting            (    ocpp   -> cabinet -> dispenser)
-        unsigned int DefaultPriceConfigRequest:1;       // 0: no request,   1: default price setting                (    ocpp   -> cabinet -> dispenser)
-        unsigned int CurrencyConfigRequest:1;           // 0: no request,   1: currency setting                     (    ocpp   -> cabinet -> dispenser)
-        unsigned int HardwareRebootRequest:1;           // 0: no request,   1: hardware reboot request              (    ocpp   -> cabinet -> dispenser)
         unsigned int HardwareRebootConfirm:1;           // 0: no effect,    1: dispenser confirmed
-        unsigned int SoftwareResetRequest:1;            // 0: no request,   1: software reset request               (    ocpp   -> cabinet -> dispenser)
         unsigned int SoftwareResetConfirm:1;            // 0: no effect,    1: dispenser confirmed
         unsigned int FirmwareUpdateRequest:1;           // firmware update request
         unsigned int FirmwareUpdateConfirm:1;           // firmware update start
         unsigned int FirmwareUpdateCompleted:1;         // firmware update completed
-        unsigned int BackendStatusRequest:1;            // 0: no request,   1: backend connection status has changed            ( cabinet -> dispenser)
-        unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
-        unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
-        unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
-        unsigned int BillingStatusRequest:1;            // 0: no request,   1: billing status has changed                       ( cabinet -> dispenser)
-        unsigned int StopButtonStatusRequest:1;         // 0: no request,   1: stop charging button status has changed          ( cabinet -> dispenser)
-        unsigned int AuthModeConfigRequest:1;           // 0: no request,   1: AuthMode Config has changed                      ( cabinet -> dispenser)
-        unsigned int EVCCIDConfigRequest:1;             // 0: no request,   1: EVCCID Config has changed                        ( cabinet -> dispenser)
-        unsigned int LEDIntensityRequest:1;             // 0: no request,   1: LED Intensity has changed                        ( cabinet -> dispenser)
-        unsigned int res:7;
+        unsigned int res:21;
     }bits;
 }DispenserSettingFlag;
 
@@ -810,10 +785,6 @@ struct DispenserInfoData
     }CheckInLog;                                                        // record dispenser checkin status
     unsigned char               ConnectorLog[GENERAL_GUN_QUANTITY];     // record connector quantity of dispenser
     struct ConnectionInfoData   ConnectionInfo[GENERAL_GUN_QUANTITY];
-
-    unsigned short      ConnectorTimeout;           // connector plug in timeout, unit 1s
-    unsigned int        DefaultPrice;               // dispenser default price, unit: 0.01 (dollar/kWh)
-    unsigned char       Currency;                   // dispenser currency index
 };
 
 struct WARNING_CODE_INFO
@@ -831,16 +802,11 @@ typedef union
     struct
     {
         unsigned int  PermissionRequest:1;              // 0: no request,    1: dispenser request to charging                   ( dispenser -> cabinet)
-        unsigned int  RemoteStartRequest:1;             // 0: no request,    1: remote start                                    (    ocpp   -> cabinet -> dispenser)
         unsigned int  RemoteStartConfirm:1;
-        unsigned int  RemoteStopRequest:1;              // 0: no request,    1: remote stop                                     (    ocpp   -> cabinet -> dispenser)
         unsigned int  RemoteStopConfirm:1;
-        unsigned int  UnlockStopRequest:1;              // 0: no request,    1: Unlock stop                                     (    ocpp   -> cabinet -> dispenser)
         unsigned int  UnlockStopConfirm:1;
         unsigned int  TimeoutStopRequest:1;             // 0: no request,    1: ethernet timeout stop                           ( dispenser -> cabinet)
         unsigned int  PsuReleasable:1;
-        unsigned int  AvailabilityRequest:1;            // 0: no request,    1: change availability                             (    ocpp   -> cabinet -> dispenser)
-        unsigned int  AccountBalanceRequest:1;          // 0: no request,    1: set account balance                             (    ocpp   -> cabinet -> dispenser)
         unsigned int  AnnounceBalance:1;                //
         unsigned int  StartWaitPlug:1;                  //
         unsigned int  NeedCleanAuthorizeInfo:1;         //
@@ -853,7 +819,7 @@ typedef union
         unsigned int  Disconnection:1;
         unsigned int  GfdDetection:1;                   // 0: stop,         1: start
         unsigned int  GetStartChargingSoc:1;            // 0: no effect,    1: get start soc
-        unsigned int  res:8;
+        unsigned int  res:13;
     }bits;
 }ConnectorParameter;
 
@@ -893,6 +859,7 @@ struct ConnectorInfoData
     unsigned int            UserPrice;                      // connector user's user price, unit: 0.01 (dollar / kWh)
     unsigned int            TotalCost;                      // connector user's total cost, unit: 0.01 dollar
     int                     AccountBalance;                 // connector user's account balance, unit: 0.01 dollar
+    int                     CostDiscount;                   // connector user's account balance, unit: 0.01 dollar
 };
 
 typedef union
@@ -908,23 +875,6 @@ typedef union
     }bits;
 }CabinetSettingFlag;
 
-typedef struct
-{
-    unsigned int ConnectionTimeout;             // unit: 1s
-    unsigned int DefaultPrice;                  // unit: 0.01dollar
-    unsigned int Currency;                      // currency index
-    unsigned int BackendStatus;                 // 0: disable, 1: connected, 2: disconnected
-    unsigned int EthernetStatus;                // 0: disable, 1: connected, 2: disconnected
-    unsigned int WiFiStatus;                    // 0: disable, 1: connected, 2: disconnected
-    unsigned int TelcomModemStatus;             // 0: disable, 1: connected, 2: disconnected
-    unsigned int BillingStatus;                 // 0: disable, 1: enable
-    unsigned int StopChargingButton;            // 0: disable, 1: enable
-    unsigned int HardwareReboot;                // 1: HardwareReboot, Other value: no effect
-    unsigned int SoftwareRestart;               // 1: SoftwareRestart, Other value: no effect
-    unsigned int AuthModeConfig;                // 0: enable,  1: disable
-    unsigned int EVCCIDConfig;                  // 0: disable, 1: enable
-}CabinetMiscCommand;
-
 typedef struct DC_METER_INFO
 {
     double presetVoltage;                       // resolution: 1.000v
@@ -1027,7 +977,6 @@ struct SysInfoData
     unsigned char           AuthorizedType;             // record authorized type
     unsigned char           AuthorizedStatus;           // cabinet authorized status
     CabinetSettingFlag      CabinetSetting;
-    CabinetMiscCommand      CabinetMicsStatus;
     struct LocalSharingInfo localSharingInfo;           // Local power sharing info structure
     DC_Meter_Info DcMeterInfo[4];
     unsigned char           OTPTemp;                    // OTP Temperature
@@ -4614,6 +4563,65 @@ struct StructSessionTarget
     unsigned short      targetDuration;     // Unit: Minutes    0 is unlimit
 };
 
+//===================================
+// YES custom protocol
+//===================================
+struct StructRefundStatus
+{
+    unsigned char status[10];
+    unsigned char chargeDate[32];
+    int holdAmt;
+    int chargeAmt;
+    int refundAmt;
+    int page;
+};
+
+struct StructDeductStatus
+{
+    unsigned char status[10];
+    int autoLoadAmt;
+    int beforeAmt;
+    int chargeAmt;
+    int afterAmt;
+    int page;
+};
+
+struct StructChargerInfo
+{
+    unsigned char station_name[64];
+    unsigned char station_id[64];
+    unsigned char charge_id[4][64];
+};
+
+struct StructWeatherInfo
+{
+    int   weatherId;
+    float temperature;
+};
+
+struct StructYesCustomData
+{
+    struct StructRefundStatus RefundStatus;
+    struct StructDeductStatus DeductStatus;
+    struct StructChargerInfo ChargerInfo;
+    struct StructWeatherInfo WeatherInfo;
+    unsigned char QrCode[4][128];
+    unsigned char CallReaderStatus[10];
+
+    unsigned char CallReaderReq:1;
+    unsigned char CallReaderConf:1;
+    unsigned char RefundStatusReq:1;
+    unsigned char RefundStatusConf:1;
+    unsigned char DeductStatusReq:1;
+    unsigned char DeductStatusConf:1;
+    unsigned char ChargerInfoReq:1;
+    unsigned char ChargerInfoConf:1;
+    unsigned char WeatherInfoReq:1;
+    unsigned char WeatherInfoConf:1;
+    unsigned char SetQrCodeReq:1;
+    unsigned char SetQrCodeConf:1;
+};
+
 struct OCPP16Data
 {
     unsigned char                           OcppServerURL[512];     //http: non-secure OCPP 1.5-S, https: secure OCPP 1.5-S, ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
@@ -4803,6 +4811,7 @@ struct OCPP16Data
     struct StructSignCertificate                    SignCertificate;
     struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
     struct StructSessionTarget                      SessionTarget[CONNECTOR_QUANTITY];
+    struct StructYesCustomData                      YesCustomData;
 };
 
 

+ 247 - 31
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -31,7 +31,8 @@
 
 //------------------------------------------------------------------------------
 static DoCommGblData gDoCommGblData             = {0};
-static MoreInfoReq gMoreInfoReq                 = {0};
+static MoreInfoReq gMoreInfoReq[2]              = {0};
+//static ChangePageReq gPageReq[2]                = {0};
 
 static struct SysConfigData *pSysConfig         = NULL;
 static struct SysInfoData *pSysInfo             = NULL;
@@ -50,6 +51,11 @@ static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 
 // Hexdump
 char old_Hexdump[10240];
+static uint8_t RemoteStartNoIDState = NO;
+static uint8_t ReservationState[2] = {0};
+static char ReservationIdTag[2][32];
+static uint8_t DeductResultReq[2] = {0};
+static int LineStatusCode[2] = {0};
 
 //------------------------------------------------------------------------------
 static void removeFaultCodeToBuf(uint8_t *Code);
@@ -444,15 +450,15 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
                       tm->tm_hour,
                       tm->tm_min);
 
-
-
     //copy QR code string
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
         //printf("data =  %s", data);
         //len =
+
         string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
         //printf("SystemId =  %s", pSysConfig->SystemId);
+        //log_info("SystemId:%s",pSysConfig->SystemId);
     }
     sprintf(ShmDcCommonData->PresentTime, "%04d/%02d/%02d",
                       tm->tm_year + 1900,
@@ -583,7 +589,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
         case MISC_CMD_DEFAULT_PRICES:
             prices = transPricesUnit((int)value);
             log_info("default prices = %.2f", prices);
-
+            ShmDcCommonData->ChargingRate = prices;
             //pSysConfig->BillingData.isBilling = YES;
             for (j = 0; j < 24; j++) {
                 pSysConfig->BillingData.Fee[j] = prices;
@@ -776,13 +782,55 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
             //clearMiscCommand();
         	break;
         case MISC_CMD_RESERVATION:
+            if(value != YES)
+            {
+                break;
+            }
+            gMoreInfoReq[plugNum].bits.ReservationReq = YES;
             break;
         case MISC_CMD_CHANGE_LCM_PAGE:
+            if(value == LCM_PAGE_REMOTE_START_NO_ID)
+            {
+                gMoreInfoReq[plugNum].bits.RemoteStartNoID = YES;
+            }
+            /*
+            if(value == LCM_PAGE_JOIN_LINE)
+            {
+                if(!gPageReq[plugNum].bits.JoinLine)
+                {
+                    log_info("Gun %d JoinLine page is trigger", plugNum);
+                }
+                gPageReq[plugNum].bits.JoinLine = YES;
+            }
+            if(value == LCM_PAGE_PAYMENT_SWITCH)
+            {
+                if(!gPageReq[plugNum].bits.PaymentSwitch)
+                {
+                    log_info("Gun %d PaymentSwitch page is trigger", plugNum);
+                }
+                gPageReq[plugNum].bits.PaymentSwitch = YES;
+            }*/
             break;
         case MISC_CMD_QR_CODE_REQ:
             break;
         case MISC_CMD_STATION_INFO_REQ:
-            gMoreInfoReq.bits.StationInfoReq = YES;
+            if(value != YES)
+            {
+                break;
+            }
+            gMoreInfoReq[plugNum].bits.StationInfoReq = YES;
+            break;
+        case MISC_CMD_FINAL_COST_REQ:
+            if(value != YES)
+            {
+                break;
+            }
+            gMoreInfoReq[plugNum].bits.FinalCostReq = YES;
+            break;
+        case MISC_CMD_LINE_STATUS_REQ:
+            LineStatusCode[plugNum] = value;
+            ShmDcCommonData->LineStatus[plugNum] = value;
+            log_info("Gun %d Line Status Code: %d", plugNum, LineStatusCode[plugNum]);
             break;
 
         default:
@@ -1074,6 +1122,9 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         log_info("OK (Left connector ID = %d, Right connector ID = %d)",
                  pCsuResult->Data.Data[0],
                  pCsuResult->Data.Data[1]);
+        ShmDcCommonData->ConnectorID[0] = pCsuResult->Data.Data[0];
+        ShmDcCommonData->ConnectorID[1] = pCsuResult->Data.Data[1];
+
         break;
 
     case REG_POWER_CABINET_STATUS:
@@ -1187,6 +1238,39 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         }
         break;
 
+    case REG_RESERVATION_IDTAG:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        uint8_t reservationState = pCsuResult->Data.Data[0] == YES ? YES : NO;
+        memset(&ReservationIdTag[plugNum][0], 0x00, 32);
+        if(reservationState)
+        {
+            strcpy(&ReservationIdTag[plugNum][0], (char *)&pCsuResult->Data.Data[1]);
+        }
+        if(reservationState != ReservationState[plugNum])
+        {
+            log_info("id = %d reservation is %s", pCsuResult->Head.ID, reservationState ? "trigger" : "expired");
+            if(reservationState)
+            {
+                log_info("id = %d reservation idTag: %s", pCsuResult->Head.ID, (char *)&ReservationIdTag[plugNum][0]);
+            }
+        }
+        ReservationState[plugNum] = reservationState;
+        break;
+
+    case REG_REMOTE_START_NO_ID:
+        if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
+            return COMMAND_RESULT_NG;
+        }
+        uint8_t remoteStartNoIdState = pCsuResult->Data.Data[0] == YES ? YES : NO;
+        if(remoteStartNoIdState != RemoteStartNoIDState)
+        {
+            log_info("RemoteStartNoID is %s", remoteStartNoIdState ? "trigger" : "expired");
+        }
+        RemoteStartNoIDState = remoteStartNoIdState;
+        break;
+
     case REG_STATION_INFO:
         if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
             return COMMAND_RESULT_NG;
@@ -1194,28 +1278,35 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         StationVar _stationInfo;
         memset((char *)&_stationInfo, 0x00, sizeof(StationVar));
 
-        memcpy(_stationInfo.StationName, (char *)&pCsuResult->Data.Data[0], 64);
-        memcpy(_stationInfo.StationID, (char *)&pCsuResult->Data.Data[64], 16);
-        _stationInfo.WeatherID |= (pCsuResult->Data.Data[80] << 24);
-        _stationInfo.WeatherID |= (pCsuResult->Data.Data[81] << 16);
-        _stationInfo.WeatherID |= (pCsuResult->Data.Data[82] << 8);
-        _stationInfo.WeatherID |= pCsuResult->Data.Data[83];
+        _stationInfo.StationID = (pCsuResult->Data.Data[0] << 24) +
+                                 (pCsuResult->Data.Data[1] << 16) +
+                                 (pCsuResult->Data.Data[2] << 8) +
+                                 pCsuResult->Data.Data[3];
+        memcpy(_stationInfo.StationName, (char *)&pCsuResult->Data.Data[4], 64);
+        _stationInfo.WeatherID |= (pCsuResult->Data.Data[68] << 24);
+        _stationInfo.WeatherID |= (pCsuResult->Data.Data[69] << 16);
+        _stationInfo.WeatherID |= (pCsuResult->Data.Data[70] << 8);
+        _stationInfo.WeatherID |= pCsuResult->Data.Data[71];
         uint8_t *pFloat = (uint8_t *)&_stationInfo.Temperature;
-        *(pFloat + 3) = pCsuResult->Data.Data[84];
-        *(pFloat + 2) = pCsuResult->Data.Data[85];
-        *(pFloat + 1) = pCsuResult->Data.Data[86];
-        *(pFloat) = pCsuResult->Data.Data[87];
+        *(pFloat + 3) = pCsuResult->Data.Data[72];
+        *(pFloat + 2) = pCsuResult->Data.Data[73];
+        *(pFloat + 1) = pCsuResult->Data.Data[74];
+        *(pFloat) = pCsuResult->Data.Data[75];
 
         ShmDcCommonData->WeatherID = _stationInfo.WeatherID;
         ShmDcCommonData->Temperature = _stationInfo.Temperature;
+        ShmDcCommonData->Location = atoi(_stationInfo.StationName);
 
-        log_info("Station Name: %s, ID: %s, Weather: %d, Temperature: %.1f",
+        log_info("Station Name: %s, ID: %d, Weather: %d, Temperature: %.1f",
                 _stationInfo.StationName,
                 _stationInfo.StationID,
                 _stationInfo.WeatherID,
                 _stationInfo.Temperature);
         break;
 
+    case REG_DEDUCT_INFO:
+        break;
+
     default:
         break;
     }
@@ -1287,6 +1378,38 @@ static int composeSocketData(int fd,
     return ret;
 }
 
+static int readReservationState(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    if ((ret = composeSocketData(fd,
+                                 id,
+                                 OP_READ_DATA,
+                                 REG_RESERVATION_IDTAG,
+                                 0,
+                                 NULL)) == FAIL) {
+        return ret;
+    }
+
+    return ret;
+}
+
+static int readRemoteStartNoIDState(int fd)
+{
+    int ret = PASS;
+
+    if ((ret = composeSocketData(fd,
+                                 ID_REGISTER,
+                                 OP_READ_DATA,
+                                 REG_REMOTE_START_NO_ID,
+                                 0,
+                                 NULL)) == FAIL) {
+        return ret;
+    }
+
+    return ret;
+}
+
 static int readChargerStationInfo(int fd)
 {
     int ret = PASS;
@@ -1303,6 +1426,37 @@ static int readChargerStationInfo(int fd)
     return ret;
 }
 
+static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex)
+{
+    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);
+
+    // copy deduct result to dataBuf here
+
+    if ((ret = composeSocketData(fd,
+                                 id,
+                                 OP_WRITE_DATA,
+                                 REG_DEDUCT_INFO,
+                                 6,
+                                 &dataBuf[0])) == FAIL) {
+        return ret;
+    }
+
+    return ret;
+}
+
 static int writeWaitPlugItState(int fd, uint8_t id)
 {
     int ret = PASS;
@@ -1866,12 +2020,21 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                 writeDispenserStatus(fd, gunID);
                 ftime(&gRegTimeUp[plugNum][curReg]);
             }
-            curReg = REG_PLUG_IN_STATE;
+            curReg = REG_CHARGING_CAP;
             break;
 
-        //case REG_CHARGING_CAP:
-        //    readChargingCapability(fd, plugNum, gunID);
-        //    break;
+        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);
+            }
+            curReg = REG_PLUG_IN_STATE;
+            break;
 
         //case REG_CHARGING_TARGET:
         //    writeChargingTarget(fd, plugNum, gunID);
@@ -1923,19 +2086,15 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
 
         case REG_MISC_CONTROL:
-            gMoreInfoReq.Value = 0;
             readMiscCommand(fd, gunID);
 
-            if(gMoreInfoReq.Value == 0)
+            if(gMoreInfoReq[plugNum].Value == 0)
             {
                 isContinue = 0;
             }
             else
             {
-                if(gMoreInfoReq.bits.StationInfoReq)
-                {
-                    curReg = REG_STATION_INFO;
-                }
+                curReg = REG_RESERVATION_IDTAG;
             }
             break;
 
@@ -1977,8 +2136,8 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                     log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
                 }
                 curReg = gDoCommGblData.MiscCmd;
-            } else if(gMoreInfoReq.bits.StationInfoReq) {
-                curReg = REG_STATION_INFO;
+            } else if (gMoreInfoReq[plugNum].Value != 0) {
+                curReg = REG_RESERVATION_IDTAG;
             } else {
                 isContinue = 0;
             }
@@ -2006,30 +2165,66 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
 
         case REG_RESERVATION_IDTAG:
+            if(gMoreInfoReq[plugNum].bits.ReservationReq)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    if(readReservationState(fd, gunID) == PASS)
+                    {
+                        gMoreInfoReq[plugNum].bits.ReservationReq = ReservationState[plugNum] == NO ? NO : YES;
+                    }
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            curReg = REG_REMOTE_START_NO_ID;
             break;
 
         //case REG_DISPENSER_REQUEST:
         //    break;
 
         case REG_REMOTE_START_NO_ID:
+            if(gMoreInfoReq[plugNum].bits.RemoteStartNoID)
+            {
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+                    if(readRemoteStartNoIDState(fd) == PASS)
+                    {
+                        gMoreInfoReq[plugNum].bits.RemoteStartNoID = RemoteStartNoIDState == NO ? NO : YES;
+                    }
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
+            }
+            curReg = REG_REFUND_AMOUNT;
             break;
 
         case REG_REFUND_AMOUNT:
+            curReg = REG_PREPAYMENT_INFO;
             break;
 
         case REG_PREPAYMENT_INFO:
+            curReg = REG_PAYMENT_FAIL_REASON;
             break;
 
         case REG_PAYMENT_FAIL_REASON:
+            curReg = REG_CONNECTOR_QR_CODE;
             break;
 
         case REG_CONNECTOR_QR_CODE:
+            curReg = REG_STATION_INFO;
             break;
 
         case REG_STATION_INFO:
-            if(readChargerStationInfo(fd) == PASS)
+            if(gMoreInfoReq[plugNum].bits.StationInfoReq)
             {
-                gMoreInfoReq.bits.StationInfoReq = NO;
+                if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
+                        DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
+
+                    if(readChargerStationInfo(fd) == PASS)
+                    {
+                        gMoreInfoReq[plugNum].bits.StationInfoReq = NO;
+                    }
+                    ftime(&gRegTimeUp[plugNum][curReg]);
+                }
             }
             isContinue = 0;
             break;
@@ -2071,6 +2266,10 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
     case S_MAINTAIN:
     case S_ALARM:
     case S_AUTHORIZING:
+        if(pDcChargingInfo->SystemStatus != S_ALARM)
+        {
+            DeductResultReq[plugNum] = NO;
+        }
         checkAuthorProcess(fd, plugNum);
 
         //authorization complete, write wait plug it state
@@ -2094,7 +2293,6 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             ftime(&gRegTimeUp[plugNum][REG_MISC_CONTROL]);
         }
         */
-
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
@@ -2104,6 +2302,14 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
 				writeGroundFaultDetection(fd, 0, gunID);
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
         }
+        if(!DeductResultReq[plugNum] && pDcChargingInfo->SystemStatus == S_ALARM &&
+        		ShmDcCommonData->finalcost_flag[plugNum] == TRUE)
+        {
+            DeductResultReq[plugNum] = YES;
+            log_info("Write Gun %d Deduct Result", plugNum);
+            writeDeductInfo(fd, gunID,plugNum);
+            ShmDcCommonData->finalcost_flag[plugNum] = FALSE;
+        }
         break;
 
     case S_PREPARNING: //get permission
@@ -2268,6 +2474,16 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
 				writeGroundFaultDetection(fd, 0, gunID);
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
         }
+        if(!DeductResultReq[plugNum] &&
+        		(pDcChargingInfo->SystemStatus == S_COMPLETE ||
+					pDcChargingInfo->SystemStatus == S_TERMINATING) &&
+        		ShmDcCommonData->finalcost_flag[plugNum] == TRUE)
+        {
+            DeductResultReq[plugNum] = YES;
+            log_info("Write Gun %d Deduct Result", plugNum);
+            writeDeductInfo(fd, gunID,plugNum);
+            ShmDcCommonData->finalcost_flag[plugNum] = FALSE;
+        }
         break;
 
     default:

+ 31 - 2
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h

@@ -92,6 +92,7 @@
 #define REG_PAYMENT_FAIL_REASON                 0x1C
 #define REG_CONNECTOR_QR_CODE                   0x1D
 #define REG_STATION_INFO                        0x1E
+#define REG_DEDUCT_INFO                         0x1F
 
 //------------------------------------------------------------------------------
 //--- dispenser result ---
@@ -133,27 +134,55 @@
 #define MISC_CMD_CHANGE_LCM_PAGE                (0x0107)
 #define MISC_CMD_QR_CODE_REQ                    (0x0108)
 #define MISC_CMD_STATION_INFO_REQ               (0x0109)
+#define MISC_CMD_FINAL_COST_REQ                 (0x010A)
+#define MISC_CMD_LINE_STATUS_REQ                (0x010B)
 
 #define ST_UPDATE_FIRMWARE                      (0x01)
 #define ST_NO_UPDATE_FIRMWARE                   (0x02)
 
+#define LCM_PAGE_REMOTE_START_NO_ID             (0x0001)
+//#define LCM_PAGE_JOIN_LINE                      (0x0002)
+//#define LCM_PAGE_PAYMENT_SWITCH                 (0x0003)
+
 //------------------------------------------------------------------------------
 #pragma pack(push)
 #pragma pack(1)
 
+typedef struct StDeductInfoVar {
+    unsigned char DeductResult;                     // 0: Fail, 1: Pass
+    unsigned char IsDonateInvoice;                  // 0: Do not donate, 1: Donate
+    int Amount;                                     // unit = 0.01 dollar
+} DeductInfoVar;
+
+/*
+typedef union
+{
+    unsigned int Value;
+    struct
+    {
+        unsigned int JoinLine:1;                    // 0: no effect,                1: JoinLine page is trigger
+        unsigned int PaymentSwitch:1;               // 0: no effect,                1: PaymentSwitch page is trigger
+        unsigned int res:30;
+    }bits;
+} ChangePageReq;
+*/
+
 typedef union
 {
     unsigned int Value;
     struct
     {
+        unsigned int ReservationReq:1;              // 0: no effect,                1: need to request Reservation
+        unsigned int RemoteStartNoID:1;             // 0: no effect,                1: need to request RemoteStartNoID
         unsigned int StationInfoReq:1;              // 0: no effect,                1: need to request StationInfo
-        unsigned int res:31;
+        unsigned int FinalCostReq:1;                // 0: no effect,                1: need to request FinalCost
+        unsigned int res:28;
     }bits;
 } MoreInfoReq;
 
 typedef struct StStationVar {
+    int StationID;
     char StationName[64];
-    char StationID[16];
     int WeatherID;
     float Temperature;
 } StationVar;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 364 - 279
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c


+ 155 - 54
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -51,6 +51,7 @@
 
 
 //#define NOODOE_QR_CODE_URL                    "https://ev-alpha-test.noodoe.com/station?id=" ////For Audi
+/*
 #define _StatuIcon				0x1000
 #define _ConfirmStopIcon		0x1002
 #define	_TccareIcon				0x1004
@@ -132,50 +133,91 @@
 #define _ConfirmRightIcon		0x1214
 #define _PayFailLeftIcon		0x1216
 #define _PayFailRightIcon		0x1218
+*/
+#define _Animation				0x1000
+#define _Icon_TouchStart		0x1002
+#define _Icon_Location			0x1004
+#define _Icon_Week				0x1006
+#define _Icon_Weather			0x1008
+#define _Icon_Welcom_Ad			0x100A
+#define _Icon_Select_Left		0x100C
+#define _Icon_Select_Right		0x100E
+#define _Icon_NHOA				0x1010
+#define _Icon_Return			0x1012
+#define _Icon_Donate			0x1014
+#define _Icon_Add_Line			0x1016
+#define _Icon_ShowLeft			0x1018
+#define _Icon_ShowRight			0x101A
+#define _Icon_ScanComplete		0x101C
+#define _Icon_WordYes			0x101E
+#define _Icon_WordNo			0x1020
+#define _Icon_WordAddFriend		0x1022
+#define _Icon_PayFrame			0x1024
+#define _Icon_SenseRadio		0x1026
+#define _Icon_MobilePay			0x1028
+#define _Icon_CardPay			0x102A
+#define _Icon_CreditCardFrame	0x102C
+#define _Icon_PreAuth			0x102E
+#define _Icon_Ani_Dot			0x1030
+#define _Icon_PreAuth_Complete	0x1032
+#define _Icon_Precharge			0x1034
+#define _Icon_ChargeFrame		0x1036
+#define _Icon_WordKW			0x1038
+#define _Icon_ChargeCircle		0x103A
+#define _Icon_ChargeBar			0x103C
+#define _Icon_Paying			0x103E
+#define _Icon_CompleteFrame		0x1040
+#define _Icon_CompleteCircle	0x1042
+#define _Icon_ExitAd			0x1044
+#define _Icon_ExitBar			0x1046
+#define _Icon_ExitWord			0x1048
+#define _Icon_PlugoutFrame		0x104A
+#define _Icon_PreAuthFail		0x104C
+#define _Icon_ReWork			0x1050
+#define _Icon_FixFrame			0x1052
+#define _Icon_Warming0			0x1054
+#define _Icon_Warming1			0x1056
+#define _Icon_Warming2			0x1058
+#define _Icon_Warming3			0x105A
+#define _Icon_Warming4			0x105C
+
+#define _String_Date			0x3000
+#define _String_Tempture		0x3010
+#define _QRCode_AddLine			0x3020
+#define _String_ChargeRate		0x3030
+#define _String_ChargeTime		0x3040
+#define _String_ChargePower		0x3050
+#define _String_Battery			0x3060
+#define _Strting_Energy			0x3070
+#define _String_Money			0x3080
+#define _String_ParkRate		0x3090
+#define _String_Carbon			0x30A0
+#define _QRCode_Service			0x30B0
+#define _Strting_Warming0		0x30C0
+#define _Strting_Warming1		0x30D0
+#define _Strting_Warming2		0x30E0
+#define _Strting_Warming3		0x30F0
+#define _Strting_Warming4		0x3100
 
-// ICON Map Address
-enum _LCM_TCC_INDEX {
-    _LCM_NONE                   = 0x00,
-    _LCM_INIT,
-    _LCM_AUTHORIZE_LEFT,
-    _LCM_PLUGIN_LEFT,
-    _LCM_PRECHARGE_LEFT,
-    _LCM_CHARGING_LEFT,
-    _LCM_COMPLETE_LEFT,
-    _LCM_FUNCTION_SELECT_LEFT,
-    _LCM_REFUND_SENSEING_LEFT,
-    _LCM_REFUNDING_LEFT,
-    _LCM_REFUND_COMPLETE_LEFT,
-    _LCM_REFUND_NONE_LEFT,
-    _LCM_MEMBER_SELECT_LEFT,
-    _LCM_MEMBER_QR_LFET,
-    _LCM_DONATE_LEFT,
-    _LCM_DONATE_SELECT_LEFT,
-    _LCM_PAY_SENSING_LEFT,
-    _LCM_PAY_ETICKET_SUCCESS_LEFT,
-    _LCM_PAY_MPAY_SUCCESS_LEFT,
-    _LCM_PAY_FAIL_LEFT,
-    _LCM_AUTHORIZE_RIGHT         = 32,
-    _LCM_PLUGIN_RIGHT,
-    _LCM_PRECHARGE_RIGHT,
-    _LCM_CHARGING_RIGHT,
-    _LCM_COMPLETE_RIGHT,
-    _LCM_FUNCTION_SELECT_RIGHT,
-    _LCM_REFUND_SENSEING_RIGHT,
-    _LCM_REFUNDING_RIGHT,
-    _LCM_REFUND_COMPLETE_RIGHT,
-    _LCM_REFUND_NONE_RIGHT,
-    _LCM_MEMBER_SELECT_RIGHT,
-    _LCM_MEMBER_QR_RIGHT,
-    _LCM_DONATE_RIGHT,
-    _LCM_DONATE_SELECT_RIGHT,
-    _LCM_PAY_SENSING_RIGHT,
-    _LCM_PAY_ETICKET_SUCCESS_RIGHT,
-    _LCM_PAY_MPAY_SUCCESS_RIGHT,
-    _LCM_PAY_FAIL_RIGHT,
-};
 
-enum _ICON_LIST_ {
+#define _Touch_IDLE				0x1500
+#define _Touch_Select_Left		0x1502
+#define _Touch_Select_Right		0x1504
+#define _Touch_Show_Left		0x1506
+#define _Touch_Show_Right		0x1508
+#define _Touch_Return			0x150A
+#define _Touch_DonateBill		0x150C
+#define _Touch_DonateYes		0x150E
+#define _Touch_DonateNo			0x1510
+#define _Touch_StopCharge		0x1512
+#define _Touch_Stop_Confirm		0x1514
+#define _Touch_Stop_Cancel		0x1516
+#define _Touch_Pay_CreditCard	0x1518
+#define _Touch_Pay_Icash		0x151A
+#define _Touch_Pay_LinePay		0x151C
+
+enum _TCC_ICON_LIST_ {
+	/*
     _ICON_Empty 			= 0,
 	_ICON_StatusInit,
 	_ICON_StatusAuthorize,
@@ -252,18 +294,7 @@ enum _ICON_LIST_ {
 	_ICON_Weather_Thunder,
 	_ICON_Weather_Snow,
 	_ICON_Weather_Fog,
-	/*
-	_ICON_Bar_1,
-	_ICON_Bar_2,
-	_ICON_Bar_3,
-	_ICON_Bar_4,
-	_ICON_Bar_5,
-	_ICON_Bar_6,
-	_ICON_Bar_7,
-	_ICON_Bar_8,
-	_ICON_Bar_9,
-	_ICON_Bar_10,
-	*/
+
 	_ICON_PrePare_1   = 86,
 	_ICON_PrePare_2,
 	_ICON_PrePare_3,
@@ -330,6 +361,76 @@ enum _ICON_LIST_ {
 	_ICON_PAYFAILRIGHTCCS1,
 	_ICON_PAYFAILRIGHTCCS2,
 	_ICON_PAYFAILRIGHTCHADEMO,
+	*/
+	_ICON_Empty 			= 0,
+	_TCC_Week_Monday,
+	_TCC_Week_Tuesday,
+	_TCC_Week_Wensday,
+	_TCC_Week_Thrusday,
+	_TCC_Week_Friday,
+	_TCC_Week_Saturday,
+	_TCC_Week_Sunday,
+	_TCC_TouchStart,
+	_TCC_Sun,
+	_TCC_Cloudy,
+	_TCC_Rain,
+	_TCC_Snow,
+	_TCC_Thunder,
+	_TCC_Fog,
+	_TCC_Taipei_ZhongShan,
+	_TCC_Hualien_Xiulin,
+	_TCC_Welcom_Coffee,
+	_TCC_SelectLeft_CCS1,
+	_TCC_SelectLeft_CCS2,
+	_TCC_SelectLeft_CHAdeMo,
+	_TCC_SelectRight_CCS1,
+	_TCC_SelectRight_CCS2,
+	_TCC_SelectRight_CHAdeMo,
+	_TCC_Return,
+	_TCC_DonateBill,
+	_TCC_GetBill,
+	_TCC_ShowLeft_CCS1_Off,
+	_TCC_ShowLeft_CCS2_Off,
+	_TCC_ShowLeft_CHAdeMo_Off,
+	_TCC_ShowLeft_CCS1_On,
+	_TCC_ShowLeft_CCS2_On,
+	_TCC_ShowLeft_CHAdeMo_On,
+	_TCC_ShowRight_CCS1_Off,
+	_TCC_ShowRight_CCS2_Off,
+	_TCC_ShowRight_CHAdeMo_Off,
+	_TCC_ShowRight_CCS1_On,
+	_TCC_ShowRight_CCS2_On,
+	_TCC_ShowRight_CHAdeMo_On,
+	_TCC_ScanQR_Pass,
+	_TCC_SelectPayMode,
+	_TCC_CreditCard_Wifi,
+	_TCC_CreditCard_Frame,
+	_TCC_iCash,
+	_TCC_LinePay,
+	_TCC_CardSensing_Frame,
+	_TCC_PreAuth,
+	_TCC_Dot_0,
+	_TCC_PaySuccess 		= 62,
+	_TCC_Plugin,
+	_TCC_ChargingFrame,
+	_TCC_StopCharging,
+	_TCC_String_KW,
+	_TCC_Charging_Circle0,
+	_TCC_Charging_Bar0     	= 104,
+	_TCC_NHOA 				= 204,
+	_TCC_WordYes			= 206,
+	_TCC_WordNo,
+	_TCC_Paying,
+	_TCC_CompleteFrame,
+	_TCC_CompleteCircle0,
+	_TCC_EnjoyLife   		= 247,
+	_TCC_BlackBar,
+	_TCC_ExitAd,
+	_TCC_PayFail,
+	_TCC_Restart,
+	_TCC_PlugOutFrame,
+	_TCC_ErrorFrame,
+	_TCC_Warming,
 };
 
 

+ 6 - 0
EVSE/Projects/DD360Tcci/Apps/timeout.h

@@ -54,6 +54,12 @@ enum Timeout_flag {
 	Timeout_DetailView             = 17,
 	Timeout_Terminating            = 18,
 	Timeout_PlugOutGun             = 19,
+	Timeout_AddLine				   = 20,
+	Timeout_LineReigster		   = 21,
+	Timeout_DonateComfirm		   = 22,
+	Timeout_SelectPayMode		   = 23,
+	Timeout_FinalCost			   = 24,
+	Timeout_ScanCard			   = 25,
 };
 
 //------------------------------------------------------------------------------

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


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно