5 changed files with 174 additions and 1 deletions
-
1CMakeLists.txt
-
2a8000_protocol
-
4src/mainwindow.cpp
-
125src/tab/plate_code_scaner_tab.cpp
-
43src/tab/plate_code_scaner_tab.hpp
@ -1 +1 @@ |
|||
Subproject commit f31a251dd7c826e3125212681c4381cf4e86f0b7 |
|||
Subproject commit 6388097349469105159878e482b826fb21c68734 |
@ -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(); |
|||
} |
|||
} |
@ -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
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue