diff --git a/ui/hand_acid_mainboard_ui.HMI b/ui/hand_acid_mainboard_ui.HMI index 27c8048..e94e697 100644 Binary files a/ui/hand_acid_mainboard_ui.HMI and b/ui/hand_acid_mainboard_ui.HMI differ diff --git a/ui/ui.h b/ui/ui.h index 786e712..f861826 100644 --- a/ui/ui.h +++ b/ui/ui.h @@ -20,6 +20,7 @@ #define pg_keybdAP 18 #define pg_keyPasswd 19 #define pg_keybMutiSel 20 +#define pg_loading 21 //gvar.objs #define ob_gvar_gvar 0 #define ob_gvar_edit 1 @@ -412,12 +413,14 @@ //popwin.objs #define ob_popwin_popwin 0 #define ob_popwin_p0 1 -#define ob_popwin_t0 2 +#define ob_popwin_popWin 2 #define ob_popwin_canclekey 3 #define ob_popwin_info 4 #define ob_popwin_confirmkey 5 #define ob_popwin_frompage 6 -#define ob_popwin_t1 7 +#define ob_popwin_popTil 7 +#define ob_popwin_loadingWin 8 +#define ob_popwin_loadingText 9 //keybAcidCh.objs #define ob_keybAcidCh_keybAcidCh 0 #define ob_keybAcidCh_bak 1 @@ -596,3 +599,7 @@ #define ob_keybMutiSel_frompage 8 #define ob_keybMutiSel_title 9 #define ob_keybMutiSel_ctent 10 +//loading.objs +#define ob_loading_loading 0 +#define ob_loading_p0 1 +#define ob_loading_frompage 2 diff --git a/usrc/uicontroler/base/page_processer.cpp b/usrc/uicontroler/base/page_processer.cpp index 8e792bd..8156992 100644 --- a/usrc/uicontroler/base/page_processer.cpp +++ b/usrc/uicontroler/base/page_processer.cpp @@ -13,20 +13,20 @@ static void regPage(IPageProcesser* page) { m_pages[m_pageNum++] = page; } -IPageProcesser::IPageProcesser(const char* name, uint32_t pageId) { +IPageProcesser::IPageProcesser(const char* name, uint32_t thisPage) { regPage(this); - this->pageId = pageId; + this->thisPage = thisPage; this->pageName = name; } void IPageProcesser::initialize() { - ZLOGI(TAG, "initialize page %s %d", pageName, pageId); + ZLOGI(TAG, "initialize page %s %d", pageName, thisPage); AppEventBus::ins()->regOnEvent([this](AppEvent_t* event) { // ZLOGI(TAG, "event type %s %d", pageName, event->type); if (event->type == KAE_UIEvent) { - if (pageId != event->d.uiEvent.pid) { + if (thisPage != event->d.uiEvent.pid) { return; } // uint8_t bid = event->d.uiEvent.bid; @@ -34,22 +34,22 @@ void IPageProcesser::initialize() { if (uiEvent->eventId == kpt_sys_event_page_id) { OnPageLoadContext cxt = {0}; - ZLOGI(TAG, "page %s(%d)-%d load", pageName, pageId, uiEvent->bid); + ZLOGI(TAG, "page %s(%d)-%d load", pageName, thisPage, uiEvent->bid); onPageLoad(&cxt); } else if (uiEvent->eventId == kpt_button_event) { - ZLOGI(TAG, "page %s(%d)-%d onClickRelease,val %d text %s", pageName, pageId, uiEvent->bid, uiEvent->val, uiEvent->text); + ZLOGI(TAG, "page %s(%d)-%d onClickRelease,val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text); onClickRelease(uiEvent->bid, uiEvent->val, uiEvent->text); } else if (uiEvent->eventId == kpt_usr_def_clik_release_event) { - ZLOGI(TAG, "page %s(%d)-%d onClickRelease,val %d text %s", pageName, pageId, uiEvent->bid, uiEvent->val, uiEvent->text); + ZLOGI(TAG, "page %s(%d)-%d onClickRelease,val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text); onClickRelease(uiEvent->bid, uiEvent->val, uiEvent->text); } else if (uiEvent->eventId == kpt_page_back_event) { - ZLOGI(TAG, "page %s(%d)-%d onBackKey", pageName, pageId, uiEvent->bid); + ZLOGI(TAG, "page %s(%d)-%d onBackKey", pageName, thisPage, uiEvent->bid); onBackKey(); } else if (uiEvent->eventId == kpt_inputfield_content_selected_change_event) { - ZLOGI(TAG, "page %s(%d)-%d onInputFieldContentChange val %d text %s", pageName, pageId, uiEvent->bid, uiEvent->val, uiEvent->text); + ZLOGI(TAG, "page %s(%d)-%d onInputFieldContentChange val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text); onInputFieldContentChange(uiEvent->bid, uiEvent->val, uiEvent->text); } else if (uiEvent->eventId == kpt_inputfield_content_change_event) { - ZLOGI(TAG, "page %s(%d)-%d onInputFieldContentChange val %d text %s", pageName, pageId, uiEvent->bid, uiEvent->val, uiEvent->text); + ZLOGI(TAG, "page %s(%d)-%d onInputFieldContentChange val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text); onInputFieldContentChange(uiEvent->bid, uiEvent->val, uiEvent->text); } // @@ -71,7 +71,7 @@ void UIControlerHock_PageInit() { } for (size_t i = 0; i < m_pageNum; i++) { - // ZLOGI(TAG, "initialize page %s %d", m_pages[i]->pageName, m_pages[i]->pageId); + // ZLOGI(TAG, "initialize page %s %d", m_pages[i]->pageName, m_pages[i]->thisPage); if (hasOnlyInitThis) { if (m_pages[i]->onlyInitThis || m_pages[i]->forceInitThis) { m_pages[i]->initialize(); diff --git a/usrc/uicontroler/base/page_processer.hpp b/usrc/uicontroler/base/page_processer.hpp index c9ce0c7..0305452 100644 --- a/usrc/uicontroler/base/page_processer.hpp +++ b/usrc/uicontroler/base/page_processer.hpp @@ -22,13 +22,13 @@ class OnPageLoadContext { class IPageProcesser { public: - uint32_t pageId = 0; + uint32_t thisPage = 0; const char* pageName = "Not Set"; bool onlyInitThis = false; // for debug bool forceInitThis = false; public: - IPageProcesser(const char* name, uint32_t pageId); + IPageProcesser(const char* name, uint32_t thisPage); virtual void initialize(); private: @@ -43,42 +43,42 @@ class IPageProcesser { virtual void setText(uint8_t bid, const char* txt, ...) { va_list args; va_start(args, txt); - UIControler::ins()->setTxt(pageId, bid, txt, args); + UIControler::ins()->setTxt(thisPage, bid, txt, args); va_end(args); } - virtual void setVal(uint8_t bid, int32_t val) { UIControler::ins()->setVal(pageId, bid, val); } + virtual void setVal(uint8_t bid, int32_t val) { UIControler::ins()->setVal(thisPage, bid, val); } void setPicturePicNum(uint8_t bid, uint8_t fromBid) { // - UIControler::ins()->setPicturePicNum(pageId, bid, fromBid); + UIControler::ins()->setPicturePicNum(thisPage, bid, fromBid); } void setButtonPicNum(uint8_t bid, uint8_t fromBid) { // - UIControler::ins()->setButtonPicNum(pageId, bid, fromBid); + UIControler::ins()->setButtonPicNum(thisPage, bid, fromBid); } void setPicturePicNumFG(uint8_t bid, uint8_t fromBid) { // - UIControler::ins()->setPicturePicNumFromGlobal(pageId, bid, pg_gvar, fromBid); + UIControler::ins()->setPicturePicNumFromGlobal(thisPage, bid, pg_gvar, fromBid); } void setButtonPicNumFG(uint8_t bid, uint8_t fromBid) { // - UIControler::ins()->setButtonPicNumFromGlobal(pageId, bid, pg_gvar, fromBid); + UIControler::ins()->setButtonPicNumFromGlobal(thisPage, bid, pg_gvar, fromBid); } - void visBySetAph(uint8_t bid, bool val) { UIControler::ins()->setAph(pageId, bid, val ? 127 : 0); } - void visEx(uint8_t bid, bool val) { UIControler::ins()->visEx(pageId, bid, val); } + void visBySetAph(uint8_t bid, bool val) { UIControler::ins()->setAph(thisPage, bid, val ? 127 : 0); } + void visEx(uint8_t bid, bool val) { UIControler::ins()->visEx(thisPage, bid, val); } bool movePicToXY(uint8_t bid, int32_t x, int32_t y) { - UIControler::ins()->movePicToXY(pageId, bid, x, y); + UIControler::ins()->movePicToXY(thisPage, bid, x, y); return true; } bool movePicTo(uint8_t bid, uint8_t toBid) { - UIControler::ins()->movePicTo(pageId, bid, toBid); + UIControler::ins()->movePicTo(thisPage, bid, toBid); return true; } bool movePicOutOfScreen(uint8_t bid) { - UIControler::ins()->movePicOutOfScreen(pageId, bid); + UIControler::ins()->movePicOutOfScreen(thisPage, bid); return true; } - void popFullKeyBoard(uint8_t fromBid, int limitLength, const char* initval) { UIControler::ins()->popFullKeyBoard(pageId, fromBid, limitLength, initval); } - void popPasswdKeyBoard(uint8_t fromBid, int limitLength) { UIControler::ins()->popPasswdKeyBoard(pageId, fromBid, limitLength); } - void popNumKeyBoard(uint8_t fromBid, int limitLength, const char* initval) { UIControler::ins()->popNumKeyBoard(pageId, fromBid, limitLength, initval); } + void popFullKeyBoard(uint8_t fromBid, int limitLength, const char* initval) { UIControler::ins()->popFullKeyBoard(thisPage, fromBid, limitLength, initval); } + void popPasswdKeyBoard(uint8_t fromBid, int limitLength) { UIControler::ins()->popPasswdKeyBoard(thisPage, fromBid, limitLength); } + void popNumKeyBoard(uint8_t fromBid, int limitLength, const char* initval) { UIControler::ins()->popNumKeyBoard(thisPage, fromBid, limitLength, initval); } }; } // namespace iflytop diff --git a/usrc/uicontroler/base/ui_state.cpp b/usrc/uicontroler/base/ui_state.cpp index f723293..32319d8 100644 --- a/usrc/uicontroler/base/ui_state.cpp +++ b/usrc/uicontroler/base/ui_state.cpp @@ -3,6 +3,7 @@ using namespace iflytop; static QueueHandle_t xQueue; static int popInfoNum; +static bool loadingState; static zmutex lock = {"UIPublicState-Lock"}; #define TAG "UIPublicState" @@ -40,3 +41,6 @@ bool UIPublicState::popUIPopInfoBlock(UIPopInfo_t* info) { } int UIPublicState::getPopInfoNum() { return popInfoNum; } + +bool UIPublicState::setLoadingState(bool state) { loadingState = state; } +bool UIPublicState::getLoadingState() { return loadingState; } diff --git a/usrc/uicontroler/base/ui_state.hpp b/usrc/uicontroler/base/ui_state.hpp index 60077ef..c164efa 100644 --- a/usrc/uicontroler/base/ui_state.hpp +++ b/usrc/uicontroler/base/ui_state.hpp @@ -22,5 +22,8 @@ class UIPublicState { static void pushUIPopInfo(UIPopWinType_t type, const char* info, function onConfirm); static bool popUIPopInfoBlock(UIPopInfo_t* info); static int getPopInfoNum(); + + static bool setLoadingState(bool state); + static bool getLoadingState() ; }; } // namespace iflytop \ No newline at end of file diff --git a/usrc/uicontroler/page/home_page.cpp b/usrc/uicontroler/page/home_page.cpp index b3b318a..f3ec2d8 100644 --- a/usrc/uicontroler/page/home_page.cpp +++ b/usrc/uicontroler/page/home_page.cpp @@ -76,19 +76,19 @@ class HomePage : public IPageProcesser { virtual void onAppEvent(AppEvent_t* event) override { if (event->type == kAE_RemoterConnectedEvent) { syncBleState(); // 同步蓝牙状态 - UIS->setTxt(pageId, ob_home_sysInfo, "连接上手柄"); + UIS->setTxt(thisPage, ob_home_sysInfo, "连接上手柄"); } else if (event->type == kAE_RemoterDisConnectedEvent) { syncBleState(); // 同步蓝牙状态 - UIS->setTxt(pageId, ob_home_sysInfo, "断开手柄连接"); + UIS->setTxt(thisPage, ob_home_sysInfo, "断开手柄连接"); } else if (event->type == kAE_RunModeChangeEvent) { syncMode(); // 初始化设备模式 - UIS->setTxt(pageId, ob_home_sysInfo, "切换模式"); + UIS->setTxt(thisPage, ob_home_sysInfo, "切换模式"); } else if (event->type == kAE_AcidStatChangeEvent) { syncStat(); // 初始化统计数据 } else if (event->type == kAppEvent_StateDisplayInfo) { - UIS->setTxt(pageId, ob_home_sysInfo, event->d.stateDisplayInfo); + UIS->setTxt(thisPage, ob_home_sysInfo, event->d.stateDisplayInfo); } } @@ -113,66 +113,66 @@ class HomePage : public IPageProcesser { void setPumpSelectState(uint8_t chIndex, bool state) { GStateMgr::ins()->setPumpSelectState(chIndex, state); if (chIndex == 0) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH0S, state ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH0S, state ? ob_home_CHState1 : ob_home_CHState0); } else if (chIndex == 1) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH1S, state ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH1S, state ? ob_home_CHState1 : ob_home_CHState0); } else if (chIndex == 2) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH2S, state ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH2S, state ? ob_home_CHState1 : ob_home_CHState0); } else if (chIndex == 3) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH3S, state ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH3S, state ? ob_home_CHState1 : ob_home_CHState0); } } void syncPumpSelectState() { - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH0S, GStateMgr::ins()->getPumpSelectState(0) ? ob_home_CHState1 : ob_home_CHState0); - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH1S, GStateMgr::ins()->getPumpSelectState(1) ? ob_home_CHState1 : ob_home_CHState0); - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH2S, GStateMgr::ins()->getPumpSelectState(2) ? ob_home_CHState1 : ob_home_CHState0); - UIControler::ins()->setPicturePicNum(pageId, ob_home_AcidCH3S, GStateMgr::ins()->getPumpSelectState(3) ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH0S, GStateMgr::ins()->getPumpSelectState(0) ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH1S, GStateMgr::ins()->getPumpSelectState(1) ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH2S, GStateMgr::ins()->getPumpSelectState(2) ? ob_home_CHState1 : ob_home_CHState0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_AcidCH3S, GStateMgr::ins()->getPumpSelectState(3) ? ob_home_CHState1 : ob_home_CHState0); } void syncAcidName() { - UIControler::ins()->setTxt(pageId, ob_home_acidname0, AcidChCfgDao::getCfg(0)->acidChooseName); - UIControler::ins()->setTxt(pageId, ob_home_acidname1, AcidChCfgDao::getCfg(1)->acidChooseName); - UIControler::ins()->setTxt(pageId, ob_home_acidname2, AcidChCfgDao::getCfg(2)->acidChooseName); - UIControler::ins()->setTxt(pageId, ob_home_acidname3, AcidChCfgDao::getCfg(3)->acidChooseName); + UIControler::ins()->setTxt(thisPage, ob_home_acidname0, AcidChCfgDao::getCfg(0)->acidChooseName); + UIControler::ins()->setTxt(thisPage, ob_home_acidname1, AcidChCfgDao::getCfg(1)->acidChooseName); + UIControler::ins()->setTxt(thisPage, ob_home_acidname2, AcidChCfgDao::getCfg(2)->acidChooseName); + UIControler::ins()->setTxt(thisPage, ob_home_acidname3, AcidChCfgDao::getCfg(3)->acidChooseName); } void syncAcidEachDistriVal() { - UIControler::ins()->setTxt(pageId, ob_home_acideval0, "%.1f", AcidChCfgDao::getCfg(0)->acidEachDistriVal); - UIControler::ins()->setTxt(pageId, ob_home_acideval1, "%.1f", AcidChCfgDao::getCfg(1)->acidEachDistriVal); - UIControler::ins()->setTxt(pageId, ob_home_acideval2, "%.1f", AcidChCfgDao::getCfg(2)->acidEachDistriVal); - UIControler::ins()->setTxt(pageId, ob_home_acideval3, "%.1f", AcidChCfgDao::getCfg(3)->acidEachDistriVal); + UIControler::ins()->setTxt(thisPage, ob_home_acideval0, "%.1f", AcidChCfgDao::getCfg(0)->acidEachDistriVal); + UIControler::ins()->setTxt(thisPage, ob_home_acideval1, "%.1f", AcidChCfgDao::getCfg(1)->acidEachDistriVal); + UIControler::ins()->setTxt(thisPage, ob_home_acideval2, "%.1f", AcidChCfgDao::getCfg(2)->acidEachDistriVal); + UIControler::ins()->setTxt(thisPage, ob_home_acideval3, "%.1f", AcidChCfgDao::getCfg(3)->acidEachDistriVal); } void syncStat() { // StatUsedC - UIControler::ins()->setTxt(pageId, ob_home_StatRmidCH0, "%.1f", GStateMgr::ins()->getAcidRemain(0)); - UIControler::ins()->setTxt(pageId, ob_home_StatRmidCH1, "%.1f", GStateMgr::ins()->getAcidRemain(1)); - UIControler::ins()->setTxt(pageId, ob_home_StatRmidCH2, "%.1f", GStateMgr::ins()->getAcidRemain(2)); - UIControler::ins()->setTxt(pageId, ob_home_StatRmidCH3, "%.1f", GStateMgr::ins()->getAcidRemain(3)); - UIControler::ins()->setTxt(pageId, ob_home_StatUsedCH0, "%.1f", GStateMgr::ins()->getAcidUsed(0)); - UIControler::ins()->setTxt(pageId, ob_home_StatUsedCH1, "%.1f", GStateMgr::ins()->getAcidUsed(1)); - UIControler::ins()->setTxt(pageId, ob_home_StatUsedCH2, "%.1f", GStateMgr::ins()->getAcidUsed(2)); - UIControler::ins()->setTxt(pageId, ob_home_StatUsedCH3, "%.1f", GStateMgr::ins()->getAcidUsed(3)); + UIControler::ins()->setTxt(thisPage, ob_home_StatRmidCH0, "%.1f", GStateMgr::ins()->getAcidRemain(0)); + UIControler::ins()->setTxt(thisPage, ob_home_StatRmidCH1, "%.1f", GStateMgr::ins()->getAcidRemain(1)); + UIControler::ins()->setTxt(thisPage, ob_home_StatRmidCH2, "%.1f", GStateMgr::ins()->getAcidRemain(2)); + UIControler::ins()->setTxt(thisPage, ob_home_StatRmidCH3, "%.1f", GStateMgr::ins()->getAcidRemain(3)); + UIControler::ins()->setTxt(thisPage, ob_home_StatUsedCH0, "%.1f", GStateMgr::ins()->getAcidUsed(0)); + UIControler::ins()->setTxt(thisPage, ob_home_StatUsedCH1, "%.1f", GStateMgr::ins()->getAcidUsed(1)); + UIControler::ins()->setTxt(thisPage, ob_home_StatUsedCH2, "%.1f", GStateMgr::ins()->getAcidUsed(2)); + UIControler::ins()->setTxt(thisPage, ob_home_StatUsedCH3, "%.1f", GStateMgr::ins()->getAcidUsed(3)); } void syncMode() { auto nowMode = GStateMgr::ins()->getRunMode(); if (nowMode == khand_acid_m_jog_mode) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_RunMode, ob_home_RunMode1); - UIControler::ins()->setTxt(pageId, ob_home_RunModeVal, "", DeviceSettingDao::get()->distrIntervalS); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_RunMode, ob_home_RunMode1); + UIControler::ins()->setTxt(thisPage, ob_home_RunModeVal, "", DeviceSettingDao::get()->distrIntervalS); } else if (nowMode == khand_acid_m_continuous_mode) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_RunMode, ob_home_RunMode0); - UIControler::ins()->setTxt(pageId, ob_home_RunModeVal, "%.1f", DeviceSettingDao::get()->distrIntervalS); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_RunMode, ob_home_RunMode0); + UIControler::ins()->setTxt(thisPage, ob_home_RunModeVal, "%.1f", DeviceSettingDao::get()->distrIntervalS); } } void syncBleState() { bool bleIsConnected = GStateMgr::ins()->getRemoterS(); if (bleIsConnected) { - UIControler::ins()->setPicturePicNum(pageId, ob_home_RemoterS, ob_home_RemoterS1); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_RemoterS, ob_home_RemoterS1); } else { - UIControler::ins()->setPicturePicNum(pageId, ob_home_RemoterS, ob_home_RemoterS0); + UIControler::ins()->setPicturePicNum(thisPage, ob_home_RemoterS, ob_home_RemoterS0); } } }; diff --git a/usrc/uicontroler/page/login_page.cpp b/usrc/uicontroler/page/login_page.cpp index 4a43557..11e0570 100644 --- a/usrc/uicontroler/page/login_page.cpp +++ b/usrc/uicontroler/page/login_page.cpp @@ -24,27 +24,27 @@ class LoginPage : public IPageProcesser { virtual void onBackKey() override {} virtual void onInputFieldContentChange(uint8_t bid, uint8_t slecId, const char* text) override { if (bid == ob_login_uName) { - UIS->setTxt(pageId, ob_login_uName, text); // + UIS->setTxt(thisPage, ob_login_uName, text); // strcpy(userName, text); // - UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // - UIS->setTxt(pageId, ob_login_uNameEMsg, ""); // + UIS->setTxt(thisPage, ob_login_pwdEMsg, ""); // + UIS->setTxt(thisPage, ob_login_uNameEMsg, ""); // } else if (bid == ob_login_pwd) { - UIS->setTxt(pageId, ob_login_pwd, text); // + UIS->setTxt(thisPage, ob_login_pwd, text); // strcpy(passwd, text); // - UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // - UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // + UIS->setTxt(thisPage, ob_login_pwdEMsg, ""); // + UIS->setTxt(thisPage, ob_login_pwdEMsg, ""); // } } virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override { if (bid == ob_login_blogin) { user_t* user = UserDao::getUserByName(userName); if (user == nullptr) { - UIS->setTxt(pageId, ob_login_uNameEMsg, "用户名不存在"); + UIS->setTxt(thisPage, ob_login_uNameEMsg, "用户名不存在"); return; } if (strcmp(user->passwd, passwd) != 0) { - UIS->setTxt(pageId, ob_login_pwdEMsg, "密码错误"); + UIS->setTxt(thisPage, ob_login_pwdEMsg, "密码错误"); return; } @@ -59,10 +59,10 @@ class LoginPage : public IPageProcesser { private: void resetPage() { - UIS->setTxt(pageId, ob_login_uName, ""); // 用户名 - UIS->setTxt(pageId, ob_login_uNameEMsg, ""); // 用户名错误信息 - UIS->setTxt(pageId, ob_login_pwd, ""); // 密码 - UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // 密码错误信息 + UIS->setTxt(thisPage, ob_login_uName, ""); // 用户名 + UIS->setTxt(thisPage, ob_login_uNameEMsg, ""); // 用户名错误信息 + UIS->setTxt(thisPage, ob_login_pwd, ""); // 密码 + UIS->setTxt(thisPage, ob_login_pwdEMsg, ""); // 密码错误信息 } }; diff --git a/usrc/uicontroler/page/mupage/muInterval_page.cpp b/usrc/uicontroler/page/mupage/muInterval_page.cpp index 1f9d9ac..f881199 100644 --- a/usrc/uicontroler/page/mupage/muInterval_page.cpp +++ b/usrc/uicontroler/page/mupage/muInterval_page.cpp @@ -38,22 +38,22 @@ class MuIntervalPage : public IPageProcesser { float distrIntervalSSecond = atof(text); if (distrIntervalSSecond <= 0) { UIS->popWarningWin("酸液间隔时间不能小于0"); - UIS->setTxt(pageId, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); + UIS->setTxt(thisPage, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); return; } if (distrIntervalSSecond > 30) { UIS->popWarningWin("酸液间隔时间不能大于30"); - UIS->setTxt(pageId, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); + UIS->setTxt(thisPage, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); return; } DeviceSettingDao::updatedistrIntervalS(distrIntervalSSecond); - UIS->setTxt(pageId, bid, "%.1f", distrIntervalSSecond); + UIS->setTxt(thisPage, bid, "%.1f", distrIntervalSSecond); } }; virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override {} - void syncState() { UIS->setTxt(pageId, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); } + void syncState() { UIS->setTxt(thisPage, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); } }; // 实例化Page, 使其自动注册 diff --git a/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp b/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp index 61184ab..514eb60 100644 --- a/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp +++ b/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp @@ -190,14 +190,22 @@ class MuUsrMgr : public IPageProcesser { UIControler::ins()->popWarningWin("用户数量已达上限"); return; } - UserDao::addUser(); - fillUsrStateUICache(); - syncUIUsrTableState(); - UIControler::ins()->popInfoWin("添加成功"); + + { + UILoadingCxt cxt; // 进入加载状态 + UserDao::addUser(); + UIControler::ins()->popInfoWin("添加成功"); + fillUsrStateUICache(); + syncUIUsrTableState(); + fillEditContext(UserDao::getUsersTableNum() - 1); + syncEditContext(); + } } void delUsr() { ZLOGI(TAG, "delUsr"); + UILoadingCxt cxt; // 进入加载状态 + // 删除用户 do { user_t* user = UserDao::getUserById(m_editContext.usrId); @@ -215,18 +223,21 @@ class MuUsrMgr : public IPageProcesser { UserDao::delUser(user->id); } while (false); + UIControler::ins()->popInfoWin("删除成功"); + fillUsrStateUICache(); syncUIUsrTableState(); fillEditContext(-1); syncEditContext(); - UIControler::ins()->popInfoWin("删除成功"); } void saveUsr() { ZLOGI(TAG, "saveUsr"); // 保存 if (m_editContext.editDirty) { + UILoadingCxt cxt; // 进入加载状态 + user_t* user = UserDao::getUserById(m_editContext.usrId); if (user == nullptr) { ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId); @@ -254,9 +265,10 @@ class MuUsrMgr : public IPageProcesser { fillUsrStateUICache(); syncUIUsrTableState(); syncEditContext(); + UIControler::ins()->popInfoWin("保存成功"); + } else { + UIControler::ins()->popInfoWin("用户无修改"); } - - UIControler::ins()->popInfoWin("保存成功"); } /*********************************************************************************************************************** @@ -322,6 +334,12 @@ class MuUsrMgr : public IPageProcesser { return; } + if (GStateMgr::ins()->isLogin() && strcmp(GStateMgr::ins()->getLoginUsr(), m_uiUsrTable[useroff].userName) == 0) { + m_editContext.enable = false; + return; + } + + m_editContext.usrId = m_uiUsrTable[useroff].usrId; strcpy(m_editContext.name, m_uiUsrTable[useroff].userName); m_editContext.role = m_uiUsrTable[useroff].role; diff --git a/usrc/uicontroler/page/popwin_page.cpp b/usrc/uicontroler/page/popwin_page.cpp index d2901e2..b68e2dd 100644 --- a/usrc/uicontroler/page/popwin_page.cpp +++ b/usrc/uicontroler/page/popwin_page.cpp @@ -6,10 +6,18 @@ using namespace iflytop; using namespace std; #define TAG "PopWinPage" +typedef enum { + kInfoWin, + kLoadingWin, +} HandupType_t; + static UIPopInfo_t hangupInfo; -static bool handupInfoFlag = false; -static int lastPage = 0; -static int displayNum = 0; + +static int lastPage = 0; +static int displayNum = 0; + +static bool handupInfoFlag = false; +static HandupType_t handupType = kInfoWin; class PopWinPage : public IPageProcesser { private: @@ -25,19 +33,69 @@ class PopWinPage : public IPageProcesser { thread.init("PopWinPage", 512); thread.start([this]() { while (true) { + // if (handupInfoFlag) { - osDelay(300); - updatePopWindowsInfo(&hangupInfo); - } else { + if (handupType == kInfoWin) { + osDelay(100); + updatePopWindowsInfo(&hangupInfo); + } else if (handupType == kLoadingWin) { + osDelay(100); + if (!UIPublicState::getLoadingState()) { + handupInfoFlag = false; + } + ZLOGI(TAG, "loading exit"); + } + continue; + } + + if (UIPublicState::getPopInfoNum() != 0) { if (UIPublicState::popUIPopInfoBlock(&hangupInfo)) { ZLOGI(TAG, "PopWinPage info:%s", hangupInfo.info); + visPopWin(true); + visLoadingWin(false); initPopWindowsInfo(&hangupInfo); + changePage(kInfoWin); + } + } else if (UIPublicState::getLoadingState()) { + ZLOGI(TAG, "PopWinPage loading"); + visPopWin(false); + visLoadingWin(true); + changePage(kLoadingWin); + } + + if (!handupInfoFlag) { + if (UIControler::ins()->getNowPage() == thisPage) { + UIControler::ins()->chpage(lastPage); } } + + osDelay(10); } }); } + void changePage(HandupType_t type) { + handupType = type; + handupInfoFlag = true; + if (UIControler::ins()->getNowPage() != thisPage) { + lastPage = UIControler::ins()->getNowPage(); + } + UIControler::ins()->chpage(pg_popwin); + } + + void visPopWin(bool state) { + visEx(ob_popwin_popWin, state); + visEx(ob_popwin_popTil, state); + visEx(ob_popwin_info, state); + visEx(ob_popwin_canclekey, state); + visEx(ob_popwin_confirmkey, state); + } + + void visLoadingWin(bool state) { + visEx(ob_popwin_loadingWin, state); + visEx(ob_popwin_loadingText, state); + } + private: virtual void onPageLoad(OnPageLoadContext* cxt) override {} virtual void onBackKey() override {} @@ -54,23 +112,19 @@ class PopWinPage : public IPageProcesser { hangupInfo.onConfirm(true); } } - - if (num <= 0) { - UIControler::ins()->chpage(lastPage); - } handupInfoFlag = false; } virtual void onAppEvent(AppEvent_t* event) override {} void updateTitle(UIPopWinType_t type, int messageNum) { if (type == UI_POP_WIN_TYPE_INFO) { - UIControler::ins()->setTxt(pageId, ob_popwin_t1, "消息(%d)", messageNum); + UIControler::ins()->setTxt(thisPage, ob_popwin_popTil, "消息(%d)", messageNum); } else if (type == UI_POP_WIN_TYPE_WARNING_INFO) { - UIControler::ins()->setTxt(pageId, ob_popwin_t1, "警告(%d)", messageNum); + UIControler::ins()->setTxt(thisPage, ob_popwin_popTil, "警告(%d)", messageNum); } else if (type == UI_POP_WIN_TYPE_CONFIRM) { - UIControler::ins()->setTxt(pageId, ob_popwin_t1, "消息(%d)", messageNum); + UIControler::ins()->setTxt(thisPage, ob_popwin_popTil, "消息(%d)", messageNum); } else if (type == UI_POP_WIN_TYPE_FATAL_ERROR) { - UIControler::ins()->setTxt(pageId, ob_popwin_t1, "警告(%d)", messageNum); + UIControler::ins()->setTxt(thisPage, ob_popwin_popTil, "警告(%d)", messageNum); } } @@ -83,50 +137,44 @@ class PopWinPage : public IPageProcesser { } void initPopWindowsInfo(UIPopInfo_t* info) { - if (UIControler::ins()->getNowPage() != pageId) { - lastPage = UIControler::ins()->getNowPage(); - } - - handupInfoFlag = true; - displayNum = UIPublicState::getPopInfoNum() + 1; - UIControler::ins()->chpage(pg_popwin); + displayNum = UIPublicState::getPopInfoNum() + 1; if (info->type == UI_POP_WIN_TYPE_INFO) { // 消息 updateTitle(info->type, displayNum); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 10591 /*蓝色*/); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_popTil, 10591 /*蓝色*/); - UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 0 /*黑色*/); + UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 0 /*黑色*/); UIControler::ins()->vis(ob_popwin_canclekey, 0); } else if (info->type == UI_POP_WIN_TYPE_WARNING_INFO) { // 警告消息 updateTitle(info->type, displayNum); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 63488 /*红色*/); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_popTil, 63488 /*红色*/); - UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 63488 /*红色*/); + UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 63488 /*红色*/); UIControler::ins()->vis(ob_popwin_canclekey, 0); } else if (info->type == UI_POP_WIN_TYPE_CONFIRM) { // 确认(可被取消) updateTitle(info->type, displayNum); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 10591 /*蓝色*/); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_popTil, 10591 /*蓝色*/); - UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 0 /*黑色*/); + UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 0 /*黑色*/); UIControler::ins()->vis(ob_popwin_canclekey, 1); } else if (info->type == UI_POP_WIN_TYPE_FATAL_ERROR) { // 警告消息 updateTitle(info->type, displayNum); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 63488 /*红色*/); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_popTil, 63488 /*红色*/); - UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); - UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 63488 /*红色*/); + UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 63488 /*红色*/); UIControler::ins()->vis(ob_popwin_canclekey, 0); UIControler::ins()->vis(ob_popwin_confirmkey, 0); diff --git a/usrc/uicontroler/ui_controler.cpp b/usrc/uicontroler/ui_controler.cpp index a4e0ca5..15d5b1f 100644 --- a/usrc/uicontroler/ui_controler.cpp +++ b/usrc/uicontroler/ui_controler.cpp @@ -358,11 +358,19 @@ void UIControler::setEnumComponentState(uint8_t pid, uint8_t bid, int32_t state) // 枚举类型使用动画组件 sendcmd("p[%d].b[%d].tim=%d", pid, bid, state * 50); } -void UIControler::setPic(uint8_t pid, uint8_t bid, int32_t picNum) { sendcmd("p[%d].b[%d].pic=%d", pid, bid, picNum); } +void UIControler::setPic(uint8_t pid, uint8_t bid, int32_t picNum) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].pic=%d", pid, bid, picNum); +} -void UIControler::setAph(uint8_t pid, uint8_t bid, int32_t state) { sendcmd("p[%d].b[%d].aph=%d", pid, bid, state); } +void UIControler::setAph(uint8_t pid, uint8_t bid, int32_t state) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].aph=%d", pid, bid, state); +} bool UIControler::visEx(uint8_t pid, uint8_t bid, bool val) { + zlock_guard lg(m_cmdlock); + component_info_t* component = UIStateMgr::ins()->forceFindComponent(pid, bid); if (component == NULL) { ZLOGW(TAG, "visEx failed,component alloc failed"); @@ -381,14 +389,19 @@ bool UIControler::visEx(uint8_t pid, uint8_t bid, bool val) { if (val) { // 显示 - sendcmd("p[%d].b[%d].x=%d", pid, bid, component->oldPosX); - sendcmd("p[%d].b[%d].y=%d", pid, bid, component->oldPosY); - component->isVis = true; + if (!component->isVis) { + sendcmd("p[%d].b[%d].x=%d", pid, bid, component->oldPosX); + sendcmd("p[%d].b[%d].y=%d", pid, bid, component->oldPosY); + component->isVis = true; + } + } else { - component->isPosInited = true; - component->isVis = false; - sendcmd("p[%d].b[%d].x=%d", pid, bid, -2000); - sendcmd("p[%d].b[%d].y=%d", pid, bid, -2000); + if (component->isVis) { + component->isPosInited = true; + component->isVis = false; + sendcmd("p[%d].b[%d].x=%d", pid, bid, -2000); + sendcmd("p[%d].b[%d].y=%d", pid, bid, -2000); + } } } while (false); diff --git a/usrc/uicontroler/ui_controler.hpp b/usrc/uicontroler/ui_controler.hpp index 02dc657..7ade592 100644 --- a/usrc/uicontroler/ui_controler.hpp +++ b/usrc/uicontroler/ui_controler.hpp @@ -75,12 +75,20 @@ class UIControler { void popWarningWin(const char* info) { popWin(UI_POP_WIN_TYPE_WARNING_INFO, info, nullptr); } void popConfirmWin(const char* info, function onConfirm) { popWin(UI_POP_WIN_TYPE_CONFIRM, info, onConfirm); } void popInfoWin(const char* info) { popWin(UI_POP_WIN_TYPE_INFO, info, nullptr); } - + void setLoadingState(bool state) { + { + zlock_guard lg(m_cmdlock); + UIPublicState::setLoadingState(state); + } + if (state) osDelay(10); + } /** * @brief */ void popFullKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].val=%d", pg_keybdAP, ob_keybdAP_loadpageid, fromPid); sendcmd("p[%d].b[%d].val=%d", pg_keybdAP, ob_keybdAP_loadcmpid, fromBid); sendcmd("p[%d].b[%d].txt=%s", pg_keybdAP, ob_keybdAP_show, initval); @@ -90,6 +98,8 @@ class UIControler { } void popPasswdKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].val=%d", pg_keyPasswd, ob_keyPasswd_loadpageid, fromPid); sendcmd("p[%d].b[%d].val=%d", pg_keyPasswd, ob_keyPasswd_loadcmpid, fromBid); sendcmd("p[%d].b[%d].txt=%s", pg_keyPasswd, ob_keyPasswd_show, ""); @@ -99,6 +109,8 @@ class UIControler { } void popNumKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].val=%d", pg_keybdB, ob_keybdB_loadpageid, fromPid); sendcmd("p[%d].b[%d].val=%d", pg_keybdB, ob_keybdB_loadcmpid, fromBid); sendcmd("p[%d].b[%d].txt=%s", pg_keybdB, ob_keybdB_show, initval); @@ -108,6 +120,7 @@ class UIControler { } void popSelcKeyBoard(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char** selectvals) { + zlock_guard lg(m_cmdlock); static char contentbus[128]; for (int i = 0;; i++) { // \r\n 拼接字符串数组 @@ -122,6 +135,7 @@ class UIControler { } void popSelcKeyBoard(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char* selectvals) { + zlock_guard lg(m_cmdlock); sendcmd("p[%d].b[%d].val=%d", pg_keybMutiSel, ob_keybMutiSel_loadpageid, fromPid); sendcmd("p[%d].b[%d].val=%d", pg_keybMutiSel, ob_keybMutiSel_loadcmpid, fromBid); sendcmd("p[%d].b[%d].val=%d", pg_keybMutiSel, ob_keybMutiSel_ctent, selectvalindex); @@ -150,4 +164,10 @@ class UIControler { bool _readFiledAsInt(uint8_t pid, uint8_t bid, const char* valName, int32_t* val); }; +class UILoadingCxt { + public: + UILoadingCxt() { UIControler::ins()->setLoadingState(true); } + ~UILoadingCxt() { UIControler::ins()->setLoadingState(false); } +}; + } // namespace iflytop