Browse Source

update

sunlight
zhaohe 11 months ago
parent
commit
a177160dc4
  1. 6
      uappbase/service/config_index.cpp
  2. 16
      uappbase/service/config_service_utils.cpp
  3. 6
      uappbase/service/config_service_utils.hpp
  4. 3
      usrc/service/front_end_controler.hpp
  5. 2
      usrc/service/page/Page_main.cpp
  6. 110
      usrc/service/page/submenu/Page_muSettings.cpp
  7. 1
      usrc/service/page/submenu/Page_muSettings.hpp
  8. 59
      usrc/service/pump_ctrl_service.cpp
  9. 6
      usrc/service/remote_controler_event_processer.cpp

6
uappbase/service/config_index.cpp

@ -13,7 +13,7 @@ static cfg_iterm_info_t cfg_iterm_infos[] = {
CFG_ITERM(kusr_passwd0, kcfgt_str, USER_DEFAULT_PWD), //
CFG_ITERM(kusr_name1, kcfgt_str, USER1_DEFAULT_NAME), //
CFG_ITERM(kusr_enable1, kcfgt_bool, "true"), //
CFG_ITERM(kusr_enable1, kcfgt_bool, "true"), //
CFG_ITERM(kusr_passwd1, kcfgt_str, USER_DEFAULT_PWD), //
CFG_ITERM(kusr_name2, kcfgt_str, USER2_DEFAULT_NAME), //
@ -79,9 +79,9 @@ static cfg_iterm_info_t cfg_iterm_infos[] = {
* *
***********************************************************************************************************************/
CFG_ITERM(kcfg_lockAcidName, kcfgt_bool, "false"), //
CFG_ITERM(kcfg_echDitrUpLi, kcfgt_int32, "40"), // 每次分配上限设定值 each distri up-limit
CFG_ITERM(kcfg_echDitrUpLi, kcfgt_int32, "99"), // 每次分配上限设定值 each distri up-limit
CFG_ITERM(kcfg_distrInterval, kcfgt_float, "1.5"), // 每次分配间隔时间
CFG_ITERM(kcfg_pumpDefVel, kcfgt_int32, "800"), //
CFG_ITERM(kcfg_pumpDefVel, kcfgt_int32, "300"), //
CFG_ITERM(kcfg_m0irun, kcfgt_int32, "20"), //
CFG_ITERM(kcfg_m1irun, kcfgt_int32, "20"), //

16
uappbase/service/config_service_utils.cpp

@ -1,21 +1,21 @@
#include "config_service_utils.hpp"
namespace iflytop {
int32_t getMotorMLPR(int32_t motorid) {
float getMotorMLPR(int32_t motorid) {
switch (motorid) {
case 0:
return getCfgInt(kcfg_mLPR0);
return getCfgFloat(kcfg_mLPR0);
case 1:
return getCfgInt(kcfg_mLPR1);
return getCfgFloat(kcfg_mLPR1);
case 2:
return getCfgInt(kcfg_mLPR2);
return getCfgFloat(kcfg_mLPR2);
case 3:
return getCfgInt(kcfg_mLPR3);
return getCfgFloat(kcfg_mLPR3);
default:
ZASSERT(0);
return 0;
}
}
void setMotorMLPR(int motorid, int32_t val) {
void setMotorMLPR(int32_t motorid, float val) {
//
switch (motorid) {
case 0:
@ -67,7 +67,9 @@ int32_t setMxIRun(int motorid, int32_t val) {
break;
default:
ZASSERT(0);
return 0;
}
return 0;
}
const char* getPasswd(const char* usrname, CfgItermCache* cache) {
@ -128,4 +130,4 @@ const void setPasswd(const char* usrname, const char* passwd) {
}
}
} // namespace iflytop
} // namespace iflytop

6
uappbase/service/config_service_utils.hpp

@ -1,8 +1,10 @@
#pragma once
#include "config_service.hpp"
namespace iflytop {
int32_t getMotorMLPR(int32_t motorid);
void setMotorMLPR(int32_t motorid, int32_t val);
float getMotorMLPR(int32_t motorid);
void setMotorMLPR(int32_t motorid, float val);
int32_t setMxIRun(int motorid, int32_t val);
int32_t getMxIRun(int motorid);

3
usrc/service/front_end_controler.hpp

@ -61,6 +61,9 @@ class FrontEndControler {
bool setVal(uint8_t pid, uint8_t bid, const char* txt, ...);
bool setVal(uint8_t pid, uint8_t bid, int32_t val);
bool setVal(uint8_t bid, const char* txt) { return setVal(m_nowPage, bid, txt); }
bool setVal(uint8_t bid, int32_t val) { return setVal(m_nowPage, bid, val); }
// bool setVal(uint16_t buuid, const char* txt) { return setVal(buuid >> 8, buuid & 0xff, txt); }
// bool setVal(uint16_t buuid, int32_t val) { return setVal(buuid >> 8, buuid & 0xff, val); }

2
usrc/service/page/Page_main.cpp

@ -78,7 +78,7 @@ void Page_main::OnPageLoad(OnPageLoadContext*cxt) {
UIS->setVal(PAGE, ob_main_acidch3, GSM->getPumpSelectState(3));
// 时间位置暂时显示版本号
// UIS->setVal(PAGE, ob_main_clock, "", APP_VERSION);
UIS->setVal(PAGE, ob_main_clock, "");
// UIS->setVal(PAGE, ob_main_clock, "版本:%s", APP_VERSION);
// 根据当前登录用户设置菜单页面

110
usrc/service/page/submenu/Page_muSettings.cpp

@ -12,31 +12,105 @@ static CfgItermCache cfgcache;
bool Page_muSettings::isBelongThisPage(int page) { return page == PAGE; }
void Page_muSettings::OnPageLoad(OnPageLoadContext*cxt) { //
void Page_muSettings::updatePage() {
UIS->setVal(PAGE, ob_muSettings_bleCliName, "testData");
UIS->setVal(PAGE, ob_muSettings_irun0, "1");
UIS->setVal(PAGE, ob_muSettings_irun1, "1");
UIS->setVal(PAGE, ob_muSettings_irun2, "1");
UIS->setVal(PAGE, ob_muSettings_irun3, "1");
UIS->setVal(PAGE, ob_muSettings_pumpCoef0, "1");
UIS->setVal(PAGE, ob_muSettings_pumpCoef1, "1");
UIS->setVal(PAGE, ob_muSettings_pumpCoef2, "1");
UIS->setVal(PAGE, ob_muSettings_pumpCoef3, "1");
UIS->setVal(PAGE, ob_muSettings_pipeLen0, "1");
UIS->setVal(PAGE, ob_muSettings_pipeLen1, "1");
UIS->setVal(PAGE, ob_muSettings_pipeLen2, "1");
UIS->setVal(PAGE, ob_muSettings_pipeLen3, "1");
UIS->setVal(PAGE, ob_muSettings_addAcidVel, "1");
UIS->setVal(PAGE, ob_muSettings_irun0, zitoa(getMxIRun(0)));
UIS->setVal(PAGE, ob_muSettings_irun1, zitoa(getMxIRun(1)));
UIS->setVal(PAGE, ob_muSettings_irun2, zitoa(getMxIRun(2)));
UIS->setVal(PAGE, ob_muSettings_irun3, zitoa(getMxIRun(3)));
UIS->setVal(PAGE, ob_muSettings_pumpCoef0, zfmt("%.1f", getMotorMLPR(0)));
UIS->setVal(PAGE, ob_muSettings_pumpCoef1, zfmt("%.1f", getMotorMLPR(1)));
UIS->setVal(PAGE, ob_muSettings_pumpCoef2, zfmt("%.1f", getMotorMLPR(2)));
UIS->setVal(PAGE, ob_muSettings_pumpCoef3, zfmt("%.1f", getMotorMLPR(3)));
UIS->setVal(PAGE, ob_muSettings_pipeLen0, getCfgStr(kcfg_pipeLengthML));
UIS->setVal(PAGE, ob_muSettings_pipeLen1, getCfgStr(kcfg_pipeLengthML));
UIS->setVal(PAGE, ob_muSettings_pipeLen2, getCfgStr(kcfg_pipeLengthML));
UIS->setVal(PAGE, ob_muSettings_pipeLen3, getCfgStr(kcfg_pipeLengthML));
UIS->setVal(PAGE, ob_muSettings_addAcidVel, getCfgStr(kcfg_pumpDefVel));
}
void Page_muSettings::OnPageLoad(OnPageLoadContext* cxt) { //
updatePage();
};
void Page_muSettings::OnInputFieldContentChange(uint8_t bid, const char* text) { UIS->setVal(PAGE, bid, text); }
void Page_muSettings::OnInputFieldContentChange(uint8_t bid, const char* text) {
/***********************************************************************************************************************
* irunx *
***********************************************************************************************************************/
if (bid == ob_muSettings_irun0) {
setMxIRun(0, atoi(text));
UIS->setVal(bid, getMxIRun(0));
} else if (bid == ob_muSettings_irun1) {
setMxIRun(1, atoi(text));
UIS->setVal(bid, getMxIRun(1));
} else if (bid == ob_muSettings_irun2) {
setMxIRun(2, atoi(text));
UIS->setVal(bid, getMxIRun(2));
} else if (bid == ob_muSettings_irun3) {
setMxIRun(3, atoi(text));
UIS->setVal(bid, getMxIRun(3));
}
/***********************************************************************************************************************
* pumpCoef *
***********************************************************************************************************************/
else if (bid == ob_muSettings_pumpCoef0) {
setMotorMLPR(0, atof(text));
UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(0)));
} else if (bid == ob_muSettings_pumpCoef1) {
setMotorMLPR(1, atof(text));
UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(1)));
} else if (bid == ob_muSettings_pumpCoef2) {
setMotorMLPR(2, atof(text));
UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(2)));
} else if (bid == ob_muSettings_pumpCoef3) {
setMotorMLPR(3, atof(text));
UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(3)));
}
/***********************************************************************************************************************
* pipeLen *
***********************************************************************************************************************/
else if (bid == ob_muSettings_pipeLen0) {
CS->setcfg(kcfg_pipeLengthML, text);
UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML));
}
else if (bid == ob_muSettings_pipeLen1) {
CS->setcfg(kcfg_pipeLengthML, text);
UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML));
}
else if (bid == ob_muSettings_pipeLen2) {
CS->setcfg(kcfg_pipeLengthML, text);
UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML));
}
else if (bid == ob_muSettings_pipeLen3) {
CS->setcfg(kcfg_pipeLengthML, text);
UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML));
}
/***********************************************************************************************************************
* addAcidVel *
***********************************************************************************************************************/
else if (bid == ob_muSettings_addAcidVel) {
CS->setcfg(kcfg_pumpDefVel, text);
UIS->setVal(bid, getCfgStr(kcfg_pumpDefVel));
}
updatePage();
}
void Page_muSettings::OnButton(uint8_t bid, uint8_t val) {
static CfgItermCache usrpasswdcache;
ZLOGI(TAG, "bid:%d", bid);
if (bid == ob_muSettings_bleScan) {
ZLOGI(TAG, "bleScan");
} else if (bid == ob_muSettings_bak) {
if (bid == ob_muSettings_bak) {
UIS->chpage(GSM->getMenuPage());
} else if (bid == ob_muSettings_bleScan) {
ZLOGI(TAG, "bleScan");
}
};

1
usrc/service/page/submenu/Page_muSettings.hpp

@ -22,6 +22,7 @@ class Page_muSettings : public IPageProcesser {
virtual void OnButton(uint8_t bid, uint8_t val) override;
private:
void updatePage();
};
} // namespace iflytop

