11 changed files with 329 additions and 30 deletions
-
3CMakeLists.txt
-
14src/mainwindow.cpp
-
2src/mainwindow.h
-
17src/mainwindow.ui
-
66src/tab/board_ext_tab.cpp
-
43src/tab/board_ext_tab.hpp
-
79src/tab/mini_servo_tab.cpp
-
43src/tab/mini_servo_tab.hpp
-
73src/tab/module_opera_tab.cpp
-
2src/tab/module_opera_tab.hpp
-
17src/tab/step_motor_ctrl_tab.cpp
@ -0,0 +1,66 @@ |
|||
#include "board_ext_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(); |
|||
|
|||
BoardExtTab *BoardExtTab::inst() { |
|||
static BoardExtTab *ins = new BoardExtTab(); |
|||
return ins; |
|||
} |
|||
|
|||
void BoardExtTab::construct(QTabWidget *fathertab) { |
|||
ZQVTabPage *tab = new ZQVTabPage(fathertab, "板载扩展资源"); |
|||
/***********************************************************************************************************************
|
|||
* 模块操作 * |
|||
***********************************************************************************************************************/ |
|||
{ |
|||
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法", 4); |
|||
|
|||
box->newFunc("读取IO", {"ioindex"}, [this](int argn, const char **args) { |
|||
int32_t status = 0; |
|||
ICM->callcmd1(getDeviceId(), kboard_read_ext_io, atoi(args[0])); |
|||
ZQUI::ins()->ishow("Status:%d", ICM->getAck(0)); |
|||
}); |
|||
|
|||
box->newFunc("写入IO", {"ioindex"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kboard_write_ext_io, atoi(args[0])); }); |
|||
} |
|||
|
|||
/***********************************************************************************************************************
|
|||
* 寄存器操作 * |
|||
***********************************************************************************************************************/ |
|||
{ |
|||
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(); |
|||
} |
@ -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 BoardExtTab { |
|||
public: |
|||
static BoardExtTab *inst(); |
|||
|
|||
void construct(QTabWidget *fathertab); |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,79 @@ |
|||
#include "mini_servo_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(); |
|||
|
|||
MiniServoTab *MiniServoTab::inst() { |
|||
static MiniServoTab *ins = new MiniServoTab(); |
|||
return ins; |
|||
} |
|||
|
|||
void MiniServoTab::construct(QTabWidget *fathertab) { |
|||
ZQVTabPage *tab = new ZQVTabPage(fathertab, "舵机"); |
|||
/***********************************************************************************************************************
|
|||
* 模块操作 * |
|||
***********************************************************************************************************************/ |
|||
{ |
|||
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "方法", 4); |
|||
|
|||
box->newFunc("使能", {"enable"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kmini_servo_enable, atoi(args[0])); }); |
|||
box->newFunc("读取位置", {}, [this](int argn, const char **args) { |
|||
ICM->callcmd0(getDeviceId(), kmini_servo_read_pos); |
|||
ZQUI::ins()->ishow("Position:%d", ICM->getAck(0)); |
|||
}); |
|||
box->newFunc("激活配置", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kmini_servo_active_cfg); }); |
|||
box->newFunc("停止", {"breakstop"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kmini_servo_stop, atoi(args[0])); }); |
|||
box->newFunc("旋转", {"direction"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kmini_servo_rotate, atoi(args[0])); }); |
|||
box->newFunc("移动到", {"position"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kmini_servo_move_to, atoi(args[0])); }); |
|||
box->newFunc("设置中点", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kmini_servo_set_mid_point); }); |
|||
box->newFunc("读取IO状态", {"ioindex"}, [this](int argn, const char **args) { |
|||
ICM->callcmd1(getDeviceId(), kmini_servo_read_io_state, atoi(args[0])); |
|||
ZQUI::ins()->ishow("IO:%d", ICM->getAck(0)); |
|||
}); |
|||
} |
|||
|
|||
/***********************************************************************************************************************
|
|||
* 寄存器操作 * |
|||
***********************************************************************************************************************/ |
|||
{ |
|||
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("pos", kreg_mini_servo_pos, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("limit-velocity", kreg_mini_servo_limit_velocity, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("limit-torque", kreg_mini_servo_limit_torque, ZRegItem::krw | ZRegItem::kdec); |
|||
tableBox->addReg("protective-torque", kreg_mini_servo_protective_torque, 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 MiniServoTab { |
|||
public: |
|||
static MiniServoTab *inst(); |
|||
|
|||
void construct(QTabWidget *fathertab); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue