Browse Source

Merge remote-tracking branch 'origin/DD360Tcci'

FolusWen 3 years ago
parent
commit
cc68284638

+ 36 - 23
EVSE/Projects/DD360Tcci/Apps/CSU/Ethernet.c

@@ -15,7 +15,7 @@
 static DcCommonInfo *ShmDcCommonData 			= NULL;
 static SelectGunInfo *ShmSelectGunInfo          = NULL;
 static struct SysInfoData *pSysInfo 			= NULL;
-#define PREAUTHMONEY	1
+#define PREAUTHMONEY	1000
 bool isDeductDb_ready;
 //------------------------------------------------------------------------------
 static char *rfidPortName = "/dev/ttyS2";
@@ -343,6 +343,31 @@ void WritePayResult(int result ,uint8_t gunIndex)
 	memcpy(&ShmDcCommonData->TransactionInfo[gunIndex].VemData,&ShmDcCommonData->pCreditCard[gunIndex].VemData,64);
 
 }
+
+void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex)
+{
+	int result = 0;
+	result = CreditCardPreAuthComplete(fd,(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]);
+	}
+}
 static int InitialRfidPort(void)
 {
     int fd = open(rfidPortName, O_RDWR);
@@ -457,38 +482,25 @@ void CreateRfidFork(void)
 				}
 
 				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;
+					if (ShmDcCommonData->finalcost[gunIndex] <= 0) {
 
 					} else {
-						log_info("PAYING FAIL");
-						ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
-						pSysInfo->SystemPage = _PAGE_PAYFAIL;
-						WritePayResult(FALSE,gunIndex);
+						ShmDcCommonData->StopCharge[gunIndex] = FALSE;
+						StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost
+						PreAuthCompleteToCardReader(fd,gunIndex);
+						ShmDcCommonData->PayFinish[gunIndex] = TRUE;
 					}
-					if (isDeductDb_ready == TRUE) {
-						InsertDeductInfo(gunIndex,&ShmDcCommonData->TransactionInfo[gunIndex]);
-					}
-					ShmDcCommonData->PayFinish[gunIndex] = TRUE;
 				}
-
 			} // for
-			if (is_idle == TRUE && tm->tm_min%2 == 0 &&
+			if (is_idle == TRUE && tm->tm_min%15 == 0 &&
 					pSysInfo->SystemPage == _PAGE_IDLE && ShmDcCommonData->reupload_deduct_status == 0) {
+				sleep(1);
 				if (DB_GetReDeductInfo(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete) == PASS ) {
 
 					result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->ReAuthComplete.Amount ,"TCC Test",
 															&ShmDcCommonData->ReAuthComplete.VemData[0],
 															&ShmDcCommonData->pCreditCard[0]);
+                    sleep(10);
 					if (result > 0) {
 						ShmDcCommonData->ReAuthComplete.DeductResult = YES;
 						ShmDcCommonData->ReAuthComplete.IsUpload = NO;
@@ -509,7 +521,7 @@ void CreateRfidFork(void)
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo[0],
 					&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0]);
-
+                sleep(10);
 				if (ShmDcCommonData->PreAuth_Result > 0 ) {
 					strcpy((char *)pSysConfig->UserId,"");
 					log_info("Card Reader Stop");
@@ -521,6 +533,7 @@ void CreateRfidFork(void)
 				ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
             } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) {
         		result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
+                sleep(10);
 				//result = 1;
 				if (result > 0) {
 					ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE;

+ 1 - 0
EVSE/Projects/DD360Tcci/Apps/CSU/SelfTest.c

@@ -4550,6 +4550,7 @@ CheckStatus:
                 	is_plugout[gunIndex] = TRUE;
                     StartGunInfoTimeoutDet(gunIndex, Timeout_PlugOutGun);
                     if (pSysInfo->CurGunSelected == gunIndex) {
+                        sleep(10);
                     	pSysInfo->SystemPage = _PAGE_EXIT;
                     	break;
                     }

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/DataBase/DataBase.c

@@ -1958,7 +1958,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
         ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
     }
 #else
-    gunID = gDoCommGblData.ConnectorID[plugNum];;
+    gunID = gDoCommGblData.ConnectorID[pSysInfo->CurGunSelected];;
 
     ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0; //非Audi 不需要等待主櫃回報餘額
 #endif // DD360Audi

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h

@@ -446,7 +446,7 @@ void CANReceiver(int fd)
                 //printf("id = %d, EvBatterytargetCurrent = %.2f", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
 
                 pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
-                //printf("RemainChargingDuration = %d",  pDcChargingInfo->RemainChargingDuration);
+                //log_info("RemainChargingDuration = %d",  pDcChargingInfo->RemainChargingDuration);
 
                 if (pDcChargingInfo->Type == _Type_Chademo) {
                     //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])

+ 46 - 16
EVSE/Projects/DD360Tcci/Apps/ModuleEventLog/Module_EventLogging.c

@@ -843,31 +843,60 @@ void ChangeRemainTime(int sec)
 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);
+	if (pDcChargingInfo->SystemStatus == S_CHARGING) {
+		if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
+				pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
+			ChangeDisplay2Value(_Icon_Select_Left,_TCC_ShowLeftGunCharging_CCS1);
 
-	} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
-			pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
-		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CCS2);
+		} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
+				pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
+			ChangeDisplay2Value(_Icon_Select_Left,_TCC_ShowLeftGunCharging_CCS2);
 
