1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096 |
- #include "Module_LcmControl_Wistron.h"
- #include "define.h"
- struct SysConfigAndInfo *ShmSysConfigAndInfo;
- struct StatusCodeData *ShmStatusCodeData;
- struct OCPP16Data *ShmOCPP16Data;
- struct OCPP20Data *ShmOCPP20Data;
- ParsingRatedCur modelnameInfo = {0};
- uint8_t gunType[4] = {0};
- struct timespec timer[TMR_IDX_CNT];
- int StoreLogMsg(const char *fmt, ...)
- {
- char Buf[4096+256];
- char buffer[4096];
- time_t CurrentTime;
- struct tm *tm;
- struct timeval tv;
- va_list args;
- va_start(args, fmt);
- int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
- va_end(args);
- memset(Buf,0,sizeof(Buf));
- CurrentTime = time(NULL);
- tm=localtime(&CurrentTime);
- gettimeofday(&tv, NULL);
- sprintf(Buf,"echo -n \'[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s\' >> /Storage/SystemLog/[%04d.%02d]Module_LcmControl_Wistron_Log",
- tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,(tv.tv_usec/1000),
- buffer,
- tm->tm_year+1900,tm->tm_mon+1);
- #ifdef SystemLogMessage
- system((const char*)Buf);
- #endif
- #ifdef ConsloePrintLog
- printf("[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,(tv.tv_usec/1000), buffer);
- #endif
- return rc;
- }
- uint32_t crc32(uint8_t *data, uint32_t length)
- {
- uint32_t crc=0xFFFFFFFF;
- for(size_t i=0;i<length;i++)
- {
- char ch=data[i];
- for(size_t j=0;j<8;j++)
- {
- uint32_t b=(ch^crc)&1;
- crc>>=1;
- if(b) crc=crc^0xEDB88320;
- ch>>=1;
- }
- }
- return ~crc;
- }
- uint32_t getFileCrc32(char *filename)
- {
- uint32_t result = 0;
- int fd = open(filename, O_RDONLY);
- if(fd < 0)
- {
- DEBUG_ERROR("Can not open file %s\n", filename);
- }
- else
- {
- struct stat st;
- stat(filename, &st);
- uint8_t data[st.st_size];
- if(read(fd,data,st.st_size) == st.st_size)
- {
- result = crc32(data, st.st_size);
- }
- close(fd);
- }
- return result;
- }
- void refreshStartTimer(struct timespec *timer)
- {
- clock_gettime(CLOCK_MONOTONIC, timer);
- }
- int getDiffSecNow(struct timespec timer)
- {
- struct timespec timerNow;
- clock_gettime(CLOCK_MONOTONIC, &timerNow);
- return (int)((((unsigned long)(timerNow.tv_sec - timer.tv_sec) * 1000) + ((unsigned long)((timerNow.tv_nsec / 1000000) - (timer.tv_nsec / 1000000))))/1000);
- }
- int InitShareMemory()
- {
- int result = PASS;
- int MeterSMId;
-
- if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
- result = FAIL;
- }
- else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
- result = FAIL;
- }
- else
- {}
-
- if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
- result = FAIL;
- }
- else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
- result = FAIL;
- }
- else
- {}
-
- if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
- result = FAIL;
- }
- else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
- result = FAIL;
- }
- else
- {}
-
- if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
- result = FAIL;
- }
- else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
- result = FAIL;
- }
- else
- {}
-
- if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
- {
- DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
- if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
- ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
- (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
- (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
- )
- {
-
- for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
- {
- gunType[gun_index] = GUN_TYPE_DO;
- switch(modelnameInfo.ParsingInfo[gun_index].GunType)
- {
- case Gun_Type_Chademo:
- DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
- break;
- case Gun_Type_CCS_2:
- DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
- break;
- case Gun_Type_GB:
- DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
- break;
- case Gun_Type_AC:
- DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
- break;
- default:
- DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
- break;
- }
- }
- }
- else
- {
- for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
- {
- switch(modelnameInfo.ParsingInfo[gun_index].GunType)
- {
- case Gun_Type_Chademo:
- gunType[gun_index] = GUN_TYPE_CHAdeMO;
- DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
- break;
- case Gun_Type_CCS_2:
- gunType[gun_index] = GUN_TYPE_CCS;
- DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
- break;
- case Gun_Type_GB:
- gunType[gun_index] = GUN_TYPE_GBT;
- DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
- break;
- case Gun_Type_AC:
- gunType[gun_index] = GUN_TYPE_AC;
- DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
- break;
- default:
- DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
- break;
- }
- }
- }
- }
- else
- {
- DEBUG_ERROR("Model name parsing fail.\n");
- result = FAIL;
- }
-
- for(uint8_t idxTmr=0;idxTmr<TMR_IDX_CNT;idxTmr++)
- {
- refreshStartTimer(&timer[idxTmr]);
- }
- return result;
- }
- int on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *msg)
- {
- json_object *payload;
- payload = json_tokener_parse(msg->payload);
- if(!is_error(payload))
- {
-
- if(strstr(msg->topic, "client/connect"))
- {
- DEBUG_INFO("HW_version: %s\n", json_object_get_string(json_object_object_get(payload, "HW_version")));
- DEBUG_INFO("FW_version_OS: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_OS")));
- DEBUG_INFO("FW_version_APK: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_APK")));
- DEBUG_INFO("FW_version_UI: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_UI")));
- DEBUG_INFO("MAC_addr: %s\n", json_object_get_string(json_object_object_get(payload, "MAC_addr")));
- DEBUG_INFO("Orientation: %s\n", json_object_get_string(json_object_object_get(payload, "Orientation")));
- }
- else if(strstr(msg->topic, "client/touch"))
- {
- if(json_object_object_get(payload, "touchlist") != NULL)
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(payload, "touchlist"));idx++)
- {
- DEBUG_INFO("Touch point-%d(%s-%s)=> x: %s, y: %s\n", idx,
- json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "obj_type")),
- json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "obj_onClick")),
- json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "touch_point_x")),
- json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "touch_point_y")));
- }
- }
- }
- else if(strstr(msg->topic, "client/info"))
- {
- if(json_object_object_get(payload, "status") != NULL)
- {
- switch(atoi(json_object_get_string(json_object_object_get(payload, "status"))))
- {
- case 1:
- DEBUG_INFO("Status normal.\n");
- break;
- case 2:
- DEBUG_INFO("Status downloading.\n");
- break;
- case 3:
- DEBUG_INFO("Status uploading.\n");
- break;
- case 4:
- DEBUG_INFO("Status reboot.\n");
- break;
- case 5:
- DEBUG_INFO("Status reset.\n");
- break;
- default:
- DEBUG_INFO("Unknown status.\n");
- break;
- }
- }
- }
- else if(strstr(msg->topic, "client/profile") ||
- strstr(msg->topic, "client/command") ||
- strstr(msg->topic, "client/timesync") ||
- strstr(msg->topic, "client/layout/textview") ||
- strstr(msg->topic, "client/layout/imageview") ||
- strstr(msg->topic, "client/layout/videoview") ||
- strstr(msg->topic, "client/layout/remove"))
- {
-
- }
- else
- {
- DEBUG_INFO("Unknown topic: %s\n", msg->topic);
- DEBUG_INFO("Unknown payload: %s\n", msg->payload);
- }
- }
- else
- {
- DEBUG_WARN("Payload is not JSON format.\n");
- }
- json_object_put(payload);
- return 0;
- }
- void on_connect(struct mosquitto *mosq, void *obj, int reason_code)
- {
- DEBUG_INFO("on_connect: %s\n", mosquitto_connack_string(reason_code));
- if(reason_code != 0)mosquitto_disconnect(mosq);
- }
- void on_disconnect(struct mosquitto *mosq, void *obj, int reason_code)
- {
- DEBUG_INFO("on_disconnect: %s\n", mosquitto_connack_string(reason_code));
- if(reason_code != 0)mosquitto_disconnect(mosq);
- }
- void on_publish(struct mosquitto *mosq, void *obj, int mid)
- {}
- void page_Booting(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Idle(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Authorizing(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Preparing(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Charging(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Terminating(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Complete(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Reservation(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Maintain(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Update(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_AlarmFault(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- void page_Unknown(struct ChargingInfoData *targetChargingInfoData)
- {
-
- }
- int publish_profile_sample(struct mosquitto *mosq)
- {
- return publish_profile(mosq, PROFILE_CONNECT_TIMEOUT, "10000");
- }
- int publish_upgrade_sample(struct mosquitto *mosq)
- {
- char url[128];
- char chkCrc32[16];
- sprintf(url, "ftp://ftpuser:ftppasswd@%s/mnt/dummy_Image.zip", BROKER_ADDRESS);
- sprintf(chkCrc32, "0x%08X", getFileCrc32("/root/main"));
- return publish_upgrade(mosq, OTA_TYPE_UI, url, chkCrc32, "V0.01");
- }
- int publish_restart_sample(struct mosquitto *mosq)
- {
- return publish_restart(mosq, TRUE);
- }
- int publish_power_saving_sample(struct mosquitto *mosq)
- {
- return publish_power_saving(mosq, TRUE);
- }
- int publish_back_dimming_sample(struct mosquitto *mosq)
- {
- return publish_back_dimming(mosq, BRIGHTNESS_LEVEL_AUTO);
- }
- int publish_timesync_sample(struct mosquitto *mosq)
- {
- return publish_timesync(mosq);
- }
- int publish_textview_add_sample(struct mosquitto *mosq)
- {
- Text_List textList[2] = {0};
- for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
- {
- textList[idx].textviewIndex = idx;
- sprintf(textList[idx].textString, "%08d", (rand()%99999999+10000000));
- sprintf(textList[idx].textFont, FONT_ARIAL);
- sprintf(textList[idx].textStyle, FONT_STYLE_NORMAL);
- textList[idx].textSize = FONT_SIZE_20PX;
- textList[idx].layout_x = (rand()%800+100);
- textList[idx].layout_y = (rand()%800+100);
- }
- return publish_textview_add(mosq, textList, ARRAY_SIZE(textList));
- }
- int publish_imageview_add_sample(struct mosquitto *mosq)
- {
- Image_List imageList[2] = {0};
- for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
- {
- imageList[idx].imageviewIndex = idx;
- imageList[idx].imgsrc_addr = (rand()%10+0);
- imageList[idx].layout_x = (rand()%800+100);
- imageList[idx].layout_y = (rand()%800+100);
- imageList[idx].width = (rand()%800+100);
- imageList[idx].height = (rand()%800+100);
- }
- return publish_imageview_add(mosq, imageList, ARRAY_SIZE(imageList));
- }
- int publish_videoview_add_sample(struct mosquitto *mosq)
- {
- Video_List videoList[2] = {0};
- for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
- {
- videoList[idx].videoviewIndex = idx;
- videoList[idx].videosrc_addr = (rand()%10+0);
- videoList[idx].layout_x = (rand()%800+100);
- videoList[idx].layout_y = (rand()%800+100);
- videoList[idx].width = (rand()%800+100);
- videoList[idx].height = (rand()%800+100);
- }
- return publish_videoview_add(mosq, videoList, ARRAY_SIZE(videoList));
- }
- int publish_view_remove_sample(struct mosquitto *mosq)
- {
- Text_List textList[2] = {0};
- Image_List imageList[2] = {0};
- Video_List videoList[2] = {0};
-
- for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
- {
- textList[idx].textviewIndex = idx;
- }
-
- for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
- {
- imageList[idx].imageviewIndex = idx;
- }
-
- for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
- {
- videoList[idx].videoviewIndex = idx;
- }
- return publish_view_remove(mosq, textList, ARRAY_SIZE(textList), imageList, ARRAY_SIZE(imageList), videoList, ARRAY_SIZE(videoList));
- }
- int publish_clear_screen_sample(struct mosquitto *mosq)
- {
- return publish_clear_screen(mosq);
- }
- int publish_audio_volume_sample(struct mosquitto *mosq)
- {
- return publish_audio_volume(mosq, 50);
- }
- int publish_trigger_report_status_sample(struct mosquitto *mosq)
- {
- return publish_trigger_report_status(mosq);
- }
- int main(void)
- {
- struct mosquitto *mosq;
- int result;
-
-
-
- if(InitShareMemory() == FAIL)
- {
- DEBUG_ERROR("InitShareMemory NG\n");
- sleep(5);
- return FAIL;
- }
- else
- {
- DEBUG_INFO("Share memory initial OK.\n");
- }
-
-
-
- system("killall mosquitto");
- sleep(1);
- system("/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d");
- DEBUG_INFO("Broker target: %s:%d\n", BROKER_ADDRESS, BROKER_PORT);
-
-
-
- mosquitto_lib_init();
-
-
-
- if(fork())
- {
- DEBUG_INFO("Initialize subscribe callback function.\n");
- result = mosquitto_subscribe_callback(on_message,
- NULL,
- "client/#",
- QOS_ENSURE_BROKER,
- BROKER_ADDRESS,
- BROKER_PORT,
- NULL,
- TIMEOUT_KEEPALIVE,
- true,
- LOGIN_USER,
- LOGIN_PASSWD,
- NULL,
- NULL);
- if(result)DEBUG_ERROR("Subscribe initialization error: %s\n", mosquitto_strerror(result));
- return -1;
- }
-
-
-
- DEBUG_INFO("Initialize publisher from host side.\n");
- mosq = mosquitto_new(NULL, true, NULL);
- if(mosq == NULL)
- {
- DEBUG_ERROR("Publisher initialization error: Out of memory.\n");
- return -1;
- }
- mosquitto_connect_callback_set(mosq, on_connect);
- mosquitto_disconnect_callback_set(mosq, on_disconnect);
- mosquitto_publish_callback_set(mosq, on_publish);
-
-
-
- DEBUG_INFO("Publisher connect to broker.\n");
- result = mosquitto_connect(mosq, BROKER_ADDRESS, BROKER_PORT, TIMEOUT_KEEPALIVE);
- if(result != MOSQ_ERR_SUCCESS)
- {
- mosquitto_destroy(mosq);
- DEBUG_ERROR("Connect broker error: %s\n", mosquitto_strerror(result));
- return -1;
- }
-
-
-
- DEBUG_INFO("Publisher loop start.\n");
- result = mosquitto_loop_start(mosq);
- if(result != MOSQ_ERR_SUCCESS)
- {
- mosquitto_destroy(mosq);
- DEBUG_ERROR("MQTT loop start initialization error: %s\n", mosquitto_strerror(result));
- return -1;
- }
- DEBUG_INFO("Module_LcmControl_Wistron initialized.\n");
-
-
-
- for(;;)
- {
- #ifndef TEST_MODE
- struct ChargingInfoData *targetChargingInfoData;
- uint8_t tempIndex;
- static struct PREVIOUS_DATA
- {
- uint8_t gun_selected;
- uint8_t SystemStatus;
- }previousData;
-
- switch(gunType[ShmSysConfigAndInfo->SysInfo.CurGunSelected])
- {
- case GUN_TYPE_CHAdeMO:
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
- }
- else
- {
- tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
- }
- }
- break;
- case GUN_TYPE_CCS:
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
- }
- else
- {
- tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
- }
- }
- break;
- case GUN_TYPE_GBT:
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
- }
- else
- {
- tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
- }
- }
- break;
- case GUN_TYPE_DO:
- tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData;
- }
- }
- break;
- case GUN_TYPE_AC:
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.AcChargingData[index];
- }
- }
- break;
- case GUN_TYPE_UNKNOWN:
- default:
- break;
- }
-
- if((previousData.gun_selected != ShmSysConfigAndInfo->SysInfo.CurGunSelected) ||
- (previousData.SystemStatus != targetChargingInfoData->SystemStatus))
- {
- publish_clear_screen(mosq);
- previousData.gun_selected = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
- previousData.SystemStatus = targetChargingInfoData->SystemStatus;
- }
-
- switch(targetChargingInfoData->SystemStatus)
- {
- case SYS_MODE_BOOTING:
- page_Booting(targetChargingInfoData);
- break;
- case SYS_MODE_IDLE:
- page_Idle(targetChargingInfoData);
- break;
- case SYS_MODE_AUTHORIZING:
- page_Authorizing(targetChargingInfoData);
- break;
- case SYS_MODE_PREPARING:
- page_Preparing(targetChargingInfoData);
- break;
- case SYS_MODE_CHARGING:
- page_Charging(targetChargingInfoData);
- break;
- case SYS_MODE_TERMINATING:
- page_Terminating(targetChargingInfoData);
- break;
- case SYS_MODE_COMPLETE:
- page_Complete(targetChargingInfoData);
- break;
- case SYS_MODE_RESERVATION:
- page_Reservation(targetChargingInfoData);
- break;
- case SYS_MODE_MAINTAIN:
- page_Maintain(targetChargingInfoData);
- break;
- case SYS_MODE_UPDATE:
- page_Update(targetChargingInfoData);
- break;
- case SYS_MODE_ALARM:
- case SYS_MODE_FAULT:
- page_AlarmFault(targetChargingInfoData);
- break;
- default:
- page_Unknown(targetChargingInfoData);
- break;
- }
- #else
-
- char cmd[128];
- system("clear");
- memset(cmd, 0x00, ARRAY_SIZE(cmd));
- printf("\n ===== main menu ==================================");
- printf("\n 1: publish_profile_sample.");
- printf("\n 2: publish_upgrade_sample.");
- printf("\n 3: publish_restart_sample.");
- printf("\n 4: publish_power_saving_sample.");
- printf("\n 5: publish_back_dimming_sample.");
- printf("\n 6: publish_timesync.");
- printf("\n 7: publish_textview_add_sample.");
- printf("\n 8: publish_imageview_add_sample.");
- printf("\n 9: publish_videoview_add_sample.");
- printf("\n 10: publish_view_remove_sample.");
- printf("\n 11: publish_clear_screen.");
- printf("\n 12: publish_audio_volume.");
- printf("\n 13: publish_trigger_report_status.");
- printf("\n ==================================================");
- printf("\n Please input item to test: ");
- scanf("%s", &cmd[0]);
- switch(atoi(cmd))
- {
- case 1:
- publish_profile_sample(mosq);
- break;
- case 2:
- publish_upgrade_sample(mosq);
- break;
- case 3:
- publish_restart_sample(mosq);
- break;
- case 4:
- publish_power_saving_sample(mosq);
- break;
- case 5:
- publish_back_dimming_sample(mosq);
- break;
- case 6:
- publish_timesync_sample(mosq);
- break;
- case 7:
- publish_textview_add_sample(mosq);
- break;
- case 8:
- publish_imageview_add_sample(mosq);
- break;
- case 9:
- publish_videoview_add_sample(mosq);
- break;
- case 10:
- publish_view_remove_sample(mosq);
- break;
- case 11:
- publish_clear_screen_sample(mosq);
- break;
- case 12:
- publish_audio_volume_sample(mosq);
- break;
- case 13:
- publish_trigger_report_status_sample(mosq);
- break;
- }
- #endif
- usleep(500000);
- }
- mosquitto_lib_cleanup();
- return -1;
- }
|