#include /*標準輸入輸出定義*/ #include /*標準函數庫定義*/ #include #include #include #include #include #include #include #include #include "Module_LcmControl.h" #include "../Log/log.h" #include "../ShareMemory/shmMem.h" #include "../Define/define.h" #include "../Config.h" #include "../SelectGun/SelectGun.h" #include "../CSU/main.h" #include "../timeout.h" #define uSEC_VAL (1000000) //------------------------------------------------------------------------------ //struct SysConfigAndInfo *ShmSysConfigAndInfo; //struct StatusCodeData *ShmStatusCodeData; 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; short _currentPage = _PAGE_NONE; uint8_t _totalCount; uint8_t _showInformIndex = 0; float ChargeMaxPower_0 = 0; float ChargeMaxPower_1 = 0; bool _battery_display_ani = false; int _port; //char* pPortName = "/dev/ttyO2"; 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; uint8_t _btn_press_count = 0; int _Text_Running_Count = 1; 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; } void GetClockTime(struct timespec *_now_time, void *null) { clock_gettime(CLOCK_MONOTONIC, _now_time); } void StartSystemTimeoutDet(uint8_t flag) { if (pSysInfo->SystemTimeoutFlag != flag) { GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL); } pSysInfo->SystemTimeoutFlag = flag; } void StopSystemTimeoutDet(void) { GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL); pSysInfo->SystemTimeoutFlag = Timeout_None; } void StartGunInfoTimeoutDet(uint8_t gunIndex, uint8_t flag) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex); if (gunIndex < pSysConfig->TotalConnectorCount) { if (pDcChargingInfo->TimeoutFlag != flag) { GetClockTime(&pDcChargingInfo->ConnectorTimeout, NULL); } pDcChargingInfo->TimeoutFlag = flag; } } void StopGunInfoTimeoutDet(uint8_t gunIndex) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex); if (gunIndex < pSysConfig->TotalConnectorCount) { pDcChargingInfo->TimeoutFlag = Timeout_None; } } unsigned long GetClockTimeoutValue(struct timespec _start_time) { struct timespec ts_end; unsigned long ret = 0; clock_gettime(CLOCK_MONOTONIC, &ts_end); ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec/ 1000))); return ret; } int CreateCommunicationLcmPort() { int fd; struct termios tios; fd = open(pPortName, O_RDWR); if (fd <= 0) { log_error("open /dev/ttyS3 NG "); return -1; } 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) 5; tios.c_lflag = 0; tcflush(fd, TCIFLUSH); ioctl(fd, TCSETS, &tios); return fd; } bool isChargingEnd(gunIndex) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex); if (pDcChargingInfo->SystemStatus == S_COMPLETE || pDcChargingInfo->SystemStatus == S_ALARM) { return TRUE; } else { return FALSE; } } 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 WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen) { int len = write(_port, cmd, cmdLen); if (len < sizeof(cmd)) { log_error("Write cmd to LCM Failure. "); } } void ReadMsgFromLcm(uint8_t* msg, uint8_t readLen) { read(_port, msg, readLen); // 5a : CMD_TITLE_1 // a5 : CMD_TITLE_2 // 5 // 81 : CMD_WRITE // 3 : CMD_REGISTER // 2 : Data length // 0 : High byte // 1 : Low byte // printf("-------------------------------------------- \n"); // printf("msg = %x \n", *msg); // A5 // printf("msg = %x \n", *(msg + 1)); // 5A // printf("msg = %x \n", *(msg + 2)); // Len : [3] ~ [6] + Data Len // printf("msg = %x \n", *(msg + 3)); // cmd : 0x83 // printf("msg = %x \n", *(msg + 4)); // addr : H // printf("msg = %x \n", *(msg + 5)); // addr : L // printf("msg = %x \n", *(msg + 6)); // Data Len // // printf("msg = %x \n", *(msg + 7)); // printf("msg = %x \n", *(msg + 8)); // printf("msg = %x \n", *(msg + 9)); // printf("msg = %x \n", *(msg + 10)); // printf("msg = %x \n", *(msg + 11)); // printf("msg = %x \n", *(msg + 12)); // printf("msg = %x \n", *(msg + 13)); // printf("msg = %x \n", *(msg + 14)); /* for(uint8_t i = 0 ; iLcmHwRev, "") != EQUAL) strcpy((char*)pSysInfo->LcmHwRev, moduleName); _currentPage = *(msg + 7); log_info("Current Page:%d", _currentPage); // if (_currentPage != 1 && _currentPage != 5 && _currentPage != 6 && _currentPage != 7 && _currentPage != 8) // printf("_currentPage = %d \n", _currentPage); } break; } } else if (*(msg + 3) == CMD_MULTI_READ) { short key = ((short)(*(msg + 4) << 8) + *(msg + 5)); if (strcmp((char*)pSysInfo->LcmHwRev, "") != EQUAL) strcpy((char*)pSysInfo->LcmHwRev, moduleName); if (key == 0x0014) _currentPage = *(msg + 8); if (key == 0x0031) { log_info("Get LCM Backlight change to 0x%x", *(msg + 8)); } if (key >= _Touch_IDLE && key <= _Touch_Parking_Complete) { _btn_press_id = key; _btn_press = *(msg + 8); } // switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5)) // { // case BUTTON_GUN_INDEX: // { // // 當前選的槍號 // _curGunIndex = (*(msg + 8)); // } // break; // } } } } void GetDeviceInfoStatus(short address, uint8_t len) { uint8_t cmd[8]; memset(cmd, 0x00, sizeof(cmd)); uint8_t msg[11]; memset(msg, 0x00, sizeof(msg)); cmd[0] = CMD_TITLE_1; cmd[1] = CMD_TITLE_2; cmd[2] = 0x04; cmd[3] = CMD_MULTI_READ; cmd[4] = (address >> 8) & 0xff; cmd[5] = (address >> 0) & 0xff; cmd[6] = len; WriteCmdToLcm(cmd, ARRAY_SIZE(cmd)); usleep(1000); ReadMsgFromLcm(msg, ARRAY_SIZE(msg)); } void DisplayValueToLcm(short address, uint8_t* data, uint8_t len) { uint8_t cmd[256]; memset(cmd, 0x00, sizeof(cmd)); uint8_t msg[9]; memset(msg, 0x00, sizeof(msg)); cmd[0] = CMD_TITLE_1; cmd[1] = CMD_TITLE_2; cmd[2] = 0x03 + len; cmd[3] = CMD_MULTI_WRITE; cmd[4] = address >> 8; cmd[5] = address & 0x00FF; for (uint8_t count = 0; count < len; count++) { cmd[6 + count] = *(data + count); } WriteCmdToLcm(cmd, cmd[2] + 3); usleep(10000); ReadMsgFromLcm(msg, ARRAY_SIZE(msg)); } void ChangeDisplay2Value(short address, short value) { uint8_t data[2]; data[0] = value >> 8; data[1] = value & 0x00FF; //log_info("Addr:0x%x, value:%d",address,value); DisplayValueToLcm(address, data, sizeof(data)); } void TradeRunning(uint8_t _run) { if (_run == TRUE) { ChangeDisplay2Value(_Icon_PreAuth, 1); ChangeDisplay2Value(_Icon_Ani_Dot, 1); ChangeDisplay2Value(_Icon_CountDownBG, 0); ChangeDisplay2Value(_Icon_CancelCntDownTen, 0); ChangeDisplay2Value(_Icon_CancelCntDownDigits, 0); ChangeDisplay2Value(_Icon_PreAuthWord, _TCC_PreAuthWord); } else { ChangeDisplay2Value(_Icon_PreAuth, _TCC_TradeCancelString); ChangeDisplay2Value(_Icon_Ani_Dot, 0); ChangeDisplay2Value(_Icon_PreAuthWord, 0); ChangeDisplay2Value(_Icon_CountDownBG, _TCC_TradeCancelFrame); //log_info("SystemTimeoutFlag:%d", pSysInfo->SystemTimeoutFlag); if (pSysInfo->SystemTimeoutFlag == Timeout_TradeCancel) { unsigned long _time = TCC_TRADECANCEL_TIMEOUT-(GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL); ChangeDisplay2Value(_Icon_CancelCntDownTen, (short)(_TCC_CancelNum_0 + (_time / 10))); ChangeDisplay2Value(_Icon_CancelCntDownDigits, (short)(_TCC_CancelNum_0 + (_time % 10))); } } } static void systemPageRestoreInit(void) { int is_idle = TRUE; int gunIndex; for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) { pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex); // 檢查電樁狀態是否為idle狀態 if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING && pDcChargingInfo->SystemStatus <= S_RESERVATION) || (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST0)) { is_idle = FALSE; } } if (is_idle) pSysInfo->SystemPage = _PAGE_IDLE; else pSysInfo->SystemPage = _PAGE_SELECT_GUN; } void CheckIdlePress() { systemPageRestoreInit(); log_info("IDLE Enter Select Gun Page"); } void CheckReturnPress() { int i; pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); //pDcChargingInfo->SystemStatus = S_IDLE; if (pSysInfo->SystemPage >= _PAGE_BILL && pSysInfo->SystemPage <= _PAGE_PLUGIN || pSysInfo->SystemPage == _PAGE_AUTHORIZE_FAIL || pSysInfo->SystemPage == _PAGE_DONATE_RIGHT) { if (pSysInfo->SystemPage == _PAGE_AUTHORIZE && ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].isParking) { log_info("Parking Status cann't press return button"); return; } ShmDcCommonData->OperateIDLE[pSysInfo->CurGunSelected] = 1; StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].GetParkingBill = FALSE; ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].isParking = FALSE; log_info("Operate return to IDLE"); } // Cancel Trade if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus) { ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].GetParkingBill = FALSE; //if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) { log_info("Press Return button Cancel Sale"); ShmDcCommonData->TradeCancel = TRUE; pSysInfo->SystemPage = _PAGE_SENSING; StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); StartSystemTimeoutDet(Timeout_TradeCancel); for (i = 0; i <= 60; i++) { if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus == _TCC_PARKING_OCCUPENCY_Ready || ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].DeductResult == _DEDUCT_SALE_PASS) break; sleep(1); } //} ShmDcCommonData->TradeCancel = FALSE; StopSystemTimeoutDet(); systemPageRestoreInit(); return; } else if ( pDcChargingInfo->SystemStatus == S_AUTHORIZING || ((pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION ) && pSysInfo->SystemPage == _PAGE_AUTHORIZE)) { log_info("Press Return button cancel PreAuth"); ShmDcCommonData->TradeCancel = TRUE; pSysInfo->SystemPage = _PAGE_SENSING; StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); StartSystemTimeoutDet(Timeout_TradeCancel); for (i = 0; i <= 30; i++) { if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE) break; sleep(1); } ShmDcCommonData->PreAuth_Result = 0; ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE; if (strcmp(ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard.VemData, "") != 0) { ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL; ShmDcCommonData->PreAuth_Result = 0; for (i = 0; i <= 30; i++) { if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE) break; sleep(1); } ShmDcCommonData->PreAuth_Result = 0; } StopSystemTimeoutDet(); pDcChargingInfo->SystemStatus = S_IDLE; systemPageRestoreInit(); strcpy((char *)pSysConfig->UserId, ""); return; } if ( pSysInfo->SystemPage == _PAGE_EXIT ) { StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); pDcChargingInfo->SystemStatus = S_IDLE; return; } if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) pSysInfo->SystemPage = _PAGE_SELECT_PAY; else systemPageRestoreInit(); } void CheckStopPress() { //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() { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); pDcChargingInfo->SystemStatus = S_TERMINATING; pSysInfo->SystemPage = _PAGE_PAYING; is_stop = TRUE; /* //ShmDcCommonData->StopCharge[pSysInfo->CurGunSelected] = TRUE; if (ShmDcCommonData->is_AutoStart[pSysInfo->CurGunSelected] || ShmDcCommonData->is_RemoteStart[pSysInfo->CurGunSelected]) { pSysInfo->SystemPage = _PAGE_COMPLETE; return; } */ } void CheckStopCancelPress() { //ChangeDisplay2Value(_ConfirmStopIcon,is_stop); pSysInfo->SystemPage = _PAGE_CHARGING; is_stop = FALSE; } void CheckConfirmGun(uint8_t gunIndex) { pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex); if (pDcChargingInfo->SystemStatus == S_RESERVATION) { log_info("Reservation can't select"); return; } //log_info("Confirm Gun%d",gunIndex); pSysInfo->CurGunSelected = gunIndex; if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus) { if (pDcChargingInfo->SystemStatus == S_IDLE) ShmDcCommonData->pGunInfo[gunIndex].ReqParkingBill = TRUE; //else if (isChargingEnd(gunIndex)) { //} if (pDcChargingInfo->SystemStatus == S_COMPLETE || pDcChargingInfo->SystemStatus == S_ALARM) { if (ShmDcCommonData->PayPass_flag[gunIndex] == TRUE) pSysInfo->SystemPage = _PAGE_COMPLETE; else { if (pDcChargingInfo->Replug_flag) pSysInfo->SystemPage = _PAGE_PLUGOUT; else pSysInfo->SystemPage = _PAGE_PAYFAIL; } } else { pSysInfo->SystemPage = _PAGE_PAYING; } } else { pSysInfo->SystemPage = _PAGE_BILL; } } void CheckDonateBill(uint8_t gunIndex) { if (gunIndex == LEFT_GUN_NUM) { pSysInfo->SystemPage = _PAGE_DONATE_LEFT; } else pSysInfo->SystemPage = _PAGE_DONATE_RIGHT; } void CheckDonateYes() { if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus) { StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); StartGunInfoTimeoutDet(pSysInfo->CurGunSelected, Timeout_ParkingSelect); ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].IsDonateInvoice = TRUE; } else { ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsDonateInvoice = TRUE; } pSysInfo->SystemPage = _PAGE_SELECT_PAY; } void CheckDonateNo() { if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus) { StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); StartGunInfoTimeoutDet(pSysInfo->CurGunSelected, Timeout_ParkingSelect); ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].IsDonateInvoice = FALSE; } else { StartSystemTimeoutDet(Timeout_AddLine); ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].IsDonateInvoice = FALSE; } pSysInfo->SystemPage = _PAGE_BILL; } void CheckPayCreditCard() { //ShmDcCommonData->LineStatus[pSysInfo->CurGunSelected] = 0; pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected); // 使用者進入線上支付,禁止使用者使用刷卡機 if (ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].LineStatus == _LINE_PAY_OPERATE || pDcChargingInfo->SystemStatus == S_RESERVATION ) { pSysInfo->SystemPage = _PAGE_LINEPAYING; StartSystemTimeoutDet(Timeout_LINEPAYING); log_info("Some one online operate"); return; } ShmDcCommonData->TradeCancel = FALSE; if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus) { if ((pDcChargingInfo->SystemStatus == S_IDLE || isChargingEnd(pSysInfo->CurGunSelected)) && ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE) { ShmDcCommonData->PreAuth_Config = _CREDITCARD_SALE; ShmDcCommonData->PreAuth_Result = 0; pSysInfo->SystemPage = _PAGE_AUTHORIZE; } } else { if ((pDcChargingInfo->SystemStatus == S_IDLE ) && pSysInfo->SystemPage == _PAGE_SELECT_PAY && ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE) { ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH; ShmDcCommonData->PreAuth_Result = 0; pSysInfo->SystemPage = _PAGE_AUTHORIZE; //log_info("Press Credit card pay status:%d Page:%d Config:%d", pDcChargingInfo->SystemStatus, // pSysInfo->SystemPage, ShmDcCommonData->PreAuth_Config); } } } void CheckPayLinePay() { log_info("Change to Add Line Friend Page"); StopSystemTimeoutDet(); StopGunInfoTimeoutDet(pSysInfo->CurGunSelected); pSysInfo->SystemPage = _PAGE_ADD_FRIEND; } void CheckTouchPress(short 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 >= 2) { ChangeDisplay2Value(id, 0); //log_info("Press id : 0x%04x",id); _btn_press_count = 0; switch (id) { case _Touch_Show_Left: if (pSysInfo->SystemPage >= _PAGE_BILL && pSysInfo->SystemPage <= _PAGE_PLUGIN) { log_info("Authorize Process can't select gun"); return; } // Show log if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM); pSysInfo->CurGunSelected = LEFT_GUN_NUM; if(pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION) { systemPageRestoreInit(); } log_info("LCM left Gun down...............................%x %x %x", pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage); } pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM); if (ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ParkingStatus) { if (pDcChargingInfo->SystemStatus == S_COMPLETE || pDcChargingInfo->SystemStatus == S_ALARM) { if (ShmDcCommonData->PayPass_flag[LEFT_GUN_NUM] == TRUE) pSysInfo->SystemPage = _PAGE_COMPLETE; else { if (pDcChargingInfo->Replug_flag) pSysInfo->SystemPage = _PAGE_PLUGOUT; else pSysInfo->SystemPage = _PAGE_PAYFAIL; } } } if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE || pSysInfo->SystemPage == _PAGE_PAYFAIL) { StopSystemTimeoutDet(); } break; case _Touch_Show_Right: if (pSysInfo->SystemPage >= _PAGE_BILL && pSysInfo->SystemPage <= _PAGE_PLUGIN) { log_info("Authorize Process can't select gun"); return; } // Show log if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM); pSysInfo->CurGunSelected = RIGHT_GUN_NUM; if (pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION) { systemPageRestoreInit(); } log_info("LCM Right Gun down...............................%x %x %x", pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage); } pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM); if (ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ParkingStatus) { if (pDcChargingInfo->SystemStatus == S_COMPLETE || pDcChargingInfo->SystemStatus == S_ALARM) { if (ShmDcCommonData->PayPass_flag[RIGHT_GUN_NUM] == TRUE) pSysInfo->SystemPage = _PAGE_COMPLETE; else if (pDcChargingInfo->Replug_flag) pSysInfo->SystemPage = _PAGE_PLUGOUT; else pSysInfo->SystemPage = _PAGE_PAYFAIL; } } if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE || pSysInfo->SystemPage == _PAGE_PAYFAIL) { StopSystemTimeoutDet(); } break; case _Touch_Return: CheckReturnPress(); break; case _Touch_IDLE: CheckIdlePress(); break; case _Touch_StopCharge: CheckStopPress(); break; case _Touch_Stop_Confirm: CheckStopConfirmPress(); break; case _Touch_Stop_Cancel: CheckStopCancelPress(); break; case _Touch_Select_Left: CheckConfirmGun(LEFT_GUN_NUM); break; case _Touch_Select_Right: CheckConfirmGun(RIGHT_GUN_NUM); break; case _Touch_DonateBill: StopSystemTimeoutDet(); CheckDonateBill(pSysInfo->CurGunSelected); break; case _Touch_DonateYes: CheckDonateYes(); break; case _Touch_DonateNo: CheckDonateNo(); break; case _Touch_Pay_CreditCard: CheckPayCreditCard(); break; case _Touch_Pay_LinePay: CheckPayLinePay(); break; case _Touch_Parking_Complete: ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ReqParkingBill = TRUE; pSysInfo->SystemPage = _PAGE_PAYING; //log_info("Set Page to %d",pSysInfo->SystemPage); break; } // switch } //if (_btn_press >= 3) } void CheckLCMPressed() { pid_t Pid = fork(); if ( Pid == 0 ) { while (1) { if (pSysInfo->SystemPage != _PAGE_SELECT_GUN && pSysInfo->SystemPage != _PAGE_IDLE) { CheckTouchPress(_Touch_Show_Left); CheckTouchPress(_Touch_Show_Right); } switch (pSysInfo->SystemPage) { case _PAGE_IDLE: //CheckTouchPress(_Touch_IDLE); CheckTouchPress(_Touch_Select_Left); CheckTouchPress(_Touch_Select_Right); break; case _PAGE_SELECT_GUN: CheckTouchPress(_Touch_Select_Left); CheckTouchPress(_Touch_Select_Right); break; case _PAGE_BILL: CheckTouchPress(_Touch_Return); CheckTouchPress(_Touch_DonateBill); CheckTouchPress(_Touch_Pay_LinePay); break; case _PAGE_ADD_FRIEND: CheckTouchPress(_Touch_Return); //CheckTouchPress(_Touch_DonateBill); break; case _PAGE_DONATE_LEFT: case _PAGE_DONATE_RIGHT: CheckTouchPress(_Touch_Return); CheckTouchPress(_Touch_DonateYes); CheckTouchPress(_Touch_DonateNo); break; case _PAGE_SELECT_PAY: CheckTouchPress(_Touch_Pay_CreditCard); CheckTouchPress(_Touch_Return); break; case _PAGE_PLUGIN: CheckTouchPress(_Touch_Return); break; ///* case _PAGE_CHARGING: CheckTouchPress(_Touch_StopCharge); break; case _PAGE_AUTHORIZE: CheckTouchPress(_Touch_Return); break; case _PAGE_STOP_CONFIRM_LEFT: case _PAGE_STOP_CONFIRM_RIGHT: StopSystemTimeoutDet(); CheckTouchPress(_Touch_Stop_Confirm); CheckTouchPress(_Touch_Stop_Cancel); break; case _PAGE_EXIT: CheckTouchPress(_Touch_Return); break; case _PAGE_AUTHORIZE_FAIL: CheckTouchPress(_Touch_Return); break; case _PAGE_COMPLETE: case _PAGE_PAYFAIL: case _PAGE_PLUGOUT: if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus >= _TCC_PARKING_OCCUPENCY) CheckTouchPress(_Touch_Parking_Complete); break; } // switch usleep(5000); } //while } // if pid log_info("Create LCM fork:%d\n\n",Pid); } void GetHrFormTimeString(char* time,char* hr) { //char tm[] = "2021-12-06 17:29:08:084"; for(int i = 0 ; i < 2 ; i++) { hr[i] = time[i+11]; } if( atoi(hr) < 0 || atoi(hr) > 24) { strcmp(hr,""); } } void GetMinFormTimeString(char* time,char* min) { //char tm[] = "2021-12-06 17:29:08:084"; for(int i = 0 ; i < 2 ; i++) { min[i] = time[i+14]; } if( atoi(min) < 0 || atoi(min) > 60) { strcmp(min,""); } } //================================================ // Function //================================================ void ChangeToOtherPage(short newPage) { uint8_t cmd[10]; memset(cmd, 0x00, sizeof(cmd)); uint8_t msg[9]; memset(msg, 0x00, sizeof(msg)); cmd[0] = CMD_TITLE_1; cmd[1] = CMD_TITLE_2; cmd[2] = 0x07; cmd[3] = 0x82; cmd[4] = 0x00; cmd[5] = 0x84; cmd[6] = 0x5A; cmd[7] = 0x01; cmd[8] = newPage >> 8; cmd[9] = newPage & 0x00FF; WriteCmdToLcm(cmd, ARRAY_SIZE(cmd)); usleep(5000); ReadMsgFromLcm(msg, ARRAY_SIZE(msg)); } void ChangeBackLight(uint8_t value) { //uint8_t value = 0x01; uint8_t msg[9]; memset(msg, 0x00, sizeof(msg)); uint8_t cmd[7]; memset(cmd, 0x00, sizeof(cmd)); cmd[0] = CMD_TITLE_1; cmd[1] = CMD_TITLE_2; cmd[2] = 0x05; cmd[3] = CMD_MULTI_WRITE; cmd[4] = 0x00; cmd[5] = 0x82; cmd[6] = value; WriteCmdToLcm(cmd, ARRAY_SIZE(cmd)); usleep(10000); ReadMsgFromLcm(msg, ARRAY_SIZE(msg)); } void GetCurrentPage() { uint8_t cmd[7]; memset(cmd, 0x00, sizeof(cmd)); uint8_t msg[9]; memset(msg, 0x00, sizeof(msg)); cmd[0] = CMD_TITLE_1; cmd[1] = CMD_TITLE_2; cmd[2] = 0x04; // 底下總長度 cmd[3] = 0x83; cmd[4] = 0x00; cmd[5] = 0x14; cmd[6] = 0x01; WriteCmdToLcm(cmd, ARRAY_SIZE(cmd)); usleep(5000); ReadMsgFromLcm(msg, ARRAY_SIZE(msg)); } //================================================ // Warning process //================================================ void string2ByteArray(uint8_t *input, uint8_t *output) { int loop; int i; loop = 0; i = 0; while (input[loop] != '\0') { output[i++] = input[loop++]; } output[loop] = '\0'; } void RefreshProgressAnimation() { _everyPageRollChange >= 30 ? _everyPageRollChange = 0 : _everyPageRollChange++; } //================================================ // Change current page //================================================ void ChangeCurPage() { //log_info("cur = %d ,system = %d, lcm = %d ",_currentPage, pSysInfo->SystemPage, pSysInfo->PageIndex); if (pSysInfo->PageIndex != pSysInfo->SystemPage) log_info("Gun[%d] Chagne LCM Page:%d",pSysInfo->CurGunSelected, pSysInfo->SystemPage); pSysInfo->PageIndex = pSysInfo->SystemPage; if (_currentPage != pSysInfo->PageIndex) { switch (pSysInfo->SystemPage) { case _PAGE_AUTHORIZE: break; case _PAGE_PLUGIN: break; case _PAGE_PRECHARGE: break; case _PAGE_CHARGING: break; case _PAGE_COMPLETE: is_stop = FALSE; break; case _PAGE_PAYFAIL: is_stop = FALSE; break; case _PAGE_MAINTAIN: break; } _currentPage = pSysInfo->PageIndex; //if (pSysInfo->PageIndex != _PAGE_IDLE) ChangeToOtherPage(pSysInfo->PageIndex); } } /* * View Page * */ unsigned long GetTimeoutValue(struct timeval _sour_time) { struct timeval _end_time; gettimeofday(&_end_time, NULL); return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec; } void showGunWorkingType() { if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM); if (ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_LeftParkingSel); } else { if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_On); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_On); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_On); } } // Set Right Gun pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM); if (ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_RightParkingSel); } else { if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_Off); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_Off); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off); } } } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM){ // Left Gun pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM); if (ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_LeftParkingSel); } else { if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_Off); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_Off); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_Off); } } // Right Gun pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM); if (ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_RightParkingSel); } else { if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_On); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_On); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_On); } } } } void ClearQrCode_Idle() { char cmd[200]; memset(cmd,0,200); DisplayValueToLcm(_QRCode_AddLine, cmd, 200); } void ChangeQrCode_Idle(char *input) { char cmd[256]; pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); int len = 0; memset(cmd,0,256); time_t timep; struct tm* tm; time(&timep); char SN[37]; memset(SN,'\0',sizeof(SN)); memcpy(SN,ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].OccupancySN,36); tm = localtime(&timep); if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus && !ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingCntDownFlag) { tm->tm_year -= 50; ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingStopTime = mktime(tm) + 120 +(ShmDcCommonData->TZOffset * 60); ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingCntDownFlag = TRUE; tm = gmtime(&ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingStopTime); log_info("QR Code Show Time:(%d)%s",ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingStopTime,asctime(tm)); } if (!ShmDcCommonData->tccdev) { if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus) { //len = sprintf(cmd, "https://nhoatcc.lineapid.tw/web/placeholder?sn=%s&ts=%d",SN, // ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingStopTime); len = sprintf(cmd, "https://liff.line.me/1656875983-yr0MMWqY/web_placeholder/sn/%s/ts/%d",SN, ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingStopTime); } else //len = sprintf(cmd, "https://nhoatcc.lineapid.tw/web/tologin?sn=%s&cid=%d", input, ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]); len = sprintf(cmd, "https://liff.line.me/1656875983-yr0MMWqY/tologin/sn/%s/cid/%d", input, ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]); } else { if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ParkingStatus) { len = sprintf(cmd, "https://liff.line.me/1656908881-rjazze69/web_placeholder/sn/%s/ts/%d",SN, ShmDcCommonData->ParkingInfo[pSysInfo->CurGunSelected].ParkingStopTime); } else { //len = sprintf(cmd, "https://nhoatcctest.lineapid.tw/web/tologin?sn=%s&cid=%d", input, ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]); len = sprintf(cmd, "https://liff.line.me/1656908881-rjazze69/tologin/sn/%s/cid/%d", input, ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]); } } //log_info("QR Code:URL:%s",cmd); if (pSysInfo->SystemPage == _PAGE_ADD_FRIEND) DisplayValueToLcm(_QRCode_AddLine, cmd, len+1); } void ClearQrCode_Error() { char cmd[200]; memset(cmd, 0, 200); DisplayValueToLcm(_QRCode_Service, cmd, 200); } void ChangeQrCode_Error() { char cmd[200]; memset(cmd, 0, 200); sprintf(cmd, "https://line.me/R/ti/p/@217tcevc"); //log_info("QR Code:URL:%s",cmd); DisplayValueToLcm(_QRCode_Service, cmd, 200); } /* void ChangeRemainTime(int sec) { int h, m, s; uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); // srand(time(NULL)); // int min = 0; // int max = 65536; // sec = rand() % (max - min + 1) + min; h = (sec / 3600); m = (sec - (3600 * h)) / 60; s = (sec - (3600 * h) - (m * 60)); sprintf((char *)value, "%02d:%02d:%02d", h, m, s); string2ByteArray(value, cmd); DisplayValueToLcm(_Text_Time, cmd, sizeof(cmd)); } */ void ShowSelectGun() { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM); if (ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ParkingStatus){ ChangeDisplay2Value(_Icon_Select_Left,_TCC_LeftParkingIdle); } else if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING && pDcChargingInfo->SystemStatus <= S_ALARM) || pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 || pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) { // 使用中 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_ShowLeftGunCharging_CCS2); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunCharging_CHAdeMo); } } else if (pDcChargingInfo->SystemStatus == S_RESERVATION) { // 預約中 if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunReservation_CCS1); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunReservation_CCS2); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_ShowLeftGunReservation_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 (ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_Select_Right,_TCC_RightParkingIdle); } else if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING && pDcChargingInfo->SystemStatus <= S_ALARM) || pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 || pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) { 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_ShowRightGunCharging_CCS2); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunCharging_CHAdeMo); } } else if (pDcChargingInfo->SystemStatus == S_RESERVATION) { if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunReservation_CCS1); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunReservation_CCS2); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_ShowRightGunReservation_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) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); sprintf((char *) value, "%d",(int)pow); string2ByteArray(value, cmd); DisplayValueToLcm(_String_ChargePower, cmd, sizeof(cmd)); } void ChangeChargingRateValue(float rate,int show) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); if (show) sprintf((char *) value, "%.1f",rate); else sprintf((char *) value, ""); string2ByteArray(value, cmd); DisplayValueToLcm(_String_ChargeRate, cmd, sizeof(cmd)); } void ChangeChargingFeeValue(float fee) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); sprintf((char *) value, "%d", (int)fee); string2ByteArray(value, cmd); DisplayValueToLcm(_String_Money, cmd, sizeof(cmd)); } void ChangeCarBonValue(float data) { uint8_t cmd[10]; uint8_t value[10]; float _carbon = 0; memset(cmd, 0x00, sizeof(cmd)); _carbon = data * 0.577; //log_info("Carbon:%d",(int)_carbon); sprintf((char *) value, "%.1f", _carbon); string2ByteArray(value, cmd); DisplayValueToLcm(_String_Carbon, cmd, sizeof(cmd)); } void ChangeChargingEnergyValue(float energy) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); if (energy >= 0.05) { energy -= 0.05; } if (energy < 0 ) ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0); else if (energy > 100) ChangeDisplay2Value(_Icon_ChargeBar,_TCC_Charging_Bar0+100); else ChangeDisplay2Value(_Icon_ChargeBar,(int)energy+_TCC_Charging_Bar0); if (energy < 10) sprintf((char *) value, "%.1f", energy); else sprintf((char *) value, "%d", (int)energy); string2ByteArray(value, cmd); DisplayValueToLcm(_Strting_Energy, cmd, sizeof(cmd)); } void ChangeParkingRateValue(float fee,int show) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); if (show) sprintf((char *) value, "%d", (int)fee); else sprintf((char *) value, ""); string2ByteArray(value, cmd); DisplayValueToLcm(_String_ParkRate, cmd, sizeof(cmd)); } void ChangeParkingLeaveTime(int min,int show) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); if (show) sprintf((char *) value, "%d", (int)min); else sprintf((char *) value, ""); string2ByteArray(value, cmd); DisplayValueToLcm(_String_ParkingLeaveTime, cmd, sizeof(cmd)); } void ChangeSaleLeaveTime(int min,int show) { uint8_t cmd[10]; uint8_t value[10]; memset(cmd, 0x00, sizeof(cmd)); if (show) sprintf((char *) value, "%d", (int)min); else sprintf((char *) value, ""); string2ByteArray(value, cmd); DisplayValueToLcm(_String_SaleLeaveTime, cmd, sizeof(cmd)); } uint8_t _battery_display_count = 0; void ChangeBattMapAndValue(int soc) { int i = (soc*36)/100; uint8_t cmd[5]; uint8_t value[5]; _battery_display_count++; if (_battery_display_count == 3 ) { if (_battery_display_ani == 0) _battery_display_ani= TRUE; else _battery_display_ani= FALSE ; _battery_display_count = 0; } if (pSysInfo->SystemPage == _PAGE_CHARGING) { if (i>=36) ChangeDisplay2Value(_Icon_ChargeCircle,_TCC_Charging_Circle0+36); else { if (_battery_display_ani) { ChangeDisplay2Value(_Icon_ChargeCircle, _TCC_Charging_Circle0+i); } else { ChangeDisplay2Value(_Icon_ChargeCircle, _TCC_Charging_Circle0+i+1); } } } else if (pSysInfo->SystemPage == _PAGE_COMPLETE) ChangeDisplay2Value(_Icon_CompleteCircle, _TCC_CompleteCircle0+i); else ChangeDisplay2Value(_Icon_CompleteCircle, _TCC_FAILCircle0 +i); memset(cmd, 0x00, sizeof(cmd)); memset(value, 0x00, sizeof(value)); sprintf((char *)value, "%d", soc); string2ByteArray(value, cmd); DisplayValueToLcm(_String_Battery, cmd, sizeof(cmd)); } unsigned long GetPreChargeTimeoutValue(struct timeval _sour_time) { struct timeval _end_time; gettimeofday(&_end_time, NULL); return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec; } void ChangeTimeValue(int time) { uint8_t cmd[6]; uint8_t value[6]; memset(cmd, 0x00, sizeof(cmd)); sprintf((char *) value, "%d", time); string2ByteArray(value, cmd); DisplayValueToLcm(_String_ChargeTime, cmd, sizeof(cmd)); } void changeWeatherValue(int _weather) { switch (_weather) { case _WEATHER_TYPE_SUN: ChangeDisplay2Value(_Icon_Weather,_TCC_Sun); break; case _WEATHER_TYPE_CLOUDY: ChangeDisplay2Value(_Icon_Weather,_TCC_Cloudy); break; case _WEATHER_TYPE_RAIN: ChangeDisplay2Value(_Icon_Weather,_TCC_Rain); break; case _WEATHER_TYPE_THUNDER: ChangeDisplay2Value(_Icon_Weather,_TCC_Thunder); break; case _WEATHER_TYPE_SNOW: ChangeDisplay2Value(_Icon_Weather,_TCC_Snow); break; case _WEATHER_TYPE_FOG: ChangeDisplay2Value(_Icon_Weather,_TCC_Fog); break; } } void changeWeekValue(int _week) { time_t timep; struct tm* tm; time(&timep); timep += (ShmDcCommonData->TZOffset * 60); tm = localtime(&timep); _week = tm->tm_wday; if (_week == 0 ) _week = 7; ChangeDisplay2Value(_Icon_Week,_week); } void changeDegreeValue(int _degree) { char value[16]; memset(value, 0x00, sizeof(value)); sprintf((char *)value,"%d",_degree); DisplayValueToLcm(_String_Tempture, (uint8_t *)value, sizeof(value)); } void changeDateValue(char* _date) { time_t timep; struct tm* tm; time(&timep); timep += (ShmDcCommonData->TZOffset * 60); tm = localtime(&timep); sprintf(_date, "%04d/%02d/%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); char value[16]; memset(value, 0x00, sizeof(value)); sprintf((char *)value,"%s",_date); DisplayValueToLcm(_String_Date, (uint8_t *)value, sizeof(value)); } void changeLocationValue(int _location) { //_location+=1000; //log_info("location:%d",_location); ChangeDisplay2Value(_Icon_Location,(short)_location); } void ShowLineRegisterCountDown(int _show) { if(!_show) { ChangeDisplay2Value(_Icon_ScanCntDw_BG,_ICON_Empty); ChangeDisplay2Value(_Icon_ScanCntDownTen, _ICON_Empty); ChangeDisplay2Value(_Icon_ScanCntDownDigits, _ICON_Empty); return; } int _ten, _digits; pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected); if (pDcChargingInfo->TimeoutFlag == Timeout_LineReigster) { _ten = (TCC_LINEREGISTER_TIMEOUT - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) / 10; _digits = (TCC_LINEREGISTER_TIMEOUT - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) % 10; ChangeDisplay2Value(_Icon_ScanCntDw_BG,_TCC_Scan_CntDw_BG); ChangeDisplay2Value(_Icon_ScanCntDownTen, (short)_TCC_CntDownNumber0+_ten); ChangeDisplay2Value(_Icon_ScanCntDownDigits, (short)_TCC_CntDownNumber0+ _digits); } else { //log_info("Not get Line Register Count Down"); } } void ShowAuthorizeCountDown() { int _ten, _digits; if (pSysInfo->SystemTimeoutFlag == Timeout_ScanCard) { ChangeDisplay2Value(_Icon_ScanCntDw_BG,_TCC_Scan_CntDw_BG); _ten = (TCC_SCANCARD_TIMEOUT - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL)) / 10; _digits = (TCC_SCANCARD_TIMEOUT - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL)) % 10; ChangeDisplay2Value(_Icon_AuthCntDownTen, (short)_TCC_CntDownNumber0 + _ten); ChangeDisplay2Value(_Icon_AuthCntDownDigits, (short)_TCC_CntDownNumber0 + _digits); } else { log_info("Not get Line Register Count Down"); } } void ShowParkingCountDown(int is_parking) { int _ten, _digits , _hun; unsigned char time_flag; int TimeoutTime; pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected); if (is_parking) { if (pSysInfo->SystemPage == _PAGE_ADD_FRIEND) { time_flag = Timeout_ParkingBill; TimeoutTime = TCC_PARKINGBILL_TIMEOUT; } else { time_flag = Timeout_ParkingSelect; TimeoutTime = TCC_PARK_SELECTPAY_TIMEOUT; } if (pDcChargingInfo->TimeoutFlag == time_flag ) { _hun = (TimeoutTime - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) / 100; _ten = ((TimeoutTime - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) / 10)%10; _digits = (TimeoutTime - (GetClockTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL)) % 10; if (pSysInfo->SystemPage == _PAGE_ADD_FRIEND) { ChangeDisplay2Value(_Icon_ParkingCntDw_BG, (short)_TCC_ParkingCntDown_BG3); ChangeDisplay2Value(_Icon_ParkingCntDw_Hun, (short)_TCC_ParkingCD_0 + _hun); ChangeDisplay2Value(_Icon_ParkingCntDw_Tens, (short)_TCC_ParkingCD_0 + _ten); ChangeDisplay2Value(_Icon_ParkingCntDw_Digits, (short)_TCC_ParkingCD_0 + _digits); } else { ChangeDisplay2Value(_Icon_ParkingCntDw_BG, (short)_TCC_ParkingCntDown_BG); ChangeDisplay2Value(_Icon_ParkingCntDw_Tens, (short)_TCC_ParkingCD_0 + _ten); ChangeDisplay2Value(_Icon_ParkingCntDw_Digits, (short)_TCC_ParkingCD_0 + _digits); } } else { log_info("Not get Parking Count Down(%d)",pDcChargingInfo->TimeoutFlag); } } else { ChangeDisplay2Value(_Icon_ParkingCntDw_BG, NULL); ChangeDisplay2Value(_Icon_ParkingCntDw_Hun, NULL); ChangeDisplay2Value(_Icon_ParkingCntDw_Tens, NULL); ChangeDisplay2Value(_Icon_ParkingCntDw_Digits, NULL); } } void changeGunType() { pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM); if (ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_Select_Left,_TCC_LeftParkingIdle); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CCS1); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CCS2); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_Select_Left, _TCC_IDLE_LEFT_CHAdeMo); } // Set Right Gun pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM); if (ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ParkingStatus) { ChangeDisplay2Value(_Icon_Select_Right,_TCC_RightParkingIdle); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CCS1); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CCS2); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_Select_Right, _TCC_IDLE_RIGHT_CHAdeMo); } } void ShowParkingInfo(bool is_show,uint8_t gunIndex) { char cmd[32]; if (is_show) { ChangeDisplay2Value(_Icon_ParkingInfo,_TCC_ParkingInfo); memset(cmd, 0x00, sizeof(cmd)); sprintf((char *)cmd,"%s",ShmDcCommonData->ParkingInfo[gunIndex].ParkingStartTime); DisplayValueToLcm(_String_ParkingStartTime, (uint8_t *)cmd, sizeof(cmd)); memset(cmd, 0x00, sizeof(cmd)); sprintf((char *)cmd,"%d",ShmDcCommonData->ParkingInfo[gunIndex].ParkingDuration); DisplayValueToLcm(_String_ParkingDuration, (uint8_t *)cmd, sizeof(cmd)); memset(cmd, 0x00, sizeof(cmd)); sprintf((char *)cmd,"%d",(int)ShmDcCommonData->ParkingInfo[gunIndex].Amount); DisplayValueToLcm(_String_ParkingFee, (uint8_t *)cmd, sizeof(cmd)); } else { if (pSysInfo->SystemPage == _PAGE_BILL) { ChangeDisplay2Value(_Icon_ParkingInfo,_TCC_ICON_SelectChargeMode); } else if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_AUTHORIZE) { ChangeDisplay2Value(_Icon_ParkingInfo,_TCC_ICON_SelectPayMode); } else { ChangeDisplay2Value(_Icon_ParkingInfo,NULL); } memset(cmd, 0x00, sizeof(cmd)); DisplayValueToLcm(_String_ParkingStartTime, (uint8_t *)cmd, sizeof(cmd)); DisplayValueToLcm(_String_ParkingDuration, (uint8_t *)cmd, sizeof(cmd)); DisplayValueToLcm(_String_ParkingFee, (uint8_t *)cmd, sizeof(cmd)); } if (pSysInfo->SystemPage >= _PAGE_BILL && pSysInfo->SystemPage <= _PAGE_SELECT_PAY) ShowParkingCountDown(is_show); } int old_money = 0; int ClearQR_flag[2]; void ProcessPageInfo() { if (ShmDcCommonData->CreditCardUpload) { pSysInfo->SystemPage = _PAGE_PAYING; } // Show Gun Working and Type if (pSysInfo->SystemPage == _PAGE_IDLE) { changeWeatherValue(ShmDcCommonData->WeatherID); changeWeekValue(0); changeDegreeValue((int)ShmDcCommonData->Temperature); changeDateValue(&ShmDcCommonData->PresentTime[0]); changeLocationValue(1000); changeGunType(); ClearQR_flag[pSysInfo->CurGunSelected] = FALSE; return; } if (pSysInfo->SystemPage == _PAGE_MAINTAIN) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM); if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS1_Off); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CCS2_Off); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_ShowLeft,_TCC_ShowLeft_CHAdeMo_Off); } // Set Right Gun pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM); if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS1_Off); } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid || pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CCS2_Off); } else if (pDcChargingInfo->Type == _Type_Chademo) { ChangeDisplay2Value(_Icon_ShowRight,_TCC_ShowRight_CHAdeMo_Off); } ChangeQrCode_Error(); return; } showGunWorkingType(); for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) { if (pSysInfo->CurGunSelected == i) { pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i); if (pDcChargingInfo->SystemStatus == S_IDLE) { _everyPageRollChange = 0; _Text_Running_Count = 1; } if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) { if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ChangeDisplay2Value(_Icon_Return,NULL); } else { ChangeDisplay2Value(_Icon_Return,_TCC_Return); } ShowParkingCountDown(FALSE); } else { ChangeDisplay2Value(_Icon_Return,_TCC_Return); } switch (pSysInfo->SystemPage) { case _PAGE_IDLE: ShowSelectGun(); ClearQR_flag[i] = FALSE; break; case _PAGE_SELECT_PAY: if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ShowParkingInfo(true,i); } else { ShowParkingInfo(false,i); } break; case _PAGE_SELECT_GUN: ShowSelectGun(); ClearQR_flag[i] = FALSE; break; case _PAGE_BILL: if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ChangeDisplay2Value(_Icon_Add_Line,_TCC_ParkingLine); ChangeDisplay2Value(_Icon_Donate,_TCC_ParkingDonate); ShowParkingInfo(true,i); } else { ChangeDisplay2Value(_Icon_Add_Line,_TCC_GetBill); ChangeDisplay2Value(_Icon_Donate,_TCC_DonateBill); ShowParkingInfo(false,i); } break; case _PAGE_AUTHORIZE: StartSystemTimeoutDet(Timeout_ScanCard); if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ShowParkingInfo(true,i); ChangeDisplay2Value(_Icon_CreditCardFrame,_TCC_ParkingFee); ChangeChargingRateValue(ShmDcCommonData->ChargingRate,FALSE); ChangeParkingRateValue(ShmDcCommonData->ParkingRate,FALSE); ChangeParkingLeaveTime(ShmDcCommonData->ParkingLeaveTime,FALSE); } else { ShowParkingInfo(false,i); ChangeDisplay2Value(_Icon_CreditCardFrame,_TCC_CardSensing_Frame); ChangeChargingRateValue(ShmDcCommonData->ChargingRate,TRUE); ChangeParkingRateValue(ShmDcCommonData->ParkingRate,TRUE); ChangeParkingLeaveTime(ShmDcCommonData->ParkingLeaveTime,TRUE); } ShowAuthorizeCountDown(); break; case _PAGE_SENSING: if (ShmDcCommonData->TradeCancel == TRUE) { TradeRunning(FALSE); } else TradeRunning(TRUE); break; case _PAGE_PLUGIN: _everyPageRollChange = 0; if (ShmDcCommonData->pGunInfo[i].isParking) { ChangeDisplay2Value(_Icon_PreAuth_Complete,_TCC_ParkingLeave); ChangeParkingRateValue(ShmDcCommonData->ParkingRate,FALSE); ChangeParkingLeaveTime(ShmDcCommonData->ParkingLeaveTime,FALSE); ChangeSaleLeaveTime(ShmDcCommonData->SaleLeaveTime,TRUE); } else { ChangeDisplay2Value(_Icon_PreAuth_Complete,_TCC_PaySuccess); ChangeParkingRateValue(ShmDcCommonData->ParkingRate,TRUE); ChangeParkingLeaveTime(ShmDcCommonData->ParkingLeaveTime,TRUE); ChangeSaleLeaveTime(ShmDcCommonData->SaleLeaveTime,FALSE); } break; case _PAGE_ADD_FRIEND: if(ClearQR_flag[i] == FALSE) { ClearQrCode_Idle(); ClearQR_flag[i] = TRUE; } ChangeQrCode_Idle((char *)pSysConfig->SystemId); if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ShowParkingInfo(true,i); ShowLineRegisterCountDown(FALSE); } else { ShowLineRegisterCountDown(TRUE); ShowParkingInfo(false,i); } break; case _PAGE_PRECHARGE: RefreshProgressAnimation(); if (_everyPageRollChange == 0) { ChangeDisplay2Value(_Icon_Precharge,_Text_Running_Count); _Text_Running_Count >= 24 ? _Text_Running_Count = 24 : _Text_Running_Count++; } break; case _PAGE_CHARGING: if (pDcChargingInfo->PresentChargingPower >= 0 && pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) { ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower); } else { ChangeChargingPowerValue(0); } if (pDcChargingInfo->PresentChargedEnergy >= 0.1 && pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) { ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy); } else { ChangeChargingEnergyValue(0); } if ( pDcChargingInfo->ChargingFee >= 0) { ChangeChargingFeeValue(pDcChargingInfo->ChargingFee); } if (pDcChargingInfo->RemainChargingDuration >= 0 && pDcChargingInfo->RemainChargingDuration <= TIME_MAX_SEC) { ChangeTimeValue(pDcChargingInfo->RemainChargingDuration/60); } else { ChangeTimeValue(0); } ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc); StartSystemTimeoutDet(Timeout_ReturnViewPage); break; case _PAGE_COMPLETE: case _PAGE_PAYFAIL: if (pDcChargingInfo->PresentChargedEnergy >= 0.1 && pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) { ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy); } else { ChangeChargingEnergyValue(0); } ChangeChargingFeeValue(ShmDcCommonData->TransactionInfo[i].Amount); ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy); ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc); if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ChangeParkingRateValue(ShmDcCommonData->ParkingRate,FALSE); ChangeDisplay2Value(_Icon_CompleteBtn,_TCC_ParkingComplete); } else { ChangeParkingRateValue(ShmDcCommonData->ParkingRate,TRUE); ChangeDisplay2Value(_Icon_CompleteBtn,_TCC_NoParkingComplete); } //StartSystemTimeoutDet(Timeout_ReturnViewPage); break; case _PAGE_PLUGOUT: if (ShmDcCommonData->pGunInfo[i].ParkingStatus) { ChangeParkingRateValue(ShmDcCommonData->ParkingRate,FALSE); ChangeDisplay2Value(_Icon_CompleteBtn,_TCC_ParkingComplete); } else { ChangeParkingRateValue(ShmDcCommonData->ParkingRate,TRUE); ChangeDisplay2Value(_Icon_CompleteBtn,NULL); } break; case _PAGE_PAYING: ChangeDisplay2Value(_Icon_Ani_Dot, 1); if (ShmDcCommonData->CreditCardUpload) { ChangeDisplay2Value(_Icon_Uploading, _TCC_Uploading); ChangeDisplay2Value(_Icon_Paying, _ICON_Empty); } else { if (ShmDcCommonData->StopCharge[i]) { ChangeDisplay2Value(_Icon_Uploading, _ICON_Empty); ChangeDisplay2Value(_Icon_Paying, _TCC_Paying); } else if (ShmDcCommonData->pGunInfo[i].isParking){ ChangeDisplay2Value(_Icon_Uploading, _TCC_WaitParkInfo); ChangeDisplay2Value(_Icon_Paying, _ICON_Empty); } } break; case _PAGE_EXIT: break; case _PAGE_LINEPAYING: StartSystemTimeoutDet(Timeout_LINEPAYING); break; case _PAGE_MAINTAIN: ChangeQrCode_Error(); break; } } } } /* void InformationShow() { is_show = true; if (_showInformIndex == 0 ) { pSysInfo->PageIndex = __SHOW_CABIENT_VERSION; } else { pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION; ShowDispenserVersion(); } } */ void DefautLayOut() { int i; for (i = 0 ; i <= 0x5C ; i+=2 ) { ChangeDisplay2Value(0x1000+i,1); if (i==0x28 || i ==0x2A) continue; } ChangeDisplay2Value(_Icon_MobilePay,0); ChangeDisplay2Value(_Icon_CardPay,0); ChangeDisplay2Value(0x5000,1); //ChangeDisplay2Value(_QRCode_Service, 1); ShowSelectGun(); } /* 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; } */ void DemoFunction(int index) { int i; showGunWorkingType(); switch (index) { case 1: // _PAGE_IDLE /* for (i = 0; i <= 100; i++) { changeWeatherValue(i / 20); ChangeDisplay2Value(_Icon_Week, i / 15); changeDegreeValue(i); sprintf(text, "20%02d/%02d/%02d %02d:%02d:%02d", i, i, i, i, i, i); DisplayValueToLcm(_String_Date, (uint8_t*)text, 30); usleep(100000); } */ break; case 3: ChangeQrCode_Idle((char*)pSysConfig->SystemId); sleep(3); break; case 4: //_PAGE_ADD_FRIEND for (i = 0; i <= 10; i++) { ChangeDisplay2Value(_Icon_ScanCntDownTen, (short)_TCC_CntDownNumber0 + i); ChangeDisplay2Value(_Icon_ScanCntDownDigits, (short)_TCC_CntDownNumber0 + i); usleep(100000); } break; case 7: //_PAGE_AUTHORIZE for (i = 0; i < 10; i++) { ChangeChargingRateValue(i+i*10,TRUE); ChangeDisplay2Value(_Icon_AuthCntDownTen, (short)_TCC_CntDownNumber0 + i); ChangeDisplay2Value(_Icon_AuthCntDownDigits, (short)_TCC_CntDownNumber0 + i); usleep(100000); } break; case 8: //_PAGE_SENSING for (i = 0; i < 10; i++) { ChangeDisplay2Value(_Icon_CancelCntDownTen, (short)(_TCC_CancelNum_0 + i)); ChangeDisplay2Value(_Icon_CancelCntDownDigits, (short)(_TCC_CancelNum_0 + i)); usleep(100000); } break; case 10: //_PAGE_PRECHARGE for (i = 1; i <= 24; i++) { ChangeDisplay2Value(_Icon_Precharge, i); usleep(100000); } break; case 11: //_PAGE_CHARGING for (i = 0; i <= 100; i++) { ChangeChargingPowerValue(i); ChangeChargingEnergyValue(i); ChangeChargingFeeValue(i); ChangeTimeValue(i); ChangeBattMapAndValue(i); usleep(100000); } break; case 13: //_PAGE_PAYING break; case 14: //_PAGE_COMPLETE case 20: //_PAGE_PAYFAIL for (i = 0; i <= 100; i++) { ChangeChargingEnergyValue(i); ChangeChargingFeeValue(i); ChangeCarBonValue(i*2); ChangeBattMapAndValue(i); usleep(100000); } break; } sleep(1); } int main(void) { bool defaulttext = false; if (CreateAllCsuShareMemory() == FAIL) { log_error("create share memory error"); return FAIL; } MappingGunChargingInfo("LCM Control Task"); pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo(); ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();; ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData(); ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo(); ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData(); ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data(); struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();; _port = CreateCommunicationLcmPort(); uint8_t changeWarningPriority = 0; uint8_t curWarningCount = 255; uint8_t light = 0x64; ShmDcCommonData->BackLight = light; ChangeBackLight(light); _totalCount = pSysConfig->TotalConnectorCount; _everyPageRollChange = 0; //Initialization(); //printf("_LCM_COMPLETE "); //ChangeToOtherPage(_LCM_COMPLETE); DefautLayOut(); //return 0; uint8_t index = 1; ShmDcCommonData->PSU_Number = 12; /* CardReadFd = InitialRfidPort(); if (CardReadFd <0) { log_info("Card Read Port open fail!"); }*/ CheckLCMPressed(); while (_port != -1) { if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) { GetCurrentPage(); sleep(1); ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true; } else { UpdateLcmFunction(ShmDcCommonData,_port); if (ShmDcCommonData->BackLight != light) { ChangeBackLight(ShmDcCommonData->BackLight); light = ShmDcCommonData->BackLight; log_info("Set Backlight:%d",light); } ///* ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false; // 頁面資訊處理 if (!ShmDcCommonData->lcmtest) ProcessPageInfo(); else pSysInfo->SystemPage = index; // 換頁處理 //GetCurrentPage(); //DS60-120 add /* if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _PAGE_AUTHORIZE) { InformationShow(); ChangeToOtherPage(pSysInfo->PageIndex); usleep(100000); continue; } else { if (is_show) _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++; is_show = false; }*/ GetCurrentPage(); //DS60-120 add ChangeCurPage(); changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++; if (ShmDcCommonData->lcmtest) { DemoFunction(index); index >= 20 ? index = 1 : index++; } usleep(10000); //*/ /* GetCurrentPage(); ChangeCurPage(); usleep(10000); //*/ } } //while ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true; log_info("Close LCM Uart Port"); CloseCommunicationLcmPort(); return FAIL; }