18 changed files with 354 additions and 177 deletions
-
7.vscode/settings.json
-
3CMakeLists.txt
-
2a8000_protocol
-
3iflytop_canbus/iflytop_canbus_master.cpp
-
5iflytop_canbus/iflytop_canbus_master.hpp
-
4libzqt/zui/z_function_list_box.cpp
-
6libzqt/zui/z_reg_table_list_box.cpp
-
4libzqt/zui/zqui.cpp
-
6libzqt/zui/zqui.hpp
-
1src/main.cpp
-
183src/mainwindow.cpp
-
2src/mainwindow.h
-
31src/qt_serial_datachannel.cpp
-
5src/qt_serial_datachannel.hpp
-
52src/tab/module_opera_tab.cpp
-
43src/tab/module_opera_tab.hpp
-
130src/tab/step_motor_ctrl_tab.cpp
-
44src/tab/step_motor_ctrl_tab.hpp
@ -1 +1 @@ |
|||
Subproject commit 00a25ecee58be21d0325226ea677a25f224e388a |
|||
Subproject commit f41c0ba7a5ca666a6038621f813001a530316a97 |
@ -0,0 +1,52 @@ |
|||
#include "module_opera_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/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(); |
|||
|
|||
|
|||
ModuleOperaTab *ModuleOperaTab::inst() { |
|||
static ModuleOperaTab *ins = new ModuleOperaTab(); |
|||
return ins; |
|||
} |
|||
|
|||
void ModuleOperaTab::construct(QTabWidget *fathertab) { |
|||
/***********************************************************************************************************************
|
|||
* 模块操作 * |
|||
***********************************************************************************************************************/ |
|||
// main_ui->
|
|||
ZQVTabPage *tab = new ZQVTabPage(fathertab, "模块操作"); |
|||
|
|||
{ |
|||
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "模块基础操作", 4); |
|||
box->newFunc("扫描模块", {}, [this](int argn, const char **args) { //
|
|||
for (size_t i = 1; i < 255; i++) { |
|||
try { |
|||
IflytopCanbusMaster::ins()->ping(i); |
|||
ZQUI::ins()->ishow("module :%d isOnline", i); |
|||
} catch (const zexception &e) { |
|||
if (e.ecode() != ke_overtime) { |
|||
ZQUI::ins()->ishow("%s", e.what()); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
ZQUI::ins()->ishow("ScanModuleEnd"); |
|||
}); |
|||
} |
|||
|
|||
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 ModuleOperaTab { |
|||
public: |
|||
static ModuleOperaTab* inst(); |
|||
|
|||
void construct(QTabWidget *fathertab); |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,130 @@ |
|||
#include "step_motor_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(); |
|||
|
|||
StepMotorCtrlTab *StepMotorCtrlTab::inst() { |
|||
static StepMotorCtrlTab *ins = new StepMotorCtrlTab(); |
|||
return ins; |
|||
} |
|||
|
|||
void StepMotorCtrlTab::construct(QTabWidget *fathertab) { |
|||
/***********************************************************************************************************************
|
|||
* 模块操作 * |
|||
***********************************************************************************************************************/ |
|||
// kstep_motor_enable = NEW_CMDID(101, 1), // para:{1}, ack:{}
|
|||
// kstep_motor_read_pos = NEW_CMDID(101, 2), // para:{}, ack:{4}
|
|||
// kstep_motor_easy_rotate = NEW_CMDID(101, 3), // para:{4}, ack:{}
|
|||
// kstep_motor_easy_move_by = NEW_CMDID(101, 4), // para:{4}, ack:{}
|
|||
// kstep_motor_easy_move_to = NEW_CMDID(101, 5), // para:{4}, ack:{}
|
|||
// kstep_motor_easy_move_to_zero = NEW_CMDID(101, 6), // para:{1}, ack:{}
|
|||
// kstep_motor_easy_set_current_pos = NEW_CMDID(101, 7), // para:{4}, ack:{}
|
|||
// kstep_motor_easy_move_to_io = NEW_CMDID(101, 8), // para:{4,4}, ack:{}
|
|||
// kstep_motor_active_cfg = NEW_CMDID(101, 9), // para:{4,4}, ack:{}
|
|||
// kstep_motor_stop = NEW_CMDID(101, 10), // para:{4}, ack:{}
|
|||
// kstep_motor_read_io_state = NEW_CMDID(101, 11), // para:{4}, ack:{4}
|
|||
|
|||
ZQVTabPage *tab = new ZQVTabPage(fathertab, "步进电机"); |
|||
|
|||
{ |
|||
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法", 4); |
|||
// kmodule_get_status = CMDID(1, 4), // para:{}, ack:{4}
|
|||
// kmodule_stop = CMDID(1, 1), // para:{}, ack:{}
|
|||
// kmodule_get_error = CMDID(1, 10), // para:{}, ack:{1}
|
|||
// kmodule_clear_error = CMDID(1, 11), // para:{}, ack:{}
|
|||
// kmodule_active_cfg = CMDID(1, 16), // para:{}, ack:{}
|
|||
|
|||
box->newFunc("M-获取状态", {}, [this](int argn, const char **args) { |
|||
int32_t status = 0; |
|||
ICM->callcmd0(getDeviceId(), kmodule_get_status); |
|||
ZQUI::ins()->ishow("Status:%d", ICM->getAck(0)); |
|||
}); |
|||
box->newFunc("M-停止", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kmodule_stop); }); |
|||
box->newFunc("M-获取错误", {}, [this](int argn, const char **args) { |
|||
ICM->callcmd0(getDeviceId(), kmodule_get_error); |
|||
ZQUI::ins()->ishow("Error:%d", ICM->getAck(0)); |
|||
}); |
|||
box->newFunc("M-清除错误", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kmodule_clear_error); }); |
|||
|
|||
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) { |
|||
int32_t pos = 0; |
|||
ICM->step_motor_read_pos(getDeviceId(), &pos); |
|||
ZQUI::ins()->ishow("Pos:%d", pos); |
|||
}); |
|||
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("设置当前位置", {"position"}, [this](int argn, const char **args) { ICM->step_motor_easy_set_current_pos(getDeviceId(), atoi(args[0])); }); |
|||
box->newFunc("移动到IO", {"ioindex"}, [this](int argn, const char **args) { ICM->step_motor_easy_move_to_io(getDeviceId(), atoi(args[0])); }); |
|||
box->newFunc("激活配置", {}, [this](int argn, const char **args) { ICM->step_motor_active_cfg(getDeviceId()); }); |
|||
box->newFunc("停止", {}, [this](int argn, const char **args) { ICM->step_motor_stop(getDeviceId(), 0); }); |
|||
box->newFunc("读取IO状态", {"ioindex"}, [this](int argn, const char **args) { |
|||
int32_t io = 0; |
|||
ICM->step_motor_read_io_state(getDeviceId(), atoi(args[0]), &io); |
|||
ZQUI::ins()->ishow("IO:%d", io); |
|||
}); |
|||
} |
|||
tab->addSpacer(); |
|||
} |
|||
|
|||
void StepMotorCtrlTab::constructRegTab(QTabWidget *fathertab) { |
|||
ZQVTabPage *tab = new ZQVTabPage(fathertab, "步进电机-寄存器"); |
|||
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->addReg("motor_pos", kreg_step_motor_pos, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_dpos", kreg_step_motor_dpos, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_shift", kreg_step_motor_shift, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_shaft", kreg_step_motor_shaft, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_one_circle_pulse", kreg_step_motor_one_circle_pulse, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_one_circle_pulse_denominator", kreg_step_motor_one_circle_pulse_denominator, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_default_velocity", kreg_step_motor_default_velocity, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_default_acc", kreg_step_motor_default_acc, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_default_dec", kreg_step_motor_default_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_default_break_dec", kreg_step_motor_default_break_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_ihold", kreg_step_motor_ihold, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_irun", kreg_step_motor_irun, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_iholddelay", kreg_step_motor_iholddelay, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_iglobalscaler", kreg_step_motor_iglobalscaler, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_run_to_zero_max_d", kreg_step_motor_run_to_zero_max_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_look_zero_edge_max_d", kreg_step_motor_look_zero_edge_max_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_run_to_zero_speed", kreg_step_motor_run_to_zero_speed, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_run_to_zero_dec", kreg_step_motor_run_to_zero_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_look_zero_edge_speed", kreg_step_motor_look_zero_edge_speed, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_look_zero_edge_dec", kreg_step_motor_look_zero_edge_dec, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_max_d", kreg_step_motor_max_d, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("motor_min_d", kreg_step_motor_min_d, ZRegItem::krw | ZRegItem::kdec); |
|||
|
|||
tableBox->addSpacer(); |
|||
tab->addSpacer(); |
|||
} |
@ -0,0 +1,44 @@ |
|||
#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 StepMotorCtrlTab { |
|||
public: |
|||
static StepMotorCtrlTab *inst(); |
|||
|
|||
void construct(QTabWidget *fathertab); |
|||
void constructRegTab(QTabWidget *fathertab); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue