#include /*標準輸入輸出定義*/ #include /*標準函數庫定義*/ #include #include #include #include #include #include #include #include #include "Module_LcmControl.h" #include "../Log/log.h" #include "../ShareMemory/shmMem.h" #include "../Define/define.h" #include "../Config.h" #include "../SelectGun/SelectGun.h" #include "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; } 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) { // 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 ) { 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[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); 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_1->SystemStatus == S_CHARGING) { pSysInfo->PageIndex = __VIEW_L_FAIL_R_CHARGE; } else if (pDcChargingInfo_0->SystemStatus == S_CHARGING && pDcChargingInfo_1->SystemStatus == S_ALARM) { pSysInfo->PageIndex = __VIEW_L_CHARGE_R_FAIL; } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && pDcChargingInfo_1->SystemStatus == S_IDLE) { pSysInfo->PageIndex = __VIEW_L_FAIL_R_IDLE; } else if (pDcChargingInfo_0->SystemStatus == S_IDLE && pDcChargingInfo_1->SystemStatus == S_ALARM) { pSysInfo->PageIndex = __VIEW_L_IDLE_R_FAIL; } else if (pDcChargingInfo_0->SystemStatus == S_ALARM && pDcChargingInfo_1->SystemStatus == S_ALARM) { pSysInfo->PageIndex = __VIEW_ALL_FAIL; } 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: pSysInfo->PageIndex = __COMMUNICATION_PROCESS; break; case _LCM_CHARGING_DETECT: pSysInfo->PageIndex = __GFD_PROCESS; break; case _LCM_PREPARECHARE: pSysInfo->PageIndex = __PRECHARGE_PROCESS; break; } if (_currentPage != pSysInfo->PageIndex) { //_currentPage = pSysInfo->PageIndex; log_info("Change Page :%d", 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); ChangeDisplay2Value(_LeftGun_Soc_Tens,(short)_ICON_Red_Num_0+tens); if (hundreds == 0 ) { ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Empty); if (tens == 0 ) ChangeDisplay2Value(_LeftGun_Soc_Tens,(short)_ICON_Empty); } else ChangeDisplay2Value(_LeftGun_Soc_Hundreds,(short)_ICON_Red_Num_1); } else { //log_info("%d %d %d",hundreds,tens,digits); ChangeDisplay2Value(_RightGun_Soc_Digits,(short)_ICON_Red_Num_0+digits); ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Red_Num_0+tens); if (hundreds == 0 ) { ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Empty); if (tens == 0) ChangeDisplay2Value(_RightGun_Soc_Tens,(short)_ICON_Empty); } else ChangeDisplay2Value(_RightGun_Soc_Hundreds,(short)_ICON_Red_Num_1); } } 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) { uint8_t value[10] = { 0 }; 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() { char value[5]; 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); ShowViewChargingTime(LEFT_GUN_NUM,pDcChargingInfo->PresentChargedDuration); 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); ShowViewChargingTime(RIGHT_GUN_NUM,pDcChargingInfo->PresentChargedDuration); 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 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 ShowGunCountDownTimer() { int min,sec; uint8_t value[10] = {0}; pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); int tm = 30 - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / 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, 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", pSysConfig->SystemId, 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 ShowSummaryPage() { float data; uint8_t value[10] = {0}; char start_hr[3],start_min[3],end_hr[3],end_min[3]; int t_hr; long eng = 0; pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); // Show Money data = pDcChargingInfo->ChargingFee; sprintf((char *)value,"%.1f",data); int discount,settlement = 0; discount = ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Discount; ChangeDisplay2Value(_Summary_cal_discount, discount*(-1)); settlement = (int)pDcChargingInfo->ChargingFee - discount; ChangeDisplay2Value(_Summary_total_money, (int)pDcChargingInfo->ChargingFee); ChangeDisplay2Value(_Summary_cal_Total_money, (int)pDcChargingInfo->ChargingFee); /* log_info("start time:%s",pDcChargingInfo->StartDateTime); log_info("stop time:%s",pDcChargingInfo->StopDateTime);*/ GetHrFormTimeString(pDcChargingInfo->StartDateTime,start_hr); GetMinFormTimeString(pDcChargingInfo->StartDateTime,start_min); GetHrFormTimeString(pDcChargingInfo->StopDateTime,end_hr); GetMinFormTimeString(pDcChargingInfo->StopDateTime,end_min); t_hr = atoi(start_hr) + (ShmDcCommonData->TZOffset / 60); if (t_hr >= 24) t_hr -= 24; if (!ShmDcCommonData->isIntoCharge[pSysInfo->CurGunSelected]) { t_hr = 0; strcpy(start_min,"0"); } ChangeDisplay2Value(_Summary_Start_time_hr, t_hr); ChangeDisplay2Value(_Summary_Start_time_min, atoi(start_min)); t_hr = atoi(end_hr) + (ShmDcCommonData->TZOffset / 60); if (t_hr >= 24) t_hr -= 24; if (!ShmDcCommonData->isIntoCharge[pSysInfo->CurGunSelected]) { t_hr = 0; strcpy(end_min, "0"); } ChangeDisplay2Value(_Summary_end_time_hr, t_hr); ChangeDisplay2Value(_Summary_end_time_min, atoi(end_min)); /* 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)); */ 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)_min); ChangeDisplay2Value(_Summary_duration_sec, (int)_sec); 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() { if (pSysWarning->Level == WARN_LV_ER) { pSysInfo->SystemPage = _LCM_MAINTAIN; if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton) pSysInfo->SystemPage = _LCM_EMERGENCY; return;; } switch (pSysInfo->SystemPage) { case _LCM_VIEW: // Confirm Charging Gun Number. SetViewPage(); break; case _LCM_START_SCAN: ChangeQrCode(); ShowSelectGunIcon(); ShowCountDownTimer(); 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; 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 <= 100; i++) { ChangeDisplay2Value(_Summary_total_money, 888); ChangeDisplay2Value(_Summary_cal_Total_money, 888); ChangeDisplay2Value(_Summary_Start_time_hr, 6); ChangeDisplay2Value(_Summary_Start_time_min, 6); ChangeDisplay2Value(_Summary_end_time_hr, 8); ChangeDisplay2Value(_Summary_end_time_min, 8); ChangeDisplay2Value(_Summary_duration_min, 88); ChangeDisplay2Value(_Summary_duration_sec, 88); ChangeDisplay2LongValue(_Summary_cap, 88888); ChangeDisplay2Value(_Summary_cal_discount,88); ChangeDisplay2Value(_Summary_cal_Settlement,888); ChangeDisplay2Value(_Summary_max_power, 888); ChangeDisplay2Value(_Summary_average_power, 888); sleep(5); //} } 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 21: ShowCabientVersion(); break; case 22: ShowDispenserVersion(); 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); } } 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(); 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; while (_port != -1) { if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) { GetCurrentPage(); sleep(1); ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true; } 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 >= 21 ? ShmDcCommonData->DemoCount = 0 : ShmDcCommonData->DemoCount++; //*/ usleep(100000); } } //while ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true; log_info("Close LCM Uart Port"); CloseCommunicationLcmPort(); return FAIL; }