-	} else if (pDcChargingInfo->Type == _Type_Chademo) {
-		ChangeDisplay2Value(_Icon_Select_Left,_TCC_SelectLeft_CHAdeMo);
+		} else if (pDcChargingInfo->Type == _Type_Chademo) {
+			ChangeDisplay2Value(_Icon_Select_Left,_TCC_ShowLeftGunCharging_CHAdeMo);
+		}
+	} else {
+		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);
+	if (pDcChargingInfo->SystemStatus == S_CHARGING) {
+		if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
+				pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
+			ChangeDisplay2Value(_Icon_Select_Right,_TCC_ShowRightGunCharging_CCS1);
 
-	} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
-			pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
-		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CCS2);
+		} else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
+				pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
+			ChangeDisplay2Value(_Icon_Select_Right,_TCC_ShowRightGunCharging_CCS2);
 
-	} else if (pDcChargingInfo->Type == _Type_Chademo) {
-		ChangeDisplay2Value(_Icon_Select_Right,_TCC_SelectRight_CHAdeMo);
+		} else if (pDcChargingInfo->Type == _Type_Chademo) {
+			ChangeDisplay2Value(_Icon_Select_Right,_TCC_ShowRightGunCharging_CHAdeMo);
+
+		}
+	} else {
+		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)
 {
@@ -1185,6 +1214,7 @@ void ProcessPageInfo()
                 ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy);
                 ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
                 //StartSystemTimeoutDet(Timeout_ReturnViewPage);
+				
                 break;
 
             case _PAGE_PLUGOUT:

+ 6 - 0
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -431,6 +431,12 @@ enum _TCC_ICON_LIST_ {
 	_TCC_PlugOutFrame,
 	_TCC_ErrorFrame,
 	_TCC_Warming,
+	_TCC_ShowLeftGunCharging_CCS1 = 292,
+	_TCC_ShowLeftGunCharging_CCS2,
+	_TCC_ShowLeftGunCharging_CHAdeMo,
+	_TCC_ShowRightGunCharging_CCS1,
+	_TCC_ShowRightGunCharging_CCS2,
+	_TCC_ShowRightGunCharging_CHAdeMo,
 };
 
 

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -499,7 +499,7 @@ void CheckFwUpdateFunction(void)
 
         pSysInfo->FirmwareUpdate = NO;
         sleep(5);
-        //system("reboot -f");
+        system("reboot -f");
     } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
 

BIN
EVSE/Projects/DD360Tcci/Apps/Readme.md


BIN
EVSE/Projects/DD360Tcci/output/Module_DoComm


BIN
EVSE/Projects/DD360Tcci/output/Module_LcmControl


BIN
EVSE/Projects/DD360Tcci/output/Module_UpdateFW


BIN
EVSE/Projects/DD360Tcci/output/main