1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252 |
- #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 = 0;
- 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 _Button_LeftGun_Select:
- 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 _Button_RightGun_Select:
- 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 _Button_Screen_Mode:
- break;
- case _Button_Charge:
- break;
- case _Button_Refund:
- ShmDcCommonData->_RefundRequest = true;
- break;
- case _Button_Return:
- ShmDcCommonData->_RefundCancel = true;
- break;
- case _Button_Member:
- break;
- case _Button_Member_None:
- break;
- case _Button_Return_Home:
- break;
- case _Button_Donate:
- ShmDcCommonData->_InvoiceRequest = true;
- break;
- case _Button_Donate_Select0:
- break;
- case _Button_Donate_Select1:
- break;
- case _Button_Donate_Select2:
- break;
- case _Button_Donate_Select3:
- break;
- case _Button_Donate_Confirm:
- break;
- case _Button_Authorize:
- 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(_Button_LeftGun_Select);
- CheckTouchPress(_Button_RightGun_Select);
- switch (pSysInfo->SystemPage) {
- case _PAGE_IDLE:
- CheckTouchPress(_Button_Authorize);
- break;
- case _PAGE_AUTHORIZE:
- CheckScreenModePress();
- break;
- case _PAGE_FUNCTION_SELECT:
- CheckTouchPress(_Button_Charge);
- CheckTouchPress(_Button_Return);
- 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->PresentChargingVoltage = i;
- pDcChargingInfo->PresentChargingPower = i;
- pDcChargingInfo->PresentChargedEnergy = i;
- pDcChargingInfo->PresentChargingCurrent =i;
- pDcChargingInfo->PresentChargedDuration = i;
- pDcChargingInfo->EvBatterySoc = i/6;
- break;
- case _PAGE_COMPLETE:
- pDcChargingInfo->PresentChargedEnergy = i;
- pDcChargingInfo->ChargingFee = i;
- pDcChargingInfo->EvBatterySoc = i/6;
- pSysConfig->BillingData.isBilling = TRUE;
- break;
- // ************************************************ */
- } // switch
- usleep(5000);
- ///*
- i++;
- if (i == 600 ) {
- index >= 22 ? index = 1 : index++;
- pSysInfo->SystemPage = 22;
- i = 0;
- /*
- if (pSysInfo->SystemPage == _PAGE_PRECHARGE)
- gettimeofday(&pDcChargingInfo->PreChargeTimer, NULL);
- */
- }//*/
- } //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 >= _Button_LeftGun_Select && key <=_Button_Authorize ) {
- _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(uint8_t progress_index)
- {
- if(_everyPageRollChange % 2) {
- progress_index+=1;
- }
- _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 (pSysInfo->CurGunSelected == RIGHT_GUN_NUM &&
- pSysInfo->SystemPage != _PAGE_IDLE &&
- pSysInfo->SystemPage != _PAGE_MAINTAIN &&
- pSysInfo->SystemPage != _PAGE_ERROR ) {
- pSysInfo->PageIndex = pSysInfo->SystemPage + 30;
- }
- 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;
- 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) {
- ChangeDisplay2Value(_LeftGun_Title,_ICON_LeftGunShow);
- // Set Left Gun
- ChangeDisplay2Value(_LeftGun_Status,_ICON_LeftGun_on);
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_LeftGun_Type,_ICON_LeftGun_on_CCCS1);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_LeftGun_Type,_ICON_LeftGun_on_CCS2);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_LeftGun_Type,_ICON_LeftGun_on_CHAdeMo);
- }
- // Set Right Gun
- ChangeDisplay2Value(_RightGun_Status,_ICON_RightGun_off);
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_RightGun_Type,_ICON_RightGun_off_CCS1);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_RightGun_Type,_ICON_RightGun_off_CCS2);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_RightGun_Type,_ICON_RightGun_off_CHAdeMo);
- }
- } else {
- // Left Gun
- ChangeDisplay2Value(_RightGun_Title,_ICON_RightGunShow);
- ChangeDisplay2Value(_LeftGun_Status,_ICON_LeftGun_off);
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_LeftGun_Type,_ICON_LeftGun_off_CCS1);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_LeftGun_Type,_ICON_LeftGun_off_CCS2);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_LeftGun_Type,_ICON_LeftGun_off_CHAdeMo);
- }
- // Right Gun
- ChangeDisplay2Value(_RightGun_Status,_ICON_RightGun_on);
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_RightGun_Type,_ICON_RightGun_on_CCS1);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_RightGun_Type,_ICON_RightGun_on_CCS2);
- } else if (pDcChargingInfo->Type == _Type_Chademo) {
- ChangeDisplay2Value(_RightGun_Type,_ICON_RightGun_on_CHAdeMo);
- }
- }
- }
- 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(_QR_CODE_, 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(_String_ChargeTime_, cmd, sizeof(cmd));
- }
- void ChangeChargingPowerValue(float pow)
- {
- uint8_t cmd[10];
- uint8_t value[10];
- memset(cmd, 0x00, sizeof(cmd));
- sprintf((char *) value, "%.1f",pow);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_String_Power_, cmd, sizeof(cmd));
- }
- void ChangeChargingVoltageValue(float vol)
- {
- uint8_t cmd[10];
- uint8_t value[10];
- memset(cmd, 0x00, sizeof(cmd));
- sprintf((char *) value, "%d", (int)vol);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_String_Voltage_, cmd, sizeof(cmd));
- }
- void ChangeChargingCurrenteValue(float vol)
- {
- uint8_t cmd[10];
- uint8_t value[10];
- memset(cmd, 0x00, sizeof(cmd));
- sprintf((char *) value, "%d", (int)vol);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_String_Current_, 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_Cost_, 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;
- }
- sprintf((char *) value, "%d", (int)energy);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_String_Rate_, cmd, sizeof(cmd));
- }
- uint8_t _battery_display_count = 0;
- void ChangeBattMapAndValue(short page, int soc)
- {
- if (page == _PAGE_CHARGING) {
- _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 (soc < 25) {
- if (_battery_display_ani) {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_0);
- } else {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_1);
- }
- } else if (soc >= 25 && soc < 50) {
- if (_battery_display_ani) {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_1);
- } else {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_2);
- }
- } else if (soc >= 50 && soc < 75) {
- if (_battery_display_ani) {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_2);
- } else {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_3);
- }
- } else if (soc >= 75 && soc < 100) {
- if (_battery_display_ani) {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_3);
- } else {
- ChangeDisplay2Value(_Battery_Progress_0, _ICON_battery_4);
- }
- }
- } else if (page == _PAGE_COMPLETE) {
- if (soc < 20) {
- ChangeDisplay2Value(_Battery_Progress_1, _ICON_text_battery_0);
- } else if (soc >= 20 && soc < 40) {
- ChangeDisplay2Value(_Battery_Progress_1, _ICON_text_battery_1);
- } else if (soc >= 40 && soc < 60) {
- ChangeDisplay2Value(_Battery_Progress_1, _ICON_text_battery_2);
- } else if (soc >= 60 && soc < 80) {
- ChangeDisplay2Value(_Battery_Progress_1, _ICON_text_battery_3);
- } else if (soc >= 80 && soc <= 100) {
- ChangeDisplay2Value(_Battery_Progress_1, _ICON_text_battery_4);
- }
- }
- uint8_t cmd[5];
- uint8_t value[5];
- memset(cmd, 0x00, sizeof(cmd));
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value, "%d", soc);
- string2ByteArray(value, cmd);
- DisplayValueToLcm(_String_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(_PreChargeTimer, 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();
- log_info("Time:%d",GetTimeoutValue(returnIdleTimer) /uSEC_VAL);
- if (GetTimeoutValue(returnIdleTimer) /uSEC_VAL >= RETURNIDLE_Timeout ) {
- pSysInfo->SystemPage = _PAGE_IDLE;
- gettimeofday(&returnIdleTimer, NULL);
- }
- break;
- case _PAGE_PLUGIN:
- _Text_Running_Count = 0;
- break;
- case _PAGE_PRECHARGE:
- if ((_Text_Running_Count/100) %2 == 0)
- ChangeDisplay2Value(_Text_PrepareToCharge,_Text_Running_Count%100);
- else
- ChangeDisplay2Value(_Text_PrepareToCharge,100-(_Text_Running_Count%100));
- _Text_Running_Count >= 200 ? _Text_Running_Count = 0 : _Text_Running_Count++;
- break;
- case _PAGE_CHARGING:
- if (pDcChargingInfo->PresentChargingVoltage >= 0 &&
- pDcChargingInfo->PresentChargingVoltage <= 950) {
- ChangeChargingVoltageValue(pDcChargingInfo->PresentChargingVoltage);
- }
- if (pDcChargingInfo->PresentChargingCurrent >= 0) {
- ChangeChargingCurrenteValue(pDcChargingInfo->PresentChargingCurrent);
- }
- 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->PresentChargedDuration >= 0 &&
- pDcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
- ChangeRemainTime(pDcChargingInfo->PresentChargedDuration);
- } else {
- ChangeRemainTime(0);
- }
- ChangeBattMapAndValue(_currentPage, 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(_currentPage, pDcChargingInfo->EvBatterySoc);
- break;
- case _PAGE_REFUND_SENSEING:
- break;
- case _PAGE_PLUGOUT:
- ChangeDisplay2Value(0x20B0, Battery_Test);
- Battery_Test >= 100 ? Battery_Test = 0 : Battery_Test++;
- 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()
- {
- ChangeDisplay2Value(_CellPhone_Mode,_ICON_cellphone_mode);
- ChangeDisplay2Value(_Screen_Mode,_ICON_screen_mode);
- ChangeDisplay2Value(_PlugIn_String,_ICON_Plugin);
- ChangeDisplay2Value(_Communication_Status,_ICON_Communication_on);
- ChangeDisplay2Value(_SaftyDetect_Status,_ICON_SaftyDetect_off);
- ChangeDisplay2Value(_PreCharge_Status,_ICON_PrepareCharge_off);
- ChangeDisplay2Value(_Text_Voltage,_ICON_text_Voltage);
- ChangeDisplay2Value(_Text_Current,_ICON_text_Current);
- ChangeDisplay2Value(_Text_Power,_ICON_text_Power);
- ChangeDisplay2Value(_Text_Rate,_ICON_text_Rate);
- ChangeDisplay2Value(_Text_Time,_ICON_text_time);
- ChangeDisplay2Value(_Battery_Progress_0,_ICON_battery_0);
- ChangeDisplay2Value(_Symbol_V,_ICON_symbol_V);
- ChangeDisplay2Value(_Symbol_A,_ICON_symbol_A);
- ChangeDisplay2Value(_Symbol_KW,_ICON_symbol_KW);
- ChangeDisplay2Value(_Symbol_Rate,_ICON_symbol_rate);
- ChangeDisplay2Value(_Symbol_Percent,_ICON_symbol_percent);
- ChangeDisplay2Value(_Text_ChargeRate,_ICON_text_ChargereRate);
- ChangeDisplay2Value(_Text_ChargePay,_ICON_text_ChargePay);
- ChangeDisplay2Value(_Battery_Progress_1,_ICON_text_battery_0);
- ChangeDisplay2Value(_Symbol_Dollar,_ICON_text_dollor);
- ChangeDisplay2Value(_Text_ChargeComplete,_ICON_text_ChargeComplete);
- }
- 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;
- }
|