|
@@ -24,13 +24,14 @@
|
|
|
static struct SysConfigData *pSysConfig = NULL;
|
|
|
static struct SysInfoData *pSysInfo = NULL;
|
|
|
static struct WARNING_CODE_INFO *pSysWarning = NULL;
|
|
|
-
|
|
|
+static struct OCPP16Data *ShmOCPP16Data = NULL;
|
|
|
static struct FanModuleData *ShmFanModuleData;
|
|
|
static struct PrimaryMcuData *ShmPrimaryMcuData;
|
|
|
static SelectGunInfo *ShmSelectGunInfo = NULL;
|
|
|
static struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
static DcCommonInfo *ShmDcCommonData = NULL;
|
|
|
-
|
|
|
+//int CardReadFd = -1;
|
|
|
+static char *rfidPortName = "/dev/ttyS2";
|
|
|
short _currentPage = _PAGE_NONE;
|
|
|
uint8_t _totalCount;
|
|
|
uint8_t _showInformIndex = 0;
|
|
@@ -42,16 +43,22 @@ int _port;
|
|
|
char *pPortName = "/dev/ttyS3";
|
|
|
char *moduleName = "DMT80480T070_09WT";
|
|
|
bool is_show = false;
|
|
|
+bool is_stop = false;
|
|
|
uint8_t _everyPageRollChange;
|
|
|
uint8_t _btn_press = 0;
|
|
|
short _btn_press_id = 0;
|
|
|
-struct timeval returnIdleTimer;
|
|
|
+uint8_t _btn_press_count = 0;
|
|
|
int _Text_Running_Count = 86;
|
|
|
int Battery_Test = 0;
|
|
|
extern void UpdateLcmFunction(DcCommonInfo *ShmDcCommonData,int _lcmport);
|
|
|
//==========================================
|
|
|
// Open and Close RS232 and R/W
|
|
|
//==========================================
|
|
|
+void AuthorizingStart(void)
|
|
|
+{
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = YES;
|
|
|
+ pSysInfo->AuthorizeFlag = YES;
|
|
|
+}
|
|
|
unsigned long GetClockTimeoutValue(struct timespec _start_time)
|
|
|
{
|
|
|
struct timespec ts_end;
|
|
@@ -92,6 +99,32 @@ void CloseCommunicationLcmPort()
|
|
|
close(_port);
|
|
|
}
|
|
|
|
|
|
+void setSelGunWaitToAuthor(uint8_t curSel)
|
|
|
+{
|
|
|
+ if (curSel == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
|
|
|
+ ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
|
|
|
+ log_info("setSelGunWaitToAuthor left");
|
|
|
+
|
|
|
+ } else if (curSel == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
|
|
|
+ ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
|
|
|
+ log_info("setSelGunWaitToAuthor right");
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+void confirmSelGun(uint8_t selGun)
|
|
|
+{
|
|
|
+ if (selGun == LEFT_GUN_NUM) {
|
|
|
+ ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
|
|
|
+ //printf("confirmSelGun left");
|
|
|
+ } else if (selGun == RIGHT_GUN_NUM) {
|
|
|
+ ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
|
|
|
+ //printf("confirmSelGun right");
|
|
|
+ }
|
|
|
+ //changeLcmPage(_PAGE_PLUGIN);
|
|
|
+
|
|
|
+ //StartGunInfoTimeoutDet(selGun, Timeout_SelectGun);
|
|
|
+ //StartSystemTimeoutDet(Timeout_ReturnViewPage);
|
|
|
+}
|
|
|
void GetDeviceInfoStatus(short address, uint8_t len)
|
|
|
{
|
|
|
uint8_t cmd[8];
|
|
@@ -138,132 +171,171 @@ void CheckDonateSelectPress()
|
|
|
}
|
|
|
void CheckIdlePress()
|
|
|
{
|
|
|
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
|
|
|
- log_info("LCM Enter Authorize Page");
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
+ if (pDcChargingInfo->Replug_flag) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_PLUGOUT;
|
|
|
+ log_info("IDLE Enter REPLUG Page");
|
|
|
+ }
|
|
|
+ pSysInfo->SystemPage = _PAGE_SELECT_GUN;
|
|
|
+ log_info("IDLE Enter Select Gun Page");
|
|
|
+}
|
|
|
+void CheckReturnPress()
|
|
|
+{
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
+ //pDcChargingInfo->SystemStatus = S_IDLE;
|
|
|
+ //pSysInfo->SystemPage = _PAGE_SELECT_GUN;
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+
|
|
|
+}
|
|
|
+void CheckStopPress()
|
|
|
+{
|
|
|
+ is_stop = TRUE;
|
|
|
+ //ChangeDisplay2Value(_ConfirmStopIcon,is_stop);
|
|
|
+ if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
|
|
|
+ pSysInfo->SystemPage = _PAGE_STOP_CONFIRM_LEFT;
|
|
|
+ else
|
|
|
+ pSysInfo->SystemPage = _PAGE_STOP_CONFIRM_RIGHT;
|
|
|
+}
|
|
|
+void CheckStopConfirmPress()
|
|
|
+{
|
|
|
+ int result;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
+ pDcChargingInfo->SystemStatus = S_TERMINATING;
|
|
|
+ pSysInfo->SystemPage = _PAGE_PAYING;
|
|
|
+ is_stop = FALSE;
|
|
|
+ ShmDcCommonData->finalcost[pSysInfo->CurGunSelected] = (int)pDcChargingInfo->ChargingFee;
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTHCOMPLETE;
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
+
|
|
|
+}
|
|
|
+void CheckStopCancelPress()
|
|
|
+{
|
|
|
+ is_stop = FALSE;
|
|
|
+ ChangeDisplay2Value(_ConfirmStopIcon,is_stop);
|
|
|
+ pSysInfo->SystemPage = _PAGE_CHARGING;
|
|
|
+}
|
|
|
+void CheckConfirmGun(uint8_t gunIndex)
|
|
|
+{
|
|
|
+ pSysInfo->CurGunSelected = gunIndex;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
|
|
|
+ if (pDcChargingInfo->SystemStatus == S_IDLE) {
|
|
|
+ confirmSelGun(gunIndex);
|
|
|
+ setSelGunWaitToAuthor(gunIndex);
|
|
|
+ pSysInfo->SystemPage = _PAGE_AUTHORIZE;
|
|
|
+ pDcChargingInfo->SystemStatus = S_AUTHORIZING;
|
|
|
+ // Set Card Reader
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH;
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
+ //
|
|
|
+ AuthorizingStart();
|
|
|
+ }
|
|
|
}
|
|
|
void CheckTouchPress(short id)
|
|
|
{
|
|
|
- GetDeviceInfoStatus(id,1);
|
|
|
|
|
|
- if (_btn_press >= 1 && _btn_press_id == id) {
|
|
|
+ GetDeviceInfoStatus(id,1);
|
|
|
+ if (_btn_press >= 1 && _btn_press_id == id ) {
|
|
|
+ _btn_press_count++;
|
|
|
+ }
|
|
|
+ if (_btn_press >= 1 && _btn_press_id == id && _btn_press_count >= 3) {
|
|
|
ChangeDisplay2Value(id, 0);
|
|
|
+ log_info("Press id : 0x%04x",id);
|
|
|
+ _btn_press_count = 0;
|
|
|
switch (id) {
|
|
|
case _Touch_LeftGun:
|
|
|
- if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
- log_info("LCM left Gun down...............................%x %x %x",
|
|
|
- pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
|
|
|
- if (pDcChargingInfo->SystemStatus == S_IDLE &&
|
|
|
- (pSysInfo->SystemPage <_PAGE_REFUND_SENSEING ||
|
|
|
- pSysInfo->SystemPage > _PAGE_REFUND_NONE ||
|
|
|
- pSysInfo->SystemPage != _PAGE_PAY_ETICKET_SUCCESS ||
|
|
|
- pSysInfo->SystemPage != _PAGE_PAY_MPAY_SUCCESS) ) {
|
|
|
- log_info("Reset LCM to IDLE");
|
|
|
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
|
|
|
- gettimeofday(&returnIdleTimer, NULL);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
|
|
|
+ log_info("Authorize Page can't select gun");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
pSysInfo->CurGunSelected = LEFT_GUN_NUM;
|
|
|
+ if(pDcChargingInfo->SystemStatus == S_IDLE) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_SELECT_GUN;
|
|
|
+ }
|
|
|
+ // Show log
|
|
|
+ if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
|
|
|
+ log_info("LCM left Gun down...............................%x %x %x",
|
|
|
+ pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
|
|
|
+ }
|
|
|
break;
|
|
|
case _Touch_RightGun:
|
|
|
- if (pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
|
|
|
- log_info("LCM right Gun down...............................%x %x %x",
|
|
|
- pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
|
|
|
- if (pDcChargingInfo->SystemStatus == S_IDLE &&
|
|
|
- (pSysInfo->SystemPage <_PAGE_REFUND_SENSEING ||
|
|
|
- pSysInfo->SystemPage > _PAGE_REFUND_NONE ||
|
|
|
- pSysInfo->SystemPage != _PAGE_PAY_ETICKET_SUCCESS ||
|
|
|
- pSysInfo->SystemPage != _PAGE_PAY_MPAY_SUCCESS) ) {
|
|
|
- log_info("Reset LCM to IDLE");
|
|
|
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
|
|
|
- gettimeofday(&returnIdleTimer, NULL);
|
|
|
- }
|
|
|
+ if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
|
|
|
+ log_info("Authorize Page can't select gun");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
|
|
|
+ pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
|
|
|
+ if(pDcChargingInfo->SystemStatus == S_IDLE) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_SELECT_GUN;
|
|
|
}
|
|
|
- pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
|
|
|
+ // Show log
|
|
|
+ if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
|
|
|
+ log_info("LCM Right Gun down...............................%x %x %x",
|
|
|
+ pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
|
|
|
+ }
|
|
|
break;
|
|
|
case _Touch_Return:
|
|
|
- CheckIdlePress();
|
|
|
+ CheckReturnPress();
|
|
|
break;
|
|
|
case _Touch_IDLE:
|
|
|
CheckIdlePress();
|
|
|
break;
|
|
|
+ case _Touch_Stop:
|
|
|
+ CheckStopPress();
|
|
|
+ is_stop = TRUE;
|
|
|
+ break;
|
|
|
+ case _Touch_Stop_Confirm:
|
|
|
+ CheckStopConfirmPress();
|
|
|
+ is_stop = FALSE;
|
|
|
+ break;
|
|
|
+ case _Touch_Stop_Cancel:
|
|
|
+ CheckStopCancelPress();
|
|
|
+ is_stop = FALSE;
|
|
|
+ break;
|
|
|
+ case _Touch_ConfirmLeft:
|
|
|
+ CheckConfirmGun(LEFT_GUN_NUM);
|
|
|
+ break;
|
|
|
+ case _Touch_ConfirmRight:
|
|
|
+ CheckConfirmGun(RIGHT_GUN_NUM);
|
|
|
+ break;
|
|
|
} // switch
|
|
|
+
|
|
|
} //if (_btn_press >= 3)
|
|
|
}
|
|
|
|
|
|
void CheckLCMPressed()
|
|
|
{
|
|
|
pid_t Pid = fork();
|
|
|
- int i = 0;
|
|
|
- int index = 0;
|
|
|
if ( Pid == 0 ) {
|
|
|
while (1) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
- CheckTouchPress(_Touch_LeftGun);
|
|
|
- CheckTouchPress(_Touch_RightGun);
|
|
|
+ if (pSysInfo->SystemPage != _PAGE_SELECT_GUN) {
|
|
|
+ CheckTouchPress(_Touch_LeftGun);
|
|
|
+ CheckTouchPress(_Touch_RightGun);
|
|
|
+ }
|
|
|
switch (pSysInfo->SystemPage) {
|
|
|
case _PAGE_IDLE:
|
|
|
CheckTouchPress(_Touch_IDLE);
|
|
|
break;
|
|
|
- case _PAGE_AUTHORIZE:
|
|
|
- CheckScreenModePress();
|
|
|
- break;
|
|
|
- case _PAGE_FUNCTION_SELECT:
|
|
|
- break;
|
|
|
- case _PAGE_MEMBER_SELECT:
|
|
|
- CheckMemberSelectPress();
|
|
|
- break;
|
|
|
- case _PAGE_DONATE:
|
|
|
- CheckDonatePress();
|
|
|
- break;
|
|
|
- case _PAGE_DONATE_SELECT:
|
|
|
- CheckDonateSelectPress();
|
|
|
- break;
|
|
|
-// ********************** Test *******************
|
|
|
-/*
|
|
|
- case _PAGE_PRECHARGE:
|
|
|
- // if ((i/100) %2 == 0)
|
|
|
- // ChangeDisplay2Value(0x109A,i%100);
|
|
|
- // else
|
|
|
- // ChangeDisplay2Value(0x109A,100-(i%100));
|
|
|
-
|
|
|
- break;
|
|
|
+ case _PAGE_SELECT_GUN:
|
|
|
+ CheckTouchPress(_Touch_ConfirmLeft);
|
|
|
+ CheckTouchPress(_Touch_ConfirmRight);
|
|
|
+ break;
|
|
|
+ ///*
|
|
|
case _PAGE_CHARGING:
|
|
|
- pSysConfig->BillingData.isBilling = TRUE;
|
|
|
- pDcChargingInfo->PresentChargingPower = i;
|
|
|
- pDcChargingInfo->PresentChargedEnergy = i/6;
|
|
|
- pDcChargingInfo->ChargingFee = i;
|
|
|
- pDcChargingInfo->RemainChargingDuration = i;
|
|
|
- pDcChargingInfo->EvBatterySoc = i/6;
|
|
|
-
|
|
|
- break;
|
|
|
- case _PAGE_COMPLETE:
|
|
|
- pDcChargingInfo->PresentChargedEnergy = i;
|
|
|
- pDcChargingInfo->ChargingFee = i;
|
|
|
- pDcChargingInfo->EvBatterySoc = i/6;
|
|
|
- pSysConfig->BillingData.isBilling = TRUE;
|
|
|
- ChangeCarBonValue(i);
|
|
|
- pSysConfig->isQRCode = 1;
|
|
|
- break;
|
|
|
- case _PAGE_PLUGOUT:
|
|
|
- pSysConfig->isQRCode = 1;
|
|
|
+ CheckTouchPress(_Touch_Stop);
|
|
|
+ break;
|
|
|
+ case _PAGE_AUTHORIZE:
|
|
|
CheckTouchPress(_Touch_Return);
|
|
|
break;
|
|
|
-// ************************************************ */
|
|
|
+ case _PAGE_STOP_CONFIRM_LEFT:
|
|
|
+ case _PAGE_STOP_CONFIRM_RIGHT:
|
|
|
+ CheckTouchPress(_Touch_Stop_Confirm);
|
|
|
+ CheckTouchPress(_Touch_Stop_Cancel);
|
|
|
+ break;
|
|
|
} // switch
|
|
|
usleep(5000);
|
|
|
-
|
|
|
- /*
|
|
|
- i++;
|
|
|
- if (i == 600 ) {
|
|
|
- index >= 8 ? index = 1 : index++;
|
|
|
- pSysInfo->SystemPage = index;
|
|
|
- i = 0;
|
|
|
-
|
|
|
- }//*/
|
|
|
-
|
|
|
} //while
|
|
|
} // if pid
|
|
|
log_info("Create LCM fork:%d",Pid);
|
|
@@ -330,7 +402,8 @@ void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
|
|
|
strcpy((char *)pSysInfo->LcmHwRev, moduleName);
|
|
|
if (key == 0x0014)
|
|
|
_currentPage = *(msg + 8);
|
|
|
- if ( key >= _Touch_LeftGun && key <=_Touch_IDLE ) {
|
|
|
+ if ( key >= _Touch_LeftGun && key <=_Touch_ConfirmRight ) {
|
|
|
+
|
|
|
_btn_press_id = key;
|
|
|
_btn_press = *(msg + 8);
|
|
|
}
|
|
@@ -507,19 +580,19 @@ void ChangeCurPage()
|
|
|
if (_currentPage != pSysInfo->PageIndex) {
|
|
|
switch (pSysInfo->SystemPage) {
|
|
|
case _PAGE_AUTHORIZE:
|
|
|
- gettimeofday(&returnIdleTimer, NULL);
|
|
|
break;
|
|
|
case _PAGE_PLUGIN:
|
|
|
break;
|
|
|
case _PAGE_PRECHARGE:
|
|
|
break;
|
|
|
case _PAGE_CHARGING:
|
|
|
+ is_stop = false;
|
|
|
break;
|
|
|
case _PAGE_COMPLETE:
|
|
|
break;
|
|
|
}
|
|
|
_currentPage = pSysInfo->PageIndex;
|
|
|
-
|
|
|
+ log_info("Chagne Page:%d",pSysInfo->PageIndex);
|
|
|
ChangeToOtherPage(pSysInfo->PageIndex);
|
|
|
}
|
|
|
}
|
|
@@ -540,7 +613,6 @@ void showGunWorkingType()
|
|
|
{
|
|
|
if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
|
|
|
|
|
|
-
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
|
|
|
pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
|
|
@@ -565,7 +637,7 @@ void showGunWorkingType()
|
|
|
} else if (pDcChargingInfo->Type == _Type_Chademo) {
|
|
|
ChangeDisplay2Value(_RightGun_status,_ICON_Right_CHAdeMo_Off);
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM){
|
|
|
// Left Gun
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
|
|
@@ -590,6 +662,30 @@ void showGunWorkingType()
|
|
|
} else if (pDcChargingInfo->Type == _Type_Chademo) {
|
|
|
ChangeDisplay2Value(_RightGun_status,_ICON_Right_CHAdeMO_ON);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
+ if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
|
|
|
+ ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CCS1_Off);
|
|
|
+
|
|
|
+ } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
|
|
|
+ ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CCS2_Off);
|
|
|
+ } else if (pDcChargingInfo->Type == _Type_Chademo) {
|
|
|
+ ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CHAdeMO_Off);
|
|
|
+ }
|
|
|
+ // Set Right Gun
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
|
|
|
+ if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
|
|
|
+ ChangeDisplay2Value(_RightGun_status,_ICON_Right_CCS1_Off);
|
|
|
+
|
|
|
+ } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
|
|
|
+ ChangeDisplay2Value(_RightGun_status,_ICON_Right_CCS2_Off);
|
|
|
+ } else if (pDcChargingInfo->Type == _Type_Chademo) {
|
|
|
+ ChangeDisplay2Value(_RightGun_status,_ICON_Right_CHAdeMo_Off);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -671,14 +767,14 @@ void ChangeChargingFeeValue(float fee)
|
|
|
string2ByteArray(value, cmd);
|
|
|
DisplayValueToLcm(_Text_Money, cmd, sizeof(cmd));
|
|
|
}
|
|
|
-void ChangeCarBonValue(int data)
|
|
|
+void ChangeCarBonValue(float data)
|
|
|
{
|
|
|
uint8_t cmd[10];
|
|
|
uint8_t value[10];
|
|
|
-
|
|
|
+ float _carbon = 0;
|
|
|
memset(cmd, 0x00, sizeof(cmd));
|
|
|
-
|
|
|
- sprintf((char *) value, "-%d", data);
|
|
|
+ _carbon = (data*9)/10*2.36 - data*0.637;
|
|
|
+ sprintf((char *) value, "%.1fkg", _carbon);
|
|
|
string2ByteArray(value, cmd);
|
|
|
DisplayValueToLcm(_Text_Carbon, cmd, sizeof(cmd));
|
|
|
}
|
|
@@ -699,14 +795,14 @@ void ChangeChargingEnergyValue(float energy)
|
|
|
else
|
|
|
ChangeDisplay2Value(_EnergyBar,(int)energy);
|
|
|
|
|
|
- sprintf((char *) value, "%d", (int)energy);
|
|
|
+ sprintf((char *) value, "%.1f", energy);
|
|
|
string2ByteArray(value, cmd);
|
|
|
DisplayValueToLcm(_Text_Energy, cmd, sizeof(cmd));
|
|
|
}
|
|
|
uint8_t _battery_display_count = 0;
|
|
|
void ChangeBattMapAndValue(int soc)
|
|
|
{
|
|
|
- int i = (soc*36)/100;
|
|
|
+ int i = (soc*37)/100;
|
|
|
uint8_t cmd[5];
|
|
|
uint8_t value[5];
|
|
|
|
|
@@ -719,22 +815,21 @@ void ChangeBattMapAndValue(int soc)
|
|
|
_battery_display_count = 0;
|
|
|
}
|
|
|
|
|
|
- if (i==36)
|
|
|
- ChangeDisplay2Value(_ChargingIcon,_ICON_Battery_35);
|
|
|
- else {
|
|
|
+ if (i>=37)
|
|
|
+ ChangeDisplay2Value(_Battery_Circle,_ICON_Battery_36);
|
|
|
+ else if (pSysInfo->SystemPage == _PAGE_CHARGING){
|
|
|
if (_battery_display_ani) {
|
|
|
- ChangeDisplay2Value(_ChargingIcon, _ICON_Battery_0+(int)i);
|
|
|
+ ChangeDisplay2Value(_Battery_Circle, _ICON_Battery_0+i);
|
|
|
} else {
|
|
|
- ChangeDisplay2Value(_ChargingIcon, _ICON_Battery_0+(int)i+1);
|
|
|
+ ChangeDisplay2Value(_Battery_Circle, _ICON_Battery_0+i+1);
|
|
|
}
|
|
|
- }
|
|
|
+ } else
|
|
|
+ ChangeDisplay2Value(_Battery_Circle, _ICON_Battery_0+i);
|
|
|
|
|
|
memset(cmd, 0x00, sizeof(cmd));
|
|
|
memset(value, 0x00, sizeof(value));
|
|
|
- if (pSysInfo->SystemPage == _PAGE_CHARGING)
|
|
|
- sprintf((char *)value, "%d", soc);
|
|
|
- else
|
|
|
- sprintf((char *)value, "%d%%", soc);
|
|
|
+
|
|
|
+ sprintf((char *)value, "%d%%", soc);
|
|
|
|
|
|
string2ByteArray(value, cmd);
|
|
|
DisplayValueToLcm(_Text_BatterySoc, cmd, sizeof(cmd));
|
|
@@ -746,10 +841,10 @@ unsigned long GetPreChargeTimeoutValue(struct timeval _sour_time)
|
|
|
|
|
|
return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
|
|
|
}
|
|
|
-void ChangeTimeValue(uint8_t time)
|
|
|
+void ChangeTimeValue(int time)
|
|
|
{
|
|
|
- uint8_t cmd[2];
|
|
|
- uint8_t value[2];
|
|
|
+ uint8_t cmd[6];
|
|
|
+ uint8_t value[6];
|
|
|
|
|
|
memset(cmd, 0x00, sizeof(cmd));
|
|
|
sprintf((char *) value, "%d", time);
|
|
@@ -791,37 +886,102 @@ void CabinetChangeLCMProcess()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+void changeWeatherValue(int _weather)
|
|
|
+{
|
|
|
+
|
|
|
+ switch (_weather) {
|
|
|
+ case _WEATHER_TYPE_SUN:
|
|
|
+ ChangeDisplay2Value(_WeatherIcon,_ICON_Weather_Sun);
|
|
|
+ break;
|
|
|
+ case _WEATHER_TYPE_CLOUDY:
|
|
|
+ ChangeDisplay2Value(_WeatherIcon,_ICON_Weather_Cloudy);
|
|
|
+ break;
|
|
|
+ case _WEATHER_TYPE_RAIN:
|
|
|
+ ChangeDisplay2Value(_WeatherIcon,_ICON_Weather_Rain);
|
|
|
+ break;
|
|
|
+ case _WEATHER_TYPE_THUNDER:
|
|
|
+ ChangeDisplay2Value(_WeatherIcon,_ICON_Weather_Thunder);
|
|
|
+ break;
|
|
|
+ case _WEATHER_TYPE_SNOW:
|
|
|
+ ChangeDisplay2Value(_WeatherIcon,_ICON_Weather_Snow);
|
|
|
+ break;
|
|
|
+ case _WEATHER_TYPE_FOG:
|
|
|
+ ChangeDisplay2Value(_WeatherIcon,_ICON_Weather_Fog);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+void changeWeekValue(int _week)
|
|
|
+{
|
|
|
+ ChangeDisplay2Value(_WeekIcon,_week);
|
|
|
+}
|
|
|
+void changeDegreeValue(int _degree)
|
|
|
+{
|
|
|
+ char value[16];
|
|
|
+ memset(value, 0x00, sizeof(value));
|
|
|
+ sprintf((char *)value,"%d",_degree);
|
|
|
+ DisplayValueToLcm(_Text_Tempture, (uint8_t *)value, sizeof(value));
|
|
|
+}
|
|
|
+void changeDateValue(char* _date)
|
|
|
+{
|
|
|
+ char value[16];
|
|
|
+ memset(value, 0x00, sizeof(value));
|
|
|
+ sprintf((char *)value,"%s",_date);
|
|
|
+ DisplayValueToLcm(_Text_Date, (uint8_t *)value, sizeof(value));
|
|
|
+}
|
|
|
+void changeLocationValue(int _location)
|
|
|
+{
|
|
|
+ ChangeDisplay2Value(_LocationIcon,_location);
|
|
|
+}
|
|
|
+int old_money = 0;
|
|
|
void ProcessPageInfo()
|
|
|
{
|
|
|
// Show Gun Working and Type
|
|
|
- float _current;
|
|
|
- uint8_t precharg_time;
|
|
|
+
|
|
|
showGunWorkingType();
|
|
|
+ if (pSysInfo->SystemPage == _PAGE_IDLE) {
|
|
|
+ changeWeatherValue(ShmDcCommonData->WeatherID);
|
|
|
+ changeWeekValue(3+114);
|
|
|
+ changeDegreeValue((int)ShmDcCommonData->Temperature);
|
|
|
+ changeDateValue(&ShmDcCommonData->PresentTime[0]);
|
|
|
+ changeLocationValue(121);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
|
|
|
+
|
|
|
if (pSysInfo->CurGunSelected == i) {
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
//CabinetChangeLCMProcess();
|
|
|
|
|
|
switch (pSysInfo->SystemPage) {
|
|
|
case _PAGE_IDLE:
|
|
|
- gettimeofday(&returnIdleTimer, NULL);
|
|
|
+
|
|
|
break;
|
|
|
case _PAGE_AUTHORIZE:
|
|
|
ShowHomePage();
|
|
|
- if (GetTimeoutValue(returnIdleTimer) /uSEC_VAL >= RETURNIDLE_Timeout ) {
|
|
|
- pSysInfo->SystemPage = _PAGE_IDLE;
|
|
|
- gettimeofday(&returnIdleTimer, NULL);
|
|
|
+ /*
|
|
|
+ int card_result = CreditCardPreAuth(CardReadFd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
|
|
|
+ if (card_result > 0 ) {
|
|
|
+ strcpy((char *)pSysConfig->UserId, (char *)ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo);
|
|
|
+ } else if (card_result < 0) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
+ }*/
|
|
|
+ if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL && ShmDcCommonData->PreAuth_Result != 0) {
|
|
|
+ pDcChargingInfo->SystemStatus = S_IDLE;
|
|
|
+ pSysInfo->SystemPage = _PAGE_SELECT_GUN;
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
}
|
|
|
+
|
|
|
break;
|
|
|
case _PAGE_PLUGIN:
|
|
|
- _Text_Running_Count = 86;
|
|
|
+ _Text_Running_Count = _ICON_PrePare_1;
|
|
|
_everyPageRollChange = 0;
|
|
|
break;
|
|
|
case _PAGE_PRECHARGE:
|
|
|
RefreshProgressAnimation();
|
|
|
if (_everyPageRollChange == 0) {
|
|
|
ChangeDisplay2Value(_PrepareBar,_Text_Running_Count);
|
|
|
- _Text_Running_Count >= 99 ? _Text_Running_Count = 86 : _Text_Running_Count++;
|
|
|
+ _Text_Running_Count >= _ICON_PrePare_14 ? _Text_Running_Count = _ICON_PrePare_1 : _Text_Running_Count++;
|
|
|
}
|
|
|
break;
|
|
|
case _PAGE_CHARGING:
|
|
@@ -840,13 +1000,13 @@ void ProcessPageInfo()
|
|
|
} else {
|
|
|
ChangeChargingEnergyValue(0);
|
|
|
}
|
|
|
- if (pSysConfig->BillingData.isBilling &&
|
|
|
- pDcChargingInfo->ChargingFee >= 0) {
|
|
|
+ if ( pDcChargingInfo->ChargingFee >= 0) {
|
|
|
ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
|
|
|
+
|
|
|
}
|
|
|
if (pDcChargingInfo->RemainChargingDuration >= 0 &&
|
|
|
pDcChargingInfo->RemainChargingDuration <= TIME_MAX_SEC) {
|
|
|
- ChangeTimeValue(pDcChargingInfo->RemainChargingDuration);
|
|
|
+ ChangeTimeValue(pDcChargingInfo->RemainChargingDuration/60);
|
|
|
} else {
|
|
|
ChangeTimeValue(0);
|
|
|
}
|
|
@@ -860,10 +1020,10 @@ void ProcessPageInfo()
|
|
|
} else {
|
|
|
ChangeChargingEnergyValue(0);
|
|
|
}
|
|
|
- if (pSysConfig->BillingData.isBilling &&
|
|
|
- pDcChargingInfo->ChargingFee >= 0) {
|
|
|
- ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
|
|
|
+ if ( ShmDcCommonData->finalcost[i] >= 0) {
|
|
|
+ ChangeChargingFeeValue(ShmDcCommonData->finalcost[i]);
|
|
|
}
|
|
|
+ ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy);
|
|
|
ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
|
|
|
|
|
|
if (pSysConfig->isQRCode) {
|
|
@@ -880,6 +1040,7 @@ void ProcessPageInfo()
|
|
|
case _PAGE_REFUND_SENSEING:
|
|
|
break;
|
|
|
case _PAGE_PLUGOUT:
|
|
|
+
|
|
|
if (pSysConfig->isQRCode) {
|
|
|
if (pSysConfig->QRCodeMadeMode == NO) {
|
|
|
//uint8_t len = strlen((char *)pSysConfig->SystemId);
|
|
@@ -890,6 +1051,15 @@ void ProcessPageInfo()
|
|
|
}
|
|
|
//ChangeQrCode_Idle((char *)pSysConfig->SystemId);
|
|
|
}
|
|
|
+ break;
|
|
|
+ case _PAGE_PAYING:
|
|
|
+ if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTHCOMPLETE) {
|
|
|
+ if (ShmDcCommonData->PreAuth_Result != 0) {
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
+ pSysInfo->SystemPage = _PAGE_COMPLETE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1071,7 +1241,8 @@ void InformationShow()
|
|
|
}
|
|
|
void DefautLayOut()
|
|
|
{
|
|
|
- for (int i = 0 ; i <= 0x72 ; i+=2 ) {
|
|
|
+ int i;
|
|
|
+ for (i = 0 ; i <= 0x6C ; i+=2 ) {
|
|
|
ChangeDisplay2Value(0x1000+i,1);
|
|
|
if (i == 0x38)
|
|
|
ChangeDisplay2Value(0x1000+i,85);
|
|
@@ -1080,9 +1251,68 @@ void DefautLayOut()
|
|
|
else if (i == 0x3A)
|
|
|
ChangeDisplay2Value(0x1000+i,99);
|
|
|
}
|
|
|
-
|
|
|
+ for (i = 0 ; i< 0x10 ; i+=2) {
|
|
|
+ if (i >= 0x08 && i <= 0x0B)
|
|
|
+ continue;
|
|
|
+ ChangeDisplay2Value(0x1200+i,1);
|
|
|
+ }
|
|
|
ChangeDisplay2Value(0x5000,1);
|
|
|
+ ChangeDisplay2Value(0x1002,0);
|
|
|
+
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
+ if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
|
|
|
+ ChangeDisplay2Value(_ConfirmLeftIcon,_ICON_WELCOMELEFTCCS1);
|
|
|
+ ChangeDisplay2Value(_PayFailLeftIcon,_ICON_PAYFAILLEFTCCS1);
|
|
|
+
|
|
|
+ } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
|
|
|
+ ChangeDisplay2Value(_ConfirmLeftIcon,_ICON_WELCOMELEFTCCS2);
|
|
|
+ ChangeDisplay2Value(_PayFailLeftIcon,_ICON_PAYFAILLEFTCCS2);
|
|
|
+ } else if (pDcChargingInfo->Type == _Type_Chademo) {
|
|
|
+ ChangeDisplay2Value(_ConfirmLeftIcon,_ICON_WELCOMELEFTCHADEMO);
|
|
|
+ ChangeDisplay2Value(_PayFailLeftIcon,_ICON_PAYFAILLETCHADEMO);
|
|
|
+ }
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
|
|
|
+ if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
|
|
|
+ ChangeDisplay2Value(_ConfirmRightIcon,_ICON_WELCOMERIGHTCCS1);
|
|
|
+ ChangeDisplay2Value(_PayFailRightIcon,_ICON_PAYFAILRIGHTCCS1);
|
|
|
+ } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
|
|
|
+ pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
|
|
|
+ ChangeDisplay2Value(_ConfirmRightIcon,_ICON_WELCOMERIGHTCCS2);
|
|
|
+ ChangeDisplay2Value(_PayFailRightIcon,_ICON_PAYFAILRIGHTCCS2);
|
|
|
+ } else if (pDcChargingInfo->Type == _Type_Chademo) {
|
|
|
+ ChangeDisplay2Value(_ConfirmRightIcon,_ICON_WELCOMERIGHTCHADEMO);
|
|
|
+ ChangeDisplay2Value(_PayFailRightIcon,_ICON_PAYFAILRIGHTCHADEMO);
|
|
|
+ }
|
|
|
}
|
|
|
+static int InitialRfidPort(void)
|
|
|
+{
|
|
|
+ int fd = open(rfidPortName, O_RDWR);
|
|
|
+ struct termios tios;
|
|
|
+ struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
|
|
|
+
|
|
|
+ if (fd != FAIL) {
|
|
|
+ ioctl (fd, TCGETS, &tios);
|
|
|
+ tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
|
|
|
+ tios.c_lflag = 0;
|
|
|
+ tios.c_iflag = 0;
|
|
|
+ tios.c_oflag = 0;
|
|
|
+ tios.c_cc[VMIN] = 0;
|
|
|
+ tios.c_cc[VTIME] = (uint8_t) 1;
|
|
|
+ tios.c_lflag = 0;
|
|
|
+ tcflush(fd, TCIFLUSH);
|
|
|
+ ioctl(fd, TCSETS, &tios);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fd < 0) {
|
|
|
+ pAlarmCode->AlarmEvents.bits.RfidModuleCommFail = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return fd;
|
|
|
+}
|
|
|
+
|
|
|
int main(void)
|
|
|
{
|
|
|
bool defaulttext = false;
|
|
@@ -1100,9 +1330,9 @@ int main(void)
|
|
|
ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
|
|
|
ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
|
|
|
ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
|
|
|
+ ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
|
|
|
struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
|
|
|
- struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
- struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
|
|
|
+
|
|
|
_port = CreateCommunicationLcmPort();
|
|
|
uint8_t changeWarningPriority = 0;
|
|
|
uint8_t curWarningCount = 255;
|
|
@@ -1116,7 +1346,15 @@ int main(void)
|
|
|
DefautLayOut();
|
|
|
//return 0;
|
|
|
//uint8_t index = 1;
|
|
|
+
|
|
|
+ int result = 0;
|
|
|
+
|
|
|
ShmDcCommonData->PSU_Number = 12;
|
|
|
+ /*
|
|
|
+ CardReadFd = InitialRfidPort();
|
|
|
+ if (CardReadFd <0) {
|
|
|
+ log_info("Card Read Port open fail!");
|
|
|
+ }*/
|
|
|
|
|
|
CheckLCMPressed();
|
|
|
|
|
@@ -1129,6 +1367,7 @@ int main(void)
|
|
|
|
|
|
} else {
|
|
|
UpdateLcmFunction(ShmDcCommonData,_port);
|
|
|
+
|
|
|
///*
|
|
|
// Warning 處理
|
|
|
if (curWarningCount != pSysWarning->WarningCount) {
|
|
@@ -1175,6 +1414,7 @@ int main(void)
|
|
|
|
|
|
ChangeCurPage();
|
|
|
changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
|
|
|
+
|
|
|
usleep(10000); //*/
|
|
|
|
|
|
/*
|