123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698 |
- #include <stdio.h> /*標準輸入輸出定義*/
- #include <stdlib.h> /*標準函數庫定義*/
- #include <stdint.h>
- #include <string.h>
- #include <unistd.h>
- #include <termios.h>
- #include <fcntl.h>
- #include <time.h>
- #include <sys/ioctl.h>
- #include <sys/timeb.h>
- #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)
- 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;
- 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/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);
- 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) {
- gettimeofday(&pDcChargingInfo->TimeoutTimer, 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;
- }
- 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;
-
- } else if (selGun == RIGHT_GUN_NUM) {
- ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
-
- }
-
-
-
- }
- 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 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 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);
- }
- else {
- ChangeDisplay2Value(_Icon_PreAuth, _TCC_TradeCancelString);
- ChangeDisplay2Value(_Icon_Ani_Dot, 0);
- ChangeDisplay2Value(_Icon_CountDownBG, _TCC_TradeCancelFrame);
- 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)));
- }
- }
- }
- void CheckIdlePress()
- {
- pSysInfo->SystemPage = _PAGE_SELECT_GUN;
- log_info("IDLE Enter Select Gun Page");
- }
- void CheckReturnPress()
- {
- int i;
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-
-
- if ( pDcChargingInfo->SystemStatus == S_AUTHORIZING ) {
- ShmDcCommonData->TradeCancel = TRUE;
-
- for (i = 0; i <= 30; i++) {
- if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE)
- break;
- sleep(1);
- }
- pSysInfo->SystemPage = _PAGE_SENSING;
- StopGunInfoTimeoutDet(pSysInfo->CurGunSelected);
- StartSystemTimeoutDet(Timeout_TradeCancel);
- ShmDcCommonData->PreAuth_Result = 0;
- log_info("Press Return button cancel PreAuth");
- 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;
- strcpy((char *)pSysConfig->UserId, "");
- return;
- }
- if (pDcChargingInfo->SystemStatus == S_IDLE && pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
- ShmDcCommonData->TradeCancel = TRUE;
- pSysInfo->SystemPage = _PAGE_SENSING;
- StartSystemTimeoutDet(Timeout_TradeCancel);
- if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) {
- for (i = 0; i <= 30; i++) {
- if (ShmDcCommonData->PreAuth_Result != 0)
- break;
- sleep(1);
- }
- ShmDcCommonData->PreAuth_Result = 0;
- if (ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] == TRUE) {
- ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
- ShmDcCommonData->PreAuth_Result = 0;
- for (i = 0; i <= 30; i++) {
- if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE)
- break;
- sleep(1);
- }
- }
- pSysInfo->SystemPage = _PAGE_SELECT_PAY;
- }
- return;
- }
- if ( pSysInfo->SystemPage == _PAGE_EXIT ) {
- StopSystemTimeoutDet();
- pDcChargingInfo->SystemStatus = S_IDLE;
- pSysInfo->SystemPage = _PAGE_IDLE;
- return;
- }
-
- if (pSysInfo->SystemPage == _PAGE_AUTHORIZE)
- pSysInfo->SystemPage = _PAGE_SELECT_PAY;
- else
- pSysInfo->SystemPage = _PAGE_SELECT_GUN;
- }
- void CheckStopPress()
- {
- is_stop = TRUE;
-
- 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->StopCharge[pSysInfo->CurGunSelected] = TRUE;
- StartGunInfoTimeoutDet(pSysInfo->CurGunSelected,Timeout_FinalCost);
-
- }
- void CheckStopCancelPress()
- {
- is_stop = FALSE;
-
- pSysInfo->SystemPage = _PAGE_CHARGING;
- }
- void CheckConfirmGun(uint8_t gunIndex)
- {
- pSysInfo->CurGunSelected = gunIndex;
- 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()
- {
- pSysInfo->SystemPage = _PAGE_SELECT_PAY;
- ShmDcCommonData->donate_flag[pSysInfo->CurGunSelected] = TRUE;
- }
- void CheckDonateNo()
- {
- pSysInfo->SystemPage = _PAGE_BILL;
- ShmDcCommonData->donate_flag[pSysInfo->CurGunSelected] = FALSE;
- }
- void CheckPayCreditCard()
- {
- ShmDcCommonData->LineStatus[pSysInfo->CurGunSelected] = 0;
- ShmDcCommonData->TradeCancel = FALSE;
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- if (pDcChargingInfo->SystemStatus == S_IDLE) {
-
- ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH;
- ShmDcCommonData->PreAuth_Result = 0;
-
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
-
-
-
- }
- }
- void CheckPayIcash()
- {
- }
- void CheckPayLinePay()
- {
- }
- 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 >= 3) {
- ChangeDisplay2Value(id, 0);
-
- _btn_press_count = 0;
- switch (id) {
- case _Touch_Show_Left:
- if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_PLUGIN) {
- log_info("Authorize Process can't select gun");
- return;
- }
-
- if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- pSysInfo->CurGunSelected = LEFT_GUN_NUM;
- if(pDcChargingInfo->SystemStatus == S_IDLE) {
- pSysInfo->SystemPage = _PAGE_SELECT_GUN;
- }
- log_info("LCM left Gun down...............................%x %x %x",
- pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
- }
- if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
- pSysInfo->SystemPage == _PAGE_PAYFAIL) {
- StopSystemTimeoutDet();
- StartSystemTimeoutDet(Timeout_ReturnViewPage);
- }
- break;
- case _Touch_Show_Right:
- if (pSysInfo->SystemPage >= _PAGE_ADD_FRIEND && pSysInfo->SystemPage <= _PAGE_PLUGIN) {
- log_info("Authorize Process can't select gun");
- return;
- }
-
- if(pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
- if(pDcChargingInfo->SystemStatus == S_IDLE) {
- pSysInfo->SystemPage = _PAGE_SELECT_GUN;
- }
- log_info("LCM Right Gun down...............................%x %x %x",
- pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
- }
- if (pSysInfo->SystemPage == _PAGE_CHARGING || pSysInfo->SystemPage == _PAGE_COMPLETE ||
- pSysInfo->SystemPage == _PAGE_PAYFAIL) {
- StopSystemTimeoutDet();
- StartSystemTimeoutDet(Timeout_ReturnViewPage);
- }
- break;
- case _Touch_Return:
- CheckReturnPress();
- break;
- case _Touch_IDLE:
- CheckIdlePress();
- break;
- case _Touch_StopCharge:
- 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_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:
- StartSystemTimeoutDet(Timeout_AddLine);
- CheckDonateNo();
- break;
- case _Touch_Pay_CreditCard:
- CheckPayCreditCard();
- break;
- case _Touch_Pay_Icash:
- CheckPayIcash();
- break;
- case _Touch_Pay_LinePay:
- CheckPayLinePay();
- break;
- }
- }
- }
- void CheckLCMPressed()
- {
- int i;
- pid_t Pid = fork();
- if ( Pid == 0 ) {
- while (1) {
- if (pSysInfo->SystemPage != _PAGE_SELECT_GUN) {
- CheckTouchPress(_Touch_Show_Left);
- CheckTouchPress(_Touch_Show_Right);
- }
- switch (pSysInfo->SystemPage) {
- case _PAGE_IDLE:
- CheckTouchPress(_Touch_IDLE);
- break;
- case _PAGE_SELECT_GUN:
- CheckTouchPress(_Touch_Select_Left);
- CheckTouchPress(_Touch_Select_Right);
- break;
- case _PAGE_BILL:
- CheckTouchPress(_Touch_Return);
- CheckTouchPress(_Touch_DonateBill);
- 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_Return);
- CheckTouchPress(_Touch_Pay_CreditCard);
- 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;
- }
- usleep(5000);
- }
- }
- log_info("Create LCM fork:%d",Pid);
- }
- void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
- {
- read(_port, msg, readLen);
-
- if(*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2)
- {
- if(*(msg + 3) == CMD_WRITE)
- {
- switch (*(msg + 4))
- {
- case CMD_REGISTER:
- {
-
- if(strcmp((char *)pSysInfo->LcmHwRev, "") != EQUAL)
- strcpy((char *)pSysInfo->LcmHwRev, moduleName);
- _currentPage = *(msg + 7);
- log_info("Current Page:%d",_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 >= _Touch_IDLE && key <=_Touch_Pay_LinePay ) {
- _btn_press_id = key;
- _btn_press = *(msg + 8);
- }
- }
- }
- }
- void GetHrFormTimeString(char* time,char* hr)
- {
-
- for(int i = 0 ; i < 2 ; i++) {
- hr[i] = time[i+11];
- }
- if( atoi(hr) == NULL ) {
- strcmp(hr,"");
- }
- }
- void GetMinFormTimeString(char* time,char* min)
- {
-
- for(int i = 0 ; i < 2 ; i++) {
- min[i] = time[i+14];
- }
- if( atoi(min) == NULL || atoi(min) > 60) {
- strcmp(min,"");
- }
- }
- 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(bool islight)
- {
- uint8_t value = 0x01;
- uint8_t msg[9];
- memset(msg, 0x00, sizeof(msg));
-
- if (islight)
- {
- value = 0x20;
- }
- uint8_t cmd[7];
- memset(cmd, 0x00, sizeof(cmd));
- cmd[0] = CMD_TITLE_1;
- cmd[1] = CMD_TITLE_2;
- cmd[2] = 0x03;
- cmd[3] = CMD_READ;
- cmd[4] = CMD_BACKLIGHT;
- cmd[5] = 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));
- }
- 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;
-
- DisplayValueToLcm(address, data, sizeof(data));
- }
- 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++;
- }
- void ChangeCurPage()
- {
-
- 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:
- is_stop = false;
- break;
- case _PAGE_COMPLETE:
- break;
- }
- _currentPage = pSysInfo->PageIndex;
-
- ChangeToOtherPage(pSysInfo->PageIndex);
- }
- }
- 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 (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);
- }
-
- 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);
- }
- } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM){
-
- 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);
- }
-
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- 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()
- {
- 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);
-
- memset(cmd,0,256);
- int len = sprintf(cmd,"https://nhoatcc.lineapid.tw/web/tologin?sn=%s&cid=%d",input,ShmDcCommonData->ConnectorID[pSysInfo->CurGunSelected]);
-
- if (pSysInfo->SystemPage == _PAGE_BILL)
- DisplayValueToLcm(_QRCode_AddLine, cmd, len+1);
- }
- void ShowSelectGun()
- {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- 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_ShowLeftGunCharging_CCS2);
- } 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->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_ShowRightGunCharging_CCS2);
- } 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)
- {
- 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(int rate)
- {
- uint8_t cmd[10];
- uint8_t value[10];
- memset(cmd, 0x00, sizeof(cmd));
- if (rate == 0) {
- log_info("Doesn't get Charge Fee");
- }
-
- sprintf((char *) value, "%d",rate);
- 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*9)/10*2.36 - data*0.637;
-
- sprintf((char *) value, "%d", (int)_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));
- }
- 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_CompleteCircle0+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 t = time(NULL);
- struct tm *now = localtime(&t);
- _week = now->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)
- {
- 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)
- {
-
-
- ChangeDisplay2Value(_Icon_Location,(short)_location);
- }
- void ShowLineRegisterCountDown()
- {
- int _ten, _digits;
- pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- if (pDcChargingInfo->TimeoutFlag == Timeout_LineReigster) {
- _ten = (TCC_LINEREGISTER_TIMEOUT - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL)) / 10;
- _digits = (TCC_LINEREGISTER_TIMEOUT - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL)) % 10;
- 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) {
- _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");
- }
- }
- int old_money = 0;
- int ClearQR_flag[2];
- void ProcessPageInfo()
- {
-
- if (pSysInfo->SystemPage == _PAGE_IDLE) {
- changeWeatherValue(ShmDcCommonData->WeatherID);
- changeWeekValue(0);
- changeDegreeValue((int)ShmDcCommonData->Temperature);
- changeDateValue(&ShmDcCommonData->PresentTime[0]);
- changeLocationValue(ShmDcCommonData->Location);
- 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);
- }
-
- 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);
- }
- return;
- }
- showGunWorkingType();
- for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
- if (pSysInfo->CurGunSelected == i) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- switch (pSysInfo->SystemPage) {
- case _PAGE_IDLE:
- StopSystemTimeoutDet();
- break;
- case _PAGE_SELECT_PAY:
- if (ShmDcCommonData->donate_flag[i] == TRUE) {
- ChangeDisplay2Value(_Icon_WordAddFriend,_ICON_Empty);
- } else
- ChangeDisplay2Value(_Icon_WordAddFriend,_TCC_SelectPayMode);
- StartSystemTimeoutDet(Timeout_SelectPayMode);
- break;
- case _PAGE_SELECT_GUN:
- ShowSelectGun();
- ClearQR_flag[i] = FALSE;
- break;
- case _PAGE_BILL:
- if(ClearQR_flag[i] == FALSE) {
- ClearQrCode();
- ClearQR_flag[i] = TRUE;
- }
- ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- break;
- case _PAGE_AUTHORIZE:
- StartSystemTimeoutDet(Timeout_ScanCard);
-
-
-
-
- ChangeChargingRateValue((int)ShmDcCommonData->ChargingRate);
- ShowAuthorizeCountDown();
- _Text_Running_Count = 1;
- break;
- case _PAGE_SENSING:
- if (ShmDcCommonData->TradeCancel == TRUE) {
- TradeRunning(FALSE);
- }
- else
- TradeRunning(TRUE);
- break;
- case _PAGE_PLUGIN:
- _everyPageRollChange = 0;
- break;
- case _PAGE_ADD_FRIEND:
- ShowLineRegisterCountDown();
- 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);
- }
- if ( ShmDcCommonData->finalcost[i] >= 0 && ShmDcCommonData->finalcost_flag[i] == TRUE) {
- StopGunInfoTimeoutDet(i);
- ChangeChargingFeeValue(ShmDcCommonData->finalcost[i]);
-
- }
- ChangeCarBonValue(pDcChargingInfo->PresentChargedEnergy);
- ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
-
-
- break;
- case _PAGE_PLUGOUT:
-
- break;
- case _PAGE_PAYING:
- break;
- }
- }
- }
- }
- void ChangeWarningFunc()
- {
- uint8_t cmd[7] = {0};
- uint8_t i = 0;
-
-
-
-
-
- for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
- log_info("Warming Code[%d]:%s",i,&pSysWarning->WarningCode[i][0]);
- memset(cmd, 0x00, sizeof(cmd));
- if ((i) >= 5) {
- break;
- }
-
- string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
- DisplayValueToLcm(_Strting_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
-
- memset(cmd, 0x00, sizeof(cmd));
- cmd[0] = 0x00;
- cmd[1] = 1;
- DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
- }
- memset(cmd, 0x00, sizeof(cmd));
- for (; i < 5; i++) {
- DisplayValueToLcm(_Strting_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
- DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
- }
- }
- void ShowCabientVersionDefaultText()
- {
- char value[16];
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value,"%s","Cabient:");
- DisplayValueToLcm(_Version_Cabient_Name_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","BootLoader:");
- DisplayValueToLcm(_Version_Cabient_BootLoader_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Kernel Fw:");
- DisplayValueToLcm(_Version_Cabient_Kernel_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","CSU Fw:");
- DisplayValueToLcm(_Version_Cabient_CSU_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Priamry Fw:");
- DisplayValueToLcm(_Version_Cabient_Priamry_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Relay(0) Fw:");
- DisplayValueToLcm(_Version_Cabient_Relay0_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Relay(1) Fw:");
- DisplayValueToLcm(_Version_Cabient_Relay1_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Fan Fw:");
- DisplayValueToLcm(_Version_Cabient_Fan_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","IP Addr:");
- DisplayValueToLcm(_Version_Cabient_IPAddr_Text, (uint8_t *)value, sizeof(value));
- if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number <= 12) {
- sprintf((char *)value,"%s","Primary");
- DisplayValueToLcm(_Version_Cabient_Primary_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Secondary");
- DisplayValueToLcm(_Version_Cabient_Secondary_Text, (uint8_t *)value, sizeof(value));
- for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
- sprintf((char *)value,"PSU(%d):",i+1);
- DisplayValueToLcm(_Version_Cabient_PSU1_Text+i*0x10, (uint8_t *)value, sizeof(value));
- }
- }
- }
- void ShowDispenserVersionDefautlText()
- {
- char value[16];
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value,"%s","Dispenser:");
- DisplayValueToLcm(_Version_Dispenser_Name_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","BootLoader:");
- DisplayValueToLcm(_Version_Dispenser_BootLoader_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Kernel Fw:");
- DisplayValueToLcm(_Version_Dispenser_Kernel_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","CSU Fw:");
- DisplayValueToLcm(_Version_Dispenser_CSU_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Relay Fw:");
- DisplayValueToLcm(_Version_Dispenser_Relay_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Fan Fw:");
- DisplayValueToLcm(_Version_Dispenser_Fan_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Prim Fw:");
- DisplayValueToLcm(_Version_Dispenser_Priamry_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","LCM Hw:");
- DisplayValueToLcm(_Version_Dispenser_LCM_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","LED Fw:");
- DisplayValueToLcm(_Version_Dispenser_LED_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Connector(0):");
- DisplayValueToLcm(_Version_Dispenser_Connector0_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","Connector(1):");
- DisplayValueToLcm(_Version_Dispenser_Connector1_Text, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s","IP Addr:");
- DisplayValueToLcm(_Version_Dispenser_IPAddr_Text, (uint8_t *)value, sizeof(value));
- }
- void ShowCabientVersion()
- {
- char value[16];
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetModelName);
- DisplayValueToLcm(_Version_Cabient_Model_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetBoolLoaderVersion);
- DisplayValueToLcm(_Version_Cabient_BootLoader_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetKernelVersion);
- DisplayValueToLcm(_Version_Cabient_Kernel_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetRFSystemVersion);
- DisplayValueToLcm(_Version_Cabient_CSU_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetPrimaryVersion);
- DisplayValueToLcm(_Version_Cabient_Priamry_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay0Version);
- DisplayValueToLcm(_Version_Cabient_Relay0_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetRelay1Version);
- DisplayValueToLcm(_Version_Cabient_Relay1_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetFanVersion);
- DisplayValueToLcm(_Version_Cabient_Fan_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->CabinetIPAddr);
- DisplayValueToLcm(_Version_Cabient_IPAddr_value, (uint8_t *)value, sizeof(value));
- if (ShmDcCommonData->PSU_Number > 0 && ShmDcCommonData->PSU_Number < 12) {
- for(uint8_t i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
- if (i>=6) {
- sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].DCVersion);
- DisplayValueToLcm(_Version_Cabient_PSU_Prim7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[(i-6)].FPCVersion);
- DisplayValueToLcm(_Version_Cabient_PSU_Sec7_value+(i-6)*0x10, (uint8_t *)value, sizeof(value));
- continue;
- }
- sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].DCVersion);
- DisplayValueToLcm(_Version_Cabient_PSU_Prim1_value+i*0x10, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",ShmDcCommonData->PsuVer[i].FPCVersion);
- DisplayValueToLcm(_Version_Cabient_PSU_Sec1_value+i*0x10, (uint8_t *)value, sizeof(value));
- }
- }
- }
- void ShowDispenserVersion()
- {
- char value[32];
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value,"%s",pSysConfig->ModelName);
- DisplayValueToLcm(_Version_Dispenser_Model_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->CsuBootLoadFwRev);
- DisplayValueToLcm(_Version_Dispenser_BootLoader_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->CsuKernelFwRev);
- DisplayValueToLcm(_Version_Dispenser_Kernel_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->CsuRootFsFwRev);
- DisplayValueToLcm(_Version_Dispenser_CSU_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->RelayModuleFwRev);
- DisplayValueToLcm(_Version_Dispenser_Relay_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->FanModuleFwRev);
- DisplayValueToLcm(_Version_Dispenser_Fan_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->CsuPrimFwRev);
- DisplayValueToLcm(_Version_Dispenser_Priamry_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->LcmHwRev);
- DisplayValueToLcm(_Version_Dispenser_LCM_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->LedModuleFwRev);
- DisplayValueToLcm(_Version_Dispenser_LED_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->Connector1FwRev);
- DisplayValueToLcm(_Version_Dispenser_Connector0_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysInfo->Connector2FwRev);
- DisplayValueToLcm(_Version_Dispenser_Connector1_value, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"%s",pSysConfig->Eth0Interface.EthIpAddress);
- DisplayValueToLcm(_Version_Dispenser_IPAddr_value, (uint8_t *)value, sizeof(value));
- }
- 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);
- ShowSelectGun();
- }
- 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;
- ChangeBackLight(true);
- _totalCount = pSysConfig->TotalConnectorCount;
- _everyPageRollChange = 0;
-
-
-
- DefautLayOut();
-
-
- int result = 0;
- ShmDcCommonData->PSU_Number = 12;
-
- 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 (curWarningCount != pSysWarning->WarningCount) {
- changeWarningPriority = 0;
- pSysWarning->PageIndex = 0;
- curWarningCount = pSysWarning->WarningCount;
- ChangeWarningFunc();
- } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
-
- if (pSysWarning->PageIndex == 0) {
- pSysWarning->PageIndex = 1;
- } else {
- pSysWarning->PageIndex = 0;
- }
- ChangeWarningFunc();
- }
-
-
- if (!defaulttext) {
- ShowCabientVersionDefaultText();
- ShowDispenserVersionDefautlText();
- defaulttext = true;
- }
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
-
- ProcessPageInfo();
-
-
-
- GetCurrentPage();
- ChangeCurPage();
- changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
- usleep(10000);
-
- }
- }
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
- log_info("Close LCM Uart Port");
- CloseCommunicationLcmPort();
- return FAIL;
- }
|