zhaohe 8 months ago
parent
commit
29ea1d5225
  1. 4
      .settings/stm32cubeide.project.prefs
  2. 2
      Core
  3. 4
      FATFS/Target/ffconf.h
  4. 4
      STM32F407VETX_FLASH.ld
  5. 2
      stm32basic
  6. 27
      uappbase/bean/appevent.hpp
  7. 12
      uappbase/bean/appevent_type.hpp
  8. 18
      uappbase/service/app_event_bus.cpp
  9. 4
      uappbase/service/app_event_bus.hpp
  10. 6
      uappbase/service/gstate_mgr.cpp
  11. 1
      uappbase/service/gstate_mgr.hpp
  12. BIN
      ui/hand_acid_mainboard_ui.HMI
  13. 32
      usrc/db/dao/acid_use_record_dao.cpp
  14. 3
      usrc/db/dao/acid_use_record_dao.hpp
  15. 1
      usrc/fileoperation/zusb_file_operator.cpp
  16. 4
      usrc/service/app_core.cpp
  17. 8
      usrc/service/pump_ctrl_service.cpp
  18. 23
      usrc/service/statistics_sync_service.cpp
  19. 16
      usrc/uicontroler/base/page_processer.cpp
  20. 20
      usrc/uicontroler/base/ui_state.cpp
  21. 5
      usrc/uicontroler/base/ui_state.hpp
  22. 6
      usrc/uicontroler/event_proceesser/sys_event_page_id_processer.cpp
  23. 1
      usrc/uicontroler/page/home_page.cpp
  24. 34
      usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp
  25. 40
      usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp
  26. 3
      usrc/uicontroler/page/mupage/muDateMgr_page.cpp
  27. 6
      usrc/uicontroler/page/mupage/muReCtrlerBind_page.cpp
  28. 97
      usrc/uicontroler/page/mupage/muUsrMgr_page.cpp
  29. 30
      usrc/uicontroler/page/navi_page.cpp
  30. 51
      usrc/uicontroler/page/popwin_page.cpp
  31. 19
      usrc/uicontroler/ui_controler.cpp
  32. 15
      usrc/uicontroler/ui_controler.hpp
  33. 2
      usrc/uicontroler/ui_state_mgr.cpp

4
.settings/stm32cubeide.project.prefs

@ -1,6 +1,6 @@
2F62501ED4689FB349E356AB974DBE57=D1D13CF78BE39097E724CD6F0136AC59
2F62501ED4689FB349E356AB974DBE57=6DA8BC97D7B900DE3B85BFD41C1C29CC
635E684B79701B039C64EA45C3F84D30=C8B026EBE17C208F17FB66CE4235156C
66BE74F758C12D739921AEA421D593D3=1
8DF89ED150041C4CBC7CB9A9CAA90856=D1D13CF78BE39097E724CD6F0136AC59
8DF89ED150041C4CBC7CB9A9CAA90856=6DA8BC97D7B900DE3B85BFD41C1C29CC
DC22A860405A8BF2F2C095E5B6529F12=EC6C4D369FD4F7EABFE17B3222B5F3A0
eclipse.preferences.version=1

2
Core

@ -1 +1 @@
Subproject commit aaf909385c23f3ed678ad802aa9850f3be487922
Subproject commit 5aebdfa1b7554fe613ffacf817c7d34588885a80

4
FATFS/Target/ffconf.h

@ -85,7 +85,7 @@
/ Locale and Namespace Configurations
/-----------------------------------------------------------------------------*/
#define _CODE_PAGE 936
#define _CODE_PAGE 1
/* This option specifies the OEM code page to be used on the target system.
/ Incorrect setting of the code page can cause a file open failure.
/
@ -242,7 +242,7 @@
/ can be opened simultaneously under file lock control. Note that the file
/ lock control is independent of re-entrancy. */
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
#define _USE_MUTEX 0 /* 0:Disable or 1:Enable */
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */

4
STM32F407VETX_FLASH.ld

@ -39,8 +39,8 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
_Min_Heap_Size = 0x2000; /* required amount of heap */
_Min_Stack_Size = 0x2000; /* required amount of stack */
_Min_Heap_Size = 0x1000; /* required amount of heap */
_Min_Stack_Size = 0x1000; /* required amount of stack */
/* Memories definition */
MEMORY

2
stm32basic

@ -1 +1 @@
Subproject commit cba5845768a21a847d3e2b528107f65516399c90
Subproject commit f9a31c529c42e35ea439998f8b6292ed0f885c70

27
uappbase/bean/appevent.hpp

