diff --git a/uappbase/service/app_event_bus.cpp b/uappbase/service/app_event_bus.cpp index eebd51a..84b7eac 100644 --- a/uappbase/service/app_event_bus.cpp +++ b/uappbase/service/app_event_bus.cpp @@ -14,7 +14,7 @@ void AppEventBus::initialize() { AppEvent_t event; while (1) { if (xQueueReceive(xQueue, &event, portMAX_DELAY) == pdTRUE) { - // ZLOGI(TAG, "pop event type %d", event.type); + ZLOGI(TAG, "pop event type %d", event.type); for (int i = 0; i < cbNum; i++) { m_cbs[i](&event); } @@ -28,7 +28,7 @@ void AppEventBus::regOnEvent(onAppEventCB_t onEvent) { cbNum++; } void AppEventBus::pushEvent(const AppEvent_t& event) { - // ZLOGI(TAG, "pushEvent %d", event.type); + ZLOGI(TAG, "pushEvent %d", event.type); if (xQueueSend(xQueue, &event, 100) != pdPASS) { ZLOGE(TAG, "xQueueSend failed"); } diff --git a/usrc/db/dao/acid_name_dao.cpp b/usrc/db/dao/acid_name_dao.cpp index 9830c41..799ea25 100644 --- a/usrc/db/dao/acid_name_dao.cpp +++ b/usrc/db/dao/acid_name_dao.cpp @@ -84,9 +84,9 @@ void AcidNameDao::updateAcidName(int index, const char* name) { storgeTableData(); } - const char* AcidNameDao::getAcidName(int index){ +const char* AcidNameDao::getAcidName(int index) { ZASSERT_INFO(module_inited, "acid name dao not inited"); ZASSERT_INFO(index < MAX_ACID_NUM, "index out of range"); return tabledata->acidName[0].acidName[index]; - } +} diff --git a/usrc/service/app_core.cpp b/usrc/service/app_core.cpp index 38fc26a..8967350 100644 --- a/usrc/service/app_core.cpp +++ b/usrc/service/app_core.cpp @@ -97,7 +97,7 @@ void AppCore::initialize() { ZLOGI(TAG, "load zhdb end"); UIControler::ins()->initialize(); - UIControler::ins()->chpage(pg_muDateMgr,true); + UIControler::ins()->chpage(pg_muAcidType,true); osDelay(1000); // UIControler::ins()->popWarningWin("警告!!!!!!!"); diff --git a/usrc/uicontroler/base/page_processer.cpp b/usrc/uicontroler/base/page_processer.cpp index be4c7d8..da9df01 100644 --- a/usrc/uicontroler/base/page_processer.cpp +++ b/usrc/uicontroler/base/page_processer.cpp @@ -20,15 +20,20 @@ IPageProcesser::IPageProcesser(const char* name, uint32_t thisPage) { } void IPageProcesser::initialize() { + if (isInit) { + ZLOGE(TAG, "page %s %d has been initialized", pageName, thisPage); + ZASSERT(false); + } + isInit = true; + 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 (thisPage != event->d.uiEvent.pid) { return; } + // uint8_t bid = event->d.uiEvent.bid; UIEvent* uiEvent = &event->d.uiEvent; @@ -37,10 +42,10 @@ void IPageProcesser::initialize() { 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, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text); + ZLOGI(TAG, "page %s(%d)-%d onClickRelease(button),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, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text); + ZLOGI(TAG, "page %s(%d)-%d onClickRelease(usrDef),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, thisPage, uiEvent->bid); @@ -74,17 +79,30 @@ void UIControlerHock_PageInit() { break; } } - + uint8_t pageId[256] = {0}; for (size_t i = 0; i < m_pageNum; i++) { + if (m_pages[i]->thisPage > 255) { + ZLOGE(TAG, "page %s %d is out of range", m_pages[i]->pageName, m_pages[i]->thisPage); + ZASSERT(false); + } + pageId[m_pages[i]->thisPage] += 1; + // + // 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(); } - } else { m_pages[i]->initialize(); } } + + for (size_t i = 0; i < 256; i++) { + if (pageId[i] > 1) { + ZLOGE(TAG, "page %d has been registed %d times", i, pageId[i]); + ZASSERT(false); + } + } } } // namespace iflytop diff --git a/usrc/uicontroler/base/page_processer.hpp b/usrc/uicontroler/base/page_processer.hpp index 56ee549..f450692 100644 --- a/usrc/uicontroler/base/page_processer.hpp +++ b/usrc/uicontroler/base/page_processer.hpp @@ -26,6 +26,7 @@ class IPageProcesser { const char* pageName = "Not Set"; bool onlyInitThis = false; // for debug bool forceInitThis = false; + bool isInit = false; public: IPageProcesser(const char* name, uint32_t thisPage); diff --git a/usrc/uicontroler/page/mupage/muAcidType_page.cpp b/usrc/uicontroler/page/mupage/muAcidType_page.cpp new file mode 100644 index 0000000..a0628dd --- /dev/null +++ b/usrc/uicontroler/page/mupage/muAcidType_page.cpp @@ -0,0 +1,118 @@ + +#include "db/dao/acid_name_dao.hpp" +#include "uappbase/apphal/apphal.hpp" +#include "ui/ui.h" +#include "uicontroler/base/page_processer.hpp" +// +#include "db/dao/acid_ch_cfg_dao.hpp" +#include "db/dao/device_setting_dao.hpp" +// +#include "service/pump_ctrl_service.hpp" + +namespace iflytop { +using namespace std; +#define TAG "MuAcidType" + +class MuAcidType : public IPageProcesser { + private: + public: + MuAcidType() : IPageProcesser(TAG, pg_muAcidType) {} + + virtual void initialize() override { + IPageProcesser::initialize(); + + setText(ob_muAcidType_t1, AcidNameDao::getAcidName(1 - 1)); + setText(ob_muAcidType_t2, AcidNameDao::getAcidName(2 - 1)); + setText(ob_muAcidType_t3, AcidNameDao::getAcidName(3 - 1)); + setText(ob_muAcidType_t4, AcidNameDao::getAcidName(4 - 1)); + setText(ob_muAcidType_t5, AcidNameDao::getAcidName(5 - 1)); + setText(ob_muAcidType_t6, AcidNameDao::getAcidName(6 - 1)); + setText(ob_muAcidType_t7, AcidNameDao::getAcidName(7 - 1)); + setText(ob_muAcidType_t8, AcidNameDao::getAcidName(8 - 1)); + setText(ob_muAcidType_t9, AcidNameDao::getAcidName(9 - 1)); + setText(ob_muAcidType_t10, AcidNameDao::getAcidName(10 - 1)); + setText(ob_muAcidType_t11, AcidNameDao::getAcidName(11 - 1)); + setText(ob_muAcidType_t12, AcidNameDao::getAcidName(12 - 1)); + setText(ob_muAcidType_t13, AcidNameDao::getAcidName(13 - 1)); + setText(ob_muAcidType_t14, AcidNameDao::getAcidName(14 - 1)); + setText(ob_muAcidType_t15, AcidNameDao::getAcidName(15 - 1)); + } + + private: + virtual void onPageLoad(OnPageLoadContext* cxt) override { return; }; + /** + * @brief 返回上一页 + */ + virtual void onBackKey() override { UIControler::ins()->chpage(pg_navi, true); }; + + virtual void onChangePageEvent() override {}; + virtual void OnInputFieldContentChange(uint8_t bid, uint8_t slecId, const char* text) { + if (bid == ob_muAcidType_t1) { + AcidNameDao::updateAcidName(1 - 1, text); + } else if (bid == ob_muAcidType_t2) { + AcidNameDao::updateAcidName(2 - 1, text); + } else if (bid == ob_muAcidType_t3) { + AcidNameDao::updateAcidName(3 - 1, text); + } else if (bid == ob_muAcidType_t4) { + AcidNameDao::updateAcidName(4 - 1, text); + } else if (bid == ob_muAcidType_t5) { + AcidNameDao::updateAcidName(5 - 1, text); + } else if (bid == ob_muAcidType_t6) { + AcidNameDao::updateAcidName(6 - 1, text); + } else if (bid == ob_muAcidType_t7) { + AcidNameDao::updateAcidName(7 - 1, text); + } else if (bid == ob_muAcidType_t8) { + AcidNameDao::updateAcidName(8 - 1, text); + } else if (bid == ob_muAcidType_t9) { + AcidNameDao::updateAcidName(9 - 1, text); + } else if (bid == ob_muAcidType_t10) { + AcidNameDao::updateAcidName(10 - 1, text); + } else if (bid == ob_muAcidType_t11) { + AcidNameDao::updateAcidName(11 - 1, text); + } else if (bid == ob_muAcidType_t12) { + AcidNameDao::updateAcidName(12 - 1, text); + } else if (bid == ob_muAcidType_t13) { + AcidNameDao::updateAcidName(13 - 1, text); + } else if (bid == ob_muAcidType_t14) { + AcidNameDao::updateAcidName(14 - 1, text); + } else if (bid == ob_muAcidType_t15) { + AcidNameDao::updateAcidName(15 - 1, text); + } + }; + virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override { + if (bid == ob_muAcidType_t1) + popFullKeyBoard(ob_muAcidType_t1, 20, AcidNameDao::getAcidName(1 - 1)); + else if (bid == ob_muAcidType_t2) + popFullKeyBoard(ob_muAcidType_t2, 20, AcidNameDao::getAcidName(2 - 1)); + else if (bid == ob_muAcidType_t3) + popFullKeyBoard(ob_muAcidType_t3, 20, AcidNameDao::getAcidName(3 - 1)); + else if (bid == ob_muAcidType_t4) + popFullKeyBoard(ob_muAcidType_t4, 20, AcidNameDao::getAcidName(4 - 1)); + else if (bid == ob_muAcidType_t5) + popFullKeyBoard(ob_muAcidType_t5, 20, AcidNameDao::getAcidName(5 - 1)); + else if (bid == ob_muAcidType_t6) + popFullKeyBoard(ob_muAcidType_t6, 20, AcidNameDao::getAcidName(6 - 1)); + else if (bid == ob_muAcidType_t7) + popFullKeyBoard(ob_muAcidType_t7, 20, AcidNameDao::getAcidName(7 - 1)); + else if (bid == ob_muAcidType_t8) + popFullKeyBoard(ob_muAcidType_t8, 20, AcidNameDao::getAcidName(8 - 1)); + else if (bid == ob_muAcidType_t9) + popFullKeyBoard(ob_muAcidType_t9, 20, AcidNameDao::getAcidName(9 - 1)); + else if (bid == ob_muAcidType_t10) + popFullKeyBoard(ob_muAcidType_t10, 20, AcidNameDao::getAcidName(10 - 1)); + else if (bid == ob_muAcidType_t11) + popFullKeyBoard(ob_muAcidType_t11, 20, AcidNameDao::getAcidName(11 - 1)); + else if (bid == ob_muAcidType_t12) + popFullKeyBoard(ob_muAcidType_t12, 20, AcidNameDao::getAcidName(12 - 1)); + else if (bid == ob_muAcidType_t13) + popFullKeyBoard(ob_muAcidType_t13, 20, AcidNameDao::getAcidName(13 - 1)); + else if (bid == ob_muAcidType_t14) + popFullKeyBoard(ob_muAcidType_t14, 20, AcidNameDao::getAcidName(14 - 1)); + else if (bid == ob_muAcidType_t15) + popFullKeyBoard(ob_muAcidType_t15, 20, AcidNameDao::getAcidName(15 - 1)); + } +}; + +// 实例化Page, 使其自动注册 +static MuAcidType instance; +} // namespace iflytop diff --git a/usrc/uicontroler/ui_controler.cpp b/usrc/uicontroler/ui_controler.cpp index 9581959..032fef5 100644 --- a/usrc/uicontroler/ui_controler.cpp +++ b/usrc/uicontroler/ui_controler.cpp @@ -111,6 +111,7 @@ void UIControler::startSchedule() { } else { event_cache.eventId = packet.data[0]; } + ZLOGI(TAG,"push event %s(%d) ", tjc::pt2str(event_cache.eventId), event_cache.eventId); callUsrEventCb(&event_cache); } osDelay(1); diff --git a/usrc/uicontroler/ui_controler.hpp b/usrc/uicontroler/ui_controler.hpp index 37212ef..d6369d5 100644 --- a/usrc/uicontroler/ui_controler.hpp +++ b/usrc/uicontroler/ui_controler.hpp @@ -95,9 +95,9 @@ class UIControler { 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); - sendcmd("p[%d].b[%d].pw=0", pg_keybdAP, ob_keybdAP_show); + sendcmd("p[%d].b[%d].txt=\"%s\"", pg_keybdAP, ob_keybdAP_show, initval); sendcmd("p[%d].b[%d].val=%d", pg_keybdAP, ob_keybdAP_inputlenth, limitLength); + sendcmd("p[%d].b[%d].pw=0", pg_keybdAP, ob_keybdAP_show); chpage(pg_keybdAP, false); } @@ -106,7 +106,7 @@ class UIControler { 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, ""); + sendcmd("p[%d].b[%d].txt=\"%s\"", pg_keyPasswd, ob_keyPasswd_show, ""); sendcmd("p[%d].b[%d].pw=1", pg_keyPasswd, ob_keyPasswd_show); sendcmd("p[%d].b[%d].val=%d", pg_keyPasswd, ob_keyPasswd_inputlenth, limitLength); chpage(pg_keyPasswd, false); @@ -117,7 +117,7 @@ class UIControler { 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); + sendcmd("p[%d].b[%d].txt=\"%s\"", pg_keybdB, ob_keybdB_show, initval); sendcmd("p[%d].b[%d].pw=0", pg_keybdB, ob_keybdB_show); sendcmd("p[%d].b[%d].val=%d", pg_keybdB, ob_keybdB_inputlenth, limitLength); chpage(pg_keybdB, false);