From a24a389a91e89a8cfb1a6da226703c18da11f0f7 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 11 Jun 2024 20:22:52 +0800 Subject: [PATCH] update --- iflytop_canbus/waveshare_can.cpp | 4 ++-- src/basic/smtp2_constant.cpp | 4 ++-- src/tab/pipette_ctrl_tab.cpp | 48 +++++++++++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/iflytop_canbus/waveshare_can.cpp b/iflytop_canbus/waveshare_can.cpp index 7f1721d..4f5c61f 100644 --- a/iflytop_canbus/waveshare_can.cpp +++ b/iflytop_canbus/waveshare_can.cpp @@ -157,8 +157,8 @@ int WaveshareCan::onReceivePacket(uint8_t* data, size_t len) { canframe.data[3] = rxpacket->frame_data_4; canframe.data[4] = rxpacket->frame_data_5; canframe.data[5] = rxpacket->frame_data_6; - canframe.data[6] = rxpacket->frame_data_6; - canframe.data[7] = rxpacket->frame_data_6; + canframe.data[6] = rxpacket->frame_data_7; + canframe.data[7] = rxpacket->frame_data_8; if (m_frame_callback) { m_frame_callback(&canframe); diff --git a/src/basic/smtp2_constant.cpp b/src/basic/smtp2_constant.cpp index 01b44c2..313b304 100644 --- a/src/basic/smtp2_constant.cpp +++ b/src/basic/smtp2_constant.cpp @@ -88,8 +88,8 @@ static state_info_t states[] = { STATE_ITEM(kstate_pump_pos_nl, "泵位置(纳升)"), STATE_ITEM(kstate_back_clearance, "背隙[K],泵位置"), STATE_ITEM(kstate_start_v, "启动速度[v]"), - STATE_ITEM(kstate_max_v, "最高速度[V]"), - STATE_ITEM(kstate_stop_v, "停止速度[c]"), + STATE_ITEM(kstate_max_v, "最高速度[V]*10, 默认:{1400}"), + STATE_ITEM(kstate_stop_v, "停止速度[c], 默认:{900}"), STATE_ITEM(kstate_acc, "加速度的[L]值"), STATE_ITEM(kstate_dec, "减速度的[L]值"), STATE_ITEM(kstate_motor_irun, "泵电机运行电流,单位0.01A"), diff --git a/src/tab/pipette_ctrl_tab.cpp b/src/tab/pipette_ctrl_tab.cpp index 7646a9c..71d294d 100644 --- a/src/tab/pipette_ctrl_tab.cpp +++ b/src/tab/pipette_ctrl_tab.cpp @@ -24,6 +24,20 @@ PipetteCtrlTab *PipetteCtrlTab::inst() { return ins; } +static void pipette_ctrl_read_state(int32_t index, string &state) { + char txbuf[256]; + snprintf(txbuf, sizeof(txbuf), "/1?%dR\r", index); + ICM->callcmd(getDeviceId(), kpipette_write_cmd_direct, (uint8_t *)txbuf, strlen(txbuf) + 1, 100); + ICM->getAckBuf()[ICM->getAckBufLen() - 2] = 0; + for (size_t i = 0; i < ICM->getAckBufLen(); i++) { + if (ICM->getAckBuf()[i] == '\r' || ICM->getAckBuf()[i] == '\n') { + ICM->getAckBuf()[i] = 0; + } + } + + state = string((char *)ICM->getAckBuf()); +} + void PipetteCtrlTab::construct(QTabWidget *fathertab) { /*********************************************************************************************************************** * 模块操作 * @@ -35,13 +49,16 @@ void PipetteCtrlTab::construct(QTabWidget *fathertab) { ZQVTabPage *tab = new ZQVTabPage(fathertab, "移液枪操作"); { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "移液枪操作", 4); - // box->newFunc("使能", {"enable"}, [this](int argn, const char **args) { ICM->step_motor_enable(getDeviceId(), atoi(args[0])); }); - // box->newFunc("停止", {}, [this](int argn, const char **args) { ICM->step_motor_stop(getDeviceId(), 0); }); - // box->newFunc("激活配置", {}, [this](int argn, const char **args) { ICM->step_motor_active_cfg(getDeviceId()); }); + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "移液枪-操作", 4); + box->newFunc("初始化操作", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kpipette_ctrl_init_device); }); box->newFunc("推出吸头", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kpipette_ctrl_put_tip); }); box->newFunc("移动到指定位置", {"ul"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kpipette_ctrl_move_to_ul, atoi(args[0])); }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "移液枪-子设备直接操作", 4); + box->newFunc("写指令到移液枪(直接)", {"cmdstr"}, [this](int argn, const char **args) { char txbuf[256]; snprintf(txbuf, sizeof(txbuf), "%sR\r", args[0]); @@ -58,7 +75,7 @@ void PipetteCtrlTab::construct(QTabWidget *fathertab) { errorcode = errorcode - '@'; workingstate = 1; } - ZQUI::ins()->ishow("RX: ecode:%s(%d),working_state:%d,raw:%s", smtp2::ecode2str(errorcode), errorcode, workingstate, ICM->getAckBuf()); + ZQUI::ins()->ishow("RX: ecode:%s(%d),working_state:%d,raw:%s(%d)", smtp2::ecode2str(errorcode), errorcode, workingstate, (char *)ICM->getAckBuf(), ICM->getAckBufLen()); }); box->newFunc("打印常用指令", {}, [this](int argn, const char **args) { @@ -97,23 +114,28 @@ void PipetteCtrlTab::construct(QTabWidget *fathertab) { box->newFunc("打印泵机状态列表", {}, [this](int argn, const char **args) { ZQUI::ins()->ishow("查看状态: /1?R"); - smtp2::cfg_info_t *table = nullptr; - int32_t itermNum = 0; + smtp2::state_info_t *table = nullptr; + int32_t itermNum = 0; - smtp2::cfg_info_get_table(&table, &itermNum); + smtp2::state_info_get_table(&table, &itermNum); + ZQUI::ins()->ishow("id, val, des"); for (int i = 0; i < itermNum; i++) { - ZQUI::ins()->ishow("id:%d, des:%s", table[i].index, table[i].description); + string val; + pipette_ctrl_read_state(table[i].index, val); + ZQUI::ins()->ishow("%2d , %s , %s", table[i].index, val.c_str(), table[i].description); } }); box->newFunc("打印泵机配置列表", {}, [this](int argn, const char **args) { ZQUI::ins()->ishow("设置配置: /1u,R"); - smtp2::state_info_t *table = nullptr; - int32_t itermNum = 0; + smtp2::cfg_info_t *table = nullptr; + int32_t itermNum = 0; + + smtp2::cfg_info_get_table(&table, &itermNum); + ZQUI::ins()->ishow("id, des"); - smtp2::state_info_get_table(&table, &itermNum); for (int i = 0; i < itermNum; i++) { - ZQUI::ins()->ishow("id:%d, des:%s", table[i].index, table[i].description); + ZQUI::ins()->ishow(" %2d , %s", table[i].index, table[i].description); } }); }