@ -17,24 +17,39 @@ extern "C" {
// typedef struct {
// } AppEvent;
struct AcidStateChangeEvent {
enum AcidStatChangeEventType subtype;
// Ìí¼Ó
uint8_t addCh;
float addChVal;
// ʹÓÃ
float useVal[4];
};
typedef struct AcidStateChangeEvent AcidStateChangeEvent_t;
typedef enum AcidStatChangeEventType AcidStatChangeEventType_t;
class AppEvent {
public:
AppEventType_t type;
std::function<void()> onfnc = nullptr;
std::function<void()> onfnc = nullptr;
const char* onfncmask = nullptr;
private:
uint8_t buf[50];
uint8_t buf[30];
UIEvent* uieventpointer = nullptr;
public:
AppEvent() { memset(buf, 0, sizeof(buf)); }
AppEvent() {
static_assert(sizeof(buf) >= sizeof(AcidStateChangeEvent_t), "buf size must be larger than AcidStateChangeEvent_t");
memset(buf, 0, sizeof(buf));
}
public:
int getBufSize() { return sizeof(buf); }
void setBleName(const char* name) { strncpy((char*)buf, name, sizeof(buf)); }
char* getBleName() { return (char*)buf; }
void setPageChangeTo(int32_t page) { *(int32_t*)buf = page; }
int32_t getPageChangeTo() { return *(int32_t*)buf; }

12
uappbase/bean/appevent_type.hpp

@ -26,18 +26,6 @@ enum AppEventType {
enum AcidStatChangeEventType { kACID_USE, kACID_STORAGE };
struct AcidStateChangeEvent {
enum AcidStatChangeEventType subtype;
// Ìí¼Ó
uint8_t addCh;
float addChVal;
// ʹÓÃ
float useVal[4];
};
typedef enum AppEventType AppEventType_t;
typedef enum AcidStatChangeEventType AcidStatChangeEventType_t;
typedef struct AcidStateChangeEvent AcidStateChangeEvent_t;

18
uappbase/service/app_event_bus.cpp

@ -7,6 +7,7 @@ using namespace iflytop;
using namespace std;
static QueueHandle_t xQueue;
static AppEvent eventtxcache;
static const char* curOnFuncMask = nullptr;
#define TAG "AppEventBus"
void AppEventBus::initialize() {
@ -14,7 +15,7 @@ void AppEventBus::initialize() {
thread.init("AppEventBus", 1024);
int AppEventSize = sizeof(AppEvent);
xQueue = xQueueCreate(20, AppEventSize);
xQueue = xQueueCreate(10, AppEventSize);
thread.start([this]() {
static AppEvent eventrxcache;
@ -24,7 +25,11 @@ void AppEventBus::initialize() {
if (eventrxcache.type == KAE_callOnAppEventBusLoop) {
if (eventrxcache.onfnc) {
// ZLOGI(TAG, "DO FUNC CB %s", eventrxcache.onfncmask);
curOnFuncMask = eventrxcache.onfncmask;
eventrxcache.onfnc();
curOnFuncMask = nullptr;
// ZLOGI(TAG, "DO FUNC CB %s END", eventrxcache.onfncmask);
}
continue;
}
@ -54,9 +59,9 @@ void AppEventBus::pushEvent(const AppEvent& event) {
}
}
void AppEventBus::pushEventBlock(AppEvent* event) {
void AppEventBus::pushEventBlock(const char* cxtmark, AppEvent* event) {
bool evenProcessed = false;
callFnInEventBus([&]() {
callFnInEventBus(cxtmark, [&]() {
for (int i = 0; i < cbNum; i++) {
m_cbs[i](event);
}
@ -81,10 +86,11 @@ void AppEventBus::pushPageChangeEvent(uint8_t toPage) {
pushEvent(eventtxcache);
}
void AppEventBus::callFnInEventBus(function<void()> onfnc) {
void AppEventBus::callFnInEventBus(const char* mask, function<void()> onfnc) {
zlock_guard lck(lock);
eventtxcache.type = KAE_callOnAppEventBusLoop;
eventtxcache.onfnc = onfnc;
eventtxcache.type = KAE_callOnAppEventBusLoop;
eventtxcache.onfnc = onfnc;
eventtxcache.onfncmask = mask;
pushEvent(eventtxcache);
}

4
uappbase/service/app_event_bus.hpp

@ -34,10 +34,10 @@ class AppEventBus {
void pushAcidStatStorageEvent(uint8_t ch, float chVal);
void pushAcidStatDisplayChangeEvent();
void pushEventBlock(AppEvent* event);
void pushEventBlock(const char* cxtmark, AppEvent* event);
//
void callFnInEventBus(function<void()> onfnc);
void callFnInEventBus(const char* mask,function<void()> onfnc);
bool isInAppEventThread();
};

6
uappbase/service/gstate_mgr.cpp

@ -55,7 +55,6 @@ void GStateMgr::setRemoterS(int32_t state, const char* name) {
ZLOGI(TAG, "on ble connect -> client name:%s", name);
strncpy(m_RemoterName, name, sizeof(m_RemoterName));
// strncpy(appevent.d.bleName, name, sizeof(appevent.d.bleName));
appevent.setBleName(name);
appevent.type = kAE_RemoterConnectedEvent;
} else {
@ -64,6 +63,11 @@ void GStateMgr::setRemoterS(int32_t state, const char* name) {
}
AppEventBus::ins()->pushEvent(appevent);
}
const char* GStateMgr::getRemoterName() {
zlock_guard l(m_mutex);
return m_RemoterName;
}
void GStateMgr::setRunMode(hand_acid_mode_t mode) {
zlock_guard l(m_mutex);
if (m_RunMode != mode) {

1
uappbase/service/gstate_mgr.hpp

@ -76,6 +76,7 @@ class GStateMgr {
*/
void setRemoterS(int32_t state, const char* name);
const char* getRemoterName();
/**
* @brief

BIN
ui/hand_acid_mainboard_ui.HMI

32
usrc/db/dao/acid_use_record_dao.cpp

@ -73,7 +73,7 @@ void AcidUseRecordDao::addRecord(const acid_use_record_t& record) {
m_table->recordNum, ACIDUSERCORD_RECORD_NUM);
}
void AcidUseRecordDao::updateLastRecord(uint16_t val0, uint16_t val1, uint16_t val2, uint16_t val3) {
void AcidUseRecordDao::updateLastRecord(float val0, float val1, float val2, float val3) {
zlock_guard l(lock);
int recordNum = m_table->recordNum - 1;
if (recordNum < 0) {
@ -86,10 +86,32 @@ void AcidUseRecordDao::updateLastRecord(uint16_t val0, uint16_t val1, uint16_t v
return;
}
m_table->record[recordNum].ch0take0p1ml = val0;
m_table->record[recordNum].ch1take0p1ml = val1;
m_table->record[recordNum].ch2take0p1ml = val2;
m_table->record[recordNum].ch3take0p1ml = val3;
m_table->record[recordNum].ch0take0p1ml = val0 * 10 + 0.5;
m_table->record[recordNum].ch1take0p1ml = val1 * 10 + 0.5;
m_table->record[recordNum].ch2take0p1ml = val2 * 10 + 0.5;
m_table->record[recordNum].ch3take0p1ml = val3 * 10 + 0.5;
ZLOGI(TAG, " [%d/%d]", m_table->recordNum, ACIDUSERCORD_RECORD_NUM);
// ZLOGI(TAG, "update record %d/%d/%d %02d:%02d:%02d %d %d %d %d %d (%d/%d)", //
// m_table->record[recordNum].date.year, m_table->record[recordNum].date.month, m_table->record[recordNum].date.day, m_table->record[recordNum].date.hours,
// m_table->record[recordNum].date.minutes, m_table->record[recordNum].date.seconds, m_table->record[recordNum].usrid, m_table->record[recordNum].ch0take0p1ml,
// m_table->record[recordNum].ch1take0p1ml, m_table->record[recordNum].ch2take0p1ml, m_table->record[recordNum].ch3take0p1ml, m_table->recordNum, ACIDUSERCORD_RECORD_NUM);
}
void AcidUseRecordDao::updateTheLastRecordDate(zdate_t* date) {
zlock_guard l(lock);
int recordNum = m_table->recordNum - 1;
if (recordNum < 0) {
ZLOGW(TAG, "no record to update");
return;
}
if (m_table->record[recordNum].dirty == 0) {
ZLOGW(TAG, "record not dirty");
return;
}
m_table->record[recordNum].date = *date;
}
void AcidUseRecordDao::syncTheLastRecord() {

3
usrc/db/dao/acid_use_record_dao.hpp

@ -31,7 +31,8 @@ class AcidUseRecordDao {
static acid_use_record_table_t* getRecordTable();
static void addRecord(const acid_use_record_t& record);
static void updateLastRecord(uint16_t val0, uint16_t val1, uint16_t val2, uint16_t val3);
static void updateTheLastRecordDate(zdate_t* date);
static void updateLastRecord(float volml0, float volml1, float volml2, float volml3);
static void setDirtyRecordClean();
static void syncTheLastRecord();

1
usrc/fileoperation/zusb_file_operator.cpp

@ -77,6 +77,7 @@ static const char* FRESULT_TO_STR(FRESULT result) {
static void setErrorInfo(bool suc, const char* info) {
memset(m_errorInfo, 0, sizeof(m_errorInfo));
strncpy(m_errorInfo, info, sizeof(m_errorInfo));
m_operationSuc = suc;
}
void ZUSBFileOperator::mount() {

4
usrc/service/app_core.cpp

@ -146,7 +146,6 @@ void AppCore::initialize() {
MX_FATFS_Init();
MX_USB_HOST_Init();
ZUSBFileOperator::mount();
/***********************************************************************************************************************
* ¿ªÊ¼ÀÑÀɨÃè *
@ -170,9 +169,6 @@ void AppCore::initialize() {
if (suc) break;
}
}
GStateMgr::ins()->setLogin(0, "admin", kadmin);
AppEventBus::ins()->pushSimpleEvent(kAE_LoginEvent);
UIControler::ins()->chpage(pg_login, true);
/***********************************************************************************************************************

8
usrc/service/pump_ctrl_service.cpp

@ -287,11 +287,11 @@ void PumpCtrlService::setCurrentPosAsZero(int32_t mid) {
void PumpCtrlService::doMotorsMoveByOnce() {
int32_t step[MOTOR_NUM] = {0};
float distriVal[MOTOR_NUM] = {0};
for (size_t i = 0; i < MOTOR_NUM; i++) {
step[i] = AcidChCfgDao::getCfg(i)->acidEachDistriVal * 1000 + AcidChCfgDao::getCfg(i)->chAppendMl * 1000;
distriVal[i] = AcidChCfgDao::getCfg(i)->acidEachDistriVal;
if (!GSM->getPumpSelectState(i)) {
if (GSM->getPumpSelectState(i)) {
step[i] = AcidChCfgDao::getCfg(i)->acidEachDistriVal * 1000 + AcidChCfgDao::getCfg(i)->chAppendMl * 1000;
distriVal[i] = AcidChCfgDao::getCfg(i)->acidEachDistriVal;
} else {
step[i] = 0;
distriVal[i] = 0;
}

23
usrc/service/statistics_sync_service.cpp

@ -56,7 +56,7 @@ void StatisticsSyncService::onLogin() {
GStateMgr::ins()->setAcidUsed(3, 0);
acid_use_record_t record = {0};
AppHal::rtc_set(&record.date);
AppHal::rtc_get(&record.date);
record.usrid = GStateMgr::ins()->getUserId();
record.dirty = 1;
@ -69,7 +69,7 @@ void StatisticsSyncService::doSyncOnUnLoginOrPowerOff() {
*/
if (!AppEventBus::ins()->isInAppEventThread()) {
bool callfinished = false;
AppEventBus::ins()->callFnInEventBus([&]() {
AppEventBus::ins()->callFnInEventBus("SYNC ON UNLOGIN OR POWEROFF", [&]() {
doSyncOnUnLoginOrPowerOff();
callfinished = true;
});
@ -77,6 +77,7 @@ void StatisticsSyncService::doSyncOnUnLoginOrPowerOff() {
while (!callfinished) {
osDelay(30);
}
return;
}
float used0 = GStateMgr::ins()->getAcidUsed(0);
@ -99,6 +100,7 @@ void StatisticsSyncService::doSyncOnUnLoginOrPowerOff() {
} else {
ZLOGI(TAG, "updateLastRecordSync : %f %f %f %f", used0, used1, used2, used3);
AcidUseRecordDao::updateLastRecord(used0, used1, used2, used3);
AcidUseRecordDao::setDirtyRecordClean();
AcidUseRecordDao::syncTheLastRecord();
}
@ -126,6 +128,8 @@ void StatisticsSyncService::onAddAcidStorage(int ch, float addChVal) {
AppEventBus::ins()->pushAcidStatDisplayChangeEvent();
}
void StatisticsSyncService::onUseAcid(float useVal0, float useVal1, float useVal2, float useVal3) {
ZLOGI(TAG, "use acid %.2f %.2f %.2f %.2f", useVal0, useVal1, useVal2, useVal3);
float now0 = GStateMgr::ins()->getAcidUsed(0);
float now1 = GStateMgr::ins()->getAcidUsed(1);
float now2 = GStateMgr::ins()->getAcidUsed(2);
@ -146,19 +150,18 @@ void StatisticsSyncService::onUseAcid(float useVal0, float useVal1, float useVal
GStateMgr::ins()->setAcidRemain(2, remain2 - useVal2 > 0 ? remain2 - useVal2 : 0);
GStateMgr::ins()->setAcidRemain(3, remain3 - useVal3 > 0 ? remain3 - useVal3 : 0);
// AcidUseRecordDao::updateLastRecord(now0 + useVal0, now1 + useVal1, now2 + useVal2, now3 + useVal3);
// DeviceAcidVolumeDao::updateAcidVolume(0, GStateMgr::ins()->getAcidRemain(0));
// DeviceAcidVolumeDao::updateAcidVolume(1, GStateMgr::ins()->getAcidRemain(1));
// DeviceAcidVolumeDao::updateAcidVolume(2, GStateMgr::ins()->getAcidRemain(2));
// DeviceAcidVolumeDao::updateAcidVolume(3, GStateMgr::ins()->getAcidRemain(3));
// m_dataIsDirty = true;
AcidUseRecordDao::updateLastRecord(now0 + useVal0, now1 + useVal1, now2 + useVal2, now3 + useVal3);
DeviceAcidVolumeDao::updateAcidVolume(0, GStateMgr::ins()->getAcidRemain(0));
DeviceAcidVolumeDao::updateAcidVolume(1, GStateMgr::ins()->getAcidRemain(1));
DeviceAcidVolumeDao::updateAcidVolume(2, GStateMgr::ins()->getAcidRemain(2));
DeviceAcidVolumeDao::updateAcidVolume(3, GStateMgr::ins()->getAcidRemain(3));
m_dataIsDirty = true;
AppEventBus::ins()->pushAcidStatDisplayChangeEvent();
}
static void syncTimer(const void* tid) {
AppEventBus::ins()->callFnInEventBus([]() {
AppEventBus::ins()->callFnInEventBus("SYNC USAGE", []() {
if (m_dataIsDirty) {
AcidUseRecordDao::syncTheLastRecord();
DeviceAcidVolumeDao::sync();

16
usrc/uicontroler/base/page_processer.cpp

@ -1,11 +1,13 @@
#include "page_processer.hpp"
using namespace iflytop;
#define TAG "PageMgr"
#define TAG "PageProcesser"
IPageProcesser* m_pages[50];
int m_pageNum;
static bool enDebugFlag = false;
static void regPage(IPageProcesser* page) {
if (m_pageNum > 50) {
return;
@ -39,22 +41,22 @@ void IPageProcesser::initialize() {
if (uiEvent->eventId == kpt_sys_event_page_id) {
OnPageLoadContext cxt = {0};
ZLOGI(TAG, "page %s(%d)-%d load", pageName, thisPage, uiEvent->bid);
ZLOGD(TAG, "[%s(%d)-%d] onLoad", pageName, thisPage, uiEvent->bid);
onPageLoad(&cxt);
} else if (uiEvent->eventId == kpt_button_event) {
ZLOGI(TAG, "page %s(%d)-%d onClickRelease(button),val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text);
ZLOGD(TAG, "[%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(usrDef),val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text);
ZLOGD(TAG, "[%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);
ZLOGD(TAG, "[%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, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text);
ZLOGD(TAG, "[%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, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text);
ZLOGD(TAG, "[%s(%d)-%d] onInputFieldContentChange val %d text %s", pageName, thisPage, uiEvent->bid, uiEvent->val, uiEvent->text);
onInputFieldContentChange(uiEvent->bid, uiEvent->val, uiEvent->text);
}
//

20
usrc/uicontroler/base/ui_state.cpp

@ -4,6 +4,7 @@ using namespace iflytop;
static QueueHandle_t xQueue;
static int popInfoNum;
static bool loadingState;
static const char* loadingInfo = "";
static zmutex lock = {"UIPublicState-Lock"};
#define TAG "UIPublicState"
@ -42,7 +43,20 @@ bool UIPublicState::popUIPopInfoBlock(UIPopInfo_t* info) {
int UIPublicState::getPopInfoNum() { return popInfoNum; }
bool UIPublicState::setLoadingState(bool state) { loadingState = state;
return true;
bool UIPublicState::setLoadingState(bool state, const char* info) {
zlock_guard guard(lock);
loadingState = state;
loadingInfo = info;
if (!state) {
loadingInfo = "";
}
return true;
}
bool UIPublicState::getLoadingState() {
zlock_guard guard(lock);
return loadingState;
}
const char* UIPublicState::getLoadingInfo() {
zlock_guard guard(lock);
return loadingInfo;
}
bool UIPublicState::getLoadingState() { return loadingState; }

5
usrc/uicontroler/base/ui_state.hpp

@ -24,7 +24,8 @@ class UIPublicState {
static bool popUIPopInfoBlock(UIPopInfo_t* info);
static int getPopInfoNum();
static bool setLoadingState(bool state);
static bool getLoadingState();
static bool setLoadingState(bool state, const char* info);
static bool getLoadingState();
static const char* getLoadingInfo() ;
};
} // namespace iflytop

6
usrc/uicontroler/event_proceesser/sys_event_page_id_processer.cpp

@ -13,8 +13,8 @@ void SysEventPageIdProcesser::process(uint8_t* indata, size_t len, UIEvent* resu
if (UIStateMgr::ins()->nowPage == indata[1]) {
// page not change
} else {
UIStateMgr::ins()->lastPage = UIStateMgr::ins()->nowPage;
UIStateMgr::ins()->nowPage = indata[1];
ZLOGI(TAG, "page change from %d to %d ", UIStateMgr::ins()->lastPage, UIStateMgr::ins()->nowPage);
// UIStateMgr::ins()->lastPage = UIStateMgr::ins()->nowPage;
// UIStateMgr::ins()->nowPage = indata[1];
// ZLOGI(TAG, "page change from %d to %d ", UIStateMgr::ins()->lastPage, UIStateMgr::ins()->nowPage);
}
}

1
usrc/uicontroler/page/home_page.cpp

@ -82,7 +82,6 @@ class HomePage : public IPageProcesser {
}
virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override {
ZLOGI(TAG, "OnButton bid:%d val:%d", bid, val);
if (PumpCtrlService::ins()->isWorking()) {
UIS->popWarningWin("工作中,请稍后再操作");
return;

34
usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp

@ -116,8 +116,7 @@ class MuAcidDistMgrPage : public IPageProcesser {
return;
}
{
UILoadingCxt ctx;
UIControler::ins()->doBlockWork("添加记录中...", [this]() {
acid_distrubt_record_t record;
AppHal::rtc_get(&record.date);
record.distrubtAcidUsrid = GStateMgr::ins()->getUserId();
@ -130,7 +129,7 @@ class MuAcidDistMgrPage : public IPageProcesser {
GStateMgr::ins()->setAcidRemain(m_chId, m_volumeVal);
AppEventBus::ins()->pushAcidStatStorageEvent(m_chId, m_volumeVal);
resetForm();
}
});
}
/***********************************************************************************************************************
@ -140,15 +139,16 @@ class MuAcidDistMgrPage : public IPageProcesser {
if (bid == ob_muAcidDistMgr_clearRecord) {
UIControler::ins()->popConfirmWin("您确定要清空领酸记录?", [this](bool isOk) {
if (isOk) {
UILoadingCxt loadingCxt;
AcidDistrubtRecordDao::clearRecord();
resetForm();
updateTableVolume();
UIControler::ins()->doBlockWork("清空领酸记录...", [this]() {
AcidDistrubtRecordDao::clearRecord();
UIControler::ins()->chpage(thisPage, true);
});
}
});
}
if (bid == ob_muAcidDistMgr_export) {
UIControler::ins()->doBlockWork("导出数据...", [this]() { doExportData(); });
}
}
virtual void onInputFieldContentChange(uint8_t bid, uint8_t slecId, const char* text) override {
@ -238,11 +238,16 @@ class MuAcidDistMgrPage : public IPageProcesser {
AppHal::rtc_get(&date);
auto* table = AcidDistrubtRecordDao::getRecordTable();
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "挂载U盘...");
osDelay(300);
ZUSBFileOperator::mount();
CHECK_USB_FILE_OPERATION();
// ZUSBFileOperator::openNew("%04d%02d%02d%02d%02d%02d_ACID_DIST_RECORD.csv", date.year, date.month, date.day, date.hours, date.minutes, date.seconds);
ZUSBFileOperator::openNew("ACID_DIST_RECORD.csv");
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "创建文件...");
osDelay(300);
// https://www.jyshare.com/front-end/3602/
// ZUSBFileOperator::openNew("\u9886\u9178\u8bb0\u5f55.csv");
ZUSBFileOperator::openNew("1.csv");
CHECK_USB_FILE_OPERATION();
ZUSBFileOperator::write("ID,时间,发放人,领酸人,酸液名称,容量\n");
@ -251,10 +256,11 @@ class MuAcidDistMgrPage : public IPageProcesser {
for (int i = 0; i < table->recordNum; i++) {
auto* record = &table->record[i];
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "导出记录(%d/%d)...", i + 1, table->recordNum);
osDelay(3);
ZUSBFileOperator::write( //
"%d,%d/%d/%d %02d:%02d:%02d,%s,%s,%s,%d\n", //
record->id, //
"%d/%d/%d %02d:%02d:%02d,%s,%s,%s,%d\n", //
record->date.year, record->date.month, record->date.day, record->date.hours, record->date.minutes, record->date.seconds, //
UserDao::getUserByIdNotNull(record->distrubtAcidUsrid)->name, //
UserDao::getUserByIdNotNull(record->takeAcidUsrid)->name, //
@ -262,12 +268,18 @@ class MuAcidDistMgrPage : public IPageProcesser {
record->distribuVolume);
CHECK_USB_FILE_OPERATION();
}
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "关闭文件...");
osDelay(300);
ZUSBFileOperator::close();
CHECK_USB_FILE_OPERATION();
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "卸载U盘...");
osDelay(300);
ZUSBFileOperator::unmount();
CHECK_USB_FILE_OPERATION();
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "导出完成");
osDelay(300);
}
};

40
usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp

@ -73,15 +73,16 @@ class MuAcidUseMgrPage : public IPageProcesser {
if (bid == ob_muAcidUseRecd_clearRecord) {
UIControler::ins()->popConfirmWin("您是否确定要清空用酸记录?", [this](bool isOk) {
if (isOk) {
UILoadingCxt loadingCxt;
AcidUseRecordDao::clearRecord();
initPage();
UIControler::ins()->doBlockWork("清空记录中....", [this]() {
AcidUseRecordDao::clearRecord();
UIControler::ins()->chpage(thisPage, true);
});
}
});
}
else if (bid == ob_muAcidUseRecd_export) {
doExportData();
UIControler::ins()->doBlockWork("导出数据...", [this]() { doExportData(); });
}
}
virtual void onInputFieldContentChange(uint8_t bid, uint8_t slecId, const char* text) override {}
@ -99,17 +100,12 @@ class MuAcidUseMgrPage : public IPageProcesser {
AcidUseRcordPage page;
AcidUseRecordDao::getRecord(0, &page);
for (int i = 0; i < page.recordNum; i++) {
if (i == 0) {
// 最新一条记录属于当前登录用户的实时状态,不显示
continue;
}
setText(cfgbid_table[i + 1].val[0], "%d/%d/%d %02d:%02d:%02d", page.record[i]->date.year, page.record[i]->date.month, page.record[i]->date.day, page.record[i]->date.hours, page.record[i]->date.minutes, page.record[i]->date.seconds);
setText(cfgbid_table[i + 1].val[1], "%s(%s)", UserDao::getUserByIdNotNull(page.record[i]->usrid)->name, page.record[i]->dirty ? "*" : "");
setText(cfgbid_table[i + 1].val[2], "%.1f", page.record[i]->ch0take0p1ml / 10.0);
setText(cfgbid_table[i + 1].val[3], "%.1f", page.record[i]->ch0take0p1ml / 10.0);
setText(cfgbid_table[i + 1].val[4], "%.1f", page.record[i]->ch0take0p1ml / 10.0);
setText(cfgbid_table[i + 1].val[5], "%.1f", page.record[i]->ch0take0p1ml / 10.0);
setText(cfgbid_table[i + 1].val[3], "%.1f", page.record[i]->ch1take0p1ml / 10.0);
setText(cfgbid_table[i + 1].val[4], "%.1f", page.record[i]->ch2take0p1ml / 10.0);
setText(cfgbid_table[i + 1].val[5], "%.1f", page.record[i]->ch3take0p1ml / 10.0);
}
for (int i = page.recordNum; i < 8; i++) {
@ -135,11 +131,16 @@ class MuAcidUseMgrPage : public IPageProcesser {
AppHal::rtc_get(&date);
auto* table = AcidUseRecordDao::getRecordTable();
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "挂载U盘...");
osDelay(300);
ZUSBFileOperator::mount();
CHECK_USB_FILE_OPERATION();
// ZUSBFileOperator::openNew("%04d%02d%02d%02d%02d%02d_ACID_USAGE_RECORD.csv", date.year, date.month, date.day, date.hours, date.minutes, date.seconds);
ZUSBFileOperator::openNew("ACID_USAGE_RECORD.csv", date.year, date.month, date.day, date.hours, date.minutes, date.seconds);
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "创建文件...");
// https://www.jyshare.com/front-end/3602/
// ZUSBFileOperator::openNew("\u7528\u9178\u8bb0\u5f55.csv");
ZUSBFileOperator::openNew("0.csv");
CHECK_USB_FILE_OPERATION();
ZUSBFileOperator::write("ID,时间,用户,正常退出,%s(ml),%s(ml),%s(ml),%s(ml)\n", AcidChCfgDao::getCfg(0)->acidChooseName, AcidChCfgDao::getCfg(1)->acidChooseName, AcidChCfgDao::getCfg(2)->acidChooseName, AcidChCfgDao::getCfg(3)->acidChooseName);
@ -152,22 +153,29 @@ class MuAcidUseMgrPage : public IPageProcesser {
// 最后一条记录属于当前登录用户的实时状态,不导出
break;
}
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "导出记录(%d/%d)...", i + 1, table->recordNum);
osDelay(3);
ZUSBFileOperator::write( //
"%d,%d/%d/%d %02d:%02d:%02d,%s,%s,%.2f,%.2f,%.2f,%.2f\n", //
record->id, //
"%d/%d/%d %02d:%02d:%02d,%s,%s,%.2f,%.2f,%.2f,%.2f\n", //
record->date.year, record->date.month, record->date.day, record->date.hours, record->date.minutes, record->date.seconds, //
UserDao::getUserByIdNotNull(record->usrid)->name, //
record->dirty ? "0" : "1", //
record->ch0take0p1ml / 10.0, record->ch1take0p1ml / 10.0, record->ch2take0p1ml / 10.0, record->ch3take0p1ml / 10.0);
CHECK_USB_FILE_OPERATION();
}
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "关闭文件...");
osDelay(300);
ZUSBFileOperator::close();
CHECK_USB_FILE_OPERATION();
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "卸载U盘...");
osDelay(300);
ZUSBFileOperator::unmount();
CHECK_USB_FILE_OPERATION();
UIControler::ins()->setTxt(pg_popwin, ob_popwin_loadingText, "导出完成");
osDelay(300);
}
};

3
usrc/uicontroler/page/mupage/muDateMgr_page.cpp

@ -6,6 +6,7 @@
//
#include "db/dao/acid_ch_cfg_dao.hpp"
#include "db/dao/device_setting_dao.hpp"
#include "usrc/db/dao/acid_use_record_dao.hpp"
//
#include "service/pump_ctrl_service.hpp"
@ -138,6 +139,8 @@ class MuDateMgrPage : public IPageProcesser {
ZLOGI(TAG, "set rtc %d-%d-%d %d:%d", date.year, date.month, date.day, date.hours, date.minutes);
AppHal::rtc_set(&date);
UIControler::ins()->setrtc(&date);
AcidUseRecordDao::updateTheLastRecordDate(&date);
UIControler::ins()->popInfoWin("ʱ¼äÉèÖóɹ¦", [](bool) { UIControler::ins()->chpage(pg_navi, true); });
}
}

6
usrc/uicontroler/page/mupage/muReCtrlerBind_page.cpp

@ -40,7 +40,7 @@ class muReCtrlerBindPage : public IPageProcesser {
if (keyEvent == hand_acid_remoter_kevent_change_next_mode) {
setText(ob_muReCtlerBind_bleEvent, "模式切换");
}
if (keyEvent == hand_acid_remoter_kevent_reflux) { //连按两次为回流事件I
if (keyEvent == hand_acid_remoter_kevent_reflux) { // 连按两次为回流事件I
setText(ob_muReCtlerBind_bleEvent, "液路回流");
}
if (keyEvent == hand_acid_remoter_kevent_preFilling) {
@ -99,9 +99,9 @@ class muReCtrlerBindPage : public IPageProcesser {
if (event->type == kAE_RemoterConnectedEvent) {
ZLOGI(TAG, "ble connect success");
setText(ob_muReCtlerBind_infoWin, "%s", "扫描到设备");
DeviceSettingDao::updateBleClientName(event->getBleName());
DeviceSettingDao::updateBleClientName(GStateMgr::ins()->getRemoterName());
setText(ob_muReCtlerBind_infoWin, "%s", "绑定成功");
setText(ob_muReCtlerBind_bleCliName, "%s", event->getBleName());
setText(ob_muReCtlerBind_bleCliName, "%s", GStateMgr::ins()->getRemoterName());
m_scaning = false;
}
}

97
usrc/uicontroler/page/mupage/muUsrMgr_page.cpp

@ -196,78 +196,75 @@ class MuUsrMgr : public IPageProcesser {
UIControler::ins()->popWarningWin("用户数量已达上限");
return;
}
{
UILoadingCxt cxt; // 进入加载状态
UIControler::ins()->doBlockWork("添加用户...", [this]() {
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);
if (user == nullptr) {
ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId);
UIControler::ins()->popWarningWin("用户不存在");
break;
}
if (user->builtIn) {
ZLOGE(TAG, "user is builtIn ,find by id %d", m_editContext.usrId);
UIControler::ins()->popWarningWin("内置管理员用户不能删除");
break;
}
UserDao::delUser(user->id);
} while (false);
UIControler::ins()->popInfoWin("删除成功");
user_t* user = UserDao::getUserById(m_editContext.usrId);
if (user == nullptr) {
ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId);
UIControler::ins()->popWarningWin("用户不存在");
return;
}
fillUsrStateUICache();
syncUIUsrTableState();
if (user->builtIn) {
ZLOGE(TAG, "user is builtIn ,find by id %d", m_editContext.usrId);
UIControler::ins()->popWarningWin("内置管理员用户不能删除");
return;
}
fillEditContext(-1);
syncEditContext();
UIControler::ins()->doBlockWork("删除用户...", [this, user]() {
UserDao::delUser(user->id);
fillUsrStateUICache();
syncUIUsrTableState();
fillEditContext(-1);
syncEditContext();
});
}
void saveUsr() {
ZLOGI(TAG, "saveUsr");
// 保存
if (m_editContext.editDirty) {
UILoadingCxt cxt; // 进入加载状态
user_t* user = UserDao::getUserById(m_editContext.usrId);
user_t* user = UserDao::getUserById(m_editContext.usrId);
if (user == nullptr) {
ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId);
UIControler::ins()->popWarningWin("用户不存在");
return;
}
if (user == nullptr) {
ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId);
UIControler::ins()->popWarningWin("用户不存在");
return;
}
if (strlen(m_editContext.name) == 0) {
UIControler::ins()->popWarningWin("用户名不能为空");
return;
}
if (!m_editContext.editDirty) {
UIControler::ins()->popInfoWin("用户无修改");
return;
}
if (user->builtIn && !m_editContext.role->isEq(UserRole::admin)) {
UIControler::ins()->popWarningWin("内置管理员用户不能修改普用户类型");
return;
}
if (strlen(m_editContext.name) == 0) {
UIControler::ins()->popWarningWin("用户名不能为空");
return;
}
if (strcmp(m_editContext.name, user->name) != 0) {
if (AcidDistrubtRecordDao::getRecordNum() > 0 || AcidUseRecordDao::getRecordNum() > 1) {
UIControler::ins()->popWarningWin("无法修改用户名,<领酸记录>或<用酸记录>不为空.");
return;
}
if (user->builtIn && !m_editContext.role->isEq(UserRole::admin)) {
UIControler::ins()->popWarningWin("内置管理员用户不能修改普用户类型");
return;
}
if (strcmp(m_editContext.name, user->name) != 0) {
if (AcidDistrubtRecordDao::getRecordNum() > 0 || AcidUseRecordDao::getRecordNum() > 1) {
UIControler::ins()->popWarningWin("无法修改用户名,<领酸记录>或<用酸记录>不为空.");
return;
}
}
UIControler::ins()->doBlockWork("更新用户配置...", [this, user]() {
if (m_editContext.resetPasswd) {
ZLOGI(TAG, "reset passwd");
UserDao::updateUser(user->id, m_editContext.name, DEFAULT_PASSWD, (user_role_t)m_editContext.role->val);
@ -279,9 +276,7 @@ class MuUsrMgr : public IPageProcesser {
syncUIUsrTableState();
syncEditContext();
UIControler::ins()->popInfoWin("保存成功");
} else {
UIControler::ins()->popInfoWin("用户无修改");
}
});
}
/***********************************************************************************************************************

30
usrc/uicontroler/page/navi_page.cpp

@ -45,8 +45,7 @@ static buttton_bid_info m_button_bid_info[] = {
// 用户菜单配置
static muInfoTable_t usrMuInfoTable = //
{
.muInfo = {
{.muInfo = {
{ob_navi_muInterval, pg_muInterval}, // 加酸间隔
{ob_navi_muChangePwd, pg_muChangePasswd}, // 修改密码
{ob_navi_muLoginOut, 0}, // 退出登录
@ -55,8 +54,7 @@ static muInfoTable_t usrMuInfoTable = //
}};
// 库管菜单配置
static muInfoTable_t storeKeeperMuInfoTable = //
{
.muInfo = {
{.muInfo = {
{ob_navi_muChangePwd, pg_muChangePasswd}, // 修改密码
{ob_navi_muAcidTakeMgr, pg_muAcidDistMgr}, // 领酸管理
{ob_navi_muAcidUseRecd, pg_muAcidUseRecd}, // 用酸记录
@ -67,8 +65,7 @@ static muInfoTable_t storeKeeperMuInfoTable = //
}};
// 管理员菜单配置
static muInfoTable_t adminMuInfoTable = //
{
.muInfo = {
{.muInfo = {
{ob_navi_muInterval, pg_muInterval}, // 加酸间隔
{ob_navi_muCHSetting, pg_muCHSetting}, // 通道设置
{ob_navi_muAcidType, pg_muAcidType}, // 酸类型管理
@ -85,7 +82,7 @@ static muInfoTable_t adminMuInfoTable = //
}};
static void initmuInfoTableStrut(muInfoTable_t* table) {
int total = 0;
int total = 0;
for (int i = 0; i < 32; i++) {
if (table->muInfo[i].bid == -1) {
break;
@ -159,19 +156,20 @@ class NaviPage : public IPageProcesser {
if (isMuButton(bid)) {
int buttonIndex = getMuButtonNum(bid);
int muIndex = curMuTable->pageNum * 8 + buttonIndex;
ZLOGI(TAG, "on muButton muIndex=%d ", muIndex);
// ZLOGI(TAG, "on muButton muIndex=%d ", muIndex);
if (buttonIndex < curMuTable->menuTotalNum) {
if (curMuTable->muInfo[muIndex].page != 0) {
UIControler::ins()->chpage(curMuTable->muInfo[muIndex].page, true);
} else {
UILoadingCxt cxt;
StatisticsSyncService::doSyncOnUnLoginOrPowerOff();
osDelay(2000);
if (curMuTable->muInfo[muIndex].bid == ob_navi_powerOff) {
UIControler::ins()->popPowerOffWin("已关机,请关闭设备电源");
} else if (curMuTable->muInfo[muIndex].bid == ob_navi_muLoginOut) {
UIControler::ins()->chpage(pg_login, true);
}
UIControler::ins()->doBlockWork("保存数据中....", [muIndex]() {
StatisticsSyncService::doSyncOnUnLoginOrPowerOff();
osDelay(2000);
if (curMuTable->muInfo[muIndex].bid == ob_navi_powerOff) {
UIControler::ins()->popPowerOffWin("已关机,请关闭设备电源");
} else if (curMuTable->muInfo[muIndex].bid == ob_navi_muLoginOut) {
UIControler::ins()->chpage(pg_login, true);
}
});
}
}
}

51
usrc/uicontroler/page/popwin_page.cpp

@ -30,7 +30,7 @@ class PopWinPage : public IPageProcesser {
IPageProcesser::initialize();
syncState();
thread.init("PopWinPage", 512);
thread.init("PopWinPage", 1024);
thread.start([this]() {
while (true) {
//
@ -42,8 +42,8 @@ class PopWinPage : public IPageProcesser {
osDelay(100);
if (!UIPublicState::getLoadingState()) {
handupInfoFlag = false;
ZLOGI(TAG, "loading exit");
}
ZLOGI(TAG, "loading exit");
}
continue;
}
@ -51,15 +51,15 @@ class PopWinPage : public IPageProcesser {
if (UIPublicState::getPopInfoNum() != 0) {
if (UIPublicState::popUIPopInfoBlock(&hangupInfo)) {
ZLOGI(TAG, "PopWinPage info:%s", hangupInfo.info);
visPopWin(true);
visLoadingWin(false);
visPopWin(false);
visLoadingWin(false, "loading...");
initPopWindowsInfo(&hangupInfo);
changePage(kInfoWin);
}
} else if (UIPublicState::getLoadingState()) {
ZLOGI(TAG, "PopWinPage loading");
visPopWin(false);
visLoadingWin(true);
visLoadingWin(true, UIPublicState::getLoadingInfo());
changePage(kLoadingWin);
}
@ -93,8 +93,9 @@ class PopWinPage : public IPageProcesser {
visEx(ob_popwin_confirmkey, state);
}
void visLoadingWin(bool state) {
void visLoadingWin(bool state, const char* txt) {
visEx(ob_popwin_loadingWin, state);
UIControler::ins()->setTxt(thisPage, ob_popwin_loadingText, txt);
visEx(ob_popwin_loadingText, state);
}
@ -108,11 +109,14 @@ class PopWinPage : public IPageProcesser {
function<void(bool)> onConfirm = hangupInfo.onConfirm;
if (bid == ob_popwin_canclekey) {
if (hangupInfo.onConfirm) {
AppEventBus::ins()->callFnInEventBus([onConfirm]() { onConfirm(false); });
// AppEventBus::ins()->callFnInEventBus("ON_CONFIRM", [onConfirm]() { onConfirm(false); });
// AppEventBus::ins()->callFnInEventBus("ON_CONFIRM", [onConfirm]() {});
onConfirm(false);
}
} else if (bid == ob_popwin_confirmkey) {
if (hangupInfo.onConfirm) {
AppEventBus::ins()->callFnInEventBus([onConfirm]() { onConfirm(true); });
// AppEventBus::ins()->callFnInEventBus("ON_CONFIRM", [onConfirm]() {});
onConfirm(true);
}
}
handupInfoFlag = false;
@ -152,10 +156,12 @@ class PopWinPage : public IPageProcesser {
UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info);
UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 0 /*黑色*/);
visEx(ob_popwin_canclekey, 0);
if (info->type == UI_POP_WIN_TYPE_POWER_OFF_INFO) {
visEx(ob_popwin_confirmkey, 0);
}
visEx(ob_popwin_popWin, true);
visEx(ob_popwin_popTil, true);
visEx(ob_popwin_info, true);
visEx(ob_popwin_canclekey, false);
visEx(ob_popwin_confirmkey, info->type != UI_POP_WIN_TYPE_POWER_OFF_INFO);
}
else if (info->type == UI_POP_WIN_TYPE_WARNING_INFO) {
@ -165,8 +171,12 @@ class PopWinPage : public IPageProcesser {
UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info);
UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 63488 /*红色*/);
visEx(ob_popwin_canclekey, 0);
visPopWin(true);
visEx(ob_popwin_popWin, true);
visEx(ob_popwin_popTil, true);
visEx(ob_popwin_info, true);
visEx(ob_popwin_canclekey, false);
visEx(ob_popwin_confirmkey, true);
} else if (info->type == UI_POP_WIN_TYPE_CONFIRM) {
// 确认(可被取消)
@ -176,7 +186,11 @@ class PopWinPage : public IPageProcesser {
UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info);
UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 0 /*黑色*/);
visEx(ob_popwin_canclekey, 1);
visEx(ob_popwin_popWin, true);
visEx(ob_popwin_popTil, true);
visEx(ob_popwin_info, true);
visEx(ob_popwin_canclekey, true);
visEx(ob_popwin_confirmkey, true);
} else if (info->type == UI_POP_WIN_TYPE_FATAL_ERROR) {
// 警告消息
updateTitle(info->type, displayNum);
@ -185,8 +199,11 @@ class PopWinPage : public IPageProcesser {
UIControler::ins()->setTxt(thisPage, ob_popwin_info, info->info);
UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", thisPage, ob_popwin_info, 63488 /*红色*/);
visEx(ob_popwin_canclekey, 0);
visEx(ob_popwin_confirmkey, 0);
visEx(ob_popwin_popWin, true);
visEx(ob_popwin_popTil, true);
visEx(ob_popwin_info, true);
visEx(ob_popwin_canclekey, false);
visEx(ob_popwin_confirmkey, false);
}
}

19
usrc/uicontroler/ui_controler.cpp

@ -18,6 +18,7 @@ using namespace iflytop;
static ZThread uart_rx_thread;
static ZThread rx_processed_thread;
static ZThread ui_block_work_thread;
static ZQueue<tjc_rx_packet_t> ackQueue;
static ZQueue<tjc_rx_packet_t> eventQueue;
@ -25,6 +26,7 @@ static ZThread usartRxThread;
static ZThread eventProcessThread;
static bool m_isWaitingForAck;
static UART_HandleTypeDef* tjcUart;
static UIEvent event_cache;
/***********************************************************************************************************************
* UTILS *
@ -45,12 +47,21 @@ __weak void UIControlerHock_PageInit() {}
/***********************************************************************************************************************
* FUNC *
***********************************************************************************************************************/
void UIControler::doBlockWork(const char* blockmask, function<void()> fn) {
ui_block_work_thread.start([fn, blockmask]() {
UIPublicState::setLoadingState(true, blockmask);
osDelay(10);
fn();
UIPublicState::setLoadingState(false, "");
});
}
void UIControler::postInitialize() {
ackQueue.initialize(5, sizeof(tjc_rx_packet_t));
eventQueue.initialize(5, sizeof(tjc_rx_packet_t));
usartRxThread.init("usartRxThread", 1024);
eventProcessThread.init("eventProcessThread", 1024);
usartRxThread.init("UI_RX", 512);
eventProcessThread.init("UI_RX_PROCESS", 1024);
ui_block_work_thread.init("UI_WORK", 1024);
tjcUart = AppHardware::ins()->tjcUart;
UIPublicState::initialize();
m_cmdlock.init();
@ -70,7 +81,7 @@ void UIControler::callUsrEventCb(UIEvent* event) {
appEvent.type = KAE_UIEvent;
appEvent.setUIEvent(event);
AppEventBus::ins()->pushEventBlock(&appEvent);
AppEventBus::ins()->pushEventBlock("UIEvent", &appEvent);
}
void UIControler::startSchedule() {
@ -118,7 +129,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);
// ZLOGI(TAG, "push event %s(%d) ", tjc::pt2str(event_cache.eventId), event_cache.eventId);
callUsrEventCb(&event_cache);
}
osDelay(1);

15
usrc/uicontroler/ui_controler.hpp

@ -23,7 +23,6 @@ class UIControler {
tjc_rx_packet_t ackcache;
zmutex m_cmdlock = {"UI_LOCK"};
UIEvent event_cache;
public:
UIControler() {};
@ -87,13 +86,6 @@ class UIControler {
void popInfoWin(const char* info, function<void(bool)> onConfirm = nullptr) { popWin(UI_POP_WIN_TYPE_INFO, info, onConfirm); }
void popPowerOffWin(const char* info) { popWin(UI_POP_WIN_TYPE_POWER_OFF_INFO, info, nullptr); }
void setLoadingState(bool state) {
{
zlock_guard lg(m_cmdlock);
UIPublicState::setLoadingState(state);
}
if (state) osDelay(10);
}
void doInUILockArea(function<void()> fn) {
zlock_guard lg(m_cmdlock);
@ -121,6 +113,8 @@ class UIControler {
bool movePicTo(uint8_t pid, uint8_t bid, uint8_t toBid);
bool movePicOutOfScreen(uint8_t pid, uint8_t bid);
void doBlockWork(const char* blockmask, function<void()> fn) ;
private:
void processScreenRxPacket(uint8_t* data, size_t len);
@ -136,10 +130,5 @@ class UIControler {
void placeHolder() {}
};
class UILoadingCxt {
public:
UILoadingCxt() { UIControler::ins()->setLoadingState(true); }
~UILoadingCxt() { UIControler::ins()->setLoadingState(false); }
};
} // namespace iflytop

2
usrc/uicontroler/ui_state_mgr.cpp

@ -54,6 +54,6 @@ void UIStateMgr::changePage(int toPage) {
} else {
lastPage = nowPage;
nowPage = toPage;
ZLOGI(TAG, "page change from %d to %d ", lastPage, nowPage);
// ZLOGI(TAG, "page change from %d to %d ", lastPage, nowPage);
}
}
Loading…
Cancel
Save