From 0a3a107147d6edab374d91b8ca8102dda0b209ea Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 28 Nov 2024 14:02:46 +0800 Subject: [PATCH] update --- uappbase/bean/appevent.hpp | 2 + uappbase/bean/appevent_type.hpp | 32 ++++++++- uappbase/bean/dbtype/acid_channel_cfg.hpp | 2 +- uappbase/bean/dbtype/acid_use_record.hpp | 8 +-- uappbase/service/app_event_bus.cpp | 33 ++++++++- uappbase/service/app_event_bus.hpp | 14 ++-- uappbase/service/gstate_mgr.cpp | 30 ++++---- uappbase/service/gstate_mgr.hpp | 82 ++++++++++++++++------ usrc/db/dao/acid_distrubt_record_dao.hpp | 2 +- usrc/db/dao/acid_use_record_dao.cpp | 4 +- usrc/db/dao/acid_use_record_dao.hpp | 2 +- usrc/service/pump_ctrl_service.cpp | 11 ++- usrc/service/remote_controler_event_processer.cpp | 57 ++++++++++----- .../event_proceesser/button_event_processer.cpp | 2 +- usrc/uicontroler/page/home_page.cpp | 25 +++++-- usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp | 12 ++++ usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp | 16 ++--- usrc/uicontroler/page/mupage/muCHSetting_page.cpp | 6 ++ usrc/uicontroler/tjc/ui_event.h | 14 +--- usrc/uicontroler/ui_controler.cpp | 12 +++- usrc/uicontroler/ui_controler.hpp | 2 +- 21 files changed, 262 insertions(+), 106 deletions(-) diff --git a/uappbase/bean/appevent.hpp b/uappbase/bean/appevent.hpp index 090d139..8084987 100644 --- a/uappbase/bean/appevent.hpp +++ b/uappbase/bean/appevent.hpp @@ -42,4 +42,6 @@ class AppEvent { void setOnFnc(std::function fnc) { onfnc = fnc; } int getBufSize() { return sizeof(buf); } + + AcidStateChangeEvent_t* getAcidStateChangeEvent() { return (AcidStateChangeEvent_t*)buf; } }; diff --git a/uappbase/bean/appevent_type.hpp b/uappbase/bean/appevent_type.hpp index f4b822f..f193df9 100644 --- a/uappbase/bean/appevent_type.hpp +++ b/uappbase/bean/appevent_type.hpp @@ -1,5 +1,8 @@ #pragma once #include + + + enum AppEventType { KAE_callOnAppEventBusLoop, @@ -14,8 +17,33 @@ enum AppEventType { kAE_unLoginEvent, KAE_PageChangeEvent, - kAE_AcidStatChangeEvent, // 统计数据变化事件 kAE_RemoterConnectedEvent, // 遥控器连接成功 kAE_RemoterDisConnectedEvent, // 遥控器断开连接 + + /** + * @brief 统计数据变化事件 + */ + kAE_AcidStatDisplayChangeEvent, // 统计数据显示数值变化 + kAE_AcidStatChangeEvent, // 使用 +}; + +enum AcidStatChangeEventType { + kACID_USE, + kACID_STORAGE, }; -typedef enum AppEventType AppEventType_t; + +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; diff --git a/uappbase/bean/dbtype/acid_channel_cfg.hpp b/uappbase/bean/dbtype/acid_channel_cfg.hpp index 0203f39..0e21cf8 100644 --- a/uappbase/bean/dbtype/acid_channel_cfg.hpp +++ b/uappbase/bean/dbtype/acid_channel_cfg.hpp @@ -8,7 +8,7 @@ typedef struct { // 基础参数 char acidChooseName[MAX_ACID_NAME_LENGTH]; // 酸液0 选择的名字 - float acidEachDistriVal; // 酸液0 distribution + float acidEachDistriVal; // 酸液0 distribution ml uint16_t pumpDefVel; // 泵机默认速度r/min RPM float pipeLengthML; // 酸液管路长度 float chAppendMl; // 通道每次小回流的液体长度 diff --git a/uappbase/bean/dbtype/acid_use_record.hpp b/uappbase/bean/dbtype/acid_use_record.hpp index 4349175..12818e4 100644 --- a/uappbase/bean/dbtype/acid_use_record.hpp +++ b/uappbase/bean/dbtype/acid_use_record.hpp @@ -9,10 +9,10 @@ typedef struct { zdate_t date; uint8_t usrid; - uint16_t ch0take; // 0.1ml - uint16_t ch1take; // 0.1ml - uint16_t ch2take; // 0.1ml - uint16_t ch3take; // 0.1ml + uint16_t ch0take0p1ml; // 0.1ml + uint16_t ch1take0p1ml; // 0.1ml + uint16_t ch2take0p1ml; // 0.1ml + uint16_t ch3take0p1ml; // 0.1ml } acid_use_record_t; } // namespace iflytop diff --git a/uappbase/service/app_event_bus.cpp b/uappbase/service/app_event_bus.cpp index d48e981..5473e7c 100644 --- a/uappbase/service/app_event_bus.cpp +++ b/uappbase/service/app_event_bus.cpp @@ -1,6 +1,8 @@ #include "app_event_bus.hpp" - +extern "C" { #include "cmsis_os.h" +} + using namespace iflytop; using namespace std; static QueueHandle_t xQueue; @@ -10,7 +12,9 @@ static AppEvent eventtxcache; void AppEventBus::initialize() { lock.init(); thread.init("AppEventBus", 1024); - xQueue = xQueueCreate(20, sizeof(AppEvent)); + int AppEventSize = sizeof(AppEvent); + + xQueue = xQueueCreate(20, AppEventSize); thread.start([this]() { static AppEvent eventrxcache; @@ -67,7 +71,30 @@ void AppEventBus::callFnInEventBus(function onfnc) { void AppEventBus::pushStateDisplayInfoEvent(const char* info) { zlock_guard lck(lock); eventtxcache.type = kAppEvent_StateDisplayInfo; - // strncpy(event.getStateDisplayInfo(), info, event.getBufSize()); eventtxcache.setStateDisplayInfo(info); pushEvent(eventtxcache); } + +void AppEventBus::pushAcidStatStorageEvent(uint8_t ch, float chVal) { + zlock_guard lck(lock); + eventtxcache.type = kAE_AcidStatChangeEvent; + eventtxcache.getAcidStateChangeEvent()->subtype = kACID_STORAGE; + eventtxcache.getAcidStateChangeEvent()->addCh = ch; + eventtxcache.getAcidStateChangeEvent()->addChVal = chVal; + pushEvent(eventtxcache); +} +void AppEventBus::pushAcidStatDisplayChangeEvent() { + zlock_guard lck(lock); + eventtxcache.type = kAE_AcidStatDisplayChangeEvent; + pushEvent(eventtxcache); +} +void AppEventBus::pushAcidStatUseEvent(float ch1, float ch2, float ch3, float ch4) { + zlock_guard lck(lock); + eventtxcache.type = kAE_AcidStatChangeEvent; + eventtxcache.getAcidStateChangeEvent()->subtype = kACID_USE; + eventtxcache.getAcidStateChangeEvent()->useVal[0] = ch1; + eventtxcache.getAcidStateChangeEvent()->useVal[1] = ch2; + eventtxcache.getAcidStateChangeEvent()->useVal[2] = ch3; + eventtxcache.getAcidStateChangeEvent()->useVal[3] = ch4; + pushEvent(eventtxcache); +} \ No newline at end of file diff --git a/uappbase/service/app_event_bus.hpp b/uappbase/service/app_event_bus.hpp index fce9694..9b3889b 100644 --- a/uappbase/service/app_event_bus.hpp +++ b/uappbase/service/app_event_bus.hpp @@ -1,7 +1,9 @@ #pragma once -#include "../appdep.hpp" -#include "uappbase/appcfg/appcfg.hpp" -#include "uappbase/bean/bean.hpp" + +#include "stm32basic\mutex.hpp" +#include "stm32basic\zthread.hpp" +#include "uappbase\bean\appevent.hpp" + // namespace iflytop { @@ -30,7 +32,11 @@ class AppEventBus { void pushPageChangeEvent(uint8_t toPage); void callFnInEventBus(function onfnc); - void pushStateDisplayInfoEvent(const char* info) ; + void pushStateDisplayInfoEvent(const char* info); + + void pushAcidStatUseEvent(float ch1, float ch2, float ch3, float ch4); + void pushAcidStatStorageEvent(uint8_t ch, float chVal); + void pushAcidStatDisplayChangeEvent(); }; } // namespace iflytop diff --git a/uappbase/service/gstate_mgr.cpp b/uappbase/service/gstate_mgr.cpp index ca7dd2b..0a3b4a4 100644 --- a/uappbase/service/gstate_mgr.cpp +++ b/uappbase/service/gstate_mgr.cpp @@ -46,14 +46,10 @@ int GStateMgr::getUserId() { // -void GStateMgr::setAcidState(int32_t state) { - zlock_guard l(m_mutex); - m_AcidState = state; -} void GStateMgr::setRemoterS(int32_t state, const char* name) { zlock_guard l(m_mutex); - AppEvent appevent; + AppEvent appevent; m_RemoterS = state; if (state) { @@ -86,10 +82,6 @@ void GStateMgr::changeToNextRunMode() { } } -int32_t GStateMgr::getAcidState() { - zlock_guard l(m_mutex); - return m_AcidState; -} int32_t GStateMgr::getRemoterS() { zlock_guard l(m_mutex); return m_RemoterS; @@ -101,11 +93,11 @@ hand_acid_mode_t GStateMgr::getRunMode() { void GStateMgr::setPumpSelectState(int32_t index, bool state) { zlock_guard l(m_mutex); - pumpSelectState[index] = state; + m_pumpSelectState[index] = state; } bool GStateMgr::getPumpSelectState(int32_t index) { zlock_guard l(m_mutex); - return pumpSelectState[index]; + return m_pumpSelectState[index]; } void GStateMgr::resetAcidUsed() { @@ -131,20 +123,22 @@ float GStateMgr::getAcidRemain(int32_t index) { zlock_guard l(m_mutex); return acidRemain[index]; // add 0.5 for force change to int } -void GStateMgr::decreaseAcidRemain(int32_t index, float val) { - zlock_guard l(m_mutex); - acidRemain[index] -= val; -} bool GStateMgr::isHasPumpSelect() { zlock_guard l(m_mutex); for (int i = 0; i < 4; i++) { - if (pumpSelectState[i]) { + if (m_pumpSelectState[i]) { return true; } } return false; } -void GStateMgr::setMenuPage(int32_t page) { m_menuPage = page; } -int32_t GStateMgr::getMenuPage() { return m_menuPage; } + + + + +void GStateMgr::decreaseAcidRemain(int32_t index, float val) { + zlock_guard l(m_mutex); + acidRemain[index] -= val; +} diff --git a/uappbase/service/gstate_mgr.hpp b/uappbase/service/gstate_mgr.hpp index 35103fb..03b8d40 100644 --- a/uappbase/service/gstate_mgr.hpp +++ b/uappbase/service/gstate_mgr.hpp @@ -13,21 +13,29 @@ using namespace std; class GStateMgr { private: - /* data */ + /** + * @brief 用户状态 + */ char m_loginUsr[MAX_USR_NAME_SIZE + 1]; int m_loginUsrId = -1; user_role_t m_loginUsrType = kuser; bool m_isLogin = false; + /** + * @brief 遥控器状态 + */ int32_t m_RemoterS; // 遥控器状态 1:在线,0:离线 char m_RemoterName[20]; - int32_t m_AcidState; // 酸液桶状态 1:在线,0:离线 - hand_acid_mode_t m_RunMode = khand_acid_m_jog_mode; // 运行模式 - int32_t m_menuPage = 0; - - bool pumpSelectState[CH_NUM] = {false}; + /** + * @brief 设备工作状态 + */ + hand_acid_mode_t m_RunMode = khand_acid_m_jog_mode; // 运行模式 + bool m_pumpSelectState[CH_NUM] = {false}; // 选择的泵 + /** + * @brief 统计数据 + */ float acidUsed[CH_NUM] = {0.0}; float acidRemain[CH_NUM] = {0.0}; @@ -41,40 +49,70 @@ class GStateMgr { void initialize(); - // loginUsrState + /** + * @brief 用户状态 + */ + void setLogin(int loginUsrId, const char* usrName, user_role_t role); void setUnLogin(); bool isLogin(); user_role_t getLoginUsrType(); const char* getLoginUsr(); - int getUserId(); + int getUserId(); + + /** + * @brief 遥控器状态 + */ - // - void setAcidState(int32_t state); void setRemoterS(int32_t state, const char* name); + + /** + * @brief 设备工作状态 + */ void setRunMode(hand_acid_mode_t mode); void changeToNextRunMode(); + void setPumpSelectState(int32_t index, bool state); - void setMenuPage(int32_t page); - - int32_t getAcidState(); int32_t getRemoterS(); hand_acid_mode_t getRunMode(); - int32_t getMenuPage(); - - bool isHasPumpSelect(); - - void setPumpSelectState(int32_t index, bool state); - bool getPumpSelectState(int32_t index); + bool isHasPumpSelect(); + bool getPumpSelectState(int32_t index); + + /** + * @brief 统计数据 + */ + + /** + * @brief + * + * + * 1.剩余量: + * .补酸时修改 + * .用酸时修改 + * + * 2.使用量: + * .登录时初始化为零 + * .使用时候修改,实时存储 + * .登出时清零,并存储 + * + * 相关数据库 + * .总量 + * .使用记录 + * + * 1. + * + */ + + void initAcidStat(); void resetAcidUsed(); - float getAcidUsed(int32_t index); void appendAcidUsed(int32_t index, float val); - void setAcidRemain(int32_t index, float val); - float getAcidRemain(int32_t index); void decreaseAcidRemain(int32_t index, float val); + + float getAcidUsed(int32_t index); + float getAcidRemain(int32_t index); }; } // namespace iflytop \ No newline at end of file diff --git a/usrc/db/dao/acid_distrubt_record_dao.hpp b/usrc/db/dao/acid_distrubt_record_dao.hpp index ff6199d..979d4c3 100644 --- a/usrc/db/dao/acid_distrubt_record_dao.hpp +++ b/usrc/db/dao/acid_distrubt_record_dao.hpp @@ -21,7 +21,7 @@ typedef struct { uint32_t version; uint32_t maxid; int recordNum; - acid_distrubt_record_t record[ACID_DISTRUBT_RECORD_NUM]; + acid_distrubt_record_t record[ACID_DISTRUBT_RECORD_NUM + 1]; uint32_t end; } acid_distrubt_record_table_t; diff --git a/usrc/db/dao/acid_use_record_dao.cpp b/usrc/db/dao/acid_use_record_dao.cpp index e15b0b5..959cd4c 100644 --- a/usrc/db/dao/acid_use_record_dao.cpp +++ b/usrc/db/dao/acid_use_record_dao.cpp @@ -47,7 +47,7 @@ void AcidUseRecordDao::init() { // ZLOGI(TAG, "record: %d/%d/%d %02d:%02d:%02d %d %d %d %d %d", // // record->date.year, record->date.month, record->date.day, record->date.hours, record->date.minutes, record->date.seconds, // - // record->usrid, record->ch0take, record->ch1take, record->ch2take, record->ch3take); + // record->usrid, record->ch0take0p1ml, record->ch1take0p1ml, record->ch2take0p1ml, record->ch3take0p1ml); // } ZLOGI(TAG, "init success"); @@ -68,7 +68,7 @@ void AcidUseRecordDao::addRecord(const acid_use_record_t& record) { ZLOGI(TAG, "add record %d/%d/%d %02d:%02d:%02d %d %d %d %d %d (%d/%d)", // record.date.year, record.date.month, record.date.day, record.date.hours, record.date.minutes, record.date.seconds, // - record.usrid, record.ch0take, record.ch1take, record.ch2take, record.ch3take, // + record.usrid, record.ch0take0p1ml, record.ch1take0p1ml, record.ch2take0p1ml, record.ch3take0p1ml, // acid_use_record_table->recordNum, ACIDUSERCORD_RECORD_NUM); } diff --git a/usrc/db/dao/acid_use_record_dao.hpp b/usrc/db/dao/acid_use_record_dao.hpp index 8a8ef41..d4e7bfd 100644 --- a/usrc/db/dao/acid_use_record_dao.hpp +++ b/usrc/db/dao/acid_use_record_dao.hpp @@ -21,7 +21,7 @@ typedef struct { uint32_t version; uint32_t maxid; int recordNum; - acid_use_record_t record[ACIDUSERCORD_RECORD_NUM]; + acid_use_record_t record[ACIDUSERCORD_RECORD_NUM + 1]; uint32_t end; } acid_use_record_table_t; diff --git a/usrc/service/pump_ctrl_service.cpp b/usrc/service/pump_ctrl_service.cpp index 3669418..9ab6437 100644 --- a/usrc/service/pump_ctrl_service.cpp +++ b/usrc/service/pump_ctrl_service.cpp @@ -285,15 +285,19 @@ void PumpCtrlService::setCurrentPosAsZero(int32_t mid) { } void PumpCtrlService::doMotorsMoveByOnce() { - int32_t step[MOTOR_NUM] = {0}; + 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; + step[i] = AcidChCfgDao::getCfg(i)->acidEachDistriVal * 1000 + AcidChCfgDao::getCfg(i)->chAppendMl * 1000; + distriVal[i] = AcidChCfgDao::getCfg(i)->acidEachDistriVal; if (!GSM->getPumpSelectState(i)) { - step[i] = 0; + step[i] = 0; + distriVal[i] = 0; } } + AppEventBus::ins()->pushAcidStatUseEvent(distriVal[0], distriVal[1], distriVal[2], distriVal[3]); ZLOGI(TAG, "doMotorsMoveByOnce, moveBy %d %d %d %d", step[0], step[1], step[2], step[3]); moveBy(step[0], step[1], step[2], step[3]); } @@ -339,6 +343,7 @@ void PumpCtrlService::doMotorsLittleRefluxOnce() { step3 = GSM->getPumpSelectState(3) ? step3 : 0; ZLOGI(TAG, "doMotorsLittleRefluxOnce, moveBy %d %d %d %d", step0, step1, step2, step3); + moveBy(step0, step1, step2, step3); } diff --git a/usrc/service/remote_controler_event_processer.cpp b/usrc/service/remote_controler_event_processer.cpp index d320ef0..5d0ec24 100644 --- a/usrc/service/remote_controler_event_processer.cpp +++ b/usrc/service/remote_controler_event_processer.cpp @@ -1,5 +1,6 @@ #include "remote_controler_event_processer.hpp" +#include "db/dao/acid_distrubt_record_dao.hpp" #include "db/dao/device_setting_dao.hpp" // @@ -93,7 +94,43 @@ void RemoteControlerEventProcesser::processKeyEventInHomePage(hand_acid_remoter_ /** * @brief 操作设备 */ - if (keyEvent == hand_acid_remoter_kevent_add_liquid) { + + if (keyEvent == hand_acid_remoter_kevent_change_next_mode) { + /** + * @brief 修改工作模式 + */ + + if (GSM->getRunMode() == khand_acid_m_jog_mode) { + GSM->setRunMode(khand_acid_m_continuous_mode); + } else if (GSM->getRunMode() == khand_acid_m_continuous_mode) { + GSM->setRunMode(khand_acid_m_jog_mode); + } + } else if (keyEvent == hand_acid_remoter_kevent_preFilling) { + /** + * @brief 预充酸液 + */ + + if (AcidDistrubtRecordDao::isFull()) { + UIS->popWarningWin("酸液分配记录已满,请清空后再操作"); + return; + } + + if (!GSM->isHasPumpSelect()) { + UIS->popWarningWin("请至少选中一个通道"); + return; + } + + PUMPCS->acidPrefilling(); + } else if (keyEvent == hand_acid_remoter_kevent_add_liquid) { + /** + * @brief 加液 + */ + + if (AcidDistrubtRecordDao::isFull()) { + UIS->popWarningWin("酸液分配记录已满,请清空后再操作"); + return; + } + // if (!GSM->isHasPumpSelect()) { UIS->popWarningWin("请至少选中一个通道"); @@ -105,23 +142,11 @@ void RemoteControlerEventProcesser::processKeyEventInHomePage(hand_acid_remoter_ } else if (GSM->getRunMode() == khand_acid_m_continuous_mode) { PUMPCS->autoMoveMutiTimes(); } - } else if (keyEvent == hand_acid_remoter_kevent_change_next_mode) { - // 修改工作模式 - if (GSM->getRunMode() == khand_acid_m_jog_mode) { - GSM->setRunMode(khand_acid_m_continuous_mode); - } else if (GSM->getRunMode() == khand_acid_m_continuous_mode) { - GSM->setRunMode(khand_acid_m_jog_mode); - } } else if (keyEvent == hand_acid_remoter_kevent_reflux) { - // 回流 + /** + * @brief 回流 + */ PUMPCS->reflux(); - } else if (keyEvent == hand_acid_remoter_kevent_preFilling) { - // 管路填充 - if (!GSM->isHasPumpSelect()) { - UIS->popWarningWin("请至少选中一个通道"); - return; - } - PUMPCS->acidPrefilling(); } } diff --git a/usrc/uicontroler/event_proceesser/button_event_processer.cpp b/usrc/uicontroler/event_proceesser/button_event_processer.cpp index bc53fc1..faa1e7d 100644 --- a/usrc/uicontroler/event_proceesser/button_event_processer.cpp +++ b/usrc/uicontroler/event_proceesser/button_event_processer.cpp @@ -5,5 +5,5 @@ void ButtonEventProcesser::process(uint8_t* indata, size_t len, UIEvent* result) result->eventId = indata[0]; result->pid = indata[1]; result->bid = indata[2]; - result->butEventType = (button_event_t)indata[3]; + result->butEventType = (jtc_button_event_t)indata[3]; } diff --git a/usrc/uicontroler/page/home_page.cpp b/usrc/uicontroler/page/home_page.cpp index 204ef7a..a72454f 100644 --- a/usrc/uicontroler/page/home_page.cpp +++ b/usrc/uicontroler/page/home_page.cpp @@ -81,8 +81,6 @@ class HomePage : public IPageProcesser { } } - // virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) { return; }; - 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()) { @@ -90,6 +88,23 @@ class HomePage : public IPageProcesser { return; } + /** + * @brief 键盘绑定 + */ + + if (bid == ob_home_acideval0) { + UIControler::ins()->popNumKeyBoard(thisPage, bid, 3, "%.1f", AcidChCfgDao::getCfg(0)->acidEachDistriVal); + } else if (bid == ob_home_acideval1) { + UIControler::ins()->popNumKeyBoard(thisPage, bid, 3, "%.1f", AcidChCfgDao::getCfg(1)->acidEachDistriVal); + } else if (bid == ob_home_acideval2) { + UIControler::ins()->popNumKeyBoard(thisPage, bid, 3, "%.1f", AcidChCfgDao::getCfg(2)->acidEachDistriVal); + } else if (bid == ob_home_acideval3) { + UIControler::ins()->popNumKeyBoard(thisPage, bid, 3, "%.1f", AcidChCfgDao::getCfg(3)->acidEachDistriVal); + } + + /** + * @brief 通道选择 + */ if (bid == ob_home_SelCH0) { setPumpSelectState(0, !GStateMgr::ins()->getPumpSelectState(0)); } else if (bid == ob_home_SelCH1) { @@ -109,12 +124,10 @@ class HomePage : public IPageProcesser { } else if (event->type == kAE_RemoterDisConnectedEvent) { syncBleState(); // 同步蓝牙状态 UIS->setTxt(thisPage, ob_home_sysInfo, "断开手柄连接"); - } else if (event->type == kAE_RunModeChangeEvent) { syncMode(); // 初始化设备模式 UIS->setTxt(thisPage, ob_home_sysInfo, "切换模式"); - - } else if (event->type == kAE_AcidStatChangeEvent) { + } else if (event->type == kAE_AcidStatDisplayChangeEvent) { syncStat(); // 初始化统计数据 } else if (event->type == kAppEvent_StateDisplayInfo) { UIS->setTxt(thisPage, ob_home_sysInfo, event->getStateDisplayInfo()); @@ -192,7 +205,7 @@ class HomePage : public IPageProcesser { UIControler::ins()->setTxt(thisPage, ob_home_RunModeVal, "", DeviceSettingDao::get()->distrIntervalS); } else if (nowMode == khand_acid_m_continuous_mode) { UIControler::ins()->setPicturePicNum(thisPage, ob_home_RunMode, ob_home_RunMode0); - UIControler::ins()->setTxt(thisPage, ob_home_RunModeVal, "%.1f", DeviceSettingDao::get()->distrIntervalS); + UIControler::ins()->setTxt(thisPage, ob_home_RunModeVal, "%.2f", DeviceSettingDao::get()->distrIntervalS); } } diff --git a/usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp b/usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp index 9c1fc4d..61292e5 100644 --- a/usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp +++ b/usrc/uicontroler/page/mupage/MuAcidDistMgrPage.cpp @@ -73,6 +73,12 @@ class MuAcidDistMgrPage : public IPageProcesser { virtual void onChangePageEvent() override { resetForm(); updateTableVolume(); + + if (GStateMgr::ins()->getLoginUsrType() == kadmin) { + visEx(ob_muAcidDistMgr_clearRecord, true); + } else { + visEx(ob_muAcidDistMgr_clearRecord, false); + } } virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override { /*********************************************************************************************************************** @@ -90,6 +96,11 @@ class MuAcidDistMgrPage : public IPageProcesser { } if (bid == ob_muAcidDistMgr_addNew) { + if (AcidDistrubtRecordDao::getRecordNum() >= ACID_DISTRUBT_RECORD_NUM) { + UIControler::ins()->popWarningWin("领酸记录已满,请联系管理员,导出数据后清空,再添加"); + return; + } + if (m_volumeVal <= 0) { UIControler::ins()->popWarningWin("请输入容量"); return; @@ -116,6 +127,7 @@ class MuAcidDistMgrPage : public IPageProcesser { DeviceAcidVolume::updateAcidVolume(m_chId, m_volumeVal); GStateMgr::ins()->setAcidRemain(m_chId, m_volumeVal); + AppEventBus::ins()->pushAcidStatStorageEvent(m_chId, m_volumeVal); resetForm(); } } diff --git a/usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp b/usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp index a0f4085..d822932 100644 --- a/usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp +++ b/usrc/uicontroler/page/mupage/muAcidUseMgr_page.cpp @@ -88,10 +88,10 @@ class MuAcidUseMgrPage : public IPageProcesser { record.date.seconds = 30; record.usrid = 0; - record.ch0take = 100; - record.ch1take = 110; - record.ch2take = 120; - record.ch3take = 130; + record.ch0take0p1ml = 100; + record.ch1take0p1ml = 110; + record.ch2take0p1ml = 120; + record.ch3take0p1ml = 130; AcidUseRecordDao::addRecord(record); } AcidUseRecordDao::sync(); @@ -103,10 +103,10 @@ class MuAcidUseMgrPage : public IPageProcesser { for (int i = 0; i < page.recordNum; i++) { 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", UserDao::getUserByIdNotNull(page.record[i]->usrid)->name); - setText(cfgbid_table[i + 1].val[2], "%.1f", page.record[i]->ch0take / 10.0); - setText(cfgbid_table[i + 1].val[3], "%.1f", page.record[i]->ch0take / 10.0); - setText(cfgbid_table[i + 1].val[4], "%.1f", page.record[i]->ch0take / 10.0); - setText(cfgbid_table[i + 1].val[5], "%.1f", page.record[i]->ch0take / 10.0); + 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); } for (int i = page.recordNum; i < 8; i++) { diff --git a/usrc/uicontroler/page/mupage/muCHSetting_page.cpp b/usrc/uicontroler/page/mupage/muCHSetting_page.cpp index d927be9..99f5d0a 100644 --- a/usrc/uicontroler/page/mupage/muCHSetting_page.cpp +++ b/usrc/uicontroler/page/mupage/muCHSetting_page.cpp @@ -144,6 +144,7 @@ class MuChSetting : public IPageProcesser { UIControler::ins()->popNumKeyBoard(thisPage, bid, 4, fmt(PRECISION, AcidChCfgDao::getCfg(0)->pipeLengthML)); } else if (MLPR_BIND_CFG && bid == MLPR_BIND_CFG->cfgbid) { // 转速转换系数 UIControler::ins()->popNumKeyBoard(thisPage, bid, 4, fmt(PRECISION, AcidChCfgDao::getCfg(0)->mLPR)); + } else if (CH_APPEND_ML_BIND_CFG && bid == CH_APPEND_ML_BIND_CFG->cfgbid) { // 防滴液体积 UIControler::ins()->popNumKeyBoard(thisPage, bid, 4, fmt(PRECISION, AcidChCfgDao::getCfg(0)->chAppendMl)); } @@ -198,6 +199,7 @@ class MuChSetting : public IPageProcesser { return; } AcidChCfgDao::getCfg(m_chId)->irun = setval; + PumpCtrlService::ins()->updateMotorSetting(); setText(bid, "%d", setval); } else if (PUMP_DEF_VEL_BIND_CFG && bid == PUMP_DEF_VEL_BIND_CFG->cfgbid) { /** @@ -209,6 +211,7 @@ class MuChSetting : public IPageProcesser { return; } AcidChCfgDao::getCfg(m_chId)->pumpDefVel = setval; + PumpCtrlService::ins()->updateMotorSetting(); setText(bid, "%d", setval); } else if (PIPE_LENGTH_ML_BIND_CFG && bid == PIPE_LENGTH_ML_BIND_CFG->cfgbid) { /** @@ -220,6 +223,7 @@ class MuChSetting : public IPageProcesser { return; } AcidChCfgDao::getCfg(m_chId)->pipeLengthML = setval; + PumpCtrlService::ins()->updateMotorSetting(); setText(bid, PRECISION, setval); } else if (MLPR_BIND_CFG && bid == MLPR_BIND_CFG->cfgbid) { /** @@ -231,6 +235,7 @@ class MuChSetting : public IPageProcesser { return; } AcidChCfgDao::getCfg(m_chId)->mLPR = setval; + PumpCtrlService::ins()->updateMotorSetting(); setText(bid, PRECISION, setval); } else if (CH_APPEND_ML_BIND_CFG && bid == CH_APPEND_ML_BIND_CFG->cfgbid) { /** @@ -242,6 +247,7 @@ class MuChSetting : public IPageProcesser { return; } AcidChCfgDao::getCfg(m_chId)->chAppendMl = setval; + PumpCtrlService::ins()->updateMotorSetting(); setText(bid, PRECISION, setval); } } diff --git a/usrc/uicontroler/tjc/ui_event.h b/usrc/uicontroler/tjc/ui_event.h index 801ce33..c964466 100644 --- a/usrc/uicontroler/tjc/ui_event.h +++ b/usrc/uicontroler/tjc/ui_event.h @@ -53,19 +53,11 @@ typedef enum { kpt_inputfield_content_selected_change_event = 0xAD, // 跨页面多选框输入事件 kpt_page_back_event = 0xB0, // 回退按键事件 - kpt_usr_def_clik_release_event = 0xB1, // 用户自定义按键释放事件 + kpt_usr_def_clik_release_event = 0xB1 // 用户自定义按键释放事件 } tjc_packet_type_t; -typedef enum { - kbutton_release = 0, - kbutton_press = 1, -} button_event_t; - -typedef enum { - k_button_release_event = 1, - k_input_confirm_event = 2, -} usr_event_type_t; +typedef enum { kbutton_release = 0, kbutton_press = 1 } jtc_button_event_t; typedef struct { int32_t eventId; @@ -73,7 +65,7 @@ typedef struct { uint8_t bid; // content - button_event_t butEventType; // 按键事件类型 + jtc_button_event_t butEventType; // 按键事件类型 int32_t val; // 数值相关 char text[TJC_MAX_PACKET_SIZE]; // 文本相关 } UIEvent; \ No newline at end of file diff --git a/usrc/uicontroler/ui_controler.cpp b/usrc/uicontroler/ui_controler.cpp index 0ec40c6..a61a5d3 100644 --- a/usrc/uicontroler/ui_controler.cpp +++ b/usrc/uicontroler/ui_controler.cpp @@ -482,12 +482,20 @@ void UIControler::popPasswdKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitL chpage(pg_keyPasswd, false); } -void UIControler::popNumKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval) { + + +void UIControler::popNumKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval,...) { zlock_guard lg(m_cmdlock); + static char buf[60]; + va_list args; + va_start(args, initval); + vsnprintf(buf, sizeof(buf), initval, args); + va_end(args); + 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, buf); 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); diff --git a/usrc/uicontroler/ui_controler.hpp b/usrc/uicontroler/ui_controler.hpp index 8ab7185..59153bc 100644 --- a/usrc/uicontroler/ui_controler.hpp +++ b/usrc/uicontroler/ui_controler.hpp @@ -99,7 +99,7 @@ class UIControler { void popFullKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval); void popPasswdKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength); - void popNumKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval); + void popNumKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval,...); void popKeyBMutSel(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char** selectvals); void popKeyBMutSel(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char* selectvals);