From cd38681ac59886515f5f9b5e12a1ac3f39ea4249 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 24 Jun 2024 15:54:13 +0800 Subject: [PATCH] update --- CMakeLists.txt | 1 + a8000_protocol | 2 +- src/mainwindow.cpp | 4 ++ src/tab/plate_code_scaner_tab.cpp | 125 ++++++++++++++++++++++++++++++++++++++ src/tab/plate_code_scaner_tab.hpp | 43 +++++++++++++ 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 src/tab/plate_code_scaner_tab.cpp create mode 100644 src/tab/plate_code_scaner_tab.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a8900d..53100a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ set(PROJECT_SOURCES src/tab/board_ext_tab.cpp src/tab/mini_servo_tab.cpp src/tab/code_scaner_tab.cpp + src/tab/plate_code_scaner_tab.cpp src/tab/fan_ctrl_tab.cpp src/tab/water_cooling_temperature_tab.cpp diff --git a/a8000_protocol b/a8000_protocol index f31a251..6388097 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit f31a251dd7c826e3125212681c4381cf4e86f0b7 +Subproject commit 6388097349469105159878e482b826fb21c68734 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f3dbb6c..bda8a5f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -31,6 +31,7 @@ #include "tab/step_motor_ctrl_tab.hpp" #include "tab/water_cooling_temperature_tab.hpp" #include "tab/xyrobot_tab.hpp" +#include "tab/plate_code_scaner_tab.hpp" #include "version.h" using namespace std; @@ -268,6 +269,9 @@ void MainWindow::constructAppUI() { XYRobotTab::inst()->construct(ui->buttonTabWidget); IDCardReaderTab::inst()->construct(ui->buttonTabWidget); + PlateCodeScanerTab::inst()->construct(ui->buttonTabWidget); + + } void MainWindow::on_PublicState_ConfirmKey_clicked() {} diff --git a/src/tab/plate_code_scaner_tab.cpp b/src/tab/plate_code_scaner_tab.cpp new file mode 100644 index 0000000..b7d4144 --- /dev/null +++ b/src/tab/plate_code_scaner_tab.cpp @@ -0,0 +1,125 @@ +#include "plate_code_scaner_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 "../basic/smtp2_constant.hpp" +#include "./mainwindow.h" +#include "zui\zqui.hpp" +// +using namespace iflytop; +using namespace std; + +extern Ui::MainWindow *main_ui; + +extern int getDeviceId(); + +PlateCodeScanerTab *PlateCodeScanerTab::inst() { + static PlateCodeScanerTab *ins = new PlateCodeScanerTab(); + return ins; +} + +void PlateCodeScanerTab::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("电机复位", {}, [this](int argn, const char **args) { + ICM->callcmd0(getDeviceId() - 1, kstep_motor_easy_move_to_zero); + ICM->callcmd0(getDeviceId() - 2, kstep_motor_easy_move_to_zero); + }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "板夹仓扫描操作", 4); + box->newFunc("开始扫描", {"startpos"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kplate_code_scaner_start_scan, atoi(args[0])); }); + box->newFunc("停止扫描", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kplate_code_scaner_stop_scan); }); + box->newFunc("读取结果", {}, [this](int argn, const char **args) { + int numResult = 0; + ICM->callcmd0(getDeviceId(), kplate_code_scaner_read_result_packet_num); + numResult = ICM->getAck(0); + + uint8_t buf[1024] = {0}; + uint8_t len = 0; + while (true) { + ICM->callcmd0(getDeviceId(), kplate_code_scaner_read_result); + if (ICM->getAckBufLen() == 0) break; + + memcpy(buf + len, ICM->getAckBuf(), ICM->getAckBufLen()); + len += ICM->getAckBufLen(); + } + + int16_t *data = (int16_t *)buf; + for (int i = 0; i < len / 2; i++) { + ZQUI::ins()->ishow("%d", data[i]); + } + }); + + box->newFunc("读取条码", {}, [this](int argn, const char **args) { + int code0 = 0; + int code1 = 0; + ICM->callcmd0(getDeviceId(), kplate_code_scaner_read_code); + code0 = ICM->getAck(0); + code1 = ICM->getAck(1); + + ZQUI::ins()->ishow("code0=%d, code1=%d", code0, code1); + }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "板夹仓扫码器-硬件调试", 4); + + // kplate_code_scaner_adc_readraw = CMDID(0x73, 6), // int32_t* val + // kplate_code_scaner_open_laser = CMDID(0x73, 7), // + // kplate_code_scaner_close_laser = CMDID(0x73, 8), // + + box->newSubButton("读取ADC", [this](int argn, const char **args) { + int val = 0; + ICM->callcmd0(getDeviceId(), kplate_code_scaner_adc_readraw); + val = ICM->getAck(0); + ZQUI::ins()->ishow("val=%d", val); + }); + + box->newSubButton("打开激光", [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kplate_code_scaner_open_laser); }); + box->newSubButton("关闭激光", [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kplate_code_scaner_close_laser); }); + + box->newFunc("设置激光发射功率", {"0...100"}, [this](int argn, const char **args) { ICM->writereg(getDeviceId(), kreg_plate_code_scaner_laster_intensity, atoi(args[0])); }); + box->newFunc("设置扫描增益", {"0...20"}, [this](int argn, const char **args) { ICM->writereg(getDeviceId(), kreg_plate_code_scaner_scan_gain, atof(args[0]) * 10); }); + } + + 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("laster_intensity", kreg_plate_code_scaner_laster_intensity, ZRegItem::krw | ZRegItem::kdec); + tableBox->addReg("scan_gain", kreg_plate_code_scaner_scan_gain, ZRegItem::krw | ZRegItem::kdec); + tableBox->addReg("scan_step_interval", kreg_plate_code_scaner_scan_step_interval, ZRegItem::krw | ZRegItem::kdec); + tableBox->addReg("scan_point_num", kreg_plate_code_scaner_scan_point_num, ZRegItem::krw | ZRegItem::kdec); + + tableBox->addSpacer(); + tab->addSpacer(); + } +} diff --git a/src/tab/plate_code_scaner_tab.hpp b/src/tab/plate_code_scaner_tab.hpp new file mode 100644 index 0000000..9a08e2b --- /dev/null +++ b/src/tab/plate_code_scaner_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 PlateCodeScanerTab { + public: + static PlateCodeScanerTab *inst(); + + void construct(QTabWidget *fathertab); +}; +} // namespace iflytop