From e8592898277e01d89804e80cac306c03b04a14c7 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 8 Jun 2024 16:17:17 +0800 Subject: [PATCH] update --- .vscode/settings.json | 3 +- CMakeLists.txt | 1 + src/mainwindow.cpp | 2 ++ src/tab/board_ext_tab.cpp | 4 --- src/tab/code_scaner_tab.cpp | 4 --- src/tab/mini_servo_tab.cpp | 4 --- src/tab/pipette_ctrl_tab.cpp | 68 +++++++++++++++++++++++++++++++++++++++++ src/tab/pipette_ctrl_tab.hpp | 43 ++++++++++++++++++++++++++ src/tab/step_motor_ctrl_tab.cpp | 25 ++++++--------- 9 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 src/tab/pipette_ctrl_tab.cpp create mode 100644 src/tab/pipette_ctrl_tab.hpp diff --git a/.vscode/settings.json b/.vscode/settings.json index 96e5204..70e1d3a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -121,7 +121,8 @@ "xmemory": "cpp", "xtr1common": "cpp", "xtree": "cpp", - "xutility": "cpp" + "xutility": "cpp", + "qstatusbar": "cpp" }, "files.autoGuessEncoding": false, } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 895cd03..a6db071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ set(PROJECT_SOURCES a8000_protocol/api/apibasic/errorcode.cpp + src/tab/pipette_ctrl_tab.cpp app.rc ) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7f56c1d..8c0ce77 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,6 +26,7 @@ #include "tab/mini_servo_tab.hpp" #include "tab/module_opera_tab.hpp" #include "tab/step_motor_ctrl_tab.hpp" +#include "tab/pipette_ctrl_tab.hpp" #include "version.h" using namespace std; @@ -296,6 +297,7 @@ void MainWindow::constructAppUI() { MiniServoTab::inst()->construct(ui->buttonTabWidget); CodeScanerTab::inst()->construct(ui->buttonTabWidget); + PipetteCtrlTab::inst()->construct(ui->buttonTabWidget); } void MainWindow::on_PublicState_ConfirmKey_clicked() {} diff --git a/src/tab/board_ext_tab.cpp b/src/tab/board_ext_tab.cpp index ddea6c9..c70c359 100644 --- a/src/tab/board_ext_tab.cpp +++ b/src/tab/board_ext_tab.cpp @@ -66,10 +66,6 @@ void BoardExtTab::construct(QTabWidget *fathertab) { return true; }); - tableBox->addReg("mod-version", kreg_module_version, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-type", kreg_module_type, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-status", kreg_module_status, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-errorcode", kreg_module_errorcode, ZRegItem::krw | ZRegItem::kdec); tableBox->addSpacer(); } diff --git a/src/tab/code_scaner_tab.cpp b/src/tab/code_scaner_tab.cpp index a781e69..5d9a78a 100644 --- a/src/tab/code_scaner_tab.cpp +++ b/src/tab/code_scaner_tab.cpp @@ -69,10 +69,6 @@ void CodeScanerTab::construct(QTabWidget *fathertab) { return true; }); - tableBox->addReg("mod-version", kreg_module_version, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-type", kreg_module_type, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-status", kreg_module_status, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-errorcode", kreg_module_errorcode, ZRegItem::krw | ZRegItem::kdec); tableBox->addSpacer(); } diff --git a/src/tab/mini_servo_tab.cpp b/src/tab/mini_servo_tab.cpp index d3760c3..2a34d29 100644 --- a/src/tab/mini_servo_tab.cpp +++ b/src/tab/mini_servo_tab.cpp @@ -65,10 +65,6 @@ void MiniServoTab::construct(QTabWidget *fathertab) { return true; }); - tableBox->addReg("mod-version", kreg_module_version, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-type", kreg_module_type, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-status", kreg_module_status, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-errorcode", kreg_module_errorcode, ZRegItem::krw | ZRegItem::kdec); tableBox->addReg("pos", kreg_mini_servo_pos, ZRegItem::krw | ZRegItem::kdec); tableBox->addReg("limit-torque(位置模式,速度模式有效)", kreg_mini_servo_limit_torque, ZRegItem::krw | ZRegItem::kdec); diff --git a/src/tab/pipette_ctrl_tab.cpp b/src/tab/pipette_ctrl_tab.cpp new file mode 100644 index 0000000..8763e01 --- /dev/null +++ b/src/tab/pipette_ctrl_tab.cpp @@ -0,0 +1,68 @@ +#include "pipette_ctrl_tab.hpp" + +#include "iflytop_canbus/iflytop_canbus_master.hpp" +#include "logger.hpp" +#include "qt_serial_datachannel.hpp" +#include "zexception.hpp" +#include "zui/z_function_list_box.hpp" +#include "zui/z_reg_table_list_box.hpp" +#include "zui/zq_vtab_page.hpp" +// +#include "./mainwindow.h" +#include "zui\zqui.hpp" +// +using namespace iflytop; +using namespace std; + +extern Ui::MainWindow *main_ui; + +extern int getDeviceId(); + +PipetteCtrlTab *PipetteCtrlTab::inst() { + static PipetteCtrlTab *ins = new PipetteCtrlTab(); + return ins; +} + +void PipetteCtrlTab::construct(QTabWidget *fathertab) { + /*********************************************************************************************************************** + * 模块操作 * + ***********************************************************************************************************************/ + // kpipette_ctrl_init_device + // kpipette_ctrl_put_tip + // kpipette_ctrl_move_to_ul + + 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()); }); + 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])); }); + } + + tab->addSpacer(); + + { + ZRegTableList *tableBox = new ZRegTableList(tab, "寄存器操作"); + tableBox->initializeRegOperation( + [this](int32_t add, int32_t val) { // + ICM->writereg(getDeviceId(), add, val); + return true; + }, + [this](int32_t add, int32_t *val) { // + ICM->readreg(getDeviceId(), add, val); + return true; + }); + + tableBox->addReg("reg_pipette_pos_ul", kreg_pipette_pos_ul, ZRegItem::krw | ZRegItem::kdec); + tableBox->addReg("reg_pipette_capactitance_val", kreg_pipette_capactitance_val, ZRegItem::krw | ZRegItem::kdec); + tableBox->addReg("reg_pipette_tip_state", kreg_pipette_tip_state, ZRegItem::krw | ZRegItem::kdec); + tableBox->addReg("reg_pipette_limit_ul", kreg_pipette_limit_ul, ZRegItem::krw | ZRegItem::kdec); + + tableBox->addSpacer(); + tab->addSpacer(); + } +} diff --git a/src/tab/pipette_ctrl_tab.hpp b/src/tab/pipette_ctrl_tab.hpp new file mode 100644 index 0000000..20ebb68 --- /dev/null +++ b/src/tab/pipette_ctrl_tab.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// +#include + +namespace iflytop { +using namespace std; + +class PipetteCtrlTab { + public: + static PipetteCtrlTab *inst(); + + void construct(QTabWidget *fathertab); +}; +} // namespace iflytop diff --git a/src/tab/step_motor_ctrl_tab.cpp b/src/tab/step_motor_ctrl_tab.cpp index 3a176e4..325879b 100644 --- a/src/tab/step_motor_ctrl_tab.cpp +++ b/src/tab/step_motor_ctrl_tab.cpp @@ -50,6 +50,16 @@ void StepMotorCtrlTab::construct(QTabWidget *fathertab) { { ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法组2", 4); + box->newFunc("旋转", {"direction"}, [this](int argn, const char **args) { ICM->step_motor_easy_rotate(getDeviceId(), atoi(args[0])); }); + box->newFunc("相对移动", {"distance"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_by(getDeviceId(), atoi(args[0])); }); + box->newFunc("移动到", {"position"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to(getDeviceId(), atoi(args[0])); }); + box->newFunc("归零", {}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_zero(getDeviceId()); }); + box->newFunc("移动到终点", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kstep_motor_easy_move_to_end_point); }); + box->newFunc("移动到IO", {"ioindex", "direction"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_io(getDeviceId(), atoi(args[0]), atoi(args[1])); }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法组3", 4); box->newFunc("设置当前位置", {"position"}, [this](int argn, const char **args) { ICM->step_motor_easy_set_current_pos(getDeviceId(), atoi(args[0])); }); box->newFunc("读取位置", {}, [this](int argn, const char **args) { int32_t pos = 0; @@ -204,16 +214,6 @@ void StepMotorCtrlTab::construct(QTabWidget *fathertab) { }); } - { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法组3", 4); - box->newFunc("旋转", {"direction"}, [this](int argn, const char **args) { ICM->step_motor_easy_rotate(getDeviceId(), atoi(args[0])); }); - box->newFunc("相对移动", {"distance"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_by(getDeviceId(), atoi(args[0])); }); - box->newFunc("移动到", {"position"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to(getDeviceId(), atoi(args[0])); }); - box->newFunc("归零", {}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_zero(getDeviceId()); }); - box->newFunc("移动到终点", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kstep_motor_easy_move_to_end_point); }); - box->newFunc("移动到IO", {"ioindex", "direction"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_io(getDeviceId(), atoi(args[0]), atoi(args[1])); }); - } - tab->addSpacer(); } @@ -230,11 +230,6 @@ void StepMotorCtrlTab::constructRegTab(QTabWidget *fathertab) { return true; }); - tableBox->addReg("mod-version", kreg_module_version, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-type", kreg_module_type, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-status", kreg_module_status, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("mod-errorcode", kreg_module_errorcode, ZRegItem::krw | ZRegItem::kdec); - tableBox->addReg("motor_pos", kreg_step_motor_pos, ZRegItem::krw | ZRegItem::kdec); tableBox->addReg("motor_dpos", kreg_step_motor_dpos, ZRegItem::krw | ZRegItem::kdec);