59
usrc/service/pump_ctrl_service.cpp

@ -12,6 +12,14 @@ static TMC51X0* m_motors[4];
static CfgItermCache cfgcache;
#define APPEND_ML 1
static int getMxRunRPM(int32_t mid) { //
float mLPmin = getCfgFloat(kcfg_pumpDefVel);
float motorX_mLPR = getMotorMLPR(mid);
int rpm = mLPmin / motorX_mLPR;
return rpm;
}
void PumpCtrlService::initialize() {
m_motors[0] = AppHardware::ins()->getPump(0);
m_motors[1] = AppHardware::ins()->getPump(1);
@ -73,6 +81,8 @@ void PumpCtrlService::stop() {
ZLOGI(TAG, "stop finish");
}
/***********************************************************************************************************************
* EXT *
***********************************************************************************************************************/
@ -82,31 +92,28 @@ void PumpCtrlService::reflux() {
m_thread.start(
[this]() {
ValveStateSyncService::ins()->setValveState(1);
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML);
int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel));
for (size_t i = 0; i < PUMP_NUM; i++) {
TMC51X0* cur_motor = m_motors[i];
cur_motor->stop();
cur_motor->setXACTUAL(0);
ZLOGI(TAG, "pump %d move %f ml", i, -pipeLenML);
cur_motor->moveBy((int32_t)-pipeLenML * 1000, vel);
}
while (!m_thread.getExitFlag()) {
if (isAllReachTarget()) {
break;
}
osDelay(10);
ValveStateSyncService::ins()->setValveState(1);
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML);
for (size_t i = 0; i < PUMP_NUM; i++) {
TMC51X0* cur_motor = m_motors[i];
cur_motor->stop();
cur_motor->setXACTUAL(0);
ZLOGI(TAG, "pump %d move %f ml", i, -pipeLenML);
cur_motor->moveBy((int32_t)-pipeLenML * 1000, getMxRunRPM(i));
}
while (!m_thread.getExitFlag()) {
if (isAllReachTarget()) {
break;
}
osDelay(10);
}
stopAll();
ZLOGI(TAG, "reflux end");
},
[]() {
ValveStateSyncService::ins()->setValveState(0);
});
[]() { ValveStateSyncService::ins()->setValveState(0); });
}
void PumpCtrlService::acidPrefilling() {
ZLOGI(TAG, "acidPrefilling");
@ -117,14 +124,13 @@ void PumpCtrlService::acidPrefilling() {
ValveStateSyncService::ins()->setValveState(1);
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML);
int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel));
for (size_t i = 0; i < PUMP_NUM; i++) {
TMC51X0* cur_motor = m_motors[i];
cur_motor->stop();
cur_motor->setXACTUAL(0);
ZLOGI(TAG, "pump %d move %f ml", i, pipeLenML);
cur_motor->moveBy((int32_t)pipeLenML * 1000, vel);
cur_motor->moveBy((int32_t)pipeLenML * 1000, getMxRunRPM(i));
}
while (!m_thread.getExitFlag()) {
@ -136,9 +142,8 @@ void PumpCtrlService::acidPrefilling() {
// ¶Ì»ØÁ÷
for (size_t i = 0; i < PUMP_NUM; i++) {
int32_t vel = getCfgInt(kcfg_pumpDefVel);
TMC51X0* cur_motor = m_motors[i];
cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, vel);
cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, getMxRunRPM(i));
}
while (!isAllReachTarget()) {
@ -195,14 +200,13 @@ void PumpCtrlService::doMoveOnce() {
for (size_t i = 0; i < PUMP_NUM; i++) {
bool pumpselect = GSM->getPumpSelectState(i);
float distribut_ml = getCfgFloat(config_index_t(kcfg_acideval0 + i));
int32_t vel = getCfgInt(kcfg_pumpDefVel);
TMC51X0* cur_motor = m_motors[i];
cur_motor->stop();
cur_motor->setXACTUAL(0);
if (pumpselect) {
ZLOGI(TAG, "pump %d move %f ml", i, distribut_ml);
cur_motor->moveBy((int32_t)(distribut_ml + APPEND_ML) * 1000, vel);
cur_motor->moveBy((int32_t)(distribut_ml + APPEND_ML) * 1000, getMxRunRPM(i));
}
}
@ -213,13 +217,12 @@ void PumpCtrlService::doMoveOnce() {
// »ØÁ÷
for (size_t i = 0; i < PUMP_NUM; i++) {
bool pumpselect = GSM->getPumpSelectState(i);
int32_t vel = getCfgInt(kcfg_pumpDefVel);
TMC51X0* cur_motor = m_motors[i];
cur_motor->stop();
cur_motor->setXACTUAL(0);
if (pumpselect) {
cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, vel);
cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, getMxRunRPM(i));
}
}

6
usrc/service/remote_controler_event_processer.cpp

@ -87,9 +87,13 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter
ZLOGW(TAG, "now page is in pump test, remote key event process by pumpTestPage");
return;
}
if (UIS->getNowPage() == pg_login || UIS->getNowPage() == pg_pStart) {
return;
}
if (UIS->getNowPage() != pg_main) {
UIS->chpage(pg_main);
UIS->alert("请先切换到首页,在控制泵机");
return;
}
if (PUMPCS->isWorking()) {

Loading…
Cancel
Save