diff --git a/README.md b/README.md index 7a81b84..c202f41 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ V101: 3. 修改提示 "泵机" 为 "通道" 4. 修改预充管路,只充满选中管路 +V102: + 1.设备在工作时,禁止离开首页 + 2.设备在工作时,禁止切换模式 ``` @@ -14,10 +17,7 @@ V101: TODO: 1. 输入超过10次错误密码后,弹出提示框,请等待24小时,24小时后,页面将自动切换到恢复出厂设置页面。 2. 添加恢复出厂设置按键,且恢复出厂设置按键按下后,需要根用户二次确认。 - 3. 转换比设置错误可能到只泵机不转 - 4. 设备在工作时,禁止退出首页 - 5. 设备在工作时,首页的任何操作都会停止设备。 ``` diff --git a/uappbase/bean/event.hpp b/uappbase/bean/event.hpp index b068511..15674af 100644 --- a/uappbase/bean/event.hpp +++ b/uappbase/bean/event.hpp @@ -1,5 +1,7 @@ #pragma once #include +#include +#include #include @@ -9,7 +11,7 @@ using namespace std; typedef enum { kAppEvent_RunModeChangeEvent, kAppEvent_RemoterConnectStateChangeEvent, - kAppEvent_PumpWorkStateChangeEvent, + kAppEvent_StateDisplayInfo, kAppEvent_ConfigChangeEvent, kAppEvent_BleConnectEvent, } AppEventType_t; @@ -28,6 +30,7 @@ typedef struct { uint32_t placeholder; config_index_t configIndex; char bleName[20]; + char stateDisplayInfo[30]; } d; } AppEvent_t; @@ -45,4 +48,10 @@ static inline AppEvent_t createConfigChangeEvent(config_index_t index) { return event; } +static inline AppEvent_t createStateDisplayInfoEvent(const char* info) { + AppEvent_t event; + event.type = kAppEvent_StateDisplayInfo; + strncpy(event.d.stateDisplayInfo, info, sizeof(event.d.stateDisplayInfo)); + return event; +} } // namespace iflytop \ No newline at end of file diff --git a/usrc/service/front_end_controler.hpp b/usrc/service/front_end_controler.hpp index c542e8f..c66372c 100644 --- a/usrc/service/front_end_controler.hpp +++ b/usrc/service/front_end_controler.hpp @@ -61,7 +61,6 @@ class FrontEndControler { bool setTxt(uint8_t pid, uint8_t bid, const char* txt, ...); bool setTxt(uint8_t bid, const char* txt) { return setTxt(m_nowPage, bid, txt); } - bool setVal(uint8_t pid, uint8_t bid, int32_t val); bool setVal(uint8_t bid, int32_t val) { return setVal(m_nowPage, bid, val); } @@ -114,4 +113,10 @@ static inline const char* zfmt(const char* fmt, ...) { return buf; } +static inline const char* refmt(const char* fmt, const char* floatval) { + static char buf[128]; + sprintf(buf, fmt, atof(floatval)); + return buf; +} + } // namespace iflytop diff --git a/usrc/service/page/Page_main.cpp b/usrc/service/page/Page_main.cpp index 8bc02b3..7f3aa01 100644 --- a/usrc/service/page/Page_main.cpp +++ b/usrc/service/page/Page_main.cpp @@ -41,7 +41,7 @@ void Page_main::updateRunModeState() { bool Page_main::isBelongThisPage(int page) { return page == PAGE; } -void Page_main::OnPageLoad(OnPageLoadContext*cxt) { +void Page_main::OnPageLoad(OnPageLoadContext* cxt) { // 只有管理员能够修改,酸液通道名称 if (GSM->isAdmin()) { UIS->setTouchEnableState(ob_main_acidname0, 1); @@ -92,10 +92,54 @@ void Page_main::OnAppEvent(AppEvent_t* event) { if (event->type == kAppEvent_RemoterConnectStateChangeEvent) { UIS->setEnumComponentState(PAGE, ob_main_RemoterS, GSM->getRemoterS()); } + + if(event->type == kAppEvent_StateDisplayInfo){ + UIS->setTxt(PAGE, ob_main_sysInfo, event->d.stateDisplayInfo); + } + return; }; void Page_main::OnInputFieldContentChange(uint8_t bid, const char* text) { + /*********************************************************************************************************************** + * 事件过滤 * + ***********************************************************************************************************************/ + if (PumpCtrlService::ins()->isWorking()) { + UIS->alert("工作中,请稍后再操作"); + return; + } + + // 运行间隔设定值 + if (bid == ob_main_RunModeVal) { + float distrIntervalSecond = atof(text); + if (distrIntervalSecond <= 0) { + UIS->alert("酸液间隔时间不能小于0"); + return; + } + if (distrIntervalSecond > 30) { + UIS->alert("酸液间隔时间不能大于30"); + return; + } + } + + // 加酸设定值过滤 + if (bid == ob_main_acideval0 || // + bid == ob_main_acideval1 || // + bid == ob_main_acideval2 || // + bid == ob_main_acideval3) { + float add_ml = atof(text); + if (add_ml < 0.009) { + UIS->alert("设定值不能小于0"); + return; + } else if (add_ml > CS->getInt(kcfg_echDitrUpLi)) { + UIS->alert(fmt("设定值不能大于%d", CS->getInt(kcfg_echDitrUpLi))); + return; + } + } + + /*********************************************************************************************************************** + * 业务逻辑 * + ***********************************************************************************************************************/ // 更新酸液每次分配设定值 if (bid == ob_main_acideval0) { processAcidevalUpdateEvent(bid, text, 0, kcfg_acideval0); @@ -129,21 +173,31 @@ void Page_main::OnInputFieldContentChange(uint8_t bid, const char* text) { // 设置加酸间隔 if (bid == ob_main_RunModeVal) { float distrIntervalSecond = atof(text); - if (distrIntervalSecond <= 0) { - UIS->alert("酸液间隔时间不能小于0"); - return; - } - - if (distrIntervalSecond > 30) { - UIS->alert("酸液间隔时间不能大于30"); - return; - } UIS->setTxt(PAGE, bid, zfmt("%.1f", distrIntervalSecond)); CS->setcfgAndFlush(kcfg_distrInterval, zfmt("%.1f", distrIntervalSecond)); } } void Page_main::OnButton(uint8_t bid, uint8_t val) { + /*********************************************************************************************************************** + * 事件过滤 * + ***********************************************************************************************************************/ + if (bid == ob_main_RunMode || // + bid == ob_main_acidch0 || // + bid == ob_main_acidch1 || // + bid == ob_main_acidch2 || // + bid == ob_main_acidch3 || // + bid == ob_main_MenuButton // + ) { + if (PumpCtrlService::ins()->isWorking()) { + UIS->alert("工作中,请稍后再操作"); + return; + } + } + + /*********************************************************************************************************************** + * 业务逻辑 * + ***********************************************************************************************************************/ if (bid == ob_main_RunMode) { // 切换模式 GSM->changeToNextRunMode(); @@ -169,17 +223,7 @@ void Page_main::OnButton(uint8_t bid, uint8_t val) { } void Page_main::processAcidevalUpdateEvent(uint8_t bid, const char* text, int ch, config_index_t cfgid) { - float add_ml = atof(text); - if (add_ml < 0) { - UIS->alert("设定值不能小于0"); - return; - } else if (add_ml > CS->getInt(kcfg_echDitrUpLi)) { - UIS->alert(fmt("设定值不能大于%d", CS->getInt(kcfg_echDitrUpLi))); - return; - } - char reformattext[20]; - sprintf(reformattext, "%.1f", add_ml); - ZLOGI(TAG, "set acid ch%d:%s", ch, reformattext); - UIS->setTxt(PAGE, bid, reformattext); - CS->setcfgAndFlush(cfgid, reformattext); // + ZLOGI(TAG, "set acid ch%d:%s", ch, text); + UIS->setTxt(PAGE, bid, refmt("%.1f", text)); + CS->setcfgAndFlush(cfgid, refmt("%.1f", text)); } diff --git a/usrc/service/pump_ctrl_service.cpp b/usrc/service/pump_ctrl_service.cpp index 00f19a2..6185628 100644 --- a/usrc/service/pump_ctrl_service.cpp +++ b/usrc/service/pump_ctrl_service.cpp @@ -12,6 +12,8 @@ static TMC51X0* m_motors[4]; static CfgItermCache cfgcache; // #define APPEND_ML 2 +#define PUSH_DIS_INFO(info) AppEventBus::ins()->pushEvent(createStateDisplayInfoEvent(info)) + void PumpCtrlService::initialize() { m_motors[0] = AppHardware::ins()->getPump(0); m_motors[1] = AppHardware::ins()->getPump(1); @@ -92,6 +94,8 @@ void PumpCtrlService::reflux() { ZLOGI(TAG, "reflux"); tryUpdateMotorSetting(); + PUSH_DIS_INFO("开始回流"); + m_thread.start([this]() { unlockAll(); do { @@ -101,12 +105,13 @@ void PumpCtrlService::reflux() { stopAll(); lock(); ZLOGI(TAG, "reflux end"); + PUSH_DIS_INFO("回流结束"); }); } void PumpCtrlService::acidPrefilling() { ZLOGI(TAG, "acidPrefilling"); tryUpdateMotorSetting(); - + PUSH_DIS_INFO("开始预充管路"); m_thread.start([this]() { unlockAll(); do { @@ -120,6 +125,7 @@ void PumpCtrlService::acidPrefilling() { stopAll(); lock(); ZLOGI(TAG, "reflux end"); + PUSH_DIS_INFO("结束预充管路"); }); } @@ -127,7 +133,7 @@ void PumpCtrlService::autoMoveMutiTimes() { // doMoveOnce(); ZLOGI(TAG, "autoMoveMutiTimes"); tryUpdateMotorSetting(); - + PUSH_DIS_INFO("开始自动加液"); m_thread.start([this]() { while (!m_thread.getExitFlag()) { unlock(); @@ -136,17 +142,18 @@ void PumpCtrlService::autoMoveMutiTimes() { doMotorsLittleRefluxOnce(); WAIT_FOR_MOTOR_STOP(); lock(); - m_thread.sleep(getCfgFloat(kcfg_distrInterval) * 1000); + sleep(getCfgFloat(kcfg_distrInterval) * 1000); } stopAll(); lock(); + PUSH_DIS_INFO("停止加液"); }); } void PumpCtrlService::moveOnce() { // doMoveOnce(); ZLOGI(TAG, "moveOnce"); tryUpdateMotorSetting(); - + PUSH_DIS_INFO("加一次液"); m_thread.start([this]() { unlock(); do { @@ -158,6 +165,7 @@ void PumpCtrlService::moveOnce() { stopAll(); lock(); + PUSH_DIS_INFO("停止加液"); }); } @@ -314,3 +322,13 @@ void PumpCtrlService::waitForMotorStop() { } return; } + +void PumpCtrlService::sleep(int32_t ms) { + for (size_t i = 0; i < ms;) { + if (m_thread.getExitFlag()) { + break; + } + osDelay(10); + i += 10; + } +} diff --git a/usrc/service/pump_ctrl_service.hpp b/usrc/service/pump_ctrl_service.hpp index 14f4ffa..d857903 100644 --- a/usrc/service/pump_ctrl_service.hpp +++ b/usrc/service/pump_ctrl_service.hpp @@ -53,6 +53,7 @@ class PumpCtrlService { void stopAll(); bool isAllReachTarget(); void waitForMotorStop(); + void sleep(int32_t ms); }; } // namespace iflytop