Browse Source

update

master
zhaohe 1 year ago
parent
commit
cd38681ac5
  1. 1
      CMakeLists.txt
  2. 2
      a8000_protocol
  3. 4
      src/mainwindow.cpp
  4. 125
      src/tab/plate_code_scaner_tab.cpp
  5. 43
      src/tab/plate_code_scaner_tab.hpp

1
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

2
a8000_protocol

@ -1 +1 @@
Subproject commit f31a251dd7c826e3125212681c4381cf4e86f0b7
Subproject commit 6388097349469105159878e482b826fb21c68734

4
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() {}

125
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();
}
}

43
src/tab/plate_code_scaner_tab.hpp

@ -0,0 +1,43 @@
#pragma once
#include <QDateTime>
#include <QMainWindow>
#include <QMessageBox>
#include <QObject>
#include <QtConcurrent>
#include <QtCore/QVariant>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
//
#include <functional>
namespace iflytop {
using namespace std;
class PlateCodeScanerTab {
public:
static PlateCodeScanerTab *inst();
void construct(QTabWidget *fathertab);
};
} // namespace iflytop
Loading…
Cancel
Save