From 1156b8defc4c4155fcfd7f356c85934750667736 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 3 Jun 2024 11:31:38 +0800 Subject: [PATCH] init proj --- CMakeLists.txt | 18 +- mainwindow.cpp | 458 --------------------- mainwindow.h | 125 ------ mainwindow.ui | 1154 ---------------------------------------------------- src/mainwindow.cpp | 458 +++++++++++++++++++++ src/mainwindow.h | 125 ++++++ src/mainwindow.ui | 1154 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1746 insertions(+), 1746 deletions(-) delete mode 100644 mainwindow.cpp delete mode 100644 mainwindow.h delete mode 100644 mainwindow.ui create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h create mode 100644 src/mainwindow.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 2444e92..dc89047 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(graphite_digester_upper VERSION 0.1 LANGUAGES CXX) +project(a8000_pc_upper VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -27,9 +27,9 @@ set(PROJECT_SOURCES libzqt/QFunction.cpp libzqt/zworkqueue.cpp src/main.cpp - mainwindow.cpp - mainwindow.h - mainwindow.ui + src/mainwindow.cpp + src/mainwindow.h + src/mainwindow.ui src/qt_serial_datachannel.cpp src/reglist.cpp @@ -47,19 +47,19 @@ set(PROJECT_SOURCES ) -add_executable(graphite_digester_upper WIN32 +add_executable(a8000_pc_upper WIN32 ${PROJECT_SOURCES} ) -target_link_options(graphite_digester_upper PRIVATE -static -static-libgcc -static-libstdc++) +target_link_options(a8000_pc_upper PRIVATE -static -static-libgcc -static-libstdc++) -target_link_libraries(graphite_digester_upper PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::SerialPort Qt${QT_VERSION_MAJOR}::Charts Qt${QT_VERSION_MAJOR}::Concurrent wsock32) +target_link_libraries(a8000_pc_upper PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::SerialPort Qt${QT_VERSION_MAJOR}::Charts Qt${QT_VERSION_MAJOR}::Concurrent wsock32) -set_target_properties(graphite_digester_upper PROPERTIES +set_target_properties(a8000_pc_upper PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} ) if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(graphite_digester_upper) + qt_finalize_executable(a8000_pc_upper) endif() diff --git a/mainwindow.cpp b/mainwindow.cpp deleted file mode 100644 index e4c9cbe..0000000 --- a/mainwindow.cpp +++ /dev/null @@ -1,458 +0,0 @@ -#include "mainwindow.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "./ui_mainwindow.h" -#include "iflytop_canbus/iflytop_canbus_master.hpp" -#include "logger.hpp" -#include "qt_serial_datachannel.hpp" -#include "reglist.hpp" -#include "zexception.hpp" -#include "zui/z_function_list_box.hpp" -#include "zui/zq_vtab_page.hpp" -// -#include - -#include "iflytop_canbus\regid.hpp" -#include "zui/zui.hpp" - -using namespace std; -using namespace iflytop; -using namespace zcr; -typedef enum { - kone_lead_ecg, - kthree_lead_ecg, -} device_type_t; - -static MainWindow *m_mainWindow; -static QTDataChannel G_QTDataChannel; -static QTDataChannel G_WaveDataChannel; - -static int PublicState_DeviceIDVal = 0; - -QT_REQUIRE_CONFIG(groupbox); - -#define TAG "MainWindow" - -static const char *fmt(const char *fmt, ...) { - va_list args; - va_start(args, fmt); - static char buf[1024] = {0}; - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - return buf; -} - -void MainWindow::log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg) {} -void MainWindow::doinui_slot(QFunction func) { - if (func.get()) func.get()(); -} - -/*********************************************************************************************************************** - * PreviewShow * - ***********************************************************************************************************************/ - -void MainWindow::instructionPreviewShow(QString text) { - QString info; - info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); - info.append(" |"); - info.append(text); - emit doinui_signal(QFunction([this, info]() { ui->instructionPreview->append(info); })); -} -void MainWindow::reportPreviewShow(QString text) { - QString info; - - info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); - info.append(text); - emit doinui_signal(QFunction([this, info]() { - if (ui->reportPreview->document()->lineCount() > 1000) { - ui->reportPreview->document()->clear(); - } - ui->reportPreview->append(info); - })); -} -void MainWindow::blockDataUploadPreviewShow(QString text) { - QString info; - - info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); - info.append(text); - emit doinui_signal(QFunction([this, info]() { - if (ui->uploadDataPreview->document()->lineCount() > 1000) { - ui->uploadDataPreview->document()->clear(); - } - ui->uploadDataPreview->append(info); - })); -} -void MainWindow::rawDataPreviewShow(QString text) { - QString info; - - info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")); - info.append(text); - emit doinui_signal(QFunction([this, info]() { - if (ui->rawDataPreview->document()->lineCount() > 1000) { - ui->rawDataPreview->document()->clear(); - } - ui->rawDataPreview->append(info); - })); -} - -void MainWindow::instructionPreviewClear() { - doinui_signal(QFunction([this]() { ui->instructionPreview->clear(); })); -} - -#pragma pack(push, 1) -typedef struct { - uint16_t header; - int16_t wave1; - int16_t wave2; - int16_t wave3; - int16_t wave4; - int16_t wave5; - uint8_t check; - uint16_t tail; -} Wave_t; -#pragma pack(pop) - -void MainWindow::displayWave(int16_t wave1, int16_t wave2, int16_t wave3) { - // 1. 生成波形数据 - Wave_t wave; - wave.header = 0xAAAA; - wave.wave1 = wave1; - wave.wave2 = wave2; - wave.wave3 = wave3; - wave.wave4 = 0; - wave.wave5 = 0; - wave.tail = 0x5555; - wave.check = 0; - - uint8_t check = 0; - for (size_t i = 2; i < sizeof(wave) - 2; i++) { - check += ((uint8_t *)&wave)[i]; - } - wave.check = check; - // 2. 发送波形数据 - G_WaveDataChannel.send((uint8_t *)&wave, sizeof(wave)); -} - -/*********************************************************************************************************************** - * UI相关构造 * - ***********************************************************************************************************************/ - -void MainWindow::constructBaseUI() { - /** - * @brief 指令串口UI - */ - { - const auto infos = QSerialPortInfo::availablePorts(); - for (const QSerialPortInfo &info : infos) { - ui->serialPortCB->addItem(info.portName()); - } - } - - ui->serialBaudrateCB->addItem("9600"); - ui->serialBaudrateCB->addItem("14400"); - ui->serialBaudrateCB->addItem("19200"); - ui->serialBaudrateCB->addItem("38400"); - ui->serialBaudrateCB->addItem("57600"); - ui->serialBaudrateCB->addItem("115200"); - ui->serialBaudrateCB->addItem("460800"); - ui->serialBaudrateCB->addItem("500000"); - ui->serialBaudrateCB->addItem("2000000"); - ui->serialBaudrateCB->setCurrentIndex(6); - - connect(ui->serialPortRefreshKey, &QPushButton::clicked, this, [this](bool check) { - ui->serialPortCB->clear(); - const auto infos = QSerialPortInfo::availablePorts(); - for (const QSerialPortInfo &info : infos) { - ui->serialPortCB->addItem(info.portName()); - } - }); - - connect(ui->serialOpenKey, &QPushButton::clicked, this, [=](bool check) { - // 打开串口 - if (ui->serialOpenKey->text() == "打开") { - G_QTDataChannel.setPortName(ui->serialPortCB->currentText().toStdString()); - G_QTDataChannel.setBaudRate(ui->serialBaudrateCB->currentText().toInt()); - G_QTDataChannel.setDataBits(QSerialPort::Data8); - G_QTDataChannel.setParity(QSerialPort::NoParity); - G_QTDataChannel.setFlowControl(QSerialPort::NoFlowControl); - G_QTDataChannel.setStopBits(QSerialPort::OneStop); - - /** - * @brief 串口打开时,初始化相应参数 - */ - - if (!G_QTDataChannel.open()) { - QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); - return; - } - ui->serialOpenKey->setText("关闭"); - // 下拉菜单控件使能 - ui->serialBaudrateCB->setEnabled(false); - ui->serialPortCB->setEnabled(false); - ui->serialPortRefreshKey->setEnabled(false); - - IflytopCanbusMaster::ins()->updateChannelConfig(); - } else { - G_QTDataChannel.close(); - ui->serialOpenKey->setText("打开"); - ui->serialBaudrateCB->setEnabled(true); - ui->serialPortCB->setEnabled(true); - ui->serialPortRefreshKey->setEnabled(true); - } - }); - - /** - * @brief 波形串口UI - */ - { - const auto infos = QSerialPortInfo::availablePorts(); - for (const QSerialPortInfo &info : infos) { - ui->waveSerialPortCB->addItem(info.portName()); - } - } - - ui->waveSerialBaudrateCB->addItem("9600"); - ui->waveSerialBaudrateCB->addItem("14400"); - ui->waveSerialBaudrateCB->addItem("19200"); - ui->waveSerialBaudrateCB->addItem("38400"); - ui->waveSerialBaudrateCB->addItem("57600"); - ui->waveSerialBaudrateCB->addItem("115200"); - ui->waveSerialBaudrateCB->addItem("460800"); - ui->waveSerialBaudrateCB->addItem("500000"); - ui->waveSerialBaudrateCB->addItem("2000000"); - // ui->waveSerialBaudrateCB->addItems - ui->waveSerialBaudrateCB->setCurrentIndex(6); - - connect(ui->waveSerialPortRefreshKey, &QPushButton::clicked, this, [this](bool check) { - ui->waveSerialPortCB->clear(); - const auto infos = QSerialPortInfo::availablePorts(); - for (const QSerialPortInfo &info : infos) { - ui->waveSerialPortCB->addItem(info.portName()); - } - }); - - connect(ui->waveSerialOpenKey, &QPushButton::clicked, this, [=](bool check) { - // 打开串口 - if (ui->waveSerialOpenKey->text() == "打开") { - G_WaveDataChannel.setPortName(ui->waveSerialPortCB->currentText().toStdString()); - G_WaveDataChannel.setBaudRate(ui->waveSerialBaudrateCB->currentText().toInt()); - G_WaveDataChannel.setDataBits(QSerialPort::Data8); - G_WaveDataChannel.setParity(QSerialPort::NoParity); - G_WaveDataChannel.setFlowControl(QSerialPort::NoFlowControl); - G_WaveDataChannel.setStopBits(QSerialPort::OneStop); - - if (!G_WaveDataChannel.open()) { - QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); - return; - } - ui->waveSerialOpenKey->setText("关闭"); - // 下拉菜单控件使能 - ui->waveSerialBaudrateCB->setEnabled(false); - ui->waveSerialPortCB->setEnabled(false); - ui->waveSerialPortRefreshKey->setEnabled(false); - } else { - G_WaveDataChannel.close(); - ui->waveSerialOpenKey->setText("打开"); - ui->waveSerialBaudrateCB->setEnabled(true); - ui->waveSerialPortCB->setEnabled(true); - ui->waveSerialPortRefreshKey->setEnabled(true); - } - }); -} - -void MainWindow::displayInfo(bool suc, QString info) {} - -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - /** - * @brief QT初始化 - */ - ui->setupUi(this); - m_mainWindow = this; - qRegisterMetaType("int32_t"); - qRegisterMetaType("uint32_t"); - qRegisterMetaType("float"); - qRegisterMetaType>("function"); - qRegisterMetaType("QFunction"); - connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); - ZQUI::ins()->initialize(); - ZQUI::ins()->setBlockDataUploadPreviewShow([this](QString text) { blockDataUploadPreviewShow(text); }); - ZQUI::ins()->setInstructionPreviewShow([this](QString text) { instructionPreviewShow(text); }); - ZQUI::ins()->setReportPreviewShow([this](QString text) { reportPreviewShow(text); }); - ZQUI::ins()->setRawDataPreviewShow([this](QString text) { rawDataPreviewShow(text); }); - ZQUI::ins()->setInstructionPreviewClear([this]() { instructionPreviewClear(); }); - - /** - * @brief 页面逻辑初始化 - */ - constructBaseUI(); - constructAppUI(); - - /** - * @brief 业务逻辑构造 - */ - G_QTDataChannel.init(); - G_WaveDataChannel.init(); - IflytopCanbusMaster::ins()->initialize(&G_QTDataChannel); - - IflytopCanbusMaster::ins()->regOnRawData([this](raw_data_type_t type, uint8_t *hex, uint32_t hexlen) { - if (type == kcmd_cmd) { - iflytop_canbus_frame_t *frame = (iflytop_canbus_frame_t *)hex; - ZQUI::ins()->rawDataPreviewShow("[CMD ] %s %s [id:%d cmd:%d,%d]", zhex2str(hex, sizeof(iflytop_canbus_frame_t)).c_str(), // - zhex2str(frame->data, hexlen - sizeof(iflytop_canbus_frame_t)).c_str(), // - frame->device_id, frame->cmd_main_id, frame->cmd_sub_id // - ); - } else if (type == kcmd_receipt) { - ZQUI::ins()->rawDataPreviewShow("[RECEIPT] %s", zhex2str(hex, hexlen).c_str()); - } else if (type == kcmd_report) { - ZQUI::ins()->rawDataPreviewShow("[REPORT ] %s", zhex2str(hex, hexlen).c_str()); - } - }); -} -MainWindow::~MainWindow() { delete ui; } - -void MainWindow::processException(const zexception &e) { // - ZQUI::ins()->instructionPreviewShow("%s", e.what()); -} - -int32_t MainWindow::getDeviceId() { return PublicState_DeviceIDVal; } - -void MainWindow::constructAppUI() { - /*********************************************************************************************************************** - * 模块操作 * - ***********************************************************************************************************************/ - - { - ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "模块操作"); - - { - 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()->instructionPreviewShow("module :%d isOnline", i); - } catch (const zexception &e) { - if (e.ecode() != ke_overtime) { - processException(e); - break; - } - } - } - ZQUI::ins()->instructionPreviewShow("ScanModuleEnd"); - }); - } - - { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电机配置", 4); - box->newFunc("电机设置编码器分辨率", {"resolution"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_set_enc_resolution(getDeviceId(), atoi(args[0])); }); - box->newFunc("设置IRUM", {"[0-31]"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->writereg(getDeviceId(), kreg_stepmotor_irun, atoi(args[0])); }); - box->newFunc("设置IHOLD", {"[0-31]"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->writereg(getDeviceId(), kreg_stepmotor_ihold, atoi(args[0])); }); - box->newFunc("设置默认速度", {"velocity"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->writereg(getDeviceId(), kreg_motor_default_velocity, atoi(args[0])); }); - box->newFunc("激活配置", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_active_cfg(getDeviceId()); }); - } - - { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电机状态读取", 4); - box->newFunc("电机读取编码器值", {}, [this](int argn, const char **args) { - int32_t retval = IflytopCanbusMaster::ins()->motor_read_enc_val(getDeviceId()); - ZQUI::ins()->instructionPreviewShow("encVal %d", retval); - }); - box->newFunc("电机读取编码器分辨率", {}, [this](int argn, const char **args) { - int32_t retval = IflytopCanbusMaster::ins()->motor_get_enc_resolution(getDeviceId()); - ZQUI::ins()->instructionPreviewShow("encResolution %d", retval); - }); - } - - { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电机操作", 4); - box->newFunc("停止电机", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_stop(getDeviceId()); }); - box->newFunc("急停电机", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_break(getDeviceId()); }); - box->newFunc("激活配置", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_active_cfg(getDeviceId()); }); - box->newFunc("电机使能", {"enable"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_enable(getDeviceId(), atoi(args[0])); }); - box->newFunc("电机旋转", {"direction"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_rotate(getDeviceId(), atoi(args[0])); }); - box->newFunc("电机移动", {"distance"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_by(getDeviceId(), atoi(args[0])); }); - box->newFunc("电机移动到", {"position"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_to(getDeviceId(), atoi(args[0])); }); - box->newFunc("电机归零", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_to_zero(getDeviceId()); }); - box->newFunc("电机设置当前位置", {"position"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_set_current_pos(getDeviceId(), atoi(args[0])); }); - box->newFunc("电机移动到IO", {"io"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_to_io(getDeviceId(), atoi(args[0])); }); - box->newFunc("电机设置子设备寄存器", {"regaddr", "val"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_set_subdevice_reg(getDeviceId(), atoi(args[0]), atoi(args[1])); }); - box->newFunc("电机读取子设备寄存器", {"regaddr"}, [this](int argn, const char **args) { - int32_t retval = IflytopCanbusMaster::ins()->motor_get_subdevice_reg(getDeviceId(), atoi(args[0])); - ZQUI::ins()->instructionPreviewShow("regVal 0x%08x", retval); - }); - } - { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "驱动底层配置", 4); - box->newFunc("电机设置子设备寄存器", {"regaddr", "val"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_set_subdevice_reg(getDeviceId(), atoi(args[0]), atoi(args[1])); }); - box->newFunc("电机读取子设备寄存器", {"regaddr"}, [this](int argn, const char **args) { - int32_t retval = IflytopCanbusMaster::ins()->motor_get_subdevice_reg(getDeviceId(), atoi(args[0])); - ZQUI::ins()->instructionPreviewShow("regVal 0x%08x", retval); - }); - } - - tab->addSpacer(); - } - - m_testThread.reset(new std::thread([this]() { - while (true) { - if (m_testState) { - try { - IflytopCanbusMaster::ins()->ping(getDeviceId()); - } catch (const zexception &e) { - processException(e); - } - } - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - })); - - { - ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "暴力测试"); - // static - { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "模块基础操作", 4); - box->newFunc("开始测试", {"间隔"}, [this](int argn, const char **args) { // - int interval = atoi(args[0]); - m_testState = true; - }); - - box->newFunc("停止测试", {}, [this](int argn, const char **args) { // - m_testState = false; - }); - } - } - - /*********************************************************************************************************************** - * 寄存器列表 * - ***********************************************************************************************************************/ - { - ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "寄存器操作"); - - ZRegTableList *tableBox = new ZRegTableList(tab, "寄存器操作"); - tableBox->initializeRegOperation( - [this](int32_t add, int32_t val) { // - IflytopCanbusMaster::ins()->writereg(getDeviceId(), add, val); - return true; - }, - [this](int32_t add, int32_t *val) { // - IflytopCanbusMaster::ins()->readreg(getDeviceId(), add, val); - return true; - }); - - tableBox->newFunc("激活配置", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_active_cfg(getDeviceId()); }); - for (auto &var : GetRegList()) { - tableBox->addReg(var.title.c_str(), var.addr, var.flag); - } - tableBox->addSpacer(); - tab->addSpacer(); - } -} - -void MainWindow::on_PublicState_ConfirmKey_clicked() { PublicState_DeviceIDVal = ui->PublicState_DeviceID->toPlainText().toInt(); } diff --git a/mainwindow.h b/mainwindow.h deleted file mode 100644 index f0920a1..0000000 --- a/mainwindow.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "logger.hpp" -#include "qfunction.hpp" -#include "zexception.hpp" -#include "zqthread.hpp" -QT_BEGIN_NAMESPACE -namespace Ui { -class MainWindow; -} -QT_END_NAMESPACE - -typedef enum { - kreg_val_type_dotted_hex, // 点分16进制 - kreg_val_type_dotted_decimal, // 点分10进制 - kreg_val_type_str, - kreg_val_type_hex, - kreg_val_type_decimal, - kreg_val_type_binary, - kreg_val_type_freq, - kreg_val_type_signal, -} reg_val_type_t; - -class DispalyRegIterm { - public: - QLabel *label = 0; - QTextBrowser *regBrowser = 0; - QTextEdit *regEditer = 0; - QPushButton *writerButton = 0; - uint32_t regvalcache; - reg_val_type_t regvaltype; -}; - -class MainWindow : public QMainWindow { - Q_OBJECT - - private: - std::map m_regdisplayer; - - std::unique_ptr m_thread; - - bool m_testState = false; - std::unique_ptr m_testThread; - - public: - Ui::MainWindow *ui; - - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - void constructBaseUI(); - void constructAppUI(); - - private slots: - void doinui_slot(QFunction); - - void on_PublicState_ConfirmKey_clicked(); - -signals: - void doinui_signal(QFunction); - - private: - static void log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg); - - void instructionPreviewClear(); - void instructionPreviewShow(QString info); - void reportPreviewShow(QString info); - void blockDataUploadPreviewShow(QString info); - void rawDataPreviewShow(QString info); - - void displayWave(int16_t wave1, int16_t wave2, int16_t wave3); - - void displayInfo(bool suc, QString info); - - private: - void processException(const std::zexception &e); - - private: - /*********************************************************************************************************************** - * UI_UTILS * - ***********************************************************************************************************************/ - - QWidget *allocNewTab(QString zh_name); - QGroupBox *allocNewBox(QWidget *tab, QString zh_name, int column); - void addNewButtonStyle1(QWidget *box, QString zh_name, QStringList params, std::function onButtonClick); - void endAllocNewBox(QGroupBox *box); - void endAllocNewTab(QWidget *tab); - - int32_t getDeviceId(); -}; -#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui deleted file mode 100644 index 9e37987..0000000 --- a/mainwindow.ui +++ /dev/null @@ -1,1154 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 1448 - 1040 - - - - - 0 - 8 - - - - 黄金测试上位机 - - - /* -Aqua Style Sheet for QT Applications -Author: Jaime A. Quiroga P. -Company: GTRONICK -Last updated: 22/01/2019, 07:55. -Available at: https://github.com/GTRONICK/QSS/blob/master/Aqua.qss -*/ -QMainWindow { - background-color:#ececec; -} -QTextEdit { - border-width: 1px; - border-style: solid; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QPlainTextEdit { - border-width: 1px; - border-style: solid; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QToolButton { - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QToolButton:hover{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QToolButton:pressed{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(142,142,142); -} -QPushButton{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QPushButton::default{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QPushButton:hover{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(255,255,255); -} -QPushButton:pressed{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: rgb(0,0,0); - padding: 2px; - background-color: rgb(142,142,142); -} -QPushButton:disabled{ - border-style: solid; - border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); - border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); - border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); - border-width: 1px; - border-radius: 5px; - color: #808086; - padding: 2px; - background-color: rgb(142,142,142); -} -QLineEdit { - border-width: 1px; border-radius: 4px; - border-style: solid; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QLabel { - color: #000000; -} -QLCDNumber { - color: rgb(0, 113, 255, 255); -} -QProgressBar { - text-align: center; - color: rgb(240, 240, 240); - border-width: 1px; - border-radius: 10px; - border-color: rgb(230, 230, 230); - border-style: solid; - background-color:rgb(207,207,207); -} -QProgressBar::chunk { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); - border-radius: 10px; -} -QMenuBar { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); -} -QMenuBar::item { - color: #000000; - spacing: 3px; - padding: 1px 4px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); -} - -QMenuBar::item:selected { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #FFFFFF; -} -QMenu::item:selected { - border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - border-bottom-color: transparent; - border-left-width: 2px; - color: #000000; - padding-left:15px; - padding-top:4px; - padding-bottom:4px; - padding-right:7px; -} -QMenu::item { - border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: transparent; - border-bottom-color: transparent; - border-bottom-width: 1px; - color: #000000; - padding-left:17px; - padding-top:4px; - padding-bottom:4px; - padding-right:7px; -} -QTabWidget { - color:rgb(0,0,0); - background-color:#000000; -} -QTabWidget::pane { - border-color: rgb(223,223,223); - background-color:rgb(226,226,226); - border-style: solid; - border-width: 2px; - border-radius: 6px; -} -QTabBar::tab:first { - border-style: solid; - border-left-width:1px; - border-right-width:0px; - border-top-width:1px; - border-bottom-width:1px; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - color: #000000; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); -} -QTabBar::tab:last { - border-style: solid; - border-width:1px; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-right-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - color: #000000; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); -} -QTabBar::tab { - border-style: solid; - border-top-width:1px; - border-bottom-width:1px; - border-left-width:1px; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - color: #000000; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); -} -QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover { - border-style: solid; - border-left-width:1px; - border-right-color: transparent; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - color: #FFFFFF; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} - -QTabBar::tab:selected, QTabBar::tab:first:selected, QTabBar::tab:hover { - border-style: solid; - border-left-width:1px; - border-bottom-width:1px; - border-top-width:1px; - border-right-color: transparent; - border-top-color: rgb(209,209,209); - border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); - border-bottom-color: rgb(229,229,229); - color: #FFFFFF; - padding: 3px; - margin-left:0px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} - -QCheckBox { - color: #000000; - padding: 2px; -} -QCheckBox:disabled { - color: #808086; - padding: 2px; -} - -QCheckBox:hover { - border-radius:4px; - border-style:solid; - padding-left: 1px; - padding-right: 1px; - padding-bottom: 1px; - padding-top: 1px; - border-width:1px; - border-color: transparent; -} -QCheckBox::indicator:checked { - - height: 10px; - width: 10px; - border-style:solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #000000; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QCheckBox::indicator:unchecked { - - height: 10px; - width: 10px; - border-style:solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #000000; -} -QRadioButton { - color: 000000; - padding: 1px; -} -QRadioButton::indicator:checked { - height: 10px; - width: 10px; - border-style:solid; - border-radius:5px; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #a9b7c6; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QRadioButton::indicator:!checked { - height: 10px; - width: 10px; - border-style:solid; - border-radius:5px; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); - color: #a9b7c6; - background-color: transparent; -} -QStatusBar { - color:#027f7f; -} -QSpinBox { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QDoubleSpinBox { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QTimeEdit { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QDateTimeEdit { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} -QDateEdit { - border-style: solid; - border-width: 1px; - border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); -} - -QToolBox { - color: #a9b7c6; - background-color:#000000; -} -QToolBox::tab { - color: #a9b7c6; - background-color:#000000; -} -QToolBox::tab:selected { - color: #FFFFFF; - background-color:#000000; -} -QScrollArea { - color: #FFFFFF; - background-color:#000000; -} -QSlider::groove:horizontal { - height: 5px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QSlider::groove:vertical { - width: 5px; - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QSlider::handle:horizontal { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - width: 12px; - margin: -5px 0; - border-radius: 7px; -} -QSlider::handle:vertical { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - height: 12px; - margin: 0 -5px; - border-radius: 7px; -} -QSlider::add-page:horizontal { - background: rgb(181,181,181); -} -QSlider::add-page:vertical { - background: rgb(181,181,181); -} -QSlider::sub-page:horizontal { - background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QSlider::sub-page:vertical { - background-color: qlineargradient(spread:pad, y1:0.5, x1:1, y2:0.5, x2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); -} -QScrollBar:horizontal { - max-height: 20px; - border: 1px transparent grey; - margin: 0px 20px 0px 20px; -} -QScrollBar:vertical { - max-width: 20px; - border: 1px transparent grey; - margin: 20px 0px 20px 0px; -} -QScrollBar::handle:horizontal { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - border-radius: 7px; - min-width: 25px; -} -QScrollBar::handle:horizontal:hover { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(147, 200, 200); - border-radius: 7px; - min-width: 25px; -} -QScrollBar::handle:vertical { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(207,207,207); - border-radius: 7px; - min-height: 25px; -} -QScrollBar::handle:vertical:hover { - background: rgb(253,253,253); - border-style: solid; - border-width: 1px; - border-color: rgb(147, 200, 200); - border-radius: 7px; - min-height: 25px; -} -QScrollBar::add-line:horizontal { - border: 2px transparent grey; - border-top-right-radius: 7px; - border-bottom-right-radius: 7px; - background: rgba(34, 142, 255, 255); - width: 20px; - subcontrol-position: right; - subcontrol-origin: margin; -} -QScrollBar::add-line:horizontal:pressed { - border: 2px transparent grey; - border-top-right-radius: 7px; - border-bottom-right-radius: 7px; - background: rgb(181,181,181); - width: 20px; - subcontrol-position: right; - subcontrol-origin: margin; -} -QScrollBar::add-line:vertical { - border: 2px transparent grey; - border-bottom-left-radius: 7px; - border-bottom-right-radius: 7px; - background: rgba(34, 142, 255, 255); - height: 20px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} -QScrollBar::add-line:vertical:pressed { - border: 2px transparent grey; - border-bottom-left-radius: 7px; - border-bottom-right-radius: 7px; - background: rgb(181,181,181); - height: 20px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} -QScrollBar::sub-line:horizontal { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-bottom-left-radius: 7px; - background: rgba(34, 142, 255, 255); - width: 20px; - subcontrol-position: left; - subcontrol-origin: margin; -} -QScrollBar::sub-line:horizontal:pressed { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-bottom-left-radius: 7px; - background: rgb(181,181,181); - width: 20px; - subcontrol-position: left; - subcontrol-origin: margin; -} -QScrollBar::sub-line:vertical { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-top-right-radius: 7px; - background: rgba(34, 142, 255, 255); - height: 20px; - subcontrol-position: top; - subcontrol-origin: margin; -} -QScrollBar::sub-line:vertical:pressed { - border: 2px transparent grey; - border-top-left-radius: 7px; - border-top-right-radius: 7px; - background: rgb(181,181,181); - height: 20px; - subcontrol-position: top; - subcontrol-origin: margin; -} -QScrollBar::left-arrow:horizontal { - border: 1px transparent grey; - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::right-arrow:horizontal { - border: 1px transparent grey; - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::up-arrow:vertical { - border: 1px transparent grey; - border-top-left-radius: 3px; - border-top-right-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::down-arrow:vertical { - border: 1px transparent grey; - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; - width: 6px; - height: 6px; - background: white; -} -QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { - background: none; -} -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { - background: none; -} - - - - - - - - - - - 0 - 0 - - - - - - - - 200 - 0 - - - - - 200 - 16777215 - - - - - - - - 16777215 - 16777215 - - - - 串口设置 - - - - - - - - - 打开 - - - - - - - - - - 波特率 - - - - - - - 串口 - - - - - - - 刷新 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - false - - - 通用参数 - - - - - - - 1 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - 设备ID - - - - - - - - 1 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - 2 - - - - - - - 提交 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - false - - - 状态 - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - 设备连接状态 - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - 2 - - - - - - - - - - - 0 - 0 - - - - 功能按键 - - - - - - - 1 - 0 - - - - - 0 - 30 - - - - 清空显示 - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::DefaultContextMenu - - - 0 - - - - 波形显示器 - - - - - 20 - 20 - 182 - 126 - - - - - 16777215 - 16777215 - - - - 波形串口设置 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 波特率 - - - - - - - 打开 - - - - - - - 串口 - - - - - - - 刷新 - - - - - - - - - - - - - 0 - 0 - - - - - 600 - 0 - - - - - 600 - 16777215 - - - - DisplayBox - - - - - - 指令回执显示 - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - 上报回执显示 - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - 上传数据显示 - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - 二进制 - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 1448 - 20 - - - - - iflytop - - - - - - - - - diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..e4c9cbe --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,458 @@ +#include "mainwindow.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "./ui_mainwindow.h" +#include "iflytop_canbus/iflytop_canbus_master.hpp" +#include "logger.hpp" +#include "qt_serial_datachannel.hpp" +#include "reglist.hpp" +#include "zexception.hpp" +#include "zui/z_function_list_box.hpp" +#include "zui/zq_vtab_page.hpp" +// +#include + +#include "iflytop_canbus\regid.hpp" +#include "zui/zui.hpp" + +using namespace std; +using namespace iflytop; +using namespace zcr; +typedef enum { + kone_lead_ecg, + kthree_lead_ecg, +} device_type_t; + +static MainWindow *m_mainWindow; +static QTDataChannel G_QTDataChannel; +static QTDataChannel G_WaveDataChannel; + +static int PublicState_DeviceIDVal = 0; + +QT_REQUIRE_CONFIG(groupbox); + +#define TAG "MainWindow" + +static const char *fmt(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + static char buf[1024] = {0}; + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + return buf; +} + +void MainWindow::log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg) {} +void MainWindow::doinui_slot(QFunction func) { + if (func.get()) func.get()(); +} + +/*********************************************************************************************************************** + * PreviewShow * + ***********************************************************************************************************************/ + +void MainWindow::instructionPreviewShow(QString text) { + QString info; + info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); + info.append(" |"); + info.append(text); + emit doinui_signal(QFunction([this, info]() { ui->instructionPreview->append(info); })); +} +void MainWindow::reportPreviewShow(QString text) { + QString info; + + info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); + info.append(text); + emit doinui_signal(QFunction([this, info]() { + if (ui->reportPreview->document()->lineCount() > 1000) { + ui->reportPreview->document()->clear(); + } + ui->reportPreview->append(info); + })); +} +void MainWindow::blockDataUploadPreviewShow(QString text) { + QString info; + + info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); + info.append(text); + emit doinui_signal(QFunction([this, info]() { + if (ui->uploadDataPreview->document()->lineCount() > 1000) { + ui->uploadDataPreview->document()->clear(); + } + ui->uploadDataPreview->append(info); + })); +} +void MainWindow::rawDataPreviewShow(QString text) { + QString info; + + info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")); + info.append(text); + emit doinui_signal(QFunction([this, info]() { + if (ui->rawDataPreview->document()->lineCount() > 1000) { + ui->rawDataPreview->document()->clear(); + } + ui->rawDataPreview->append(info); + })); +} + +void MainWindow::instructionPreviewClear() { + doinui_signal(QFunction([this]() { ui->instructionPreview->clear(); })); +} + +#pragma pack(push, 1) +typedef struct { + uint16_t header; + int16_t wave1; + int16_t wave2; + int16_t wave3; + int16_t wave4; + int16_t wave5; + uint8_t check; + uint16_t tail; +} Wave_t; +#pragma pack(pop) + +void MainWindow::displayWave(int16_t wave1, int16_t wave2, int16_t wave3) { + // 1. 生成波形数据 + Wave_t wave; + wave.header = 0xAAAA; + wave.wave1 = wave1; + wave.wave2 = wave2; + wave.wave3 = wave3; + wave.wave4 = 0; + wave.wave5 = 0; + wave.tail = 0x5555; + wave.check = 0; + + uint8_t check = 0; + for (size_t i = 2; i < sizeof(wave) - 2; i++) { + check += ((uint8_t *)&wave)[i]; + } + wave.check = check; + // 2. 发送波形数据 + G_WaveDataChannel.send((uint8_t *)&wave, sizeof(wave)); +} + +/*********************************************************************************************************************** + * UI相关构造 * + ***********************************************************************************************************************/ + +void MainWindow::constructBaseUI() { + /** + * @brief 指令串口UI + */ + { + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) { + ui->serialPortCB->addItem(info.portName()); + } + } + + ui->serialBaudrateCB->addItem("9600"); + ui->serialBaudrateCB->addItem("14400"); + ui->serialBaudrateCB->addItem("19200"); + ui->serialBaudrateCB->addItem("38400"); + ui->serialBaudrateCB->addItem("57600"); + ui->serialBaudrateCB->addItem("115200"); + ui->serialBaudrateCB->addItem("460800"); + ui->serialBaudrateCB->addItem("500000"); + ui->serialBaudrateCB->addItem("2000000"); + ui->serialBaudrateCB->setCurrentIndex(6); + + connect(ui->serialPortRefreshKey, &QPushButton::clicked, this, [this](bool check) { + ui->serialPortCB->clear(); + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) { + ui->serialPortCB->addItem(info.portName()); + } + }); + + connect(ui->serialOpenKey, &QPushButton::clicked, this, [=](bool check) { + // 打开串口 + if (ui->serialOpenKey->text() == "打开") { + G_QTDataChannel.setPortName(ui->serialPortCB->currentText().toStdString()); + G_QTDataChannel.setBaudRate(ui->serialBaudrateCB->currentText().toInt()); + G_QTDataChannel.setDataBits(QSerialPort::Data8); + G_QTDataChannel.setParity(QSerialPort::NoParity); + G_QTDataChannel.setFlowControl(QSerialPort::NoFlowControl); + G_QTDataChannel.setStopBits(QSerialPort::OneStop); + + /** + * @brief 串口打开时,初始化相应参数 + */ + + if (!G_QTDataChannel.open()) { + QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); + return; + } + ui->serialOpenKey->setText("关闭"); + // 下拉菜单控件使能 + ui->serialBaudrateCB->setEnabled(false); + ui->serialPortCB->setEnabled(false); + ui->serialPortRefreshKey->setEnabled(false); + + IflytopCanbusMaster::ins()->updateChannelConfig(); + } else { + G_QTDataChannel.close(); + ui->serialOpenKey->setText("打开"); + ui->serialBaudrateCB->setEnabled(true); + ui->serialPortCB->setEnabled(true); + ui->serialPortRefreshKey->setEnabled(true); + } + }); + + /** + * @brief 波形串口UI + */ + { + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) { + ui->waveSerialPortCB->addItem(info.portName()); + } + } + + ui->waveSerialBaudrateCB->addItem("9600"); + ui->waveSerialBaudrateCB->addItem("14400"); + ui->waveSerialBaudrateCB->addItem("19200"); + ui->waveSerialBaudrateCB->addItem("38400"); + ui->waveSerialBaudrateCB->addItem("57600"); + ui->waveSerialBaudrateCB->addItem("115200"); + ui->waveSerialBaudrateCB->addItem("460800"); + ui->waveSerialBaudrateCB->addItem("500000"); + ui->waveSerialBaudrateCB->addItem("2000000"); + // ui->waveSerialBaudrateCB->addItems + ui->waveSerialBaudrateCB->setCurrentIndex(6); + + connect(ui->waveSerialPortRefreshKey, &QPushButton::clicked, this, [this](bool check) { + ui->waveSerialPortCB->clear(); + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) { + ui->waveSerialPortCB->addItem(info.portName()); + } + }); + + connect(ui->waveSerialOpenKey, &QPushButton::clicked, this, [=](bool check) { + // 打开串口 + if (ui->waveSerialOpenKey->text() == "打开") { + G_WaveDataChannel.setPortName(ui->waveSerialPortCB->currentText().toStdString()); + G_WaveDataChannel.setBaudRate(ui->waveSerialBaudrateCB->currentText().toInt()); + G_WaveDataChannel.setDataBits(QSerialPort::Data8); + G_WaveDataChannel.setParity(QSerialPort::NoParity); + G_WaveDataChannel.setFlowControl(QSerialPort::NoFlowControl); + G_WaveDataChannel.setStopBits(QSerialPort::OneStop); + + if (!G_WaveDataChannel.open()) { + QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); + return; + } + ui->waveSerialOpenKey->setText("关闭"); + // 下拉菜单控件使能 + ui->waveSerialBaudrateCB->setEnabled(false); + ui->waveSerialPortCB->setEnabled(false); + ui->waveSerialPortRefreshKey->setEnabled(false); + } else { + G_WaveDataChannel.close(); + ui->waveSerialOpenKey->setText("打开"); + ui->waveSerialBaudrateCB->setEnabled(true); + ui->waveSerialPortCB->setEnabled(true); + ui->waveSerialPortRefreshKey->setEnabled(true); + } + }); +} + +void MainWindow::displayInfo(bool suc, QString info) {} + +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { + /** + * @brief QT初始化 + */ + ui->setupUi(this); + m_mainWindow = this; + qRegisterMetaType("int32_t"); + qRegisterMetaType("uint32_t"); + qRegisterMetaType("float"); + qRegisterMetaType>("function"); + qRegisterMetaType("QFunction"); + connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); + ZQUI::ins()->initialize(); + ZQUI::ins()->setBlockDataUploadPreviewShow([this](QString text) { blockDataUploadPreviewShow(text); }); + ZQUI::ins()->setInstructionPreviewShow([this](QString text) { instructionPreviewShow(text); }); + ZQUI::ins()->setReportPreviewShow([this](QString text) { reportPreviewShow(text); }); + ZQUI::ins()->setRawDataPreviewShow([this](QString text) { rawDataPreviewShow(text); }); + ZQUI::ins()->setInstructionPreviewClear([this]() { instructionPreviewClear(); }); + + /** + * @brief 页面逻辑初始化 + */ + constructBaseUI(); + constructAppUI(); + + /** + * @brief 业务逻辑构造 + */ + G_QTDataChannel.init(); + G_WaveDataChannel.init(); + IflytopCanbusMaster::ins()->initialize(&G_QTDataChannel); + + IflytopCanbusMaster::ins()->regOnRawData([this](raw_data_type_t type, uint8_t *hex, uint32_t hexlen) { + if (type == kcmd_cmd) { + iflytop_canbus_frame_t *frame = (iflytop_canbus_frame_t *)hex; + ZQUI::ins()->rawDataPreviewShow("[CMD ] %s %s [id:%d cmd:%d,%d]", zhex2str(hex, sizeof(iflytop_canbus_frame_t)).c_str(), // + zhex2str(frame->data, hexlen - sizeof(iflytop_canbus_frame_t)).c_str(), // + frame->device_id, frame->cmd_main_id, frame->cmd_sub_id // + ); + } else if (type == kcmd_receipt) { + ZQUI::ins()->rawDataPreviewShow("[RECEIPT] %s", zhex2str(hex, hexlen).c_str()); + } else if (type == kcmd_report) { + ZQUI::ins()->rawDataPreviewShow("[REPORT ] %s", zhex2str(hex, hexlen).c_str()); + } + }); +} +MainWindow::~MainWindow() { delete ui; } + +void MainWindow::processException(const zexception &e) { // + ZQUI::ins()->instructionPreviewShow("%s", e.what()); +} + +int32_t MainWindow::getDeviceId() { return PublicState_DeviceIDVal; } + +void MainWindow::constructAppUI() { + /*********************************************************************************************************************** + * 模块操作 * + ***********************************************************************************************************************/ + + { + ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "模块操作"); + + { + 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()->instructionPreviewShow("module :%d isOnline", i); + } catch (const zexception &e) { + if (e.ecode() != ke_overtime) { + processException(e); + break; + } + } + } + ZQUI::ins()->instructionPreviewShow("ScanModuleEnd"); + }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电机配置", 4); + box->newFunc("电机设置编码器分辨率", {"resolution"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_set_enc_resolution(getDeviceId(), atoi(args[0])); }); + box->newFunc("设置IRUM", {"[0-31]"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->writereg(getDeviceId(), kreg_stepmotor_irun, atoi(args[0])); }); + box->newFunc("设置IHOLD", {"[0-31]"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->writereg(getDeviceId(), kreg_stepmotor_ihold, atoi(args[0])); }); + box->newFunc("设置默认速度", {"velocity"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->writereg(getDeviceId(), kreg_motor_default_velocity, atoi(args[0])); }); + box->newFunc("激活配置", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_active_cfg(getDeviceId()); }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电机状态读取", 4); + box->newFunc("电机读取编码器值", {}, [this](int argn, const char **args) { + int32_t retval = IflytopCanbusMaster::ins()->motor_read_enc_val(getDeviceId()); + ZQUI::ins()->instructionPreviewShow("encVal %d", retval); + }); + box->newFunc("电机读取编码器分辨率", {}, [this](int argn, const char **args) { + int32_t retval = IflytopCanbusMaster::ins()->motor_get_enc_resolution(getDeviceId()); + ZQUI::ins()->instructionPreviewShow("encResolution %d", retval); + }); + } + + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电机操作", 4); + box->newFunc("停止电机", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_stop(getDeviceId()); }); + box->newFunc("急停电机", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_break(getDeviceId()); }); + box->newFunc("激活配置", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_active_cfg(getDeviceId()); }); + box->newFunc("电机使能", {"enable"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_enable(getDeviceId(), atoi(args[0])); }); + box->newFunc("电机旋转", {"direction"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_rotate(getDeviceId(), atoi(args[0])); }); + box->newFunc("电机移动", {"distance"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_by(getDeviceId(), atoi(args[0])); }); + box->newFunc("电机移动到", {"position"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_to(getDeviceId(), atoi(args[0])); }); + box->newFunc("电机归零", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_to_zero(getDeviceId()); }); + box->newFunc("电机设置当前位置", {"position"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_set_current_pos(getDeviceId(), atoi(args[0])); }); + box->newFunc("电机移动到IO", {"io"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_easy_move_to_io(getDeviceId(), atoi(args[0])); }); + box->newFunc("电机设置子设备寄存器", {"regaddr", "val"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_set_subdevice_reg(getDeviceId(), atoi(args[0]), atoi(args[1])); }); + box->newFunc("电机读取子设备寄存器", {"regaddr"}, [this](int argn, const char **args) { + int32_t retval = IflytopCanbusMaster::ins()->motor_get_subdevice_reg(getDeviceId(), atoi(args[0])); + ZQUI::ins()->instructionPreviewShow("regVal 0x%08x", retval); + }); + } + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "驱动底层配置", 4); + box->newFunc("电机设置子设备寄存器", {"regaddr", "val"}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->motor_set_subdevice_reg(getDeviceId(), atoi(args[0]), atoi(args[1])); }); + box->newFunc("电机读取子设备寄存器", {"regaddr"}, [this](int argn, const char **args) { + int32_t retval = IflytopCanbusMaster::ins()->motor_get_subdevice_reg(getDeviceId(), atoi(args[0])); + ZQUI::ins()->instructionPreviewShow("regVal 0x%08x", retval); + }); + } + + tab->addSpacer(); + } + + m_testThread.reset(new std::thread([this]() { + while (true) { + if (m_testState) { + try { + IflytopCanbusMaster::ins()->ping(getDeviceId()); + } catch (const zexception &e) { + processException(e); + } + } + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + })); + + { + ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "暴力测试"); + // static + { + ZQFunctionListBox *box = new ZQFunctionListBox(tab, "模块基础操作", 4); + box->newFunc("开始测试", {"间隔"}, [this](int argn, const char **args) { // + int interval = atoi(args[0]); + m_testState = true; + }); + + box->newFunc("停止测试", {}, [this](int argn, const char **args) { // + m_testState = false; + }); + } + } + + /*********************************************************************************************************************** + * 寄存器列表 * + ***********************************************************************************************************************/ + { + ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "寄存器操作"); + + ZRegTableList *tableBox = new ZRegTableList(tab, "寄存器操作"); + tableBox->initializeRegOperation( + [this](int32_t add, int32_t val) { // + IflytopCanbusMaster::ins()->writereg(getDeviceId(), add, val); + return true; + }, + [this](int32_t add, int32_t *val) { // + IflytopCanbusMaster::ins()->readreg(getDeviceId(), add, val); + return true; + }); + + tableBox->newFunc("激活配置", {}, [this](int argn, const char **args) { IflytopCanbusMaster::ins()->module_active_cfg(getDeviceId()); }); + for (auto &var : GetRegList()) { + tableBox->addReg(var.title.c_str(), var.addr, var.flag); + } + tableBox->addSpacer(); + tab->addSpacer(); + } +} + +void MainWindow::on_PublicState_ConfirmKey_clicked() { PublicState_DeviceIDVal = ui->PublicState_DeviceID->toPlainText().toInt(); } diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..f0920a1 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,125 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "logger.hpp" +#include "qfunction.hpp" +#include "zexception.hpp" +#include "zqthread.hpp" +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +typedef enum { + kreg_val_type_dotted_hex, // 点分16进制 + kreg_val_type_dotted_decimal, // 点分10进制 + kreg_val_type_str, + kreg_val_type_hex, + kreg_val_type_decimal, + kreg_val_type_binary, + kreg_val_type_freq, + kreg_val_type_signal, +} reg_val_type_t; + +class DispalyRegIterm { + public: + QLabel *label = 0; + QTextBrowser *regBrowser = 0; + QTextEdit *regEditer = 0; + QPushButton *writerButton = 0; + uint32_t regvalcache; + reg_val_type_t regvaltype; +}; + +class MainWindow : public QMainWindow { + Q_OBJECT + + private: + std::map m_regdisplayer; + + std::unique_ptr m_thread; + + bool m_testState = false; + std::unique_ptr m_testThread; + + public: + Ui::MainWindow *ui; + + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + void constructBaseUI(); + void constructAppUI(); + + private slots: + void doinui_slot(QFunction); + + void on_PublicState_ConfirmKey_clicked(); + +signals: + void doinui_signal(QFunction); + + private: + static void log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg); + + void instructionPreviewClear(); + void instructionPreviewShow(QString info); + void reportPreviewShow(QString info); + void blockDataUploadPreviewShow(QString info); + void rawDataPreviewShow(QString info); + + void displayWave(int16_t wave1, int16_t wave2, int16_t wave3); + + void displayInfo(bool suc, QString info); + + private: + void processException(const std::zexception &e); + + private: + /*********************************************************************************************************************** + * UI_UTILS * + ***********************************************************************************************************************/ + + QWidget *allocNewTab(QString zh_name); + QGroupBox *allocNewBox(QWidget *tab, QString zh_name, int column); + void addNewButtonStyle1(QWidget *box, QString zh_name, QStringList params, std::function onButtonClick); + void endAllocNewBox(QGroupBox *box); + void endAllocNewTab(QWidget *tab); + + int32_t getDeviceId(); +}; +#endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 0000000..385d7b2 --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,1154 @@ + + + MainWindow + + + + 0 + 0 + 1448 + 1040 + + + + + 0 + 8 + + + + A8000上位机 + + + /* +Aqua Style Sheet for QT Applications +Author: Jaime A. Quiroga P. +Company: GTRONICK +Last updated: 22/01/2019, 07:55. +Available at: https://github.com/GTRONICK/QSS/blob/master/Aqua.qss +*/ +QMainWindow { + background-color:#ececec; +} +QTextEdit { + border-width: 1px; + border-style: solid; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QPlainTextEdit { + border-width: 1px; + border-style: solid; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QToolButton { + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QToolButton:hover{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QToolButton:pressed{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(142,142,142); +} +QPushButton{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QPushButton::default{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QPushButton:hover{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(197, 197, 197), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(197, 197, 197)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(195, 195, 195), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(255,255,255); +} +QPushButton:pressed{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: rgb(0,0,0); + padding: 2px; + background-color: rgb(142,142,142); +} +QPushButton:disabled{ + border-style: solid; + border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-right-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(217, 217, 217), stop:1 rgb(227, 227, 227)); + border-left-color: qlineargradient(spread:pad, x1:0, y1:0.5, x2:1, y2:0.5, stop:0 rgb(227, 227, 227), stop:1 rgb(217, 217, 217)); + border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgb(215, 215, 215), stop:1 rgb(222, 222, 222)); + border-width: 1px; + border-radius: 5px; + color: #808086; + padding: 2px; + background-color: rgb(142,142,142); +} +QLineEdit { + border-width: 1px; border-radius: 4px; + border-style: solid; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QLabel { + color: #000000; +} +QLCDNumber { + color: rgb(0, 113, 255, 255); +} +QProgressBar { + text-align: center; + color: rgb(240, 240, 240); + border-width: 1px; + border-radius: 10px; + border-color: rgb(230, 230, 230); + border-style: solid; + background-color:rgb(207,207,207); +} +QProgressBar::chunk { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); + border-radius: 10px; +} +QMenuBar { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); +} +QMenuBar::item { + color: #000000; + spacing: 3px; + padding: 1px 4px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(207, 209, 207, 255), stop:1 rgba(230, 229, 230, 255)); +} + +QMenuBar::item:selected { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #FFFFFF; +} +QMenu::item:selected { + border-style: solid; + border-top-color: transparent; + border-right-color: transparent; + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + border-bottom-color: transparent; + border-left-width: 2px; + color: #000000; + padding-left:15px; + padding-top:4px; + padding-bottom:4px; + padding-right:7px; +} +QMenu::item { + border-style: solid; + border-top-color: transparent; + border-right-color: transparent; + border-left-color: transparent; + border-bottom-color: transparent; + border-bottom-width: 1px; + color: #000000; + padding-left:17px; + padding-top:4px; + padding-bottom:4px; + padding-right:7px; +} +QTabWidget { + color:rgb(0,0,0); + background-color:#000000; +} +QTabWidget::pane { + border-color: rgb(223,223,223); + background-color:rgb(226,226,226); + border-style: solid; + border-width: 2px; + border-radius: 6px; +} +QTabBar::tab:first { + border-style: solid; + border-left-width:1px; + border-right-width:0px; + border-top-width:1px; + border-bottom-width:1px; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + color: #000000; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); +} +QTabBar::tab:last { + border-style: solid; + border-width:1px; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-right-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + color: #000000; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); +} +QTabBar::tab { + border-style: solid; + border-top-width:1px; + border-bottom-width:1px; + border-left-width:1px; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + color: #000000; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(255, 255, 255, 255)); +} +QTabBar::tab:selected, QTabBar::tab:last:selected, QTabBar::tab:hover { + border-style: solid; + border-left-width:1px; + border-right-color: transparent; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + color: #FFFFFF; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} + +QTabBar::tab:selected, QTabBar::tab:first:selected, QTabBar::tab:hover { + border-style: solid; + border-left-width:1px; + border-bottom-width:1px; + border-top-width:1px; + border-right-color: transparent; + border-top-color: rgb(209,209,209); + border-left-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(209, 209, 209, 209), stop:1 rgba(229, 229, 229, 229)); + border-bottom-color: rgb(229,229,229); + color: #FFFFFF; + padding: 3px; + margin-left:0px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} + +QCheckBox { + color: #000000; + padding: 2px; +} +QCheckBox:disabled { + color: #808086; + padding: 2px; +} + +QCheckBox:hover { + border-radius:4px; + border-style:solid; + padding-left: 1px; + padding-right: 1px; + padding-bottom: 1px; + padding-top: 1px; + border-width:1px; + border-color: transparent; +} +QCheckBox::indicator:checked { + + height: 10px; + width: 10px; + border-style:solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #000000; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QCheckBox::indicator:unchecked { + + height: 10px; + width: 10px; + border-style:solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #000000; +} +QRadioButton { + color: 000000; + padding: 1px; +} +QRadioButton::indicator:checked { + height: 10px; + width: 10px; + border-style:solid; + border-radius:5px; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #a9b7c6; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QRadioButton::indicator:!checked { + height: 10px; + width: 10px; + border-style:solid; + border-radius:5px; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); + color: #a9b7c6; + background-color: transparent; +} +QStatusBar { + color:#027f7f; +} +QSpinBox { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QDoubleSpinBox { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QTimeEdit { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QDateTimeEdit { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} +QDateEdit { + border-style: solid; + border-width: 1px; + border-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(0, 113, 255, 255), stop:1 rgba(91, 171, 252, 255)); +} + +QToolBox { + color: #a9b7c6; + background-color:#000000; +} +QToolBox::tab { + color: #a9b7c6; + background-color:#000000; +} +QToolBox::tab:selected { + color: #FFFFFF; + background-color:#000000; +} +QScrollArea { + color: #FFFFFF; + background-color:#000000; +} +QSlider::groove:horizontal { + height: 5px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QSlider::groove:vertical { + width: 5px; + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QSlider::handle:horizontal { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + width: 12px; + margin: -5px 0; + border-radius: 7px; +} +QSlider::handle:vertical { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + height: 12px; + margin: 0 -5px; + border-radius: 7px; +} +QSlider::add-page:horizontal { + background: rgb(181,181,181); +} +QSlider::add-page:vertical { + background: rgb(181,181,181); +} +QSlider::sub-page:horizontal { + background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QSlider::sub-page:vertical { + background-color: qlineargradient(spread:pad, y1:0.5, x1:1, y2:0.5, x2:0, stop:0 rgba(49, 147, 250, 255), stop:1 rgba(34, 142, 255, 255)); +} +QScrollBar:horizontal { + max-height: 20px; + border: 1px transparent grey; + margin: 0px 20px 0px 20px; +} +QScrollBar:vertical { + max-width: 20px; + border: 1px transparent grey; + margin: 20px 0px 20px 0px; +} +QScrollBar::handle:horizontal { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + border-radius: 7px; + min-width: 25px; +} +QScrollBar::handle:horizontal:hover { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(147, 200, 200); + border-radius: 7px; + min-width: 25px; +} +QScrollBar::handle:vertical { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(207,207,207); + border-radius: 7px; + min-height: 25px; +} +QScrollBar::handle:vertical:hover { + background: rgb(253,253,253); + border-style: solid; + border-width: 1px; + border-color: rgb(147, 200, 200); + border-radius: 7px; + min-height: 25px; +} +QScrollBar::add-line:horizontal { + border: 2px transparent grey; + border-top-right-radius: 7px; + border-bottom-right-radius: 7px; + background: rgba(34, 142, 255, 255); + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} +QScrollBar::add-line:horizontal:pressed { + border: 2px transparent grey; + border-top-right-radius: 7px; + border-bottom-right-radius: 7px; + background: rgb(181,181,181); + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} +QScrollBar::add-line:vertical { + border: 2px transparent grey; + border-bottom-left-radius: 7px; + border-bottom-right-radius: 7px; + background: rgba(34, 142, 255, 255); + height: 20px; + subcontrol-position: bottom; + subcontrol-origin: margin; +} +QScrollBar::add-line:vertical:pressed { + border: 2px transparent grey; + border-bottom-left-radius: 7px; + border-bottom-right-radius: 7px; + background: rgb(181,181,181); + height: 20px; + subcontrol-position: bottom; + subcontrol-origin: margin; +} +QScrollBar::sub-line:horizontal { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-bottom-left-radius: 7px; + background: rgba(34, 142, 255, 255); + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} +QScrollBar::sub-line:horizontal:pressed { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-bottom-left-radius: 7px; + background: rgb(181,181,181); + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} +QScrollBar::sub-line:vertical { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-top-right-radius: 7px; + background: rgba(34, 142, 255, 255); + height: 20px; + subcontrol-position: top; + subcontrol-origin: margin; +} +QScrollBar::sub-line:vertical:pressed { + border: 2px transparent grey; + border-top-left-radius: 7px; + border-top-right-radius: 7px; + background: rgb(181,181,181); + height: 20px; + subcontrol-position: top; + subcontrol-origin: margin; +} +QScrollBar::left-arrow:horizontal { + border: 1px transparent grey; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::right-arrow:horizontal { + border: 1px transparent grey; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::up-arrow:vertical { + border: 1px transparent grey; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::down-arrow:vertical { + border: 1px transparent grey; + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; + width: 6px; + height: 6px; + background: white; +} +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { + background: none; +} +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + + + + + + + + + + + 0 + 0 + + + + + + + + 200 + 0 + + + + + 200 + 16777215 + + + + + + + + 16777215 + 16777215 + + + + 串口设置 + + + + + + + + + 打开 + + + + + + + + + + 波特率 + + + + + + + 串口 + + + + + + + 刷新 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + 通用参数 + + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 设备ID + + + + + + + + 1 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 2 + + + + + + + 提交 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + false + + + 状态 + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 设备连接状态 + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 2 + + + + + + + + + + + 0 + 0 + + + + 功能按键 + + + + + + + 1 + 0 + + + + + 0 + 30 + + + + 清空显示 + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Qt::DefaultContextMenu + + + 0 + + + + 波形显示器 + + + + + 20 + 20 + 182 + 126 + + + + + 16777215 + 16777215 + + + + 波形串口设置 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 波特率 + + + + + + + 打开 + + + + + + + 串口 + + + + + + + 刷新 + + + + + + + + + + + + + 0 + 0 + + + + + 600 + 0 + + + + + 600 + 16777215 + + + + DisplayBox + + + + + + 指令回执显示 + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + 上报回执显示 + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + 上传数据显示 + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + 二进制 + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1448 + 20 + + + + + iflytop + + + + + + + + +