12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184 |
- #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"
- #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 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/ttyO2";
- char *pPortName = "/dev/ttyS3";
- char *moduleName = "DMT80480T070_09WT";
- bool is_show = false;
- uint8_t _everyPageRollChange;
- uint8_t _btn_press = 0;
- short _btn_press_id = 0;
- struct timeval returnIdleTimer;
- int _Text_Running_Count = 86;
- int Battery_Test = 0;
- extern void UpdateLcmFunction(DcCommonInfo *ShmDcCommonData,int _lcmport);
- //==========================================
- // Open and Close RS232 and R/W
- //==========================================
- 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 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 CheckScreenModePress()
- {
- }
- void CheckMemberSelectPress()
- {
- }
- void CheckDonatePress()
- {
- }
- void CheckDonateSelectPress()
- {
- }
- void CheckIdlePress()
- {
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
- log_info("LCM Enter Authorize Page");
- }
- void CheckTouchPress(short id)
- {
- GetDeviceInfoStatus(id,1);
- if (_btn_press >= 1 && _btn_press_id == id) {
- ChangeDisplay2Value(id, 0);
- switch (id) {
- case _Touch_LeftGun:
- if(pSysInfo->CurGunSelected != LEFT_GUN_NUM) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- log_info("LCM left Gun down...............................%x %x %x",
- pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
- if (pDcChargingInfo->SystemStatus == S_IDLE &&
- (pSysInfo->SystemPage <_PAGE_REFUND_SENSEING ||
- pSysInfo->SystemPage > _PAGE_REFUND_NONE ||
- pSysInfo->SystemPage != _PAGE_PAY_ETICKET_SUCCESS ||
- pSysInfo->SystemPage != _PAGE_PAY_MPAY_SUCCESS) ) {
- log_info("Reset LCM to IDLE");
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
- gettimeofday(&returnIdleTimer, NULL);
- }
- }
- pSysInfo->CurGunSelected = LEFT_GUN_NUM;
- break;
- case _Touch_RightGun:
- if (pSysInfo->CurGunSelected != RIGHT_GUN_NUM) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- log_info("LCM right Gun down...............................%x %x %x",
- pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
- if (pDcChargingInfo->SystemStatus == S_IDLE &&
- (pSysInfo->SystemPage <_PAGE_REFUND_SENSEING ||
- pSysInfo->SystemPage > _PAGE_REFUND_NONE ||
- pSysInfo->SystemPage != _PAGE_PAY_ETICKET_SUCCESS ||
- pSysInfo->SystemPage != _PAGE_PAY_MPAY_SUCCESS) ) {
- log_info("Reset LCM to IDLE");
- pSysInfo->SystemPage = _PAGE_AUTHORIZE;
- gettimeofday(&returnIdleTimer, NULL);
- }
- }
- pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
- break;
- case _Touch_Return:
- CheckIdlePress();
- break;
- case _Touch_IDLE:
- CheckIdlePress();
- break;
- } // switch
- } //if (_btn_press >= 3)
- }
- void CheckLCMPressed()
- {
- pid_t Pid = fork();
- int i = 0;
- int index = 0;
- if ( Pid == 0 ) {
- while (1) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- CheckTouchPress(_Touch_LeftGun);
- CheckTouchPress(_Touch_RightGun);
- switch (pSysInfo->SystemPage) {
- case _PAGE_IDLE:
- CheckTouchPress(_Touch_IDLE);
- break;
- case _PAGE_AUTHORIZE:
- CheckScreenModePress();
- break;
- case _PAGE_FUNCTION_SELECT:
- break;
- case _PAGE_MEMBER_SELECT:
- CheckMemberSelectPress();
- break;
- case _PAGE_DONATE:
- CheckDonatePress();
- break;
- case _PAGE_DONATE_SELECT:
- CheckDonateSelectPress();
- break;
- // ********************** Test *******************
- ///*
- case _PAGE_PRECHARGE:
- /*
- if ((i/100) %2 == 0)
- ChangeDisplay2Value(0x109A,i%100);
- else
- ChangeDisplay2Value(0x109A,100-(i%100));
- */
- break;
- case _PAGE_CHARGING:
- pDcChargingInfo->PresentChargingPower = i;
- pDcChargingInfo->PresentChargedEnergy = i/6;
- pDcChargingInfo->RemainChargingDuration = i;
- pDcChargingInfo->EvBatterySoc = i/6;
- break;
- case _PAGE_COMPLETE:
- pDcChargingInfo->PresentChargedEnergy = i;
- pDcChargingInfo->ChargingFee = i;
- pDcChargingInfo->EvBatterySoc = i/6;
- pSysConfig->BillingData.isBilling = TRUE;
- ChangeCarBonValue(i);
- pSysConfig->isQRCode = 1;
- break;
- case _PAGE_PLUGOUT:
- pSysConfig->isQRCode = 1;
- CheckTouchPress(_Touch_Return);
- break;
- // ************************************************ */
- } // switch
- usleep(5000);
- ///*
- i++;
- if (i == 600 ) {
- index >= 8 ? index = 1 : index++;
- pSysInfo->SystemPage = index;
- i = 0;
- }//*/
- } //while
- } // if pid
- log_info("Create LCM fork:%d",Pid);
- }
- 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 ; i<readLen+3; i++) {
- log_info("Read data[%d]:0x%x",i,msg[i]);
- }*/
- 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);
- // 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 >= _Touch_LeftGun && key <=_Touch_IDLE ) {
- _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 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) == NULL ) {
- 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) == NULL || 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(bool islight)
- {
- uint8_t value = 0x01;
- uint8_t msg[9];
- memset(msg, 0x00, sizeof(msg));
- // 0x00 ~ 0x40
- 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;
- //log_info("Addr:0x%x, value:%d",address,value);
- DisplayValueToLcm(address, data, sizeof(data));
- }
- //================================================
- // 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 >= 10 ? _everyPageRollChange = 0 : _everyPageRollChange++;
- }
- //================================================
- // Change current page
- //================================================
- void ChangeCurPage()
- {
- //log_info("cur = %d ,system = %d, lcm = %d ",_currentPage, pSysInfo->SystemPage, pSysInfo->PageIndex);
- struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- pSysInfo->PageIndex = pSysInfo->SystemPage;
- if (_currentPage != pSysInfo->PageIndex) {
- switch (pSysInfo->SystemPage) {
- case _PAGE_AUTHORIZE:
- gettimeofday(&returnIdleTimer, NULL);
- break;
- case _PAGE_PLUGIN:
- break;
- case _PAGE_PRECHARGE:
- break;
- case _PAGE_CHARGING:
- break;
- case _PAGE_COMPLETE:
- break;
- }
- _currentPage = pSysInfo->PageIndex;
- log_info("Page:%d",pSysInfo->PageIndex);
- 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 (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CCS1_ON);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CCS2_ON);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CHAdeMO_ON);
- }
- // Set Right Gun
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_RightGun_status,_ICON_Right_CCS1_Off);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_RightGun_status,_ICON_Right_CCS2_Off);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_RightGun_status,_ICON_Right_CHAdeMo_Off);
- }
- } else {
- // Left Gun
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CCS1_Off);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CCS2_Off);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_LeftGun_status,_ICON_Left_CHAdeMO_Off);
- }
- // Right Gun
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_RightGun_status,_ICON_Right_CCS1_ON);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_RightGun_status,_ICON_Right_CCS2_ON);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_RightGun_status,_ICON_Right_CHAdeMO_ON);
- }
- }
- }
- void ChangeQrCode_Idle(char *input)
- {
- int len = strlen(input);
- uint8_t cmd[len];
- int loop = 0;
- int i = 0;
- while (input[loop] != '\0') {
- cmd[i++] = input[loop++];
- }
- DisplayValueToLcm(_QRCode_Authorize, cmd, len + 1);
- }
- void ShowHomePage()
- {
- // Show QR Code
- if (pSysConfig->isQRCode) {
- if (pSysConfig->QRCodeMadeMode == NO) {
- //uint8_t len = strlen((char *)pSysConfig->SystemId);
- ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- } else {
- //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
- ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
- }
- //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- }
- }
- /*
- 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 ChangeChargingPowerValue(float pow)
- {
- uint8_t cmd[10];
- uint8_t value[10];
- memset(cmd, 0x00, sizeof(cmd));
- sprintf((char *) value, "%.1fkW",pow);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_Text_Power, 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(_Text_Money, cmd, sizeof(cmd));
- }
- void ChangeCarBonValue(int data)
- {
- uint8_t cmd[10];
- uint8_t value[10];
- memset(cmd, 0x00, sizeof(cmd));
- sprintf((char *) value, "-%d", data);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_Text_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(_EnergyBar,_ICON_Empty);
- else if (energy > 100)
- ChangeDisplay2Value(_EnergyBar,_ICON_Bar_10);
- else
- ChangeDisplay2Value(_EnergyBar,((int)energy/10)+_ICON_Bar_1);
- sprintf((char *) value, "%d", (int)energy);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_Text_Energy, cmd, sizeof(cmd));
- }
- uint8_t _battery_display_count = 0;
- void ChangeBattMapAndValue(int soc)
- {
- int i = (soc*36)/100;
- 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 (i==36)
- ChangeDisplay2Value(_Battery_Circle,_ICON_Battery_35);
- else {
- if (_battery_display_ani) {
- ChangeDisplay2Value(_Battery_Circle, _ICON_Battery_0+(int)i);
- } else {
- ChangeDisplay2Value(_Battery_Circle, _ICON_Battery_0+(int)i+1);
- }
- }
- memset(cmd, 0x00, sizeof(cmd));
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value, "%d%%", soc);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_Text_BatterySoc, 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(uint8_t time)
- {
- uint8_t cmd[2];
- uint8_t value[2];
- memset(cmd, 0x00, sizeof(cmd));
- sprintf((char *) value, "%d", time);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_Text_Time, cmd, sizeof(cmd));
- }
- void CabinetChangeLCMProcess()
- {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- if ( (pDcChargingInfo->ChangeLcmPage == _CHANGE_REFUNDAMOUNT ||
- pDcChargingInfo->ChangeLcmPage == _CHANGE_PREPAYMENTINFO ||
- pDcChargingInfo->ChangeLcmPage == _CHANGE_PAYMENT_FAIL) &&
- ShmDcCommonData->_ChangeLCMRequest != TRUE) {
- return;
- }
- switch(pDcChargingInfo->ChangeLcmPage) {
- case _CHANGE_REMOTESTART:
- break;
- case _CHANGE_REFUNDING:
- pSysInfo->SystemPage = _PAGE_REFUNDING;
- break;
- case _CHANGE_REFUNDAMOUNT:
- pSysInfo->SystemPage = _PAGE_REFUND_COMPLETE;
- ShmDcCommonData->_ChangeLCMRequest = FALSE;
- break;
- case _CHANGE_NOREFUND:
- pSysInfo->SystemPage = _PAGE_REFUND_NONE;
- break;
- case _CHANGE_PREPAYMENTINFO:
- pSysInfo->SystemPage = _PAGE_PAY_ETICKET_SUCCESS;
- ShmDcCommonData->_ChangeLCMRequest = FALSE;
- break;
- case _CHANGE_PAYMENT_OK:
- pSysInfo->SystemPage = _PAGE_PAY_MPAY_SUCCESS;
- break;
- case _CHANGE_PAYMENT_FAIL:
- pSysInfo->SystemPage = _PAGE_PAY_FAIL;
- ShmDcCommonData->_ChangeLCMRequest = FALSE;
- break;
- }
- }
- void ProcessPageInfo()
- {
- // Show Gun Working and Type
- float _current;
- uint8_t precharg_time;
- showGunWorkingType();
- for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
- if (pSysInfo->CurGunSelected == i) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- CabinetChangeLCMProcess();
- switch (pSysInfo->SystemPage) {
- case _PAGE_AUTHORIZE:
- ShowHomePage();
- if (GetTimeoutValue(returnIdleTimer) /uSEC_VAL >= RETURNIDLE_Timeout ) {
- pSysInfo->SystemPage = _PAGE_IDLE;
- gettimeofday(&returnIdleTimer, NULL);
- }
- break;
- case _PAGE_PLUGIN:
- _Text_Running_Count = 86;
- _everyPageRollChange = 0;
- break;
- case _PAGE_PRECHARGE:
- RefreshProgressAnimation();
- if (_everyPageRollChange == 0) {
- ChangeDisplay2Value(_PrepareBar,_Text_Running_Count);
- _Text_Running_Count >= 99 ? _Text_Running_Count = 86 : _Text_Running_Count++;
- }
- 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 (pSysConfig->BillingData.isBilling &&
- pDcChargingInfo->ChargingFee >= 0) {
- ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
- }
- if (pDcChargingInfo->RemainChargingDuration >= 0 &&
- pDcChargingInfo->RemainChargingDuration <= TIME_MAX_SEC) {
- ChangeTimeValue(pDcChargingInfo->RemainChargingDuration);
- } else {
- ChangeTimeValue(0);
- }
- ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
- break;
- case _PAGE_COMPLETE:
- if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
- pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
- ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
- } else {
- ChangeChargingEnergyValue(0);
- }
- if (pSysConfig->BillingData.isBilling &&
- pDcChargingInfo->ChargingFee >= 0) {
- ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
- }
- ChangeBattMapAndValue(pDcChargingInfo->EvBatterySoc);
- if (pSysConfig->isQRCode) {
- if (pSysConfig->QRCodeMadeMode == NO) {
- //uint8_t len = strlen((char *)pSysConfig->SystemId);
- ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- } else {
- //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
- ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
- }
- //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- }
- break;
- case _PAGE_REFUND_SENSEING:
- break;
- case _PAGE_PLUGOUT:
- if (pSysConfig->isQRCode) {
- if (pSysConfig->QRCodeMadeMode == NO) {
- //uint8_t len = strlen((char *)pSysConfig->SystemId);
- ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- } else {
- //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
- ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
- }
- //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
- }
- break;
- }
- }
- }
- }
- void ChangeWarningFunc()
- {
- uint8_t cmd[7] = {0};
- uint8_t i = 0;
- //uint8_t j = 0;
- //log_info("ChangeWarningFunc ");
- // 最多一次五筆
- //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
- //log_info("WarningCount = %d ", pSysWarning->WarningCount);
- //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
- 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;
- }
- //error code
- string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
- DisplayValueToLcm(0x3020 + ((i) * 6), cmd, sizeof(cmd));
- //警告標示
- memset(cmd, 0x00, sizeof(cmd));
- cmd[0] = 0x00;
- cmd[1] = 85;
- DisplayValueToLcm(0x1090 + ((i) * 2), cmd, 2);
- }
- memset(cmd, 0x00, sizeof(cmd));
- for (; i < 5; i++) {
- DisplayValueToLcm(0x3020 + ((i) * 6), cmd, sizeof(cmd));
- DisplayValueToLcm(0x1090 + ((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 InformationShow()
- {
- is_show = true;
- if (_showInformIndex == 0 ) {
- pSysInfo->PageIndex = __SHOW_CABIENT_VERSION;
- } else {
- pSysInfo->PageIndex = __SHOW_DISPENSER_VERASION;
- ShowDispenserVersion();
- }
- }
- void DefautLayOut()
- {
- for (int i = 0 ; i <= 0x72 ; i+=2 ) {
- ChangeDisplay2Value(0x1000+i,1);
- if (i == 0x38)
- ChangeDisplay2Value(0x1000+i,85);
- else if (i == 0x36)
- ChangeDisplay2Value(0x1000+i,75);
- else if (i == 0x3A)
- ChangeDisplay2Value(0x1000+i,99);
- }
- ChangeDisplay2Value(0x5000,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();
- struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
- struct ChargingInfoData *pDcChargingInfo_0 = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- struct ChargingInfoData *pDcChargingInfo_1 = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- _port = CreateCommunicationLcmPort();
- uint8_t changeWarningPriority = 0;
- uint8_t curWarningCount = 255;
- ChangeBackLight(true);
- _totalCount = pSysConfig->TotalConnectorCount;
- _everyPageRollChange = 0;
- //Initialization();
- //printf("_LCM_COMPLETE ");
- //ChangeToOtherPage(_LCM_COMPLETE);
- DefautLayOut();
- //return 0;
- //uint8_t index = 1;
- 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);
- ///*
- // Warning 處理
- if (curWarningCount != pSysWarning->WarningCount) {
- changeWarningPriority = 0;
- pSysWarning->PageIndex = 0;
- curWarningCount = pSysWarning->WarningCount;
- ChangeWarningFunc();
- } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
- // 當有兩頁 Warning 則每隔三秒改變一次
- if (pSysWarning->PageIndex == 0) {
- pSysWarning->PageIndex = 1;
- } else {
- pSysWarning->PageIndex = 0;
- }
- ChangeWarningFunc();
- }
- /*
- // Show Default Text
- if (!defaulttext) {
- ShowCabientVersionDefaultText();
- ShowDispenserVersionDefautlText();
- defaulttext = true;
- }
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
- // 頁面資訊處理
- ProcessPageInfo();
- // 換頁處理
- //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++;
- usleep(10000); //*/
- ///*
- ProcessPageInfo();
- GetCurrentPage();
- ChangeCurPage();
- usleep(10000);
- //*/
- }
- } //while
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
- log_info("Close LCM Uart Port");
- CloseCommunicationLcmPort();
- return FAIL;
- }
|