1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747 |
- #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 "main.h"
- #include "../timeout.h"
- #define uSEC_VAL (1000000)
- //------------------------------------------------------------------------------
- //struct SysConfigAndInfo *ShmSysConfigAndInfo;
- //struct StatusCodeData *ShmStatusCodeData;
- static struct SysConfigData *pSysConfig = NULL;
- static struct SysInfoData *pSysInfo = NULL;
- static struct WARNING_CODE_INFO *pSysWarning = NULL;
- static struct FanModuleData *ShmFanModuleData;
- static struct PrimaryMcuData *ShmPrimaryMcuData;
- static SelectGunInfo *ShmSelectGunInfo = NULL;
- static struct ChargingInfoData *pDcChargingInfo = NULL;
- static DcCommonInfo *ShmDcCommonData = NULL;
- short _currentPage = _LCM_NONE;
- uint8_t _totalCount;
- uint8_t _showInformIndex = 0;
- float ChargeMaxPower_0 = 0;
- float ChargeMaxPower_1 = 0;
- int _port;
- //char* pPortName = "/dev/ttyO2";
- char *pPortName = "/dev/ttyS3";
- char *moduleName = "DMT80480T070_09WT";
- bool is_show = false;
- uint8_t _everyPageRollChange;
- void GetClockTime(struct timespec* _now_time, void* null)
- {
- clock_gettime(CLOCK_MONOTONIC, _now_time);
- }
- void StartSystemTimeoutDet(uint8_t flag)
- {
- if (pSysInfo->SystemTimeoutFlag != flag) {
- log_info("Set System Timeout Flag %d", flag);
- GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
- }
- pSysInfo->SystemTimeoutFlag = flag;
- }
- void StopSystemTimeoutDet(void)
- {
- GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
- pSysInfo->SystemTimeoutFlag = Timeout_None;
- }
- //==========================================
- // 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;
- }
- void changeTimeFormat(char* str, struct tm *_trTime)
- {
- //2022-04-29 06:22:00
- int i;
- char year[4];
- char mon[2];
- char day[2];
- char hr[2];
- char min[2];
- char sec[2];
- for (i = 0; i < 4; i++) {
- year[i] = str[i];
- }
- _trTime->tm_year = atoi(year) - 1900;
- for (i = 0; i < 2; i++) {
- mon[i] = str[i+5];
- }
- _trTime->tm_mon = atoi(mon) - 1;
- for (i = 0; i < 2; i++) {
- day[i] = str[i + 8];
- }
- _trTime->tm_mday = atoi(day);
- for (i = 0; i < 2; i++) {
- hr[i] = str[i + 11];
- }
- _trTime->tm_hour = atoi(hr);
- for (i = 0; i < 2; i++) {
- min[i] = str[i + 14];
- }
- _trTime->tm_min = atoi(min);
- for (i = 0; i < 2; i++) {
- sec[i] = str[i + 17];
- }
- _trTime->tm_sec = atoi(sec);
- _trTime->tm_isdst = 0;
- }
- int GetChargingDuration(char* st,char* et)
- {
- struct tm StartTime,EndTime;
- time_t t_start, t_end;
- changeTimeFormat(st, &StartTime);
- changeTimeFormat(et, &EndTime);
- t_start = mktime(&StartTime);
- t_end = mktime(&EndTime);
- return difftime(t_end, t_start);
- }
- 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 WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
- {
- int len = write(_port, cmd, cmdLen);
- if (len < sizeof(cmd)) {
- log_error("Write cmd to LCM Failure. ");
- }
- }
- void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
- {
- read(_port, msg, readLen);
- if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2) {
- if (*(msg + 3) == CMD_WRITE) {
- switch (*(msg + 4)) {
- case CMD_REGISTER: {
- // 頁面
- strcpy((char *)pSysInfo->LcmHwRev, moduleName);
- //_currentPage = *(msg + 7);
- }
- break;
- }
- } else if (*(msg + 3) == CMD_MULTI_READ) {
- short key = ((short)(*(msg + 4) << 8) + *(msg + 5));
- if (key == _LCM_VERSION) {
- if (strcmp((char*)pSysInfo->LcmHwRev, "") != EQUAL)
- strcpy((char*)pSysInfo->LcmHwRev, moduleName);
- if (atoi((char*)(msg + 7)) != 0)
- ShmDcCommonData->LcmFwVersion = atoi((char*)(msg + 7));
- }
- // 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";
- int _temp_hr;
- for(int i = 0 ; i < 2 ; i++) {
- hr[i] = time[i+11];
- }
- if ((atoi(hr) + 8) > 23) {
- _temp_hr = atoi(hr) + 8 - 24;
- sprintf(hr, "%02d", _temp_hr);
- } else if( atoi(hr) == NULL ) {
- strcpy(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) {
- strcpy(min,"");
- }
- }
- void GetSecFormTimeString(char* time, char* sec)
- {
- //char tm[] = "2021-12-06 17:29:08:084";
- for (int i = 0; i < 2; i++) {
- sec[i] = time[i + 17];
- }
- if (atoi(sec) == NULL || atoi(sec) > 60) {
- strcpy(sec, "");
- }
- }
- //================================================
- // Function
- //================================================
- void ChangeToOtherPage(short newPage)
- {
- uint8_t cmd[7];
- memset(cmd, 0x00, sizeof(cmd));
- cmd[0] = CMD_TITLE_1;
- cmd[1] = CMD_TITLE_2;
- cmd[2] = 0x02 + sizeof(newPage);
- cmd[3] = CMD_READ;
- cmd[4] = CMD_REGISTER;
- cmd[5] = newPage >> 8;
- cmd[6] = newPage & 0x00FF;
- WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
- usleep(100000);
- }
- void ChangeBackLight(bool islight)
- {
- uint8_t value = 0x01;
- 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(100000);
- }
- void GetCurrentPage()
- {
- uint8_t cmd[6];
- memset(cmd, 0x00, sizeof(cmd));
- uint8_t msg[8];
- memset(msg, 0x00, sizeof(msg));
- cmd[0] = CMD_TITLE_1;
- cmd[1] = CMD_TITLE_2;
- cmd[2] = 0x03; // 底下總長度
- cmd[3] = CMD_WRITE;
- cmd[4] = CMD_REGISTER;
- cmd[5] = 0x02;
- 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));
- 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);
- }
- void ChangeDisplay2Value(short address, short value)
- {
- uint8_t data[2];
- data[0] = value >> 8;
- data[1] = value & 0x00FF;
- //log_info("Addr:0x%x, value:%d",address,value);
- DisplayValueToLcm(address, data, sizeof(data));
- }
- void ChangeDisplay2LongValue(short address, long value)
- {
- uint8_t data[4];
- data[0] = (value >> 24) & 0xFF;
- data[1] = (value >> 16 ) & 0xFF;
- data[2] = (value >> 8) & 0xFF;
- data[3] = value & 0x000000FF;
- /*
- log_info("long Addr:0x%x, value:%d",address,value);
- for (int i = 0; i < 4; i++) {
- log_info("data[%d]:%d",i,data[i]);
- }
- */
- 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;
- }
- ChangeDisplay2Value(_ProgressBar_LEVEL,progress_index);
- _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);
- if (pSysWarning->Level == WARN_LV_ER) {
- pSysInfo->SystemPage = _LCM_MAINTAIN;
- if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton)
- pSysInfo->SystemPage = _LCM_EMERGENCY;
- }
-
- switch (pSysInfo->SystemPage) {
- case _LCM_VIEW:
- if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_IDLE ) {
- pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
- } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_IDLE) {
- pSysInfo->PageIndex = __VIEW_LEFT_CHARGE_;
- } else if(pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
- pSysInfo->PageIndex = __VIEW_RIGHT_CHARGE_;
- } else if(pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
- pSysInfo->PageIndex = __VIEW_ALL_CHARGE_;
- } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT )&&
- pDcChargingInfo_1->SystemStatus == S_CHARGING) {
- if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_LINK_R_CHARGE;
- else
- pSysInfo->PageIndex = __VIEW_L_FAIL_R_CHARGE;
- } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING &&
- (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
- if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_CHARGE_R_LINK;
- else
- pSysInfo->PageIndex = __VIEW_L_CHARGE_R_FAIL;
- } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT) &&
- pDcChargingInfo_1->SystemStatus == S_IDLE) {
- if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_LINK_R_IDLE;
- else
- pSysInfo->PageIndex = __VIEW_L_FAIL_R_IDLE;
- } else if (pDcChargingInfo_0->SystemStatus == S_IDLE &&
- (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
- if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_IDLE_R_LINK;
- else
- pSysInfo->PageIndex = __VIEW_L_IDLE_R_FAIL;
- } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT) &&
- (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
- if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM] &&
- pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM]) {
- pSysInfo->PageIndex = __VIEW_L_FAIL_R_FAIL;
- } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM]) {
- pSysInfo->PageIndex = __VIEW_L_LINK_R_FAIL;
- } else if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM]) {
- pSysInfo->PageIndex = __VIEW_L_FAIL_R_LINK;
- } else
- pSysInfo->PageIndex = __VIEW_ALL_FAIL;
- } else if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
- pSysInfo->PageIndex = __VIEW_L_IDLE_R_MAINTAIN;
- } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_IDLE) {
- pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_IDLE;
- } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
- pSysInfo->PageIndex = __VIEW_L_CHARGE_R_MAINTAIN;
- } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_CHARGING) {
- pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_CHARGE;
- } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
- pSysInfo->PageIndex = __MAINTAIN_PAGE_;
- } else if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_COMPLETE /* &&
- pDcChargingInfo_1->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_IDLE_R_OUT;
- } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_IDLE /* &&
- pDcChargingInfo_0->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_OUT_R_IDLE;
- } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_COMPLETE /* &&
- pDcChargingInfo_1->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_CHARGE_R_OUT;
- } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_CHARGING /* &&
- pDcChargingInfo_0->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_OUT_R_CHARGE;
- } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN && pDcChargingInfo_1->SystemStatus == S_COMPLETE /* &&
- pDcChargingInfo_1->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_OUT;
- } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_MAINTAIN /* &&
- pDcChargingInfo_0->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_OUT_R_MAINTAIN;
- } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE && pDcChargingInfo_1->SystemStatus == S_COMPLETE /* &&
- pDcChargingInfo_0->ConnectorPlugIn && pDcChargingInfo_1->ConnectorPlugIn*/) {
- pSysInfo->PageIndex = __VIEW_L_OUT_R_OUT;
- } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT) &&
- pDcChargingInfo_1->SystemStatus == S_COMPLETE /* && pDcChargingInfo_1->ConnectorPlugIn*/) {
- if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_LINK_R_OUT;
- else
- pSysInfo->PageIndex = __VIEW_L_FAIL_R_OUT;
- } else if (pDcChargingInfo_0->SystemStatus == S_COMPLETE /* && pDcChargingInfo_0->ConnectorPlugIn*/ &&
- (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
- if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_OUT_R_LINK;
- else
- pSysInfo->PageIndex = __VIEW_L_OUT_R_FAIL;
- } else if (pDcChargingInfo_0->SystemStatus == S_MAINTAIN &&
- (pDcChargingInfo_1->SystemStatus == S_ALARM || pDcChargingInfo_1->SystemStatus == S_FAULT)) {
- if (pDcChargingInfo_1->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[RIGHT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_LINK;
- else
- pSysInfo->PageIndex = __VIEW_L_MAINTAIN_R_FAIL;
- } else if ((pDcChargingInfo_0->SystemStatus == S_ALARM || pDcChargingInfo_0->SystemStatus == S_FAULT ) &&
- pDcChargingInfo_1->SystemStatus == S_MAINTAIN) {
- if (pDcChargingInfo_0->SystemStatus == S_ALARM && !ShmDcCommonData->isIntoCharge[LEFT_GUN_NUM])
- pSysInfo->PageIndex = __VIEW_L_LINK_R_MAINTAIN;
- else
- pSysInfo->PageIndex = __VIEW_L_FAIL_R_MAINTAIN;
- } else {
- if (pDcChargingInfo_0->SystemStatus == S_CHARGING) {
- pSysInfo->PageIndex = __VIEW_LEFT_CHARGE_;
- } else if (pDcChargingInfo_1->SystemStatus == S_CHARGING) {
- pSysInfo->PageIndex = __VIEW_RIGHT_CHARGE_;
- } else {
- pSysInfo->PageIndex = __VIEW_ALL_IDLE_;
- }
-
- }
- break;
- case _LCM_START_SCAN:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __START_SCAN_LEFT;
- else
- pSysInfo->PageIndex = __START_SCAN_RIGHT;
- break;
- case _LCM_START_AUTHORIZING:
- pSysInfo->PageIndex = __START_AUTHORIZE_;
- break;
- case _LCM_START_AUTHORIZE_FAIL:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __START_AUTHORIZE_FAIL_LEFT;
- else
- pSysInfo->PageIndex = __START_AUTHORIZE_FAIL_RIGHT;
- break;
- case _LCM_WAIT_PLUGIN:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __WAIT_PLUGIN_;
- else
- pSysInfo->PageIndex = __WAIT_PLUGIN_RIGHT;
- break;
- case _LCM_PRECHARGE:
- pSysInfo->PageIndex =__PRE_CHARGE_;
- break;
- case _LCM_LINK_ERROR:
- if(pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __LINKING_ERROR_LEFT;
- else
- pSysInfo->PageIndex = __LINKING_ERROR_RIGHT;
- break;
- /*
- case _LCM_DETAIL_VIEW:
- pSysInfo->PageIndex =__DETAIL_VIEW_;
- break;
- case _LCM_STOP_RFID:
- pSysInfo->PageIndex =__STOP_SCAN_RFID_;
- break;
-
- case _LCM_STOP_APP:
- pSysInfo->PageIndex =__STOP_SCAN_APP_;
- break;
- case _LCM_STOP_RFID_FAIL:
- pSysInfo->PageIndex =__STOP_RFID_FAIL_;
- break;
- */
- case _LCM_STOPPING:
- pSysInfo->PageIndex = __STOP_AUTHORIZE_;
- break;
- case _LCM_WAIT_PLUGOUT:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __WAIT_PLUGOUT_LEFT;
- else
- pSysInfo->PageIndex = __WAIT_PLUGOUT_RIGHT;
- break;
- case _LCM_SUMMARY:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __SUMMARY_LEFT;
- else
- pSysInfo->PageIndex = __SUMMARY_RIGHT;
- break;
- case _LCM_MAINTAIN:
- pSysInfo->PageIndex =__MAINTAIN_PAGE_;
- break;
- case _LCM_ERROR:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM)
- pSysInfo->PageIndex = __ERROR_PAGE_LEFT;
- else
- pSysInfo->PageIndex = __ERROR_PAGE_RIGHT;
- break;
- case _LCM_EMERGENCY:
- pSysInfo->PageIndex =__EMERGENCY_BUTTON_;
- break;
- case _LCM_CONFIRM_STOP:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
- pSysInfo->PageIndex = __CONFIRM_STOP_LEFT;
- } else
- pSysInfo->PageIndex = __CONFIRM_STOP_RIGHT;
- break;
- case _LCM_COMMUNICATION:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
- pSysInfo->PageIndex = __PRECHARGE_LEFT_CONNECT;
- } else {
- pSysInfo->PageIndex = __PRECHARGE_RIGHT_CONNECT;
- }
- break;
- case _LCM_CHARGING_DETECT:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
- pSysInfo->PageIndex = __PRECHARGE_LEFT_CHECK;
- } else {
- pSysInfo->PageIndex = __PRECHARGE_RIGHT_CHECK;
- }
- break;
- case _LCM_PREPARECHARE:
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
- pSysInfo->PageIndex = __PRECHARGE_LEFT_START;
- } else {
- pSysInfo->PageIndex = __PRECHARGE_RIGHT_START;
- }
- break;
- }
- if (_currentPage != pSysInfo->PageIndex) {
- log_info("Gun%d Change Page from %d to %d",pSysInfo->CurGunSelected, _currentPage, pSysInfo->PageIndex);
- }
- _currentPage = pSysInfo->PageIndex;
- ChangeToOtherPage(pSysInfo->PageIndex);
-
- }
- /*
- * View Page
- *
- */
- void ShowViewChargingSoc(uint8_t gunIndex,int soc)
- {
- uint8_t digits = soc % 10;
- uint8_t tens = (soc / 10) %10;
- uint8_t hundreds = soc / 100;
- if (gunIndex == LEFT_GUN_NUM) {
- ChangeDisplay2Value(_LeftGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
- if (hundreds == 0 ) {
- ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Empty);
- if (tens == 0 )
- ChangeDisplay2Value(_LeftGun_Soc_Tens,(short)_ICON_Empty);
- else
- ChangeDisplay2Value(_LeftGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
- } else {
- ChangeDisplay2Value(_LeftGun_Soc_Hundreds, (short)_ICON_Red_Num_1);
- ChangeDisplay2Value(_LeftGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
- }
- } else {
- ChangeDisplay2Value(_RightGun_Soc_Digits,(short)_ICON_Red_Num_0+digits);
- if (hundreds == 0 ) {
- ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Empty);
- if (tens == 0)
- ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Empty);
- else
- ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Red_Num_0+ tens);
- } else {
- ChangeDisplay2Value(_RightGun_Soc_Hundreds, (short)_ICON_Red_Num_1);
- ChangeDisplay2Value(_RightGun_Soc_Tens, (short)_ICON_Red_Num_0 + tens);
- }
- }
- }
- void ShowViewChargingTime(uint8_t gunIndex,int time)
- {
- int min,sec;
- int ShowTime;
- min = time/60;
- sec = time % 60;
- ShowTime = min * 100 + sec;
- //sprintf((char *)value,"%d:%02d",min,sec);
- if (gunIndex == LEFT_GUN_NUM) {
- ChangeDisplay2Value(_LeftGun_info_time, (short)ShowTime);
- } else {
- ChangeDisplay2Value(_RightGun_info_time, (short)ShowTime);
- }
- }
- void ShowViewChargingEngery(uint8_t gunIndex, float energy)
- {
- float data = energy * 10;
- if (energy < 0)
- data = fabs(energy);
- if (gunIndex == LEFT_GUN_NUM) {
- ChangeDisplay2Value(_LeftGun_info_cap, data);
- } else
- ChangeDisplay2Value(_RightGun_info_cap, data);
- /*
- if(energy < 100)
- sprintf((char*)value, "%.1f", energy);
- else
- sprintf((char*)value, "%d", (int)energy);
- //log_info("gun[%d] energy:%.1f", gunIndex, energy);
- if (gunIndex == LEFT_GUN_NUM) {
- DisplayValueToLcm(_LeftGun_info_cap, (uint8_t*)value, sizeof(value));
- }
- else
- DisplayValueToLcm(_RightGun_info_cap, (uint8_t*)value, sizeof(value));
- */
- }
- void ShowViewCharingMoney(uint8_t gunIndex,float money)
- {
- float data = money;
- if (money < 0)
- data = fabs(money);
- if (gunIndex == LEFT_GUN_NUM) {
- ChangeDisplay2Value(_LeftGun_info_money, data);
- } else
- ChangeDisplay2Value(_RightGun_info_money, data);
- /*
- uint8_t value[10] = {0};
- sprintf((char *)value,"%d",(int)money);
- //log_info("gun[%d] money:%.1f", gunIndex, money);
- if (gunIndex == LEFT_GUN_NUM) {
- DisplayValueToLcm(_LeftGun_info_money, (uint8_t *)value, sizeof(value));
- } else
- DisplayValueToLcm(_RightGun_info_money, (uint8_t *)value, sizeof(value));
- */
- }
- void ShowViewChargingPower(uint8_t gunIndex,float power)
- {
- uint8_t value[10] = {0};
- float _data = power * 10;
- sprintf((char *)value,"%.1f",power);
- //log_info("gun[%d] power:%.1f",gunIndex,power);
- if (power >= 0 && power <= POWER_MAX_KW) {
- if (gunIndex == LEFT_GUN_NUM) {
- ChangeDisplay2Value(_LeftGun_info_power_number, _data);
- //DisplayValueToLcm(_LeftGun_info_power_number, (uint8_t *)value, sizeof(value));
- } else {
- //DisplayValueToLcm(_RightGun_info_power_number, (uint8_t*)value, sizeof(value));
- ChangeDisplay2Value(_RightGun_info_power_number, _data);
- }
- }
- }
- void ShowConnectId()
- {
- int id = atoi(pSysConfig->SystemId);
- if (id == 0)
- id = 1;
- ChangeDisplay2Value(_Text_SystemID, id);
-
- if (ShmDcCommonData->ConnectorId[0] <= 2) {
- ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
- ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
- } else {
- ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_C);
- ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_D);
- }
-
- }
- void ShowViewLeftGunInfo()
- {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
- if (pDcChargingInfo->SystemStatus == S_IDLE ) {
- switch (pDcChargingInfo->CCSGunType) {
- case _TYPE_CCS1_Liquid:
- case _TYPE_CCS1_Natural:
- ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS1_GUN_U);
- ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS1_GUN_L);
- ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS1_Name);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
- ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
- } else {
- ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
- }
- break;
- case _TYPE_CCS2_Liquid:
- case _TYPE_CCS2_Natural:
- ChangeDisplay2Value(_LeftGun_type_pic_U,_ICON_CCS2_GUN_U);
- ChangeDisplay2Value(_LeftGun_type_pic_L,_ICON_CCS2_GUN_L);
- ChangeDisplay2Value(_LeftGun_type_name,_ICON_CCS2_Name);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
- ChangeDisplay2Value(_LeftGun_type_speed,_ICON_High_Speed);
- } else {
- ChangeDisplay2Value(_LeftGun_type_speed,_ICON_Speed);
- }
- break;
- default:
- log_error("CCS Gun Type Error! Not Show in LCM!!");
- }
- } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
- ShowViewChargingSoc(LEFT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
- if (strlen(ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeStartTime) > 1) {
- int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeStartTime,
- ShmDcCommonData->pGunInfo[LEFT_GUN_NUM].ChargeDuration);
- ShowViewChargingTime(LEFT_GUN_NUM, duration);
- } else {
- ShowViewChargingTime(LEFT_GUN_NUM, 0);
- }
- ShowViewCharingMoney(LEFT_GUN_NUM,pDcChargingInfo->ChargingFee);
- ShowViewChargingPower(LEFT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
- ShowViewChargingEngery(LEFT_GUN_NUM, pDcChargingInfo->PresentChargedEnergy);
- switch (pDcChargingInfo->CCSGunType) {
- case _TYPE_CCS1_Liquid:
- case _TYPE_CCS1_Natural:
- ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS1_Name);
- break;
- case _TYPE_CCS2_Liquid:
- case _TYPE_CCS2_Natural:
- ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS2_Name);
- break;
- }
- }
- }
- void ShowViewRightGunInfo()
- {
- char value[5];
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
- if (pDcChargingInfo->SystemStatus == S_IDLE ) {
- switch (pDcChargingInfo->CCSGunType) {
- case _TYPE_CCS1_Liquid:
- case _TYPE_CCS1_Natural:
- ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS1_GUN_U);
- ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS1_GUN_L);
- ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS1_Name);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
- ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
- } else {
- ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
- }
- break;
- case _TYPE_CCS2_Liquid:
- case _TYPE_CCS2_Natural:
- ChangeDisplay2Value(_RightGun_type_pic_U,_ICON_CCS2_GUN_U);
- ChangeDisplay2Value(_RightGun_type_pic_L,_ICON_CCS2_GUN_L);
- ChangeDisplay2Value(_RightGun_type_name,_ICON_CCS2_Name);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
- ChangeDisplay2Value(_RightGun_type_speed,_ICON_High_Speed);
- } else {
- ChangeDisplay2Value(_RightGun_type_speed,_ICON_Speed);
- }
- break;
- default:
- log_error("CCS Gun Type Error! Not Show in LCM!!");
- }
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value,"1 B");
- DisplayValueToLcm(_RightGun_location, (uint8_t *)value, sizeof(value));
- } else if (pDcChargingInfo->SystemStatus == S_CHARGING ) {
- ShowViewChargingSoc(RIGHT_GUN_NUM,pDcChargingInfo->EvBatterySoc);
- if (strlen(ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeStartTime) > 1) {
- int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeStartTime,
- ShmDcCommonData->pGunInfo[RIGHT_GUN_NUM].ChargeDuration);
- ShowViewChargingTime(RIGHT_GUN_NUM, duration);
- } else {
- ShowViewChargingTime(RIGHT_GUN_NUM, 0);
- }
- ShowViewCharingMoney(RIGHT_GUN_NUM,pDcChargingInfo->ChargingFee);
- ShowViewChargingPower(RIGHT_GUN_NUM,pDcChargingInfo->PresentChargingPower);
- ShowViewChargingEngery(RIGHT_GUN_NUM, pDcChargingInfo->PresentChargedEnergy);
- switch (pDcChargingInfo->CCSGunType) {
- case _TYPE_CCS1_Liquid:
- case _TYPE_CCS1_Natural:
- ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS1_Name);
- break;
- case _TYPE_CCS2_Liquid:
- case _TYPE_CCS2_Natural:
- ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS2_Name);
- break;
- }
- }
- }
- void SetViewPage()
- {
- // Set Background pic.
- if (pSysConfig->TotalConnectorCount == 1) {
- } else if (pSysConfig->TotalConnectorCount == 2) {
- ShowConnectId();
- ShowViewLeftGunInfo();
- ShowViewRightGunInfo();
- }
- }
- void ShowSelectGunIcon()
- {
- uint8_t value[5] = {0};
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS2_Symbol);
- }
- ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
- sprintf((char *)value,"%s",LEFT_GUN_LOCAL_NAME);
- DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
- memset(value, 0x00, sizeof(value));
- DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
- } else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS1_Natural) {
- ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS1_Symbol);
- } else if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid ||
- pDcChargingInfo->CCSGunType == _TYPE_CCS2_Natural) {
- ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
- }
- ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
- sprintf((char *)value,"%s",RIGHT_GUN_LOCAL_NAME);
- DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
- memset(value, 0x00, sizeof(value));
- DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
- }
- }
- void ShowCountDownTimer()
- {
- int min,sec;
- uint8_t value[10] = {0};
- int tm = 120 - (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL);
- // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
- min = tm/60;
- sec = tm%60;
- sprintf((char *)value,"%02d:%02d",min,sec);
- if (pSysInfo->SystemPage == _LCM_SUMMARY) {
- sprintf((char*)value, "");
- DisplayValueToLcm(_Count_Down_Time, (uint8_t*)value, sizeof(value));
- }
- else
- DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
- }
- unsigned long GetTimeoutValue(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;
- }
- void ShowGunCountDownTimer()
- {
- int min,sec;
- uint8_t value[10] = {0};
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- int tm = 120 - (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL);
- // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
- min = tm/60;
- sec = tm%60;
- sprintf((char *)value,"%02d:%02d",min,sec);
- DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
- }
- void ClearQrCode()
- {
- char cmd[200];
- memset(cmd, 0, 200);
- DisplayValueToLcm(_QR_CODE_AUTHORIZE, (uint8_t *)cmd, 200);
- }
- void ChangeQrCode()
- {
- char cmd[200];
- pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- memset(cmd, 0 , 200);
- int len = sprintf(cmd, "https://qrcode.u-power.app/connector?chargebox=%s&connectorno=%d", ShmDcCommonData->QRCodeString, ShmDcCommonData->ConnectorId[pSysInfo->CurGunSelected]);
- //int len = sprintf(cmd, "http://www.u-power.com.tw/");
- if (len > 200) {
- log_info("QR Code URL length too long");
- }
- DisplayValueToLcm(_QR_CODE_AUTHORIZE, cmd, 200);
- }
- void ShowProgressBar()
- {
- /*
- for(int i = 0 ; i <= 19 ; i++) {
- ChangeDisplay2Value(_ProgressBar_LEVEL,_ICON_ProgressBar_10+i);
- usleep(100000);
- }*/
- }
- void ShowChargeTime(int addr,int _time)
- {
- int tens, digits;
- tens = _time / 10;
- digits = _time % 10;
- ChangeDisplay2Value(addr, tens);
- ChangeDisplay2Value(addr+2, digits);
- }
- void ShowSummaryMoney(int addr, int money)
- {
- int dig, tens, hund, thou,shift;
- if (addr == _Summary_total_money) {
- shift = 42;
- } else {
- shift = 100;
- }
- if (money > 9999) {
- money = 9999;
- }
- thou = money / 1000;
- hund = (money / 100) % 10;
- tens = (money / 10) % 10;
- dig = money % 10;
-
- ChangeDisplay2Value(addr + 6, thou == 0 ? _ICON_Empty : thou+shift);
- if (thou == 0) {
- ChangeDisplay2Value(addr + 4, hund == 0 ? _ICON_Empty : hund + shift);
- if (addr == _Summary_cal_discount)
- ChangeDisplay2Value(addr + 8, _ICON_Empty);
- if (hund == 0) {
- ChangeDisplay2Value(addr + 2, tens == 0 ? _ICON_Empty : tens + shift);
- } else {
- ChangeDisplay2Value(addr + 2, tens + shift);
- }
- } else {
- ChangeDisplay2Value(addr + 4, hund + shift);
- ChangeDisplay2Value(addr + 2, tens + shift);
- }
- ChangeDisplay2Value(addr, dig + shift);
- // 給UPOINT負號
- if (addr == _Summary_cal_discount) {
- if (thou == 0) {
- if (hund == 0) {
- if (tens == 0) {
- ChangeDisplay2Value(addr + 2, _ICON_negative);
- } else {
- ChangeDisplay2Value(addr + 4, _ICON_negative);
- }
- } else {
- ChangeDisplay2Value(addr + 6, _ICON_negative);
- }
- } else {
- ChangeDisplay2Value(addr + 8, _ICON_negative);
- }
- }
- }
- void ShowSummaryMoneyDash(int addr)
- {
- if (addr == _Summary_total_money) {
- ChangeDisplay2Value(addr , _ICON_DASH_SINGLE);
- ChangeDisplay2Value(addr + 2, _ICON_DASH_SINGLE);
- ChangeDisplay2Value(addr + 4, _ICON_Empty);
- ChangeDisplay2Value(addr + 6, _ICON_Empty);
- } else {
- ChangeDisplay2Value(addr, _ICON_DASH_SINGLE);
- ChangeDisplay2Value(addr + 2, _ICON_DASH_SINGLE);
- ChangeDisplay2Value(addr + 4, _ICON_Empty);
- ChangeDisplay2Value(addr + 6, _ICON_Empty);
- ChangeDisplay2Value(addr + 8, _ICON_Empty);
- }
- }
- void ShowSummaryPage()
- {
- float data;
- char start_hr[3],start_min[3],start_sec[3],end_hr[3],end_min[3],end_sec[3];
- int t_hr;
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
- // Show Money
- if (ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].finalcost_flag &&
- ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].RemainAmount > 0) {
- ShowSummaryMoney(_Summary_total_money, (int)ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].RemainAmount);
- //ShowSummaryMoney(_Summary_cal_Total_money, (int)pDcChargingInfo->ChargingFee);
- ShowSummaryMoney(_Summary_cal_discount, (int)ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Discount);
- } else {
- // 未收到Final cost
- ShowSummaryMoneyDash(_Summary_total_money);
- //ShowSummaryMoneyDash(_Summary_cal_Total_money);
- ShowSummaryMoneyDash(_Summary_cal_discount);
- }
- /*
- log_info("start time:%s",pDcChargingInfo->StartDateTime);
- log_info("stop time:%s",pDcChargingInfo->StopDateTime);*/
- GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_hr);
- GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime,start_min);
- GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_sec);
- GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime,end_hr);
- GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime,end_min);
- GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_sec);
- t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
- if (t_hr >= 24)
- t_hr -= 24;
- if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime) == 0) {
- ShowChargeTime(_Summary_Start_time_hr,0);
- ShowChargeTime(_Summary_Start_time_min, 0);
- ShowChargeTime(_Summary_Start_time_sec, 0);
- } else {
- ShowChargeTime(_Summary_Start_time_hr, t_hr);
- ShowChargeTime(_Summary_Start_time_min, atoi(start_min));
- ShowChargeTime(_Summary_Start_time_sec, atoi(start_sec));
- }
- t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
- if (t_hr >= 24)
- t_hr -= 24;
- if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime) == 0) {
- ShowChargeTime(_Summary_end_time_hr, 0);
- ShowChargeTime(_Summary_end_time_min, 0);
- ShowChargeTime(_Summary_end_time_sec, 0);
- } else {
- ShowChargeTime(_Summary_end_time_hr, t_hr);
- ShowChargeTime(_Summary_end_time_min, atoi(end_min));
- ShowChargeTime(_Summary_end_time_sec, atoi(end_sec));
- }
- /*
- DisplayValueToLcm(_Summary_Start_time_hr, (uint8_t *)start_hr, sizeof(start_hr));
- DisplayValueToLcm(_Summary_Start_time_min, (uint8_t *)start_min, sizeof(start_min));
- DisplayValueToLcm(_Summary_end_time_hr, (uint8_t *)end_hr, sizeof(end_hr));
- DisplayValueToLcm(_Summary_end_time_min, (uint8_t *)end_min, sizeof(end_min));
- */
- int duration = GetChargingDuration(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime,
- ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime);
- //uint8_t _min = (pDcChargingInfo->PresentChargedDuration)/60;
- //uint8_t _sec = (pDcChargingInfo->PresentChargedDuration) % 60;
- /*
- sprintf((char *)value,"%d",min);
- DisplayValueToLcm(_Summary_duration_time, (uint8_t *)value, sizeof(value));
- */
- ChangeDisplay2Value(_Summary_duration_min, (int)duration/60);
- ChangeDisplay2Value(_Summary_duration_sec, (int)duration%60);
- if (pDcChargingInfo->PresentChargedEnergy > 0.001 &&
- pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
- data = pDcChargingInfo->PresentChargedEnergy*1000;
- } else
- data = 0;
- //sprintf((char *)value,"%.1f",data);
- ChangeDisplay2LongValue(_Summary_cap, data);
- if (pSysInfo->CurGunSelected == LEFT_GUN_NUM) {
- ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_0);
- }
- else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
- ChangeDisplay2Value(_Summary_max_power, (int)ChargeMaxPower_1);
- }
- if (pDcChargingInfo->PowerConsumption >= 0.1 ) {
- data = pDcChargingInfo->PowerConsumption / pDcChargingInfo->PresentChargedDuration;
- } else
- data = 0;
- //sprintf((char *)value,"%.1f",data);
- ChangeDisplay2Value(_Summary_average_power, (int)data);
- //DisplayValueToLcm(_Summary_average_power, (uint8_t *)value, sizeof(value));
- }
- void ProcessPageInfo()
- {
- switch (pSysInfo->SystemPage) {
- case _LCM_VIEW:
- // Confirm Charging Gun Number.
- SetViewPage();
- break;
- case _LCM_START_SCAN:
- ChangeQrCode();
- ShowSelectGunIcon();
- ShowGunCountDownTimer();
- break;
- case _LCM_START_AUTHORIZING:
- case _LCM_PRECHARGE:
- case _LCM_STOPPING:
- ChangeDisplay2Value(_Animation_Running, 1);
- break;
- case _LCM_START_AUTHORIZE_FAIL:
- case _LCM_LINK_ERROR:
- ShowCountDownTimer();
- break;
- case _LCM_SUMMARY:
- StartSystemTimeoutDet(Timeout_ReturnViewPage);
- ShowCountDownTimer();
- ShowSummaryPage();
- break;
- case _LCM_ERROR:
- break;
- case _LCM_MAINTAIN:
- break;
- case _LCM_WAIT_PLUGIN:
- case _LCM_WAIT_PLUGOUT:
- break;
- case _LCM_EMERGENCY:
- break;
- case _LCM_COMMUNICATION:
- ChangeDisplay2Value(_Animation_Communcation, 1);
- break;
- case _LCM_CHARGING_DETECT:
- ChangeDisplay2Value(_Animation_GFD, 1);
- break;
- case _LCM_PREPARECHARE:
- ChangeDisplay2Value(_Animation_Precharge, 1);
- break;
- }
- }
- void DemoFunction()
- {
- int i;
- uint8_t value[10];
- struct timeb SeqEndTime;
- struct tm *tm;
- int t_hr;
- char start_hr[3], start_min[3], start_sec[3], end_hr[3], end_min[3], end_sec[3];
- ChangeDisplay2Value(_Animation_Running, 1);
- ChangeDisplay2Value(_Animation_Communcation, 1);
- ChangeDisplay2Value(_Animation_GFD, 1);
- ChangeDisplay2Value(_Animation_Precharge, 1);
- ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
- ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
- ChangeDisplay2Value(_LeftGun_ConnectorId, _ICON_CONNECTOR_1);
- ChangeDisplay2Value(_RightGun_ConnectorId, _ICON_CONNECTOR_1);
- switch (pSysInfo->PageIndex) {
- case __VIEW_ALL_IDLE_:
- pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
- switch (pDcChargingInfo->CCSGunType) {
- case _TYPE_CCS1_Liquid:
- case _TYPE_CCS1_Natural:
- ChangeDisplay2Value(_LeftGun_type_pic_U, _ICON_CCS1_GUN_U);
- ChangeDisplay2Value(_LeftGun_type_pic_L, _ICON_CCS1_GUN_L);
- ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS1_Name);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
- ChangeDisplay2Value(_LeftGun_type_speed, _ICON_High_Speed);
- ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_B);
- } else {
- ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_A);
- ChangeDisplay2Value(_LeftGun_type_speed, _ICON_Speed);
- }
- break;
- case _TYPE_CCS2_Liquid:
- case _TYPE_CCS2_Natural:
- ChangeDisplay2Value(_LeftGun_type_pic_U, _ICON_CCS2_GUN_U);
- ChangeDisplay2Value(_LeftGun_type_pic_L, _ICON_CCS2_GUN_L);
- ChangeDisplay2Value(_LeftGun_type_name, _ICON_CCS2_Name);
- ChangeDisplay2Value(_LeftGun_Symbol_Icon, _ICON_CONNECTOR_C);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
- ChangeDisplay2Value(_LeftGun_type_speed, _ICON_High_Speed);
- } else {
- ChangeDisplay2Value(_LeftGun_type_speed, _ICON_Speed);
- }
- break;
- }
- pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
- switch (pDcChargingInfo->CCSGunType) {
- case _TYPE_CCS1_Liquid:
- case _TYPE_CCS1_Natural:
- ChangeDisplay2Value(_RightGun_type_pic_U, _ICON_CCS1_GUN_U);
- ChangeDisplay2Value(_RightGun_type_pic_L, _ICON_CCS1_GUN_L);
- ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS1_Name);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid) {
- ChangeDisplay2Value(_RightGun_type_speed, _ICON_High_Speed);
- ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_B);
- } else {
- ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_A);
- ChangeDisplay2Value(_RightGun_type_speed, _ICON_Speed);
- }
- break;
- case _TYPE_CCS2_Liquid:
- case _TYPE_CCS2_Natural:
- ChangeDisplay2Value(_RightGun_type_pic_U, _ICON_CCS2_GUN_U);
- ChangeDisplay2Value(_RightGun_type_pic_L, _ICON_CCS2_GUN_L);
- ChangeDisplay2Value(_RightGun_type_name, _ICON_CCS2_Name);
- ChangeDisplay2Value(_RightGun_Symol_Icon, _ICON_CONNECTOR_D);
- if (pDcChargingInfo->CCSGunType == _TYPE_CCS2_Liquid) {
- ChangeDisplay2Value(_RightGun_type_speed, _ICON_High_Speed);
- } else {
- ChangeDisplay2Value(_RightGun_type_speed, _ICON_Speed);
- }
- break;
- }
- sleep(5);
- break;
- case __VIEW_LEFT_CHARGE_:
- for (i = 0; i <= 100; i++) {
- ShowViewChargingSoc(LEFT_GUN_NUM,66+i/20);
- ShowViewChargingTime(LEFT_GUN_NUM,i);
- ShowViewCharingMoney(LEFT_GUN_NUM,i);
- ShowViewChargingPower(LEFT_GUN_NUM, (float)(66 + i *0.1));
- ShowViewChargingEngery(LEFT_GUN_NUM,50+i/30);
- usleep(100000);
- }
- break;
- case __VIEW_RIGHT_CHARGE_:
- for (i = 0; i <= 100; i++) {
- ShowViewChargingSoc(RIGHT_GUN_NUM,88+i/25);
- ShowViewChargingTime(RIGHT_GUN_NUM,i);
- ShowViewCharingMoney(RIGHT_GUN_NUM,i);
- ShowViewChargingPower(RIGHT_GUN_NUM, (float)(88 + i*0.1));
- ShowViewChargingEngery(RIGHT_GUN_NUM, 30+i/30);
- usleep(100000);
- }
- break;
- case __VIEW_ALL_CHARGE_:
- for(i=0;i<=100;i++) {
- ShowViewChargingSoc(LEFT_GUN_NUM, 66 + i / 20);
- ShowViewChargingTime(LEFT_GUN_NUM, i);
- ShowViewCharingMoney(LEFT_GUN_NUM, i);
- ShowViewChargingPower(LEFT_GUN_NUM, (float)(66 + i*0.1));
- ShowViewChargingEngery(LEFT_GUN_NUM, 50 + i / 30);
- ShowViewChargingSoc(RIGHT_GUN_NUM, 88 + i / 25);
- ShowViewChargingTime(RIGHT_GUN_NUM, i);
- ShowViewCharingMoney(RIGHT_GUN_NUM, i);
- ShowViewChargingPower(RIGHT_GUN_NUM, (float)(88 + i *0.1));
- ShowViewChargingEngery(RIGHT_GUN_NUM, 30 + i / 30);
- usleep(100000);
- }
- break;
- case 7:
- case 9:
- case 23:
- case 24:
- break;
- case 11:
- for(i = 0 ; i <= 100 ; i++) {
- // RefreshProgressAnimation(_ICON_ProgressBar_10+((i/10)*2));
- uint8_t digits = i % 10;
- uint8_t tens = (i / 10) %10;
- uint8_t hundreds = i / 100;
- ChangeDisplay2Value(_Percent_Number_Digits,(short)_ICON_White_Num_0+digits);
- ChangeDisplay2Value(_Percent_Number_Tens,(short)_ICON_White_Num_0+tens);
- if (hundreds == 0 )
- ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_Empty);
- else
- ChangeDisplay2Value(_Percent_Number_Hundreds,(short)_ICON_White_Num_1);
- sprintf((char *)value,"%03d",i);
- DisplayValueToLcm(_Detail_Power_Num, (uint8_t *)value, sizeof(value));
- DisplayValueToLcm(_Detail_Time_Num, (uint8_t *)value, sizeof(value));
- DisplayValueToLcm(_Detail_Cap_Num, (uint8_t *)value, sizeof(value));
- DisplayValueToLcm(_Detail_Money_Num, (uint8_t *)value, sizeof(value));
- if (i%2 == 0 ) {
- ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_CCS1_Symbol);
- ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_Empty);
- memset(value, 0x00, sizeof(value));
- DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"1 A");
- DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
- } else {
- ChangeDisplay2Value(_Confirm_Gun_Left_symbol,_ICON_Empty);
- ChangeDisplay2Value(_Confirm_Gun_Right_symbol,_ICON_CCS2_Symbol);
- memset(value, 0x00, sizeof(value));
- DisplayValueToLcm(_Confirm_Gun_Left_name, (uint8_t *)value, sizeof(value));
- sprintf((char *)value,"1 B");
- DisplayValueToLcm(_Confirm_Gun_Right_name, (uint8_t *)value, sizeof(value));
- }
- usleep(100000);
- }
- break;
- case 12:
- case 13:
- case 15:
- case 17:
- case 28:
- ftime(&SeqEndTime);
- SeqEndTime.time = time(NULL);
- tm = localtime(&SeqEndTime.time);
- memset(value, 0x00, sizeof(value));
- sprintf((char *)value,"%02d:%02d",tm->tm_hour,tm->tm_min);
- DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
- if (pSysInfo->PageIndex == 17 || pSysInfo->PageIndex == 28) {
- for (i = 0; i <= 9999; i++) {
- strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, "2022-05-15 16:42:11");
- strcpy((char*)ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, "2022-05-15 16:47:44");
- GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_hr);
- GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_min);
- GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime, start_sec);
- GetHrFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_hr);
- GetMinFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_min);
- GetSecFormTimeString(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime, end_sec);
- t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60);
- if (t_hr >= 24)
- t_hr -= 24;
- if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStartTime) == 0) {
- ShowChargeTime(_Summary_Start_time_hr, 0);
- ShowChargeTime(_Summary_Start_time_min, 0);
- ShowChargeTime(_Summary_Start_time_sec, 0);
- } else {
- ShowChargeTime(_Summary_Start_time_hr, t_hr);
- ShowChargeTime(_Summary_Start_time_min, atoi(start_min));
- ShowChargeTime(_Summary_Start_time_sec, atoi(start_sec));
- }
- t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60);
- if (t_hr >= 24)
- t_hr -= 24;
- if (strlen(ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].ChargeStopTime) == 0) {
- ShowChargeTime(_Summary_end_time_hr, 0);
- ShowChargeTime(_Summary_end_time_min, 0);
- ShowChargeTime(_Summary_end_time_sec, 0);
- } else {
- ShowChargeTime(_Summary_end_time_hr, t_hr);
- ShowChargeTime(_Summary_end_time_min, atoi(end_min));
- ShowChargeTime(_Summary_end_time_sec, atoi(end_sec));
- }
- ChangeDisplay2Value(_Summary_cal_discount,88);
- ChangeDisplay2Value(_Summary_max_power, 888);
- ChangeDisplay2Value(_Summary_average_power, 888);
- if (i < 100) {
- ShowSummaryMoneyDash(_Summary_total_money);
- ShowSummaryMoneyDash(_Summary_cal_Total_money);
- ShowSummaryMoneyDash(_Summary_cal_discount);
- } else {
- ShowSummaryMoney(_Summary_total_money, i);
- ShowSummaryMoney(_Summary_cal_Total_money, i);
- ShowSummaryMoney(_Summary_cal_discount, i);
- }
- usleep(100000);
- }
- }
- break;
- case __START_AUTHORIZE_:
- case __PRE_CHARGE_:
- case __STOP_AUTHORIZE_:
- for( i = 0 ; i <= 20 ; i++) {
- //RefreshProgressAnimation(_ICON_ProgressBar_10);
- usleep(100000);
- }
- for( i = 0 ; i <= 20 ; i++) {
- //RefreshProgressAnimation(_ICON_ProgressBar_20);
- usleep(100000);
- }
- break;
- case 29:
- break;
- case 5:
- pSysInfo->CurGunSelected = 0;
- ChangeQrCode();
- sleep(5);
- break;
- case 31:
- pSysInfo->CurGunSelected = 1;
- ChangeQrCode();
- sleep(5);
- break;
- case 8:
- case 16:
- case 18:
- case 19:
- case 25:
- case 26:
- case 27:
- case 30:
- case 32:
- case 33:
- case 34:
- sleep(5);
- break;
- }
- }
- 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 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(_Text_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(_Text_Warming0 + ((i) * 0x10), cmd, sizeof(cmd));
- DisplayValueToLcm(_Icon_Warming0 + ((i) * 2), cmd, 2);
- }
- }
- 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(5000);
- ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
- }
- int main(void)
- {
- 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();
- ChangeBackLight(true);
- _totalCount = pSysConfig->TotalConnectorCount;
- _everyPageRollChange = 0;
- uint8_t curWarningCount = 255;
- uint8_t changeWarningPriority = 0;
- //Initialization();
- //printf("_LCM_COMPLETE ");
- //ChangeToOtherPage(_LCM_COMPLETE);
- //return 0;
- uint8_t index = 35;
- ShmDcCommonData->PSU_Number = 12;
- uint8_t _verShowCount = 5;
- while (_port != -1) {
- if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
- GetDeviceInfoStatus(_LCM_VERSION, 3);
- GetCurrentPage();
- sleep(1);
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
- if (_verShowCount > 0) {
- log_info("LCM Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
- _verShowCount--;
- }
- } else {
- // Show Default Text
- /*
- if (!defaulttext) {
- ShowCabientVersionDefaultText();
- ShowDispenserVersionDefautlText();
- defaulttext = true;
- }
- */
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
- if(pSysConfig->TotalConnectorCount>=2) {
- if (pDcChargingInfo_0->SystemStatus == S_IDLE) {
- ChargeMaxPower_0 = 0;
- } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING) {
- if (pDcChargingInfo_0->PresentChargingPower > ChargeMaxPower_0 &&
- pDcChargingInfo_0->PresentChargingPower >= 0 &&
- pDcChargingInfo_0->PresentChargingPower <= POWER_MAX_KW)
- ChargeMaxPower_0 = pDcChargingInfo_0->PresentChargingPower;
- }
- if (pDcChargingInfo_1->SystemStatus == S_IDLE) {
- ChargeMaxPower_1 = 0;
- } else if (pDcChargingInfo_1->SystemStatus == S_CHARGING) {
- if (pDcChargingInfo_1->PresentChargingPower > ChargeMaxPower_1 &&
- pDcChargingInfo_1->PresentChargingPower >= 0 &&
- pDcChargingInfo_1->PresentChargingPower <= POWER_MAX_KW)
- ChargeMaxPower_1 = pDcChargingInfo_1->PresentChargingPower;
- }
- }
- // Warming處理
- 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();
- }
- // 頁面資訊處理
- ///*
- ProcessPageInfo();
- // 換頁處理
- GetCurrentPage(); //DS60-120 add
- ChangeCurPage();
- changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
- //*/
- /*
- if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _LCM_VIEW) {
- InformationShow();
- ChangeToOtherPage(pSysInfo->PageIndex);
- usleep(100000);
- continue;
- } else {
- if (is_show)
- _showInformIndex >= 1 ? _showInformIndex = 0 : _showInformIndex++;
- is_show = false;
- }
- */
- /*
- pSysInfo->PageIndex = DemoPage[ShmDcCommonData->DemoCount];
- GetCurrentPage();
- ChangeToOtherPage(DemoPage[ShmDcCommonData->DemoCount]);
- GetCurrentPage();
- DemoFunction();
- ShmDcCommonData->DemoCount >= 1 ? ShmDcCommonData->DemoCount = 0 : ShmDcCommonData->DemoCount++;
- //*/
- usleep(100000);
- }
- } //while
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
- log_info("Close LCM Uart Port");
- CloseCommunicationLcmPort();
- return FAIL;
- }
|