Browse Source

update

master
zhaohe 1 year ago
parent
commit
4c9e6b55ac
  1. 1
      CMakeLists.txt
  2. 2
      a8000_protocol
  3. 3
      iflytop_canbus/iflytop_canbus_master.cpp
  4. 2
      iflytop_canbus/iflytop_canbus_master.hpp
  5. 2
      src/mainwindow.cpp
  6. 2
      src/mainwindow.ui
  7. 11
      src/tab/board_ext_tab.cpp
  8. 80
      src/tab/code_scaner_tab.cpp
  9. 43
      src/tab/code_scaner_tab.hpp
  10. 5
      src/tab/module_opera_tab.cpp

1
CMakeLists.txt

@ -51,6 +51,7 @@ set(PROJECT_SOURCES
src/tab/module_opera_tab.cpp src/tab/module_opera_tab.cpp
src/tab/board_ext_tab.cpp src/tab/board_ext_tab.cpp
src/tab/mini_servo_tab.cpp src/tab/mini_servo_tab.cpp
src/tab/code_scaner_tab.cpp
a8000_protocol/api/apibasic/errorcode.cpp a8000_protocol/api/apibasic/errorcode.cpp

2
a8000_protocol

@ -1 +1 @@
Subproject commit 97b8fb482b00a1eef33677f582e4ecbf2ed6db25
Subproject commit a85673b9c1b9a54c0e91a3e3f4299106a749e56d

3
iflytop_canbus/iflytop_canbus_master.cpp

@ -107,6 +107,9 @@ void IflytopCanbusMaster::readreg(int32_t device_id, int32_t regaddr, int32_t *v
int32_t IflytopCanbusMaster::getAck(int32_t index) { return *(int32_t *)(&m_receipt_frame->data[index]); } int32_t IflytopCanbusMaster::getAck(int32_t index) { return *(int32_t *)(&m_receipt_frame->data[index]); }
uint8_t *IflytopCanbusMaster::getAckBuf() { return m_receipt_frame->data; }
int32_t IflytopCanbusMaster::getAckBufLen() { return m_receipt_len - sizeof(zcr_cmd_header_t); }
void IflytopCanbusMaster::writereg(int32_t device_id, int32_t regaddr, int32_t val) { callcmd2(device_id, kmodule_set_reg, regaddr, val, 10); } void IflytopCanbusMaster::writereg(int32_t device_id, int32_t regaddr, int32_t val) { callcmd2(device_id, kmodule_set_reg, regaddr, val, 10); }
void IflytopCanbusMaster::callcmd0(int32_t device_id, int32_t cmdid, int32_t overtime) { callcmd(device_id, cmdid, nullptr, 0, overtime); } void IflytopCanbusMaster::callcmd0(int32_t device_id, int32_t cmdid, int32_t overtime) { callcmd(device_id, cmdid, nullptr, 0, overtime); }

2
iflytop_canbus/iflytop_canbus_master.hpp

@ -97,6 +97,8 @@ class IflytopCanbusMaster {
void sendraw(int32_t fromId, uint8_t *data, size_t len); void sendraw(int32_t fromId, uint8_t *data, size_t len);
int32_t getAck(int32_t index); int32_t getAck(int32_t index);
uint8_t* getAckBuf();
int32_t getAckBufLen();
public: public:
/*********************************************************************************************************************** /***********************************************************************************************************************

2
src/mainwindow.cpp

@ -22,6 +22,7 @@
#include "zui/zui.hpp" #include "zui/zui.hpp"
// //
#include "tab/board_ext_tab.hpp" #include "tab/board_ext_tab.hpp"
#include "tab/code_scaner_tab.hpp"
#include "tab/mini_servo_tab.hpp" #include "tab/mini_servo_tab.hpp"
#include "tab/module_opera_tab.hpp" #include "tab/module_opera_tab.hpp"
#include "tab/step_motor_ctrl_tab.hpp" #include "tab/step_motor_ctrl_tab.hpp"
@ -279,6 +280,7 @@ void MainWindow::constructAppUI() {
StepMotorCtrlTab::inst()->constructRegTab(ui->buttonTabWidget); StepMotorCtrlTab::inst()->constructRegTab(ui->buttonTabWidget);
MiniServoTab::inst()->construct(ui->buttonTabWidget); MiniServoTab::inst()->construct(ui->buttonTabWidget);
CodeScanerTab::inst()->construct(ui->buttonTabWidget);
} }
void MainWindow::on_PublicState_ConfirmKey_clicked() {} void MainWindow::on_PublicState_ConfirmKey_clicked() {}

2
src/mainwindow.ui

@ -1010,8 +1010,8 @@ p, li { white-space: pre-wrap; }
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;">50  板夹仓加热</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;">50  板夹仓加热</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;">60  进出料 </span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;">60  进出料 </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 进料电机(61)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 进料电机(61)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 出料电机(63)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 转移电机(62)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 转移电机(62)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 出料电机(63)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 扫码器(64)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 扫码器(64)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;">70  孵育盘 </span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;">70  孵育盘 </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 孵育盘转盘(71)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Consolas','Courier New','monospace'; font-size:11pt; color:#ff0000;"> 孵育盘转盘(71)</span></p>

11
src/tab/board_ext_tab.cpp

@ -23,6 +23,12 @@ BoardExtTab *BoardExtTab::inst() {
return ins; return ins;
} }
static inline const char *hex2binstr(int32_t hex) {
static char buf[32];
sprintf(buf, "%d%d%d%d_%d%d%d%d", (hex >> 7) & 1, (hex >> 6) & 1, (hex >> 5) & 1, (hex >> 4) & 1, (hex >> 3) & 1, (hex >> 2) & 1, (hex >> 1) & 1, (hex >> 0) & 1);
return buf;
}
void BoardExtTab::construct(QTabWidget *fathertab) { void BoardExtTab::construct(QTabWidget *fathertab) {
ZQVTabPage *tab = new ZQVTabPage(fathertab, "板载扩展资源"); ZQVTabPage *tab = new ZQVTabPage(fathertab, "板载扩展资源");
/*********************************************************************************************************************** /***********************************************************************************************************************
@ -36,6 +42,11 @@ void BoardExtTab::construct(QTabWidget *fathertab) {
ICM->callcmd1(getDeviceId(), kboard_read_ext_io, atoi(args[0])); ICM->callcmd1(getDeviceId(), kboard_read_ext_io, atoi(args[0]));
ZQUI::ins()->ishow("Status:%d", ICM->getAck(0)); ZQUI::ins()->ishow("Status:%d", ICM->getAck(0));
}); });
box->newFunc("读取全部IO", {"ioindex"}, [this](int argn, const char **args) {
int32_t status = 0;
ICM->callcmd1(getDeviceId(), kboard_read_muti_io, atoi(args[0]));
ZQUI::ins()->ishow("IOState:%s", hex2binstr(ICM->getAck(0)));
});
box->newFunc("写入IO", {"ioindex", "iostate"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kboard_write_ext_io, atoi(args[0]), atoi(args[1])); }); box->newFunc("写入IO", {"ioindex", "iostate"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kboard_write_ext_io, atoi(args[0]), atoi(args[1])); });
} }

80
src/tab/code_scaner_tab.cpp

@ -0,0 +1,80 @@
#include "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 "./mainwindow.h"
#include "zui\zqui.hpp"
//
using namespace iflytop;
using namespace std;
extern Ui::MainWindow *main_ui;
extern int getDeviceId();
CodeScanerTab *CodeScanerTab::inst() {
static CodeScanerTab *ins = new CodeScanerTab();
return ins;
}
void CodeScanerTab::construct(QTabWidget *fathertab) {
ZQVTabPage *tab = new ZQVTabPage(fathertab, "扫码器");
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
{
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法", 4);
box->newFunc("开始扫描", {}, [this](int argn, const char **args) {
ICM->callcmd0(getDeviceId(), kcode_scaner_start_scan);
});
box->newFunc("停止扫描", {}, [this](int argn, const char **args) {
ICM->callcmd0(getDeviceId(), kcode_scaner_stop_scan);
});
box->newFunc("扫描结果是否准备好", {}, [this](int argn, const char **args) {
ICM->callcmd0(getDeviceId(), kcode_scaner_result_is_ready);
ZQUI::ins()->ishow("ready:%d", ICM->getAck(0));
});
box->newFunc("读取扫描结果", {}, [this](int argn, const char **args) {
ICM->callcmd0(getDeviceId(), kcode_scaner_read_scaner_result);
uint8_t *resultbuf = ICM->getAckBuf();
int32_t resultlen = ICM->getAckBufLen();
ZQUI::ins()->ishow("result:%s(%d)", string(resultbuf, resultbuf + resultlen).c_str(), resultlen);
});
}
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
{
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("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();
}
tab->addSpacer();
}

43
src/tab/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 CodeScanerTab {
public:
static CodeScanerTab *inst();
void construct(QTabWidget *fathertab);
};
} // namespace iflytop

5
src/tab/module_opera_tab.cpp

@ -46,7 +46,7 @@ static const char *module_type2_str(int id) {
case kfan_ctrl_module: case kfan_ctrl_module:
return "风扇控制"; return "风扇控制";
case kcode_scaner: case kcode_scaner:
return "风扇控制";
return "扫码器";
case kpipette_ctrl_module: case kpipette_ctrl_module:
return "移液体枪控制"; return "移液体枪控制";
case ka8000_optical_module: case ka8000_optical_module:
@ -87,6 +87,9 @@ void ModuleOperaTab::construct(QWidget *parent) {
int moduleType; int moduleType;
IflytopCanbusMaster::ins()->readreg(i, kreg_module_type, &moduleType); IflytopCanbusMaster::ins()->readreg(i, kreg_module_type, &moduleType);
if (i % 10 == 0) {
ZQUI::ins()->ishow("");
}
ZQUI::ins()->ishow("module :%d isOnline type:%s", i, module_type2_str(moduleType)); ZQUI::ins()->ishow("module :%d isOnline type:%s", i, module_type2_str(moduleType));
} catch (const zexception &e) { } catch (const zexception &e) {
if (e.ecode() != ke_overtime) { if (e.ecode() != ke_overtime) {

Loading…
Cancel
Save