Prechádzať zdrojové kódy

V0.7
1、基本完成了

Apple 3 dní pred
rodič
commit
0694a791a0
55 zmenil súbory, kde vykonal 2112 pridanie a 2045 odobranie
  1. 2 0
      .gitignore
  2. 9 11
      CMakeLists.txt
  3. BIN
      Common/TipWidget/Tip/Complete2x.png
  4. BIN
      Common/TipWidget/Tip/Failed2x.png
  5. BIN
      Common/TipWidget/Tip/Tips2x.png
  6. BIN
      Common/TipWidget/Tip/Wait2x.png
  7. 8 0
      Common/TipWidget/tip.qrc
  8. 244 0
      Common/TipWidget/tipwidget.cpp
  9. 54 0
      Common/TipWidget/tipwidget.h
  10. 84 0
      Common/TipWidget/tipwidget.ui
  11. 28 0
      Common/combox/ColorDelegate.cpp
  12. 18 0
      Common/combox/ColorDelegate.h
  13. BIN
      Common/softdog/DOGDLL.DLL
  14. BIN
      Common/softdog/DogCheck3.dll
  15. BIN
      Common/softdog/DogCheck4.dll
  16. 39 0
      Common/softdog/softdog.cpp
  17. 28 0
      Common/softdog/softdog.h
  18. 33 0
      Common/warning/warning.cpp
  19. 8 1
      Common/warning/warning.h
  20. 36 39
      Common/warning/warning.ui
  21. 8 5
      Common/warning/warning_dark.qss
  22. 23 16
      Common/warning/warning_light.qss
  23. 21 4
      EyeMap/CMakeLists.txt
  24. 32 22
      EyeMap/EyeMapWidget/eyemapwidget.cpp
  25. 78 19
      EyeMap/GlobalInfo/EyeMapInfo.cpp
  26. 16 5
      EyeMap/GlobalInfo/EyeMapInfo.h
  27. 203 113
      EyeMap/GlobalInfo/OscDataInfo.cpp
  28. 34 31
      EyeMap/GlobalInfo/OscDataInfo.h
  29. 138 36
      EyeMap/OneEyeMap/OneEyeMap.cpp
  30. 21 8
      EyeMap/OneEyeMap/OneEyeMap.h
  31. 480 120
      EyeMap/OscData/OneOsc.cpp
  32. 73 27
      EyeMap/OscData/OneOsc.h
  33. 0 1129
      EyeMap/OscData/OscData.cpp_
  34. 0 132
      EyeMap/OscData/OscData.h_
  35. 1 1
      EyeMap/ParameterConfig/OneParamItem/OneParamItem.qss
  36. 32 18
      EyeMap/ParameterConfig/paramconfig.cpp
  37. 7 4
      EyeMap/ParameterConfig/paramconfig.h
  38. BIN
      EyeMap/Resource/icon/EyePattern_Logo.ico
  39. BIN
      EyeMap/Resource/icon/EyePattern_Logo.png
  40. 17 1
      EyeMap/SettingNum/OneItem/OneSettingItem.qss
  41. 38 0
      EyeMap/SettingNum/OneItem/onesettingitem.cpp
  42. 5 0
      EyeMap/SettingNum/OneItem/onesettingitem.h
  43. 10 1
      EyeMap/SettingNum/SettingNum.qss
  44. 118 47
      EyeMap/SettingNum/settingnum.cpp
  45. 15 4
      EyeMap/SettingNum/settingnum.h
  46. 13 0
      EyeMap/SettingNum/settingnum.ui
  47. 50 0
      EyeMap/app.rc
  48. 4 0
      EyeMap/eyemap.qrc
  49. 41 7
      EyeMap/main.cpp
  50. 21 0
      EyeMap/version.h
  51. 0 124
      oscwidget.cpp
  52. 0 38
      oscwidget.h
  53. 0 82
      oscwidget.ui
  54. 20 0
      说明.md
  55. 2 0
      问题.txt

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+/.svn
+External/

+ 9 - 11
CMakeLists.txt

@@ -13,20 +13,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 
 #=========================================================
-#********************  指定Qt安装路径 ********************
+#*******************  设置可执行文件名称 ******************
 #=========================================================
-# option(QT_5.12.12 "使用Qt5.12.12" OFF)
 
-# if(QT_5.12.12)
-#     if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
-#         set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.12.12/5.12.12/mingw73_64")
-#     elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
-#         set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.12.12/5.12.12/msvc2017_64/bin")
-#     endif()
-# endif()
+set(execName1 EyePattern)
+
 
 #=========================================================
-#*************  设置可执行文件的名称和输出位置 *************
+#*****************  设置可执行文件输出位置 ****************
 #=========================================================
 
 
@@ -95,13 +89,17 @@ if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
     )
     #消除MSVC对SPDLOG的兼容性警告
     add_compile_definitions("_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING")
+    #添加MSVC的宏定义
+    add_compile_definitions(MSVC)
 endif()
 
 #添加一些gcc的编译属性
 if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
 #    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
 #    #添加编译参数,这个参数会应用到全局,C和C++都会生效
-#    add_compile_options(-Wall -O2)
+   add_compile_options(-Wall -O2)
+    #添加GCC的宏定义
+    add_compile_definitions(GCC)
 endif()
 
 

BIN
Common/TipWidget/Tip/Complete2x.png


BIN
Common/TipWidget/Tip/Failed2x.png


BIN
Common/TipWidget/Tip/Tips2x.png


BIN
Common/TipWidget/Tip/Wait2x.png


+ 8 - 0
Common/TipWidget/tip.qrc

@@ -0,0 +1,8 @@
+<RCC>
+    <qresource prefix="/">
+        <file>Tip/Complete2x.png</file>
+        <file>Tip/Failed2x.png</file>
+        <file>Tip/Tips2x.png</file>
+        <file>Tip/Wait2x.png</file>
+    </qresource>
+</RCC>

+ 244 - 0
Common/TipWidget/tipwidget.cpp

@@ -0,0 +1,244 @@
+#include "tipwidget.h"
+#include "ui_tipwidget.h"
+#include <QPainter>
+#include <QTimer>
+#include <QPropertyAnimation>
+#include <QGraphicsOpacityEffect>
+#include <QPixmap>
+#include <QElapsedTimer>
+#include <QTime>
+#include <QDebug>
+
+static QList<TipWidget*> sl_tipWdgs{Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR};
+
+void TipWidget::display(FormType type, QWidget* parent, int nTitleHeight)
+{
+    if (Q_NULLPTR == parent || sl_tipWdgs.count() > 4)
+        return;
+    static QElapsedTimer s_timer;
+    if (s_timer.elapsed() > 5 && s_timer.restart() < 500)
+    {
+        return;
+    }
+
+    int nPosX = (parent->width() - WIDTH) / 2;
+    int nPosY = nTitleHeight;
+    TipWidget* obj = Q_NULLPTR;
+    for (int i = 0; i < sl_tipWdgs.count(); ++i)
+    {
+        if (sl_tipWdgs.at(i) == Q_NULLPTR)
+        {
+            obj = new TipWidget(type, parent);
+            obj->setEndPos(nPosX, nPosY + i * HEIGHT + 10);
+            if (!obj->isVisible())
+                obj->show();
+            obj->run();
+            sl_tipWdgs[i] = obj;
+            break;
+        }
+    }
+}
+/* 这个是上面的重载函数,可以自定义文本 */
+void TipWidget::display(FormType type, QString text, QWidget *parent, int nTitleHeight)
+{
+    if (Q_NULLPTR == parent || sl_tipWdgs.count() > 4)
+        return;
+    static QElapsedTimer s_timer;
+    if (s_timer.elapsed() > 5 && s_timer.restart() < 500)
+    {
+        return;
+    }
+
+    int nPosX = (parent->width() - WIDTH) / 2;
+    int nPosY = nTitleHeight;
+    TipWidget* obj = Q_NULLPTR;
+    for (int i = 0; i < sl_tipWdgs.count(); ++i)
+    {
+        if (sl_tipWdgs.at(i) == Q_NULLPTR)
+        {
+            obj = new TipWidget(type, text, parent);
+
+            obj->setEndPos(nPosX, nPosY + i * HEIGHT + 10);
+            if (!obj->isVisible())
+                obj->show();
+            obj->run();
+            sl_tipWdgs[i] = obj;
+            break;
+        }
+    }
+}
+
+TipWidget::TipWidget(FormType type, QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::TipWidget)
+{
+    ui->setupUi(this);
+    setWindowFlag(Qt::FramelessWindowHint);
+    _endRect = rect();
+    setFormType(type);
+//    ui->label_tipIcon->hide();
+    m_customText = false;
+}
+
+TipWidget::TipWidget(FormType type, QString& text, QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::TipWidget),
+    m_tipText(text)
+{
+    ui->setupUi(this);
+    setWindowFlag(Qt::FramelessWindowHint);
+    _endRect = rect();
+    m_customText = true;
+    setFormType(type);
+    /* 设置字体居中 */
+    ui->label_tipTitle->setAlignment(Qt::AlignCenter);
+    if(text.count() > 5)
+    {
+        QFontMetrics fm(ui->label_tipTitle->font());
+        auto textWidth = fm.width(text);
+        int width = textWidth + this->width() - ui->label_tipTitle->width();
+        this->setFixedWidth(width);
+    }
+}
+
+TipWidget::~TipWidget()
+{
+    delete ui;
+}
+
+void TipWidget::setFormType(FormType type)
+{
+    QPixmap img;
+    switch(type)
+    {
+    case OPERATOR_OK:
+        _backgroundColor = QColor(246, 255, 237);
+        _borderColor = QColor(183, 235, 143);
+        img.load(R"(:/Tip/Complete2x.png)");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("操作成功!");
+        }
+        break;
+    case OPERATOR_FAIL:
+        _backgroundColor = QColor(255, 241, 240);
+        _borderColor = QColor(255, 163, 158);
+        img.load(":/Tip/Failed2x.png");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("操作失败!");
+        }
+        break;
+    case OPERATOR_TIP:
+        _backgroundColor = QColor(236, 238, 254);
+        _borderColor = QColor(68, 88, 254);
+        img.load(":/Tip/Wait2x.png");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("普通提示!");
+        }
+        break;
+    case OPERATOR_WARN:
+        _backgroundColor = QColor(255, 251, 230);
+        _borderColor = QColor(255, 229, 143);
+        img.load(":/Tip/Tips2x.png");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("需注意!");
+        }
+        break;
+
+    default:
+        break;
+    }
+    img = img.scaled(ui->label_tipIcon->width(), ui->label_tipIcon->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    ui->label_tipIcon->setPixmap(img);
+}
+
+void TipWidget::setEndPos(int x, int y)
+{
+    _endRect.moveTo(x, y);
+}
+
+void TipWidget::run()
+{
+    if (nullptr == _animation)
+        _animation = new QPropertyAnimation(this, "geometry");
+    _animation->setDuration(1 * 1000);
+    _animation->setStartValue(QRect(_endRect.x(), _endRect.y() + 150, _endRect.width(), _endRect.height()));
+    _animation->setEndValue(_endRect);
+    connect(_animation, &QPropertyAnimation::finished, this, [this]{
+        if (nullptr == _pKillTimer)
+            _pKillTimer = new QTimer(this);
+        _pKillTimer->start(1 * 1000);
+        connect(_pKillTimer, &QTimer::timeout, this, &TipWidget::onFadeOut);
+    });
+    _animation->start();
+}
+
+void TipWidget::onFadeOut()
+{
+    if (nullptr != _pKillTimer && _pKillTimer->isActive())
+    {
+        _pKillTimer->stop();
+    }
+    QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect(this);
+    this->setGraphicsEffect(effect);
+    if (nullptr == _animFadeOut)
+        _animFadeOut = new QPropertyAnimation(effect, "opacity");
+    _animFadeOut->setDuration(1 * 1000);
+    _animFadeOut->setStartValue(1.0);
+    _animFadeOut->setEndValue(0.0);
+    connect(_animFadeOut, &QPropertyAnimation::finished, this, [this]{
+        onBtnClose();
+    });
+    _animFadeOut->start();
+}
+
+void TipWidget::onBtnClose()
+{
+    close();
+    for (int i = 0; i < sl_tipWdgs.count(); ++i)
+    {
+        if (sl_tipWdgs.at(i) == this)
+        {
+            sl_tipWdgs[i] = Q_NULLPTR;
+        }
+    }
+    deleteLater();
+}
+
+void TipWidget::paintEvent(QPaintEvent *event)
+{
+    QRect rc(rect());
+    rc.adjust(1, 1, -2, -2);
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing, true);
+    painter.save();
+    QBrush brush(_backgroundColor);
+    painter.setBrush(brush);
+    painter.drawRoundedRect(rc, 2.0, 2.0);
+    painter.restore();
+
+    painter.save();
+    QPen pen;
+    pen.setWidth(2);
+    pen.setColor(_borderColor);
+    painter.setPen(pen);
+    painter.setBrush(Qt::transparent);
+    painter.drawRoundedRect(rc, 2.0, 2.0);
+    painter.restore();
+    QWidget::paintEvent(event);
+}

+ 54 - 0
Common/TipWidget/tipwidget.h

@@ -0,0 +1,54 @@
+#ifndef TIPWIDGET_H
+#define TIPWIDGET_H
+
+#include <QWidget>
+
+class QPropertyAnimation;
+namespace Ui {
+class TipWidget;
+}
+
+class TipWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    enum FormType
+    {
+        OPERATOR_OK = 0,        // 操作成功!
+        OPERATOR_FAIL,          // 操作失败!
+        OPERATOR_TIP,           // 普通提示!
+        OPERATOR_WARN,          // 需注意!
+    };
+public:
+    static const int WIDTH = 168;
+    static const int HEIGHT = 56;
+    static void display(FormType type, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
+    static void display(FormType type, QString text, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
+
+    explicit TipWidget(FormType type, QWidget *parent = 0);
+    TipWidget(FormType type, QString& text, QWidget *parent = 0);
+    ~TipWidget();
+
+    void setEndPos(int x, int y);
+    void run();
+public slots:
+    void onBtnClose();
+    void onFadeOut();
+protected:
+    void paintEvent(QPaintEvent *event) override;
+private:
+    void setFormType(FormType type);
+private:
+    Ui::TipWidget *ui;
+    QColor _backgroundColor{246, 255, 237};
+    QColor _borderColor{183, 235, 143};
+    QRect _endRect;
+    QTimer* _pKillTimer{nullptr};
+    QPropertyAnimation* _animation{nullptr};
+    QPropertyAnimation* _animFadeOut{nullptr};
+
+    QString m_tipText;              /* 提示文本 */
+    bool m_customText;              /* 自定义文本标志 */
+};
+
+#endif // TIPWIDGET_H

+ 84 - 0
Common/TipWidget/tipwidget.ui

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TipWidget</class>
+ <widget class="QWidget" name="TipWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>168</width>
+    <height>56</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">QLabel
+{
+background:transparent;
+}
+
+QLabel#label_tipIcon
+{
+font-weight: 500;
+font-size: 16px;
+color: rgba(0,0,0,0.85);
+line-height: 24px;
+text-align: left;
+font-style: normal;
+}
+</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout">
+   <item>
+    <widget class="QLabel" name="label_tipIcon">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>24</width>
+       <height>24</height>
+      </size>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>24</width>
+       <height>24</height>
+      </size>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="label_tipTitle">
+     <property name="styleSheet">
+      <string notr="true">font-family:&quot;Source Han Sans CN&quot;;
+font-size: 16px;
+font-weight: 500;
+color: rgba(0,0,0,0.85);</string>
+     </property>
+     <property name="text">
+      <string>保存成功!</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+  <zorder>label_tipTitle</zorder>
+  <zorder>label_tipIcon</zorder>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 28 - 0
Common/combox/ColorDelegate.cpp

@@ -0,0 +1,28 @@
+#include "ColorDelegate.h"
+
+
+
+void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+    painter->save();
+    // 获取文本
+    QString text = index.data().toString();
+    // 分割文本为两部分
+    QStringList parts = text.split(" ");
+    if (parts.size() < 2) {
+        QStyledItemDelegate::paint(painter, option, index);
+        painter->restore();
+        return;
+    }
+    // 设置第一部分的颜色
+    painter->setPen(Qt::red);
+    painter->drawText(option.rect, Qt::AlignLeft, parts[0]);
+    // 计算第一部分文本的宽度
+    int firstPartWidth = painter->fontMetrics().width(parts[0]);
+    // 设置第二部分的颜色
+    painter->setPen(Qt::green);
+    painter->drawText(option.rect.adjusted(firstPartWidth, 0, 0, 0), Qt::AlignRight, parts[1]);
+    painter->restore();
+}
+
+

+ 18 - 0
Common/combox/ColorDelegate.h

@@ -0,0 +1,18 @@
+#ifndef COLORDELEGATE_H
+#define COLORDELEGATE_H
+
+#include <QStyledItemDelegate>
+#include <QPainter>
+
+class ColorDelegate : public QStyledItemDelegate 
+{
+    Q_OBJECT
+public:
+    ColorDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
+
+    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+    
+};
+
+
+#endif /* COLORDELEGATE_H */

BIN
Common/softdog/DOGDLL.DLL


BIN
Common/softdog/DogCheck3.dll


BIN
Common/softdog/DogCheck4.dll


+ 39 - 0
Common/softdog/softdog.cpp

@@ -0,0 +1,39 @@
+#include "softdog.h"
+
+#include <QApplication>
+
+bool SoftDog::DogCheck(QString &errMsg, int nAddr, const QString &appName)
+{
+    errMsg = "";
+#ifdef Q_OS_WIN
+    QString appPath = QApplication::applicationDirPath() + "/DogCheck4.dll";
+#else
+    QString appPath = QApplication::applicationDirPath() + "/libLHDogCheck.so";
+#endif
+    QLibrary mylib(appPath);
+    if(!mylib.load())
+    {
+        errMsg = "加载动态库失败! 路径:" + appPath;
+        return false;
+    }
+    
+    if(!mylib.isLoaded() && !mylib.load())
+    {
+        errMsg = "缺少认证库,请不要非法使用软件!";
+        return false;
+    }
+    typedef int (*FunLHCheckDog)(int nAddr, const char* lpszName);
+    FunLHCheckDog fnCheck = reinterpret_cast<FunLHCheckDog>(mylib.resolve("LHCheckDog"));
+    if(fnCheck == nullptr)
+    {
+        errMsg = "认证库不对,请不要非法使用软件!";
+        return false;
+    }
+    if(fnCheck == nullptr) return false;
+    if(fnCheck(nAddr, appName.toLocal8Bit()) != 0)
+    {
+        errMsg = "请不要非法使用软件!";
+        return false;
+    }
+    return true;
+}

+ 28 - 0
Common/softdog/softdog.h

@@ -0,0 +1,28 @@
+#ifndef SOFTDOG_H
+#define SOFTDOG_H
+
+#include <QObject>
+#include <QLibrary>
+    
+// 加密狗
+// QString errMsg;
+// if(!(GeneralUtility::DogCheck(errMsg, 35, QLatin1String("cas0m")))) 
+// {
+//     MessageBox::execTip(errMsg, MessageBox::ERROR, true);
+//     return 0;
+// }
+	
+
+class SoftDog
+{
+
+public:
+    static bool DogCheck(QString &errMsg, int nAddr, const QString &appName);
+
+
+};
+
+
+
+
+#endif // SOFTDOG_H

+ 33 - 0
Common/warning/warning.cpp

@@ -5,6 +5,7 @@
 #include <QLayout>
 #include <QDebug>
 #include <QFile>
+#include <QMouseEvent>
 
 #include "oneshadow.h"
 
@@ -72,6 +73,38 @@ void Warning::paintEvent(QPaintEvent *event)
     painter.drawImage(QPoint(0,0),m_shadow->image());
 }
 
+/* 鼠标点击事件 */
+void Warning::mousePressEvent(QMouseEvent *event)
+{
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标移动事件 */
+void Warning::mouseMoveEvent(QMouseEvent *event)
+{
+    // auto point = ui->widget_top->mapToGlobal(QPoint(0, 0));
+    auto point = this->mapToGlobal(QPoint(0, 0));
+    QRect rect(point, QSize(this->width(), 60));
+    if(!rect.contains(m_lastPos))
+    {
+        event->accept();
+        return;
+    }
+
+    int dx = event->globalX() - m_lastPos.x();
+    int dy = event->globalY() - m_lastPos.y();
+    this->move(this->x() + dx, this->y() + dy);
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标释放事件 */
+void Warning::mouseReleaseEvent(QMouseEvent *event)
+{
+    event->accept();
+}
+
 
 
 void Warning::do_ok()

+ 8 - 1
Common/warning/warning.h

@@ -24,7 +24,13 @@ signals:
     void signal_ok();
 
 protected:
-    void paintEvent(QPaintEvent *event);
+    void paintEvent(QPaintEvent *event) override;
+    /* 鼠标点击事件 */
+    void mousePressEvent(QMouseEvent *event) override;
+    /* 鼠标移动事件 */
+    void mouseMoveEvent(QMouseEvent *event) override;
+    /* 鼠标释放事件 */
+    void mouseReleaseEvent(QMouseEvent *event) override;
 
 private slots:
     void do_ok();
@@ -35,6 +41,7 @@ private:
     OneShadow* m_shadow = nullptr;
     const int SHADOW_W = 16;                /* 阴影的大小 */
     bool m_isOk = false;
+    QPoint m_lastPos;
 };
 
 #endif // WARNING_H

+ 36 - 39
Common/warning/warning.ui

@@ -40,45 +40,6 @@ background:transparent;
      <property name="styleSheet">
       <string notr="true"/>
      </property>
-     <widget class="QLabel" name="label_NC1">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>18</y>
-        <width>90</width>
-        <height>18</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>提示</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_line">
-      <property name="geometry">
-       <rect>
-        <x>0</x>
-        <y>56</y>
-        <width>416</width>
-        <height>1</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_close">
-      <property name="geometry">
-       <rect>
-        <x>368</x>
-        <y>12</y>
-        <width>32</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
      <widget class="QLabel" name="label_Warn">
       <property name="geometry">
        <rect>
@@ -118,6 +79,42 @@ background:transparent;
        <string>确定</string>
       </property>
      </widget>
+     <widget class="QWidget" name="widget_Top" native="true">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>416</width>
+        <height>50</height>
+       </rect>
+      </property>
+      <widget class="QLabel" name="label_NC1">
+       <property name="geometry">
+        <rect>
+         <x>32</x>
+         <y>16</y>
+         <width>90</width>
+         <height>18</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>提示</string>
+       </property>
+      </widget>
+      <widget class="QPushButton" name="pBtn_close">
+       <property name="geometry">
+        <rect>
+         <x>368</x>
+         <y>13</y>
+         <width>24</width>
+         <height>24</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </widget>
     </widget>
    </item>
   </layout>

+ 8 - 5
Common/warning/warning_dark.qss

@@ -25,9 +25,11 @@ QLabel#label_NC1
     text-transform: uppercase;
 }
 
-QLabel#label_line
+QWidget#widget_Top
 {
-    background: rgba(255,255,255,0.15);
+    background: rgba(108,105,124,0.2);
+    border-top-left-radius: 10px;
+    border-top-right-radius: 10px;
 }
 
 QLabel#label_Warn
@@ -40,13 +42,14 @@ QLabel#label_Warn
     font-style: normal;
 }
 
-QPushButton#pBtn_close{
+QPushButton#pBtn_close
+{
     background: transparent;
     border: none;
 	border-image: url(:/image/Resource/image/close_dark/close_default.png);
 }
-QPushButton#pBtn_close:hover{
-	
+QPushButton#pBtn_close:hover
+{
 	border-image: url(:/image/Resource/image/close_dark/close_pass.png);
 }
 

+ 23 - 16
Common/warning/warning_light.qss

@@ -1,27 +1,34 @@
-QWidget{
-background: #FFFFFF;
-border-radius: 8px;
-font-family: 思源黑体R;
-font-weight: 400;
-font-size: 18px;
-color: #3A3F63;
-line-height: 21px;
-text-align: left;
-font-style: normal;
+
+QWidget
+{
+    background: #FFFFFF;
+    border-radius: 8px;
+    font-family: 思源黑体R;
+    font-weight: 400;
+    font-size: 18px;
+    color: #3A3F63;
+    line-height: 21px;
+    text-align: left;
+    font-style: normal;
 }
 
 QLabel#label_NC1
 {
-font-family: 思源黑体M;
-font-size: 18px;
-color: #3A3F63;
-line-height: 27px;
-text-transform: uppercase;
+    font-family: 思源黑体M;
+    font-size: 18px;
+    color: #3A3F63;
+    line-height: 27px;
+    text-transform: uppercase;
 }
 
 QLabel#label_line
 {
-background: #E6E9F4;
+    background: #E6E9F4;
+}
+
+QWidget#widget_Top
+{
+
 }
 
 QLabel#label_Warn

+ 21 - 4
EyeMap/CMakeLists.txt

@@ -1,7 +1,6 @@
 cmake_minimum_required(VERSION 3.12)
 
 #设置可执行文件名称
-set(execName1 EyeMap)
 
 #包含源文件
 file(GLOB LOCAL_SRC
@@ -34,22 +33,38 @@ file(GLOB LOCAL_SRC
     ${CMAKE_SOURCE_DIR}/External/common/ImageBlur/*.cpp
     ${CMAKE_SOURCE_DIR}/External/common/Shadow/*.cpp
     ${CMAKE_SOURCE_DIR}/External/module/ThreadPool/*.cpp
-    ${CMAKE_SOURCE_DIR}/External/UI/Resource/*.qrc
+    # ${CMAKE_SOURCE_DIR}/External/UI/Resource/*.qrc
 
     ${CMAKE_SOURCE_DIR}/Common/*.qrc
     ${CMAKE_SOURCE_DIR}/Common/Logs/*.cpp
     ${CMAKE_SOURCE_DIR}/Common/combox/*.cpp
     ${CMAKE_SOURCE_DIR}/Common/warning/*.cpp
     ${CMAKE_SOURCE_DIR}/Common/warning/*.ui
+    ${CMAKE_SOURCE_DIR}/Common/TipWidget/*.cpp
+    ${CMAKE_SOURCE_DIR}/Common/TipWidget/*.qrc
+    ${CMAKE_SOURCE_DIR}/Common/softdog/*.cpp
 
     ${CMAKE_SOURCE_DIR}/USBInterFace/*.cpp
-    
+
+
+    #添加版本文件
+    ${CMAKE_CURRENT_SOURCE_DIR}/app.rc
     
     # ${LHQLog_SOURCE_DIRS}/*.cpp
 )
 
 #生成可执行程序
-add_executable(${execName1} ${LOCAL_SRC})
+
+if(CMAKE_BUILD_TYPE MATCHES Debug)
+    add_executable(${execName1} 
+        ${LOCAL_SRC}
+    )
+elseif(CMAKE_BUILD_TYPE MATCHES Release)
+    add_executable(${execName1} 
+        WIN32 
+        ${LOCAL_SRC}
+    )
+endif()
 
 
 #添加头文件
@@ -77,6 +92,8 @@ target_include_directories(${execName1} PRIVATE
     ${CMAKE_SOURCE_DIR}/Common/Logs
     ${CMAKE_SOURCE_DIR}/Common/combox
     ${CMAKE_SOURCE_DIR}/Common/warning
+    ${CMAKE_SOURCE_DIR}/Common/TipWidget
+    ${CMAKE_SOURCE_DIR}/Common/softdog
 
     ${CMAKE_SOURCE_DIR}/USBInterFace
 

+ 32 - 22
EyeMap/EyeMapWidget/eyemapwidget.cpp

@@ -12,7 +12,7 @@
 #include "warning.h"
 
 #include "OscDataInfo.h"
-#include "OneOscData.h"
+#include "OneOsc.h"
 
 EyeMapWidget::EyeMapWidget(QWidget *parent) :
     QWidget(parent),
@@ -26,6 +26,8 @@ EyeMapWidget::EyeMapWidget(QWidget *parent) :
         qDebug() << "获取 EyeMap logger 失败";
         return;
     }
+    /* 设置软件名称 */
+    this->setWindowTitle("EyePattern");
 
     /* 设置无边框和自动全屏 */
     this->setWindowFlags(Qt::FramelessWindowHint);
@@ -71,6 +73,8 @@ EyeMapWidget::EyeMapWidget(QWidget *parent) :
 
 EyeMapWidget::~EyeMapWidget()
 {
+    /* 停止采集数据 */
+    GOscDataInfo.stopAllCapture();
     delete ui;
 }
 
@@ -118,8 +122,8 @@ void EyeMapWidget::do_pBtnSettingNum()
     // {
     //     SPDLOG_LOGGER_DEBUG(m_logger, "眼图序号: {}, 通道号:{} ", it->getNum(), it->getChannelInfo().channelName.toStdString());
     // }
-    /* 这里不能设置父指针 */
-    // settingNum->setParent(this);
+    /* 弹窗不能设置父指针,这里川润 父指针给内部其他组件使用 */
+    settingNum->setParentPtr(this);
 
     /* 设置眼图显示的个数 */
     settingNum->setRowAndColumn(m_row, m_column);
@@ -138,6 +142,7 @@ void EyeMapWidget::do_pBtnSettingNum()
     GOscDataInfo.stopAllCapture();
     m_row = settingNum->m_row;
     m_column = settingNum->m_column;
+    /* 排列布局眼图 */
     eyeMapLayout();
     /* 重置眼图数据矩阵 */
     resetMatrix();
@@ -180,19 +185,25 @@ void EyeMapWidget::initEyeMap()
     for(const auto &it : GEyeMapInfo.listInitEyeMapInfo)
     {
         OneEyeMap* oneEyeMap = new OneEyeMap(ui->widget_container);
+        // oneEyeMap->setUID(it.uid);
         oneEyeMap->setNum(it.num);
         oneEyeMap->setTitle(it.title);
         oneEyeMap->setTitleBarColor(it.titleBarColor);
         oneEyeMap->setVoltageRange(it.voltageRange);
         oneEyeMap->setChannelInfo(it.channelInfo);
         oneEyeMap->setTimeGridValue(it.tGridValue);
-
-        oneEyeMap->setEyeDataPtrFromOscData(it.channelInfo.channel);
+        /* 将眼图显示实例和示波器实例对应上 */
+        oneEyeMap->getOneOscFromGlobalOscData();
         oneEyeMap->hide();
         GEyeMapInfo.addEyeMapPtr(oneEyeMap);
+        
+        /* 设置示波器类的初始化信息 */
+        GOscDataInfo.setVoltageRange(it.channelInfo.channel, it.voltageRange);
+        GOscDataInfo.setTimeGridValue(it.channelInfo.channel, it.tGridValue);
     }
     m_row = GEyeMapInfo.row;
     m_column = GEyeMapInfo.column;
+    /* 排列眼图,在排列的过程中,会对示波器设置是否有显示的眼图 */
     eyeMapLayout();
 
     /* 根据示波器打开的情况判断是刷新网格还是显示“暂无设备” */
@@ -204,7 +215,10 @@ void EyeMapWidget::initEyeMap()
 }
 
 
-/* 排列眼图布局 */
+/**
+ * @brief 排列眼图布局,在排列的过程中会设置眼图是否有显示
+ * 
+ */
 void EyeMapWidget::eyeMapLayout()
 {
     // SPDLOG_LOGGER_DEBUG(m_logger, "眼图显示区域总大小: width = {}, height = {}", ui->widget_container->width(), ui->widget_container->height());
@@ -270,21 +284,23 @@ void EyeMapWidget::eyeMapLayout()
         else 
         {
             /* 奇数放左边,偶数放右边 */
-            int row = ( it->getNum() - 1) / 2;
-            int column = ( it->getNum() % 2 == 1 ) ? 0 : 1;
+            int mapNum = it->getNum();
+            int row = ( mapNum - 1) / 2;
+            int column = ( mapNum % 2 == 1 ) ? 0 : 1;
             int dx = m_marginLeft + column * (oneWidth + m_spacing);
             int dy = m_marginTop + row * (oneHeight + m_spacing);
             it->move(dx, dy);
-            if(it->getNum() == num)
-            {
-                break;
-            }
+            // if(mapNum == num)
+            // {
+            //     break;
+            // }
         }
     }
     /* 设置显示或隐藏 */
     for(const auto &it : GEyeMapInfo.getEyeMapList())
     {
-        if(it->getNum() <= num)
+        // SPDLOG_LOGGER_DEBUG(m_logger, "设置显示: 序号: {}, 通道: {}, 是否显示: {}", it->getNum(), it->getChannelInfo().channelName.toStdString(), it->getShow());
+        if((it->getNum() <= num) && (it->getNum() != 0))
         {
             it->setShow(true);
         } else
@@ -300,14 +316,8 @@ void EyeMapWidget::eyeMapLayout()
 void EyeMapWidget::resetMatrix()
 {
     /* 重新初始化数据矩阵 */
-    GOscDataInfo.resetDataMatrix();
-    /* 每个眼图模块的大小都是一样的,所以这里获取序号为1的眼图大小,1号是肯定会显示的 */
-    auto pEyeMap = GEyeMapInfo.findEyeMap(1);
-    if(pEyeMap == nullptr)
-    {
-        return;
-    }
-    auto size = pEyeMap->getEyeMapSize();
-    GOscDataInfo.resetColorMatrix(size.width(), size.height());
+    GOscDataInfo.resetDevMatrix();
+    /* 重新初始化眼图模块的颜色矩阵 */
+    GEyeMapInfo.resetAllEyeMap();
 }
 

+ 78 - 19
EyeMap/GlobalInfo/EyeMapInfo.cpp

@@ -65,7 +65,7 @@ void AllEyeMapInfo::readSaveFile(const QString& fileName)
         for(const auto& it : jsonArray)
         {
             OneEyeMapInfo info;
-            info.uid = static_cast<EyeMapUID>(it["uid"].is_null() ? 0 : it["uid"].get<int>());
+            // info.uid = static_cast<EyeMapUID>(it["uid"].is_null() ? 0 : it["uid"].get<int>());
             info.num = it["num"];
             info.title = QString::fromStdString(it["title"].get<std::string>());
             info.titleBarColor = QColor(QString::fromStdString(it["titleBarColor"].get<std::string>()));
@@ -111,15 +111,7 @@ void AllEyeMapInfo::createSaveFile(const QString& fileName)
     for(int i = 0; i < 8; i++)
     {
         OneEyeMapInfo info = getInitEyeMapInfo(i + 1);
-        // info.uid = static_cast<EyeMapUID>(i + 1);
-        // info.num = i + 1;
-        // info.title = "通道" + QString::number(i + 1);
-        // info.titleBarColor = QColor("#2D2D31");
-        // info.isShow = false;
-        // info.channelInfo.channel = static_cast<OscChnNum>(i + 1);
-        // info.channelInfo.channelName = getChannelName(static_cast<OscChnNum>(i + 1));
-        // info.voltageRange = OscVoltageRange::CR_2V5;
-        // info.tGridValue = OscTimeGridValue::TGV_200NS;
+
         listInitEyeMapInfo.append(info);
     }
     row = 4;
@@ -130,7 +122,7 @@ void AllEyeMapInfo::createSaveFile(const QString& fileName)
     for(const auto& it : listInitEyeMapInfo)
     {
         nJson json2;
-        json2["uid"] = static_cast<int>(it.uid);
+        // json2["uid"] = static_cast<int>(it.uid);
         json2["num"] = it.num;
         json2["title"] = it.title.toStdString();
         json2["titleBarColor"] = it.titleBarColor.name().toStdString();
@@ -167,8 +159,9 @@ void AllEyeMapInfo::updateSaveFile()
     nJson jsonArray1 = json0.array();
     for(const auto& it : listInitEyeMapInfo)
     {
+        // SPDLOG_DEBUG("UID: {}", static_cast<int>(it.uid));
         nJson json2;
-        json2["uid"] = static_cast<int>(it.uid);
+        // json2["uid"] = static_cast<int>(it.uid);
         json2["num"] = it.num;
         json2["title"] = it.title.toStdString();
         json2["titleBarColor"] = it.titleBarColor.name().toStdString();
@@ -228,6 +221,11 @@ QList<OneEyeMapInfo> AllEyeMapInfo::getEyeMapInfo()
         info.tGridValue = it->getTimeGridValue();
         list.append(info);
     }
+    /* 打印每个项的信息 */
+    // for(const auto& it : list)
+    // {
+    //     SPDLOG_DEBUG("序号: {}, 标题: {}, 通道号: {}", it.num, it.title.toStdString(), it.channelInfo.channelName.toStdString());
+    // }
     return list;
 }
 
@@ -261,22 +259,43 @@ void AllEyeMapInfo::updateModuleInfo(OneEyeMapInfo& info)
 /* 更新设置组屏页面的信息 */
 void AllEyeMapInfo::updateSettingNum(OneEyeMapInfo& info)
 {
+    /* 根据通道号设置眼图模块编号 */
     for(auto& it : listEyeMapPtr)
     {
-        if(it->getUID() == info.uid)
+        /* 根据通道号设置颜色标题等信息,不用重新获取眼图对应的示波器实例了 */
+        if(it->getChannelInfo().channel == info.channelInfo.channel)
         {
+            SPDLOG_DEBUG("更新设置组屏页面的信息: {}, {}", info.num, info.channelInfo.channelName.toStdString());
             it->updateSettingNum(info);
             break;
         }
     }
 }
 
+/* 清空所有的编号 */
+void AllEyeMapInfo::clearAllNum()
+{
+    for(auto& it : listEyeMapPtr)
+    {
+        it->setNum(0);
+    }
+}
+
+/* 重置所有的颜色矩阵 */
+void AllEyeMapInfo::resetAllEyeMap()
+{
+    for(auto& it : listEyeMapPtr)
+    {
+        it->resetEyeMap();
+    }
+}
+
 /* 更新显示的电压刻度信息,这里只更新电压相关的参数 */
 void AllEyeMapInfo::updateVoltageAndTimeGardInfo(const OneEyeMapInfo& info)
 {
     for(auto& it : listEyeMapPtr)
     {
-        if(it->getUID() == info.uid)
+        if(it->getChannelInfo().channel == info.channelInfo.channel)
         {
             it->setVoltageRange(info.voltageRange);
             it->setTimeGridValue(info.tGridValue);
@@ -292,6 +311,7 @@ void AllEyeMapInfo::updateInitEyeMapInfo()
     for (const auto& it : listEyeMapPtr)
     {
         OneEyeMapInfo info;
+        // info.uid = it->getUID();
         info.num = it->getNum();
         info.title = it->getTitle();
         info.titleBarColor = it->getTitleBarColor();
@@ -359,21 +379,60 @@ void AllEyeMapInfo::setEyeMapOscOpen(int oscNum, bool isOpen)
     }
 }
 
-/* 获取一项初始化数据 */
+/* 获取一项初始化数据,通道号和通道名设置为none */
+OneEyeMapInfo AllEyeMapInfo::getOneEyeMapInfo(int num)
+{
+    OneEyeMapInfo info;
+    // info.uid = static_cast<EyeMapUID>(num);
+    info.num = num;
+    // info.title = "通道" + QString::number(num);
+    info.titleBarColor = QColor("#2D2D31");
+    info.isShow = false;
+    info.channelInfo.channel = OscChnNum::Osc_None;
+    info.channelInfo.channelName = getChannelName(info.channelInfo.channel);
+    info.title = info.channelInfo.channelName;
+    info.voltageRange = OscVoltageRange::CR_2V5;
+    info.tGridValue = OscTimeGridValue::TGV_200NS;
+    return info;
+    
+}
+
 OneEyeMapInfo AllEyeMapInfo::getInitEyeMapInfo(int num)
 {
     OneEyeMapInfo info;
-    info.uid = static_cast<EyeMapUID>(num);
+    // info.uid = static_cast<EyeMapUID>(num);
     info.num = num;
-    info.title = "通道" + QString::number(num);
+    // info.title = "通道" + QString::number(num);
     info.titleBarColor = QColor("#2D2D31");
     info.isShow = false;
     info.channelInfo.channel = static_cast<OscChnNum>(num);
-    info.channelInfo.channelName = getChannelName(static_cast<OscChnNum>(num));
+    info.channelInfo.channelName = getChannelName(info.channelInfo.channel);
+    info.title = info.channelInfo.channelName;
     info.voltageRange = OscVoltageRange::CR_2V5;
     info.tGridValue = OscTimeGridValue::TGV_200NS;
     return info;
-    
+}
+
+/* 获取未使用的通道号 */
+OscChnNum AllEyeMapInfo::getUnusedChannel()
+{
+    for(int i = 1; i <= 8; i++)
+    {
+        bool isUsed = false;
+        for(const auto& it : listEyeMapPtr)
+        {
+            if(it->getChannelInfo().channel == static_cast<OscChnNum>(i))
+            {
+                isUsed = true;
+                break;
+            }
+        }
+        if(!isUsed)
+        {
+            return static_cast<OscChnNum>(i);
+        }
+    }
+    return OscChnNum::Osc_None;
 }
 
 

+ 16 - 5
EyeMap/GlobalInfo/EyeMapInfo.h

@@ -32,20 +32,20 @@ struct OneChannelInfo
 struct OneEyeMapInfo
 {
     bool isShow;                    /* 是否显示 */
-    EyeMapUID uid;                  /* 唯一标识符 */
+    // EyeMapUID uid;                  /* 唯一标识符 */
     int num;                        /* 序号 */
     QString title;                  /* 标题 */
     QColor titleBarColor;           /* 颜色 */
-    OneChannelInfo channelInfo;     /* 通道信息 */
+    OneChannelInfo channelInfo;     /* 通道信息,这个作为眼图显示模块和示波器模块对应的唯一标识符 */
     OscVoltageRange voltageRange;   /* 电压范围 */
     OscTimeGridValue tGridValue;    /* 时间刻度 */
 
-    OneEyeMapInfo() : isShow(false),uid(EyeMapUID::EMUID_1), num(0), title(""), titleBarColor(QColor()), channelInfo(), 
+    OneEyeMapInfo() : isShow(false), num(0), title(""), titleBarColor(QColor()), channelInfo(), 
                     voltageRange(OscVoltageRange::CR_2V5), tGridValue(OscTimeGridValue::TGV_200NS) {}
     OneEyeMapInfo& operator=(const OneEyeMapInfo& info)
     {
         isShow = info.isShow;
-        uid = info.uid;
+        // uid = info.uid;
         num = info.num;
         title = info.title;
         titleBarColor = info.titleBarColor;
@@ -54,13 +54,17 @@ struct OneEyeMapInfo
         tGridValue = info.tGridValue;
         return *this;
     }
+
 };
 
 
 
 #define GEyeMapInfo AllEyeMapInfo::getInstance()
 
-/* 保存8个眼图的指针信息 */
+/**
+ * @brief 保存8个眼图的指针信息,以及通道信息
+ * 
+ */
 class AllEyeMapInfo
 {
 
@@ -96,6 +100,10 @@ public:
     void updateModuleInfo(OneEyeMapInfo& info);
     /* 更新设置组屏页面的信息 */
     void updateSettingNum(OneEyeMapInfo& info);
+    /* 清空所有的编号 */
+    void clearAllNum();
+    /* 重置所有的颜色矩阵 */
+    void resetAllEyeMap();
 
     /* 获取所有的通道信息 */
     QList<OneChannelInfo>& getChannelInfo() { return listChannelInfo; }
@@ -117,7 +125,10 @@ public:
     void setEyeMapOscOpen(int oscNum, bool isOpen);
 
     /* 获取初始化数据 */
+    OneEyeMapInfo getOneEyeMapInfo(int num);
     OneEyeMapInfo getInitEyeMapInfo(int num);
+    /* 获取未使用的通道号 */
+    OscChnNum getUnusedChannel();
 
 public:
     QList<OneEyeMap*> listEyeMapPtr;                    /* 保存8个眼图的指针 */

+ 203 - 113
EyeMap/GlobalInfo/OscDataInfo.cpp

@@ -1,7 +1,7 @@
 #include "OscDataInfo.h"
 
 #include "EyeMapInfo.h"
-#include "OneOscData.h"
+#include "OneOsc.h"
 
 
 /* OscData使用的眼图矩阵 */
@@ -54,7 +54,7 @@ void EyeDataMatrix::eyeStatisticalWeight()
     int num = 0;            /* 点数大于0的个数 */
     int num2 = 0;           /* 点数大于79999的个数 */
     double num3 = 0.0;
-    int numMax = 79999;
+    double numMax = 79999.0;
     for (int i = 0; i < g_HorPixel; i++)
     {
         for (int j = 0; j < g_VerPixel; j++)
@@ -62,7 +62,7 @@ void EyeDataMatrix::eyeStatisticalWeight()
             if (dataMatrix[i][j].fCnt > 0.0)
             {
                 num++;
-                if (dataMatrix[i][j].fCnt >= (double)numMax)
+                if (dataMatrix[i][j].fCnt >= numMax)
                 {
                     num2++;
                 }
@@ -102,6 +102,8 @@ void EyeDataMatrix::eyeLessenTheBurden()
 		}
 	}
 	eyenWeightCoefficient *= eyenWeightCoefficient;
+
+
 }
 
 
@@ -117,13 +119,17 @@ std::shared_ptr<Vec2D> EyeDataMatrix::eyeZoomOut()
 			pEyeData2.y = dataMatrix[i][j].y;
 			pEyeData2.fCnt = dataMatrix[i][j].fCnt;
 			pEyeData2.data = dataMatrix[i][j].data;
-			if (dataMatrix[i][j].fCnt > 0.0) {
+			if (dataMatrix[i][j].fCnt > 0.0) 
+            {
 				pEyeData2.fCnt /= 100.0;
 				pEyeData2.Cnt = (int)pEyeData2.fCnt;
+                // dataMatrix[i][j].fCnt /= 100.0;
+                // dataMatrix[i][j].Cnt = (int)dataMatrix[i][j].fCnt;
 			}
 			(*array)[i][j] = pEyeData2;
 		}
 	}
+
 	return array;
 }
 
@@ -134,7 +140,7 @@ std::shared_ptr<Vec2D> EyeDataMatrix::eyeZoomOut()
  * @param width 显示范围的宽
  * @param height 显示范围的高
  */
-void EyeMapMatrix::initEyeMapData(int width, int height)
+void EyeColorMatrix::initEyeMapData(int width, int height)
 {
     mutexEyeData.lock();
     /*先清空 */
@@ -146,23 +152,46 @@ void EyeMapMatrix::initEyeMapData(int width, int height)
     {
         for(int j = 0; j < g_VerPixel; j++)
         {
-            dataMatrix[i][j].x = (int)(i * saW);
-            dataMatrix[i][j].y = (int)(j * saH);
-            dataMatrix[i][j].rect = QRect(dataMatrix[i][j].x, dataMatrix[i][j].y, (int)saW, (int)saH);
-            dataMatrix[i][j].brush = QBrush(QColor(255, 255, 255));
+            dataMatrix[i][j].isDraw = false;
+            dataMatrix[i][j].x = (i * saW);
+            dataMatrix[i][j].y = (j * saH);
+            dataMatrix[i][j].rect = QRectF(dataMatrix[i][j].x, dataMatrix[i][j].y, saW, saH);
+            dataMatrix[i][j].brush = QBrush(QColor(0, 0, 0));
+        }
+    }
+    mutexEyeData.unlock();
+}
+
+/* 只清空颜色,其他不需要 */
+void EyeColorMatrix::initEyeMapData()
+{
+    mutexEyeData.lock();
+    /*先清空 */
+    // dataMatrix.clear();
+
+    for(int i = 0; i < g_HorPixel; i++)
+    {
+        for(int j = 0; j < g_VerPixel; j++)
+        {
+            dataMatrix[i][j].isDraw = false;
+            dataMatrix[i][j].Count = 0;
+            dataMatrix[i][j].brush = QBrush(QColor(0, 0, 0));
         }
     }
     mutexEyeData.unlock();
 }
 
 /* 拷贝数据到数组中 */
-void EyeMapMatrix::copyDataMatrix(Vec2D& data)
+void EyeColorMatrix::copyDataMatrix(Vec2D& data)
 {
+    /* 拷贝数据 */
+    // SPDLOG_INFO("data.size = {}, data[0].size = {}", data.size(), data[0].size());
     for (int i = 0; i < g_HorPixel; i++)
     {
         for (int j = 0; j < g_VerPixel; j++)
         {
-            if (dataMatrix[i][j].Count != data[i][j].fCnt)
+            /* 判断相较以前累积的数据有没有变化,有变化就新增设置为true */
+            if (dataMatrix[i][j].Count != data[i][j].Cnt)
             {
                 if (data[i][j].fCnt > 799.0)
                 {
@@ -170,21 +199,26 @@ void EyeMapMatrix::copyDataMatrix(Vec2D& data)
                 }
                 else
                 {
-                    dataMatrix[i][j].Count = data[i][j].fCnt;
+                    dataMatrix[i][j].Count = data[i][j].Cnt;
                 }
                 dataMatrix[i][j].isDraw = true;
+            }else {
+                /* 添加这一句,会实时清空之前残留的颜色 */
+                // dataMatrix[i][j].isDraw = false;
             }
+            // SPDLOG_DEBUG("Count = {}, Cnt = {}", dataMatrix[i][j].Count, data[i][j].Cnt);
         }
     }
 }
 
 /* 将Count数值与颜色对应 */
-void EyeMapMatrix::addColorBySample()
+void EyeColorMatrix::addColorBySample()
 {
     int r = 0;
     int g = 0;
     int b = 0;
-    double dec = 255 / 100.0;
+    // double dec = 255 / 100.0;
+    // int dec = 2;
     for(int i = 0; i < g_HorPixel; i++)
     {
         for(int j = 0; j < g_VerPixel; j++)
@@ -193,91 +227,146 @@ void EyeMapMatrix::addColorBySample()
             {
                 continue;
             }
-            if(dataMatrix[i][j].Count <= 0)
+            int count = dataMatrix[i][j].Count;
+            // SPDLOG_WARN("color");
+            if(count <= 0)
             {
                 dataMatrix[i][j].Count = 0;
                 continue;
             }
-            if(dataMatrix[i][j].Count > 799)
+            if(count > 799)
             {
                 dataMatrix[i][j].Count = 799;
             }
-            /* 1~100,RGB开始减G,往紫色方向走,为显示清楚,G直接从200开始减 */
-            if(dataMatrix[i][j].Count >= 1 && dataMatrix[i][j].Count <= 100)
-            {
-                r = 255;
-                g = 200 - dataMatrix[i][j].Count * 2;
-                b = 255;
-            }
-            /* 101~200,R0B开始减R,往蓝色方向走,这里开始100分成255份 */
-            else if(dataMatrix[i][j].Count >= 101 && dataMatrix[i][j].Count <= 200)
-            {
-                r = 255 - (dataMatrix[i][j].Count - 100) * dec;
-                g = 0;
-                b = 255;
-            }
-            /* 201~300,00B开始增加G,往青色方向走 */
-            else if (dataMatrix[i][j].Count >= 201 && dataMatrix[i][j].Count <= 300)
+
+            /* 0~150,从蓝色往青色那边走 */
+            if(count > 0 && count <= 150)
             {
                 r = 0;
-                g = (dataMatrix[i][j].Count - 200) * dec;
+                g = 100 + count;
                 b = 255;
             }
-            /* 301~400,0GB开始减B,往绿色方向走 */
-            else if (dataMatrix[i][j].Count >= 301 && dataMatrix[i][j].Count <= 400)
+            /* 150~400,往绿色方向走 */
+            else if(count > 150 && count <= 400)
             {
                 r = 0;
                 g = 255;
-                b = 255 - (dataMatrix[i][j].Count - 300) * dec;
+                b = 255 - (count - 150);
             }
-            /* 401~500,0G0开始增加R,往黄色方向走 */
-            else if (dataMatrix[i][j].Count >= 401 && dataMatrix[i][j].Count <= 500)
+            /* 400~650,增加红色,往黄色方向走 */
+            else if (count > 400 && count <= 650)
             {
-                r = (dataMatrix[i][j].Count - 400) * dec;
+                r = count - 400;
                 g = 255;
                 b = 0;
             }
-            /* 501~600,RG0开始减G,往红色方向走 */
-            else if (dataMatrix[i][j].Count >= 501 && dataMatrix[i][j].Count <= 600)
+            /* 650~799,减少绿色,往红色方向走 */
+            else if (count > 650 && count <= 799)
             {
                 r = 255;
-                g = 255 - (dataMatrix[i][j].Count - 500) * dec;
-                b = 0;
-            }
-            /* 601~700,R00开始减R,往黑色方向走 */
-            else if (dataMatrix[i][j].Count >= 601 && dataMatrix[i][j].Count <= 700)
-            {
-                r = 255 - (dataMatrix[i][j].Count - 600) * dec;
-                g = 0;
+                g = 255 - (count - 650);
                 b = 0;
             }
-            /* 大于700,直接显示黑色 */
-            else
-            {
-                r = 0;
-                g = 0;
+            else {
+                r = 255;
+                g = 100;
                 b = 0;
             }
-            // dataMatrix[i][j].color = QColor(r, g, b);
             dataMatrix[i][j].brush = QBrush(QColor(r, g, b));
+
+
+            // /* 1~100,RGB开始减G,往紫色方向走,为显示清楚,G直接从200开始减 */
+            // if(dataMatrix[i][j].Count >= 1 && dataMatrix[i][j].Count <= 100)
+            // {
+            //     r = 255;
+            //     g = 200 - dataMatrix[i][j].Count * 2;
+            //     b = 255;
+            // }
+            // /* 101~200,R0B开始减R,往蓝色方向走,这里开始100分成255份 */
+            // else if(dataMatrix[i][j].Count >= 101 && dataMatrix[i][j].Count <= 200)
+            // {
+            //     r = 255 - (dataMatrix[i][j].Count - 100) * dec;
+            //     g = 0;
+            //     b = 255;
+            // }
+            // /* 201~300,00B开始增加G,往青色方向走 */
+            // else if (dataMatrix[i][j].Count >= 201 && dataMatrix[i][j].Count <= 300)
+            // {
+            //     r = 0;
+            //     g = (dataMatrix[i][j].Count - 200) * dec;
+            //     b = 255;
+            // }
+            // /* 301~400,0GB开始减B,往绿色方向走 */
+            // else if (dataMatrix[i][j].Count >= 301 && dataMatrix[i][j].Count <= 400)
+            // {
+            //     r = 0;
+            //     g = 255;
+            //     b = 255 - (dataMatrix[i][j].Count - 300) * dec;
+            // }
+            // /* 401~500,0G0开始增加R,往黄色方向走 */
+            // else if (dataMatrix[i][j].Count >= 401 && dataMatrix[i][j].Count <= 500)
+            // {
+            //     r = (dataMatrix[i][j].Count - 400) * dec;
+            //     g = 255;
+            //     b = 0;
+            // }
+            // /* 501~600,RG0开始减G,往红色方向走 */
+            // else if (dataMatrix[i][j].Count >= 501 && dataMatrix[i][j].Count <= 600)
+            // {
+            //     r = 255;
+            //     g = 255 - (dataMatrix[i][j].Count - 500) * dec;
+            //     b = 0;
+            // }
+            // /* 601~700,R00开始减R,往黑色方向走 */
+            // else if (dataMatrix[i][j].Count >= 601 && dataMatrix[i][j].Count <= 700)
+            // {
+            //     r = 255 - (dataMatrix[i][j].Count - 600) * dec;
+            //     g = 0;
+            //     b = 0;
+            // }
+            // /* 大于700,直接显示黑色 */
+            // else
+            // {
+            //     r = 0;
+            //     g = 0;
+            //     b = 0;
+            // }
+            // dataMatrix[i][j].brush = QBrush(QColor(r, g, b));
         }
     }
 }
 
 /**
- * @brief Destroy the Oscilloscope Data:: Oscilloscope Data object
+ * @brief 拷贝颜色数据到数组中,这里只拷贝颜色数据
  * 
+ * @param data 
  */
-OscilloscopeData::~OscilloscopeData()
+void EyeColorMatrix::copyColorMatrix(Vec2DMap& data)
 {
-    for(auto it = mapEyeDataMatrix.begin(); it != mapEyeDataMatrix.end(); ++it)
-    {
-        delete it.value();
-    }
-    for(auto it = mapEyeMapMatrix.begin(); it != mapEyeMapMatrix.end(); ++it)
+    for(int i = 0; i < g_HorPixel; i++)
     {
-        delete it.value();
+        for(int j = 0; j < g_VerPixel; j++)
+        {
+            dataMatrix[i][j].brush = data[i][j].brush;
+            dataMatrix[i][j].isDraw = data[i][j].isDraw;
+        }
     }
+}
+
+/**
+ * @brief Destroy the Oscilloscope Data:: Oscilloscope Data object
+ * 
+ */
+OscilloscopeData::~OscilloscopeData()
+{
+    // for(auto it = mapEyeDataMatrix.begin(); it != mapEyeDataMatrix.end(); ++it)
+    // {
+    //     delete it.value();
+    // }
+    // for(auto it = mapEyeMapMatrix.begin(); it != mapEyeMapMatrix.end(); ++it)
+    // {
+    //     delete it.value();
+    // }
     for(auto it = mapOsc.begin(); it != mapOsc.end(); ++it)
     {
         delete it.value();
@@ -288,30 +377,13 @@ OscilloscopeData::~OscilloscopeData()
 /* 初始化示波器参数 */
 void OscilloscopeData::initOscData()
 {
-
-    /* 创建数据矩阵,根据实际的通道个数来创建 */
-    auto listChn = GEyeMapInfo.getChannelInfo();
-    for(auto chn : listChn)
-    {
-        EyeDataMatrix* pEyeDataMatrix = new EyeDataMatrix();
-        pEyeDataMatrix->initEyeData();
-        mapEyeDataMatrix.insert(chn.channel, pEyeDataMatrix);
-
-        EyeMapMatrix* pEyeMapMatrix = new EyeMapMatrix();
-        pEyeMapMatrix->initEyeMapData(g_HorPixel, g_VerPixel);
-        mapEyeMapMatrix.insert(chn.channel, pEyeMapMatrix);
-    }
-
-    /* 加载示波器动态库,初始化示波器相关内容,这里只是初始化完成了,并为开始采集 */
+    /* 加载示波器动态库,初始化示波器相关内容,这里只是初始化完成了,并未开始采集
+     * 编号从1开始,1是主设备,2、3、4是辅设备 */
     for(int i = 1; i <= 4; i++)
     {
-        OneOscilloscopeData* pOscData = new OneOscilloscopeData();
+        OneOscilloscope* pOscData = new OneOscilloscope();
         pOscData->initOSC(i);
-        if(!pOscData->openOSC())
-        {
-            
-            continue;
-        }
+        pOscData->openOSC();
         /* 获取零电压值 */
         pOscData->getZeroVoltage();
         /* 获取电压校准系数 */
@@ -340,29 +412,30 @@ void OscilloscopeData::initOscData()
 }
 
 /* 查找EyeDataMatrix */
-EyeDataMatrix* OscilloscopeData::findEyeDataMatrix(OscChnNum channel)
-{
-    auto it = mapEyeDataMatrix.find(channel);
-    if(it != mapEyeDataMatrix.end())
-    {
-        return it.value();
-    }
-    return nullptr;
-}
+// EyeDataMatrix* OscilloscopeData::findEyeDataMatrix(OscChnNum channel)
+// {
+//     auto it = mapEyeDataMatrix.find(channel);
+//     if(it != mapEyeDataMatrix.end())
+//     {
+//         return it.value();
+//     }
+//     return nullptr;
+// }
 
 /* 查找EyeMapMatrix */
-EyeMapMatrix* OscilloscopeData::findEyeMapMatrix(OscChnNum channel)
-{
-    auto it = mapEyeMapMatrix.find(channel);
-    if(it != mapEyeMapMatrix.end())
-    {
-        return it.value();
-    }
-    return nullptr;
-}
+// EyeColorMatrix* OscilloscopeData::findEyeMapMatrix(OscChnNum channel)
+// {
+//     auto it = mapEyeMapMatrix.find(channel);
+//     if(it != mapEyeMapMatrix.end())
+//     {
+//         // SPDLOG_DEBUG("findEyeMapMatrix: {}", (int)it.key());
+//         return it.value();
+//     }
+//     return nullptr;
+// }
 
 /* 根据通道号查找示波器 */
-OneOscilloscopeData* OscilloscopeData::findOsc(OscChnNum oscNum)
+OneOscilloscope* OscilloscopeData::findOsc(OscChnNum oscNum)
 {
     int num = 0;
     switch (oscNum)
@@ -433,21 +506,32 @@ void OscilloscopeData::setTimeGridValue(OscChnNum oscNum, OscTimeGridValue value
 
 
 /* 清空数据矩阵 */
-void OscilloscopeData::resetDataMatrix()
+void OscilloscopeData::resetDevMatrix()
 {
-    for(auto it = mapEyeDataMatrix.begin(); it != mapEyeDataMatrix.end(); ++it)
+    /* 重新设置每个眼图的数据矩阵 */
+    for(auto it = mapOsc.begin(); it != mapOsc.end(); ++it)
     {
-        it.value()->initEyeData();
+        it.value()->resetData();
     }
 }
 
 /* 清空颜色矩阵,重新初始化 */
-void OscilloscopeData::resetColorMatrix(int width, int height)
+// void OscilloscopeData::resetColorMatrix(int width, int height)
+// {
+//     /* 清空全局的颜色矩阵 */
+//     // for(auto it = mapEyeMapMatrix.begin(); it != mapEyeMapMatrix.end(); ++it)
+//     // {
+//     //     it.value()->initEyeMapData(width, height);
+//     // }
+// }
+/* 只清空颜色 */
+void OscilloscopeData::resetColorMatrix()
 {
-    for(auto it = mapEyeMapMatrix.begin(); it != mapEyeMapMatrix.end(); ++it)
-    {
-        it.value()->initEyeMapData(width, height);
-    }
+    /* 清空全局的颜色矩阵 */
+    // for(auto it = mapEyeMapMatrix.begin(); it != mapEyeMapMatrix.end(); ++it)
+    // {
+    //     it.value()->initEyeMapData();
+    // }
 }
 
 /* 暂停所有的采集 */
@@ -465,10 +549,16 @@ void OscilloscopeData::startAllCapture()
     for(const auto& it : getOsc())
     {
         /* 判断是否显示的眼图,示波器对应的两个眼图都不显示则不开启采集 */
-        if(GEyeMapInfo.hasShowEyeMap(it->getOscNum()))
+        // if(GEyeMapInfo.hasShowEyeMap(it->getOscNum()))
+        // {
+        //     it->startCapture();
+        // }
+        /* 判断示波器是否已经打开 */
+        if(!it->isOpen())
         {
-            it->startCapture();
+            it->openOSC();
         }
+        it->startCaptureWithCondition();
     }
 }
 

+ 34 - 31
EyeMap/GlobalInfo/OscDataInfo.h

@@ -10,7 +10,7 @@
 
 #include "GlobalInfo.h"
 
-class OneOscilloscopeData;
+class OneOscilloscope;
 
 
 
@@ -91,12 +91,11 @@ private:
 struct EyeMapDataSample
 {
     bool isDraw;    /* 是否绘制 */
-    int x;
-    int y;
+    float x;
+    float y;
     int Count;      /* 像素点的个数(颜色深度),这里限制为799,不知道为什么 */
     unsigned char data;     /* 数据值 */
-    QRect rect;     /* 像素点的矩形区域 */
-    // QColor color;   /* 颜色 */
+    QRectF rect;     /* 像素点的矩形区域 */
     QBrush brush;   /* 颜色 */
 
     // EyeMapDataSample() : isDraw(false), x(0), y(0), Count(0), data(0), color(255, 255, 255) {}
@@ -116,26 +115,29 @@ struct EyeMapDataSample
 
 using Vec2DMap = std::vector<std::vector<EyeMapDataSample>>;
 /**
- * @brief 眼图数据矩阵
+ * @brief 眼图颜色矩阵
  * 
  */
-class EyeMapMatrix
+class EyeColorMatrix
 {
 public:
-    EyeMapMatrix() : dataMatrix(g_HorPixel, std::vector<EyeMapDataSample>(g_VerPixel)) {}
-    ~EyeMapMatrix() {}
+    EyeColorMatrix() : dataMatrix(g_HorPixel, std::vector<EyeMapDataSample>(g_VerPixel)) {}
+    ~EyeColorMatrix() {}
 
-    Vec2DMap dataMatrix;
-    std::mutex mutexEyeData;
     /* 初始化数据点 */
     void initEyeMapData(int width, int height);
+    void initEyeMapData();
     /* 拷贝数据到数组中 */
     void copyDataMatrix(Vec2D& data);
     /* 将Count数值与颜色对应 */
     void addColorBySample();
-};
-// extern EyeMapMatrix g_eyeMapMatrix;
+    /* 拷贝颜色数据到数组中 */
+    void copyColorMatrix(Vec2DMap& data);
 
+public:
+    Vec2DMap dataMatrix;
+    std::mutex mutexEyeData;
+};
 
 
 #define OscParams OscilloscopeParameters::getInstance()
@@ -167,7 +169,6 @@ public:
     /* 眼图参数 */
     // int eyeMapWidth = g_HorPixel;         /* 眼图x轴宽度(像素矩形的个数) */
 
-    
 
 public:
     
@@ -177,13 +178,15 @@ public:
 
 
 /**
- * @brief 示波器全局数据
+ * @brief 示波器全局数据,这里存储示波器实例和示波器需要传出的颜色矩阵数据
  * 
  */
-
 #define GOscDataInfo OscilloscopeData::getInstance()
-class OscilloscopeData
+
+class OscilloscopeData : public QObject
 {
+    Q_OBJECT
+
     OscilloscopeData() {}
     OscilloscopeData(const OscilloscopeData&) = delete;
     OscilloscopeData& operator=(const OscilloscopeData&) = delete;
@@ -199,37 +202,37 @@ public:
     /* 初始化示波器参数 */
     void initOscData();
 
-    /* 查找EyeDataMatrix */
-    EyeDataMatrix* findEyeDataMatrix(OscChnNum channel);
-    /* 查找EyeMapMatrix */
-    EyeMapMatrix* findEyeMapMatrix(OscChnNum channel);
     /* 获取示波器列表 */
-    QMap<int, OneOscilloscopeData*>& getOsc() { return mapOsc; }
+    QMap<int, OneOscilloscope*>& getOsc() { return mapOsc; }
     /* 根据通道号查找示波器 */
-    OneOscilloscopeData* findOsc(OscChnNum oscNum);
+    OneOscilloscope* findOsc(OscChnNum oscNum);
     /* 根据通道号设置电压范围 */
     void setVoltageRange(OscChnNum oscNum, OscVoltageRange range);
     /* 根据通道号设置时间刻度值 */
     void setTimeGridValue(OscChnNum oscNum, OscTimeGridValue value);
 
-    /* 清空数据矩阵 */
-    void resetDataMatrix();
+    /* 清空每个设备的数据矩阵 */
+    void resetDevMatrix();
     /* 清空颜色矩阵 */
-    void resetColorMatrix(int width, int height);
+    // void resetColorMatrix(int width, int height);
+    void resetColorMatrix();
 
     /* 暂停所有的采集 */
     void stopAllCapture();
     /* 开启所有的采集 */
     void startAllCapture();
 
+signals:
+    void signal_updateOneEyeMap(int channel);
+    /* 示波器离线了 */
+    void signal_oscOffline(int oscNum);
+    /* 示波器上线了 */
+    void signal_oscOnline(int oscNum);
+
 private:
     /************ 数据相关 ************/
-    /* 眼图数据矩阵 */
-    QMap<OscChnNum, EyeDataMatrix*> mapEyeDataMatrix;
-    /* 眼图颜色矩阵 */
-    QMap<OscChnNum, EyeMapMatrix*> mapEyeMapMatrix;
     /* 示波器类指针,int是示波器编号 */
-    QMap<int, OneOscilloscopeData*> mapOsc;
+    QMap<int, OneOscilloscope*> mapOsc;
 };
 
 

+ 138 - 36
EyeMap/OneEyeMap/OneEyeMap.cpp

@@ -6,6 +6,7 @@
 #include <QPaintEvent>
 
 #include "GlobalInfo.h"
+#include "OneOsc.h"
 
 
 OneEyeMap::OneEyeMap(QWidget *parent) :
@@ -32,6 +33,9 @@ OneEyeMap::OneEyeMap(QWidget *parent) :
         SPDLOG_LOGGER_ERROR(m_logger, "加载qss文件失败");
     }
 
+    /* 初始化变量 */
+    // m_info.uid = EyeMapUID::EMUID_0;
+
     /* 自定义大小 */
     // setFixedSize(1600, 900);
 
@@ -69,12 +73,14 @@ OneEyeMap::OneEyeMap(QWidget *parent) :
     /* 设置定时器 */
     m_timer.setTimerType(Qt::PreciseTimer);
     m_timer.setSingleShot(false);
-    m_timer.start(100);      /* 100ms刷新一次,大约10帧 */
-
-    connect(this, &OneEyeMap::signal_update, this, &OneEyeMap::do_update);
     connect(&m_timer, &QTimer::timeout, this, &OneEyeMap::do_update);
+    m_timer.start(1000);      /* 1s刷新一次 */
+    
+    // connect(&GOscDataInfo, &OscilloscopeData::signal_updateOneEyeMap, this, &OneEyeMap::do_updateColorMatrix);
+    connect(&GOscDataInfo, &OscilloscopeData::signal_oscOffline, this, &OneEyeMap::do_deviceOffline);
+    connect(&GOscDataInfo, &OscilloscopeData::signal_oscOnline, this, &OneEyeMap::do_deviceOnline);
 
-    SPDLOG_LOGGER_INFO(m_logger, "OneEyeMap 初始化成功");
+    SPDLOG_LOGGER_INFO(m_logger, "{} OneEyeMap 初始化成功", m_info.channelInfo.channelName.toStdString());
 
 }
 
@@ -84,18 +90,35 @@ OneEyeMap::~OneEyeMap()
     delete ui;
 }
 
-/* 根据通道号获取数据指针 */
-void OneEyeMap::setEyeDataPtrFromOscData(OscChnNum channel)
+/* 根据通道号获取示波器指针 */
+void OneEyeMap::getOneOscFromGlobalOscData()
 {
-    m_eyeMapMatrix = GOscDataInfo.findEyeMapMatrix(channel);
-    if(m_eyeMapMatrix == nullptr)
+    /* 初始化本地的颜色矩阵 */
+    if(m_colorMatrix == nullptr)
+    {
+        m_colorMatrix = new EyeColorMatrix();
+        m_colorMatrix->initEyeMapData(this->width(), this->height());
+    }
+
+    m_osc = GOscDataInfo.findOsc(m_info.channelInfo.channel);
+    if(m_osc == nullptr)
     {
-        SPDLOG_LOGGER_ERROR(m_logger, "获取颜色矩阵错误! 通道号: {}", static_cast<int>(channel));
+        SPDLOG_LOGGER_ERROR(m_logger, "获取示波器指针错误! 通道号: {}", static_cast<int>(m_info.channelInfo.channel));
         return;
     }
-    m_eyeMapMatrix->initEyeMapData(this->width(), this->height());
+    m_osc->setColorMatrixPtr(m_info.channelInfo.channel, m_colorMatrix);
+    /* 先设置为不使用通道采集 */
+    m_osc->setChannelUsed(m_info.channelInfo.channel, false);
 }
 
+/* 设置UID,只能设置一次 */
+// void OneEyeMap::setUID(EyeMapUID uid)
+// {
+//     if(m_info.uid == EyeMapUID::EMUID_0)
+//     {
+//         m_info.uid = uid;
+//     }
+// }
 
 /* 设置标题 */
 void OneEyeMap::setTitle(const QString &title)
@@ -119,9 +142,11 @@ void OneEyeMap::setShow(bool isShow)
     m_info.isShow = isShow;
     if(isShow)
     {
+        m_osc->setChannelUsed(m_info.channelInfo.channel, true);
         this->show();
     } else
     {
+        m_osc->setChannelUsed(m_info.channelInfo.channel, false);
         this->hide();
     }
 }
@@ -130,6 +155,28 @@ void OneEyeMap::setShow(bool isShow)
 void OneEyeMap::setVoltageRange(OscVoltageRange range)
 {
     m_info.voltageRange = range;
+    /* 设置示波器的电压范围 */
+    if(m_osc != nullptr)
+    {
+        if(static_cast<int>(m_info.channelInfo.channel) % 2 == 1)
+        {
+            m_osc->setChannelARange(range);
+        } else
+        {
+            m_osc->setChannelBRange(range);
+        }
+    }
+}
+
+/* 设置时间刻度 */
+void OneEyeMap::setTimeGridValue(OscTimeGridValue value)
+{
+    m_info.tGridValue = value;
+    /* 设置示波器的时间刻度 */
+    if(m_osc != nullptr)
+    {
+        m_osc->setTimeGridValue(value);
+    }
 }
 
 /* 更新组件信息 */
@@ -155,9 +202,49 @@ void OneEyeMap::updateSettingNum(const OneEyeMapInfo &info)
     setChannelInfo(info.channelInfo);
 }
 
+/* 重置眼图显示区域为默认 */
+void OneEyeMap::resetEyeMap()
+{
+    m_colorMatrix->initEyeMapData(this->width(), this->height());
+    update();
+}
+
 /* 刷新页面 */
 void OneEyeMap::do_update()
 {
+    // SPDLOG_LOGGER_DEBUG(m_logger, "{} 刷新页面", m_info.title.toStdString());
+    if(!m_osc->isOpen())
+    {
+        return;
+    }
+
+    
+    update();
+}
+
+
+/* 设备离线了 */
+void OneEyeMap::do_deviceOffline(int oscNum)
+{
+    /* 判断是不是这个编号 */
+    if(static_cast<OscChnNum>(oscNum) != m_info.channelInfo.channel)
+    {
+        return;
+    }
+    SPDLOG_LOGGER_WARN(m_logger, "{} 离线了", oscNum, m_info.channelInfo.channelName.toStdString());
+    m_isOpen = false;
+    update();
+}
+
+/* 设备上线了 */
+void OneEyeMap::do_deviceOnline(int oscNum)
+{
+    /* 判断是不是这个编号 */
+    if(static_cast<OscChnNum>(oscNum) != m_info.channelInfo.channel)
+    {
+        return;
+    }
+    m_isOpen = true;
     update();
 }
 
@@ -168,7 +255,7 @@ void OneEyeMap::do_update()
  */
 void OneEyeMap::paintEvent(QPaintEvent *event)
 {
-    if(m_eyeMapMatrix == nullptr)
+    if(m_colorMatrix == nullptr)
     {
         return;
     }
@@ -177,18 +264,18 @@ void OneEyeMap::paintEvent(QPaintEvent *event)
 
     /******************** 绘制背景 ********************/
     drawBackground(painter);
-
-    /* 判断设备是否打开,没打开就显示“暂无设备”图片 */
-    // if(!m_isOpen)
-    // {
-    //     ui->widget_title->hide();
-    //     drawNoDevice(painter);
-    //     return;
-    // }
     ui->widget_title->show();
+    /* 判断设备是否打开,没打开就显示“暂无设备”图片 */
+    if(!m_isOpen)
+    {
+        // ui->widget_title->hide();
+        drawNoDevice(painter);
+        event->accept();
+        return;
+    }
 
-    m_eyeMapMatrix->mutexEyeData.lock();
-
+    m_colorMatrix->mutexEyeData.lock();
+    // SPDLOG_LOGGER_DEBUG(m_logger, "{} 获取到了颜色矩阵锁", m_info.title.toStdString());
     /******************** 绘制刻度值 ********************/
     drawScaleValue(painter);
     
@@ -201,7 +288,7 @@ void OneEyeMap::paintEvent(QPaintEvent *event)
     /******************** 绘制眼图区域 ********************/
     drawEyeMap(painter);
 
-    m_eyeMapMatrix->mutexEyeData.unlock();
+    m_colorMatrix->mutexEyeData.unlock();
 
     event->accept();
 }
@@ -225,6 +312,12 @@ void OneEyeMap::resizeEvent(QResizeEvent *event)
     m_rectEyeMap.setWidth(m_rectScaleValue.width() - m_leftMargin - m_rightMargin);
     m_rectEyeMap.setHeight(m_rectScaleValue.height() - m_topMargin - m_bottomMargin);
 
+    /* 重新设置颜色矩阵 */
+    if(m_colorMatrix != nullptr)
+    {
+        m_colorMatrix->initEyeMapData(this->width(), this->height());
+    }
+
     /* 刷新一下页面 */
     update();
     event->accept();
@@ -272,15 +365,7 @@ void OneEyeMap::drawScaleValue(QPainter &painter)
     }
 
     /* 绘制参渐变考颜色 */
-    QLinearGradient linearGradient(m_rectRefColor.topLeft(), m_rectRefColor.bottomRight());
-    linearGradient.setColorAt(0, QColor("#003590"));
-    linearGradient.setColorAt(0.4, QColor(0, 255, 255));
-    linearGradient.setColorAt(0.6, QColor(0, 255, 0));
-    linearGradient.setColorAt(0.8, QColor(255, 255, 0));
-    linearGradient.setColorAt(1, QColor("#FF4123"));
-    painter.setBrush(linearGradient);
-    painter.setPen(Qt::NoPen);
-    painter.drawRect(m_rectRefColor);
+    drawRefColor(painter);
 
 }
 
@@ -401,19 +486,22 @@ void OneEyeMap::drawScale(QPainter &painter)
 /* 绘制眼图区域 */
 void OneEyeMap::drawEyeMap(QPainter &painter)
 {
+    // SPDLOG_ERROR("绘制眼图区域");
     /* 绘制眼图,就是绘制 1000 * 256 个矩形 */
     painter.setPen(Qt::NoPen);
     for(int i = 0; i < g_HorPixel; i++)
     {
         for(int j = 0; j < g_VerPixel; j++)
         {
-            if(m_eyeMapMatrix->dataMatrix[i][j].isDraw == false)
+            /* 这里需要根据是否需要显示进行判断,不然全绘制太卡了 */
+            if(m_colorMatrix->dataMatrix[i][j].isDraw == false)
             {
                 continue;
             }
-            // painter.setBrush(QBrush(g_eyeMapMatrix.dataMatrix[i][j].color));
-            painter.setBrush(m_eyeMapMatrix->dataMatrix[i][j].brush);
-            painter.drawRect(m_eyeMapMatrix->dataMatrix[i][j].rect);
+            /* 打印出颜色 */
+            // SPDLOG_LOGGER_WARN(m_logger, "颜色: {}", m_eyeColorMatrix->dataMatrix[i][j].brush.color().name().toStdString());
+            painter.setBrush(m_colorMatrix->dataMatrix[i][j].brush);
+            painter.drawRect(m_colorMatrix->dataMatrix[i][j].rect);
         }
     }
 }
@@ -424,7 +512,21 @@ void OneEyeMap::drawNoDevice(QPainter &painter)
     int x = (this->width() - m_rectNoDevice.width()) / 2;
     int y = (this->height() - m_rectNoDevice.height()) / 2;
     m_rectNoDevice.moveTo(x, y);
-    painter.drawPixmap(m_rectNoDevice, *m_pixmapNoDevice);
+    painter.drawPixmap(m_rectNoDevice, *m_pixmapDeviceOffline);
+}
+
+/* 绘制参考渐变色 */
+void OneEyeMap::drawRefColor(QPainter &painter)
+{
+    QLinearGradient linearGradient(m_rectRefColor.topLeft(), m_rectRefColor.bottomRight());
+    linearGradient.setColorAt(0, QColor("#003590"));
+    linearGradient.setColorAt(0.4, QColor(0, 255, 255));
+    linearGradient.setColorAt(0.6, QColor(0, 255, 0));
+    linearGradient.setColorAt(0.8, QColor(255, 255, 0));
+    linearGradient.setColorAt(1, QColor("#FF4123"));
+    painter.setBrush(linearGradient);
+    painter.setPen(Qt::NoPen);
+    painter.drawRect(m_rectRefColor);
 }
 
 /* 获取一个格子的电压值 */

+ 21 - 8
EyeMap/OneEyeMap/OneEyeMap.h

@@ -23,13 +23,15 @@ public:
     explicit OneEyeMap(QWidget *parent = nullptr);
     ~OneEyeMap();
 
-    /* 根据通道号获取数据指针 */
-    void setEyeDataPtrFromOscData(OscChnNum channel);
+    /* 根据通道号获取示波器指针 */
+    void getOneOscFromGlobalOscData();
 
     /* 设置对应的示波器是否已经打开 */
     void setOpen(bool isOpen) { m_isOpen = isOpen; }
     /* 获取UID */
-    EyeMapUID getUID() { return m_info.uid; }
+    // EyeMapUID getUID() { return m_info.uid; }
+    /* 设置UID */
+    // void setUID(EyeMapUID uid);
     /* 设置序号 */
     void setNum(int num) { m_info.num = num; }
     /* 获取序号 */
@@ -55,7 +57,7 @@ public:
     /* 获取电压值 */
     OscVoltageRange getVoltageRange() { return m_info.voltageRange; }
     /* 设置时间刻度 */
-    void setTimeGridValue(OscTimeGridValue value) { m_info.tGridValue = value; }
+    void setTimeGridValue(OscTimeGridValue value);
     /* 获取时间刻度 */
     OscTimeGridValue getTimeGridValue() { return m_info.tGridValue; }
     /* 更新组件信息 */
@@ -66,11 +68,19 @@ public:
     /* 获取眼图显示区域的大小 */
     QSize getEyeMapSize() { return m_rectEyeMap.size(); }
 
+    /* 重置眼图显示区域为默认 */
+    void resetEyeMap();
+
 signals:
-    void signal_update();
+    // void signal_update();
 
 private slots:
+    /* 刷新页面 */
     void do_update();
+    /* 设备离线了 */
+    void do_deviceOffline(int oscNum);
+    /* 设备上线了 */
+    void do_deviceOnline(int oscNum);
 
 protected:
     void paintEvent(QPaintEvent *event) override;
@@ -88,6 +98,8 @@ private:
     void drawEyeMap(QPainter &painter);
     /* 绘制暂无设备 */
     inline void drawNoDevice(QPainter &painter);
+    /* 绘制参考渐变色 */
+    inline void drawRefColor(QPainter &painter);
 
     /* 获取一个格子的电压值 */
     inline QString getVScaleValue(int index);
@@ -121,10 +133,11 @@ private:
     // OscVoltageRange m_cRange = OscVoltageRange::CR_2V5;    /* 通道输入档位 */
     // OscTimeGridValue m_tGridValue = OscTimeGridValue::TGV_200NS;    /* 时间刻度值 */
 
-    EyeMapMatrix* m_eyeMapMatrix = nullptr; /* 眼图矩阵,从外面获取 */
+    OneOscilloscope* m_osc = nullptr;    /* 示波器指针 */
+    EyeColorMatrix* m_colorMatrix = nullptr;    /* 本地眼图矩阵 */
 
-    QPixmap* m_pixmapNoDevice = nullptr; /* 暂无设备图片 */
-    QPixmap* m_pixmapDeviceOffline = nullptr; /* 设备离线图片 */
+    QPixmap* m_pixmapNoDevice = nullptr;        /* 暂无设备图片 */
+    QPixmap* m_pixmapDeviceOffline = nullptr;   /* 设备离线图片 */
 };
 
 #endif // ONEEYEMAP_H

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 480 - 120
EyeMap/OscData/OneOsc.cpp


+ 73 - 27
EyeMap/OscData/OneOscData.h → EyeMap/OscData/OneOsc.h

@@ -1,36 +1,37 @@
-#ifndef _OneOscilloscopeData_H_
-#define _OneOscilloscopeData_H_
+#ifndef _OneOscilloscope_H_
+#define _OneOscilloscope_H_
 
 #include <QObject>
 #include <QMap>
+#include <QTimer>
 
 #include "USBInterFace.h"
 #include "spdlog/spdlog.h"
 #include "GlobalInfo.h"
-#include "OscDataInfo.h"
 #include "RingQueue/RingQueue.hpp"
 
-#define OneOscData OneOscilloscopeData
+class EyeDataMatrix;
+class EyeColorMatrix;
+struct EyeDataT;
 
-class OneOscilloscopeData : public QObject
+#define OneOscData OneOscilloscope
+
+class OneOscilloscope : public QObject
 {
     Q_OBJECT
 
 const uint32_t BUFFER_SIZE = 1024 * 128 ;    /* 缓冲区大小,OSCA02的缓冲区应该是128KB的SRAM */
 
+using Vec2Data = std::vector<std::vector<EyeDataT>>;
+
 private:
     
-    OneOscilloscopeData(const OneOscilloscopeData&) = delete;
-    OneOscilloscopeData& operator=(const OneOscilloscopeData&) = delete;
+    OneOscilloscope(const OneOscilloscope&) = delete;
+    OneOscilloscope& operator=(const OneOscilloscope&) = delete;
 public:
-    OneOscilloscopeData();
-    ~OneOscilloscopeData();
-
-    // static OneOscilloscopeData& getInstance()
-    // {
-    //     static OneOscilloscopeData instance;
-    //     return instance;
-    // }
+    OneOscilloscope();
+    ~OneOscilloscope();
+
     /* 初始化示波器 */
     void initOSC(int oscNum);
     /* 打开示波器 */
@@ -39,12 +40,19 @@ public:
     void closeOSC();
     /* 示波器是否打开 */
     bool isOpen() { return m_isOpen; }
-    /*  */
+
     /* 开始采集数据 */
     bool startCapture();
+    /* 开启采集数据,带有条件判断 */
+    bool startCaptureWithCondition();
     /* 停止采集数据 */
     void stopCapture();
 
+    /* 获取颜色矩阵内存指针 */
+    EyeColorMatrix* getColorMatrixPtr(OscChannel chn);
+    /* 设置颜色矩阵,把外部的颜色矩阵设置过来,通过这里的子线程拷贝进去 */
+    void setColorMatrixPtr(OscChnNum num, EyeColorMatrix* colorMatrix);
+
     /***** 设置示波器的功能命令 *****/
     /* 设置示波器的采样率 */
     void setSampleRate(OscSampleRate rate);
@@ -83,6 +91,15 @@ public:
 
     /***** 示波器其他属性 *****/
     int getOscNum() { return m_oscNum; }
+    /* 清空数据 */
+    void resetData();
+
+    /* 设置示波器的两个通道是否在使用,都不使用则停止采集 */
+    void setChannelUsed(OscChnNum chn, bool used);
+
+signals:
+    /* 重新连接示波器 */
+    void signal_reconnectOsc();
 
 private:
 // public:
@@ -94,39 +111,61 @@ private:
     void threadProcessData_A();
     /* 处理B通道数据 */
     void threadProcessData_B();
+    /* 拷贝数据线程 */
+    void threadCopyData(OscChannel chn);
 
     /* 解析数据,眼图需要的数据 */
-    void parseEyeMapData(OscChannel chn, unsigned char* buffer, unsigned int size);
+    bool parseEyeMapData(OscChannel chn, unsigned char* buffer, unsigned int size);
     /* 设置零电压值和电压校准系数 */
     void setZeroVoltageAndCalibration(OscChannel chn, OscVoltageRange range);
     /* 校准电压 */
     inline double calibrationVoltageA(uint8_t& data);
     inline double calibrationVoltageB(uint8_t& data);
 
-    /* 根据示波器编号获取示波器的数据矩阵指针 */
-    bool getEyeDataMatrixPtr();
+    /* 初始化数据矩阵很颜色矩阵 */
+    bool initMatrixPtr();
+    /* 等待所有线程退出,调用此函数之前,需要先设置线程运行标志为false,并发送所有的条件变量
+     * 这个函数会阻塞一直等待所有线程退出 */
+    void waitAllThreadExit();
+    /* 发送示波器在线或者离线状态 */
+    void sendOscState(bool state);
+
+private slots:
+    /* 示波器离线了,重新连接 */
+    void do_reconnectOsc();
 
 private:
     std::shared_ptr<spdlog::logger> m_logger = nullptr;
     std::shared_ptr<USBInterface> m_usbInterface = nullptr;
+
     std::atomic_bool m_isOpen = false;                      /* 示波器是否打开 */
     std::atomic_bool m_isConnected = false;                 /* 示波器是否连接 */
-    std::atomic_bool m_runCapture = false;                  /* 采集数据的线程标志 */
-    std::atomic_bool m_isRunCapture = false;                /* 采集数据的线程运行标志,这个标志位作为线程运行的标志 */
+    std::atomic_bool m_runCapture = false;                  /* 线程运行的变量 */
+    std::map<std::thread::id, bool> m_mapThreadState;       /* 线程是否正在运行的标志位 */
+    std::atomic_bool m_isRunCapture = false;                /* 线程运行标志,这个标志位作为线程运行的标志 */
+    QTimer m_timerConnect;                                  /* 连接定时器 */
+
     std::atomic_bool m_isCapturedData = false;              /* 是否采集到数据 */
     std::condition_variable m_condCapture;                  /* 采集数据的条件变量 */
     std::condition_variable m_condBuffer_A;                 /* 通道A的条件变量 */
     std::condition_variable m_condBuffer_B;                 /* 通道B的条件变量 */
+    std::condition_variable m_condCopyData_A;               /* 拷贝数据的条件变量 */
+    std::condition_variable m_condCopyData_B;               /* 拷贝数据的条件变量 */
     std::mutex m_mutexBuffer;                               /* 互斥锁,用于保护采集到的数据 */
     std::mutex m_mutexBuffer_A;                             /* 互斥锁,用于保护采集到的数据 */
     std::mutex m_mutexBuffer_B;                             /* 互斥锁,用于保护采集到的数据 */
+    std::mutex m_mutexThreadState;                          /* 互斥锁,用于保护线程状态 */
+    
     unsigned char* m_devBuffer = nullptr;                   /* 设备缓冲区指针,拷贝数据用的 */
     unsigned char* m_buffer = nullptr;                      /* 缓冲区指针,用于存储拷贝出来的数据 */
     unsigned char* m_bufferChnA = nullptr;                  /* 通道A的缓冲区指针 */
     unsigned char* m_bufferChnB = nullptr;                  /* 通道B的缓冲区指针 */
-    // RingQueue<unsigned char*> m_ringQueue;                  /* 环形队列,用于存储示波器采集到的数据 */
 
     int m_oscNum = 0;                                       /* 示波器编号 */
+    OscChnNum m_chnNumA = OscChnNum::Osc_None;              /* 示波器通道数 */
+    OscChnNum m_chnNumB = OscChnNum::Osc_None;              /* 示波器通道数 */
+    bool m_chnUsedA = false;                                /* 通道A是否在使用 */
+    bool m_chnUsedB = false;                                /* 通道B是否在使用 */
     
 
     /************* 示波器控制相关 *************/
@@ -147,19 +186,26 @@ private:
     double m_rangeRatioA = 0.0;                             /* 通道A量程比例 */
     double m_rangeRatioB = 0.0;                             /* 通道B量程比例 */
 
+    OscVoltageRange m_rangeA = OscVoltageRange::CR_2V5;     /* 通道A输入量程,用于记录外部设置的当前输入量程 */
+    OscVoltageRange m_rangeB = OscVoltageRange::CR_2V5;     /* 通道B输入量程 */
+
     std::atomic_int m_oneTimeGrid = 0;                      /* 一个时间刻度的时间长度,单位ns,和枚举值OscTimeGridValue相对应 */
     std::atomic<double> m_SampleIntervalTime = 0;           /* 采样点之间的时间间隔,单位ns(采样率的倒数,设置采样率的时候会设置) */
     // std::atomic_int m_eyeMapWidth = 0;                      /* 眼图x轴宽度(像素矩形的个数) */
 
     /************* 数据指针 *************/
-    EyeDataMatrix* m_eyeDataMatrix_A = nullptr;               /* 眼图数据矩阵,A通道 */
-    EyeDataMatrix* m_eyeDataMatrix_B = nullptr;               /* 眼图数据矩阵,B通道 */
-    EyeMapMatrix* m_eyeMapMatrix_A = nullptr;                 /* 眼图矩阵,A通道 */
-    EyeMapMatrix* m_eyeMapMatrix_B = nullptr;                 /* 眼图矩阵,B通道 */
+    EyeDataMatrix* m_dataMatrix_A = nullptr;             /* 眼图数据矩阵,A通道 */
+    EyeDataMatrix* m_dataMatrix_B = nullptr;             /* 眼图数据矩阵,B通道 */
+    EyeColorMatrix* m_colorMatrix_A = nullptr;           /* 眼图颜色矩阵,A通道 */
+    EyeColorMatrix* m_colorMatrix_B = nullptr;           /* 眼图颜色矩阵,B通道 */
+
+
+    EyeColorMatrix* m_gColorMatrix_A = nullptr;             /* 外部的颜色矩阵,A通道,一帧完成后拷贝给全局的矩阵 */
+    EyeColorMatrix* m_gColorMatrix_B = nullptr;             /* 外部的颜色矩阵,B通道,一帧完成后拷贝给全局的矩阵 */
 
 };
 
 
 
 
-#endif /* _OneOscilloscopeData_H_ */
+#endif /* _OneOscilloscope_H_ */

+ 0 - 1129
EyeMap/OscData/OscData.cpp_

@@ -1,1129 +0,0 @@
-#include "OscData.h"
-#include <QApplication>
-#include <QRandomGenerator>
-
-#include "ThreadPool/ThreadPool.h"
-
-
-OscilloscopeData::OscilloscopeData()
-{
-    
-}
-
-
-OscilloscopeData::~OscilloscopeData()
-{
-    if(m_isOpen)
-    {
-        closeOSC();
-    }
-    if(m_buffer != nullptr)
-    {
-        delete[] m_buffer;
-        m_buffer = nullptr;
-    }
-    if(m_bufferChnA != nullptr)
-    {
-        delete[] m_bufferChnA;
-        m_bufferChnA = nullptr;
-    }
-    if(m_bufferChnB != nullptr)
-    {
-        delete[] m_bufferChnB;
-        m_bufferChnB = nullptr;
-    }
-}
-
-/* 初始化示波器 */
-void OscilloscopeData::initOsc()
-{
-    m_logger = spdlog::get("OscData");
-    if(m_logger == nullptr)
-    {
-        SPDLOG_ERROR("获取 OscData logger 失败");
-        return;
-    }
-    m_usbInterface = std::make_shared<USBInterface>();
-    if(!m_usbInterface->loadLib(QApplication::applicationDirPath()))
-    {
-        return;
-    }
-    /* 分配缓冲区内存 */
-    m_buffer = new unsigned char[BUFFER_SIZE];
-    m_bufferChnA = new unsigned char[BUFFER_SIZE / 2];
-    m_bufferChnB = new unsigned char[BUFFER_SIZE / 2];
-}
-
-/* 打开示波器 */
-bool OscilloscopeData::openOSC()
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return false;
-    }
-    /* 指定示波器设备型号,OSCA02是6 */
-    m_usbInterface->specifyDevId(6);
-    auto ret = m_usbInterface->devOpen();
-    if(ret != 0)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "打开示波器失败!");
-        return false;
-    }
-    /* 获取缓冲区首指针 */
-    m_devBuffer = m_usbInterface->bufferWR(-1);
-    if(m_devBuffer == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "获取缓冲区指针失败!");
-        return false;
-    }
-    /* 设置硬件触发命令,关闭外部触发,好像是有的设备需要,有的不需要 */
-    m_ctrlByte1 &= 0xdf;
-    m_ctrlByte1 |= 0x00;
-    m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-    /* 设置触发位置在缓冲区中间 */
-    m_usbInterface->usbCtrlTrans(0x18, 0xff);
-    m_usbInterface->usbCtrlTrans(0x17, 0x7f);
-    /* 设置缓冲区大小 */
-    m_usbInterface->setInfo(BUFFER_SIZE);
-    /* 获取零电压值 */
-    getZeroVoltage();
-    /* 获取电压校准系数 */
-    getVoltageCalibration();
-
-
-    m_isOpen = true;
-    return true;
-}
-
-/* 关闭示波器 */
-void OscilloscopeData::closeOSC()
-{
-    if(m_runCapture)
-    {
-        stopCapture();
-    }
-    
-    if(m_usbInterface != nullptr)
-    {
-        m_usbInterface->devClose();
-    }
-    m_isOpen = false;
-    SPDLOG_INFO("示波器已关闭");
-}
-
-/* 开始采集数据 */
-bool OscilloscopeData::startCapture()
-{
-    if(m_buffer == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "缓冲区指针为空!");
-        return false;
-    }
-    /* 启动子线程 */
-    m_runCapture = true;
-    CPPTP.add_task(&OscilloscopeData::threadCaptureData, this);
-    CPPTP.add_task(&OscilloscopeData::threadProcessData, this);
-    CPPTP.add_task(&OscilloscopeData::threadAddColorBySample, this);
-    return true;
-}
-
-/* 停止采集数据 */
-void OscilloscopeData::stopCapture()
-{
-    if(!m_runCapture)
-    {
-        return;
-    }
-    m_runCapture = false;
-    while (m_isRunCapture)
-    {
-        std::this_thread::sleep_for(std::chrono::milliseconds(5));
-    }
-    SPDLOG_LOGGER_INFO(m_logger, "停止采集数据");
-}
-
-/* 设置示波器的采样率 */
-void OscilloscopeData::setSampleRate(OscSampleRate rate)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    m_ctrlByte0 &= 0xf0;
-    if(rate == OscSampleRate::SR_49KHZ)
-    {
-        m_ctrlByte0 |= 0x0e;
-        OscParams.SampleIntervalTime = 20408.16;
-    }
-    else if(rate == OscSampleRate::SR_96KHZ)
-    {
-        m_ctrlByte0 |= 0x04;
-        OscParams.SampleIntervalTime = 10416.67;
-    }
-    else if(rate == OscSampleRate::SR_781KHZ)
-    {
-        m_ctrlByte0 |= 0x0c;
-        OscParams.SampleIntervalTime = 1280.0;
-    }
-    else if(rate == OscSampleRate::SR_12_5MHZ)
-    {
-        m_ctrlByte0 |= 0x08;
-        OscParams.SampleIntervalTime = 80.0;
-    }
-    else if(rate == OscSampleRate::SR_100MHZ)
-    {
-        m_ctrlByte0 |= 0x00;
-        OscParams.SampleIntervalTime = 10;
-    }
-    else
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "采样率设置错误!");
-        return;
-    }
-    m_usbInterface->usbCtrlTrans(0x94, m_ctrlByte0);
-}
-
-/**
- * @brief 将示波器两个通道合并为一个通道
- *        将AB两个通道的资源全部给A,B通道失效,A通道的采样率和带宽翻倍
- * @param merge 是否合并
- */
-void OscilloscopeData::setChannelMerge(bool merge)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    if(merge)
-    {
-        m_ctrlByte1 |= 0x80;
-    }else {
-        m_ctrlByte1 &= 0x7f;
-    }
-    m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-}
-
-/**
- * @brief 设置通道A输入量程,这个函数需要在打开示波器之后调用
- * 
- * @param range 
- */
-void OscilloscopeData::setChannelARange(OscVoltageRange range)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    m_ctrlByte1 &= 0xf7;
-    if(range == OscVoltageRange::CR_100MV)
-    {
-        m_usbInterface->usbCtrlTrans(0x22, 0x06);
-    }
-    else if(range == OscVoltageRange::CR_250MV)
-    {
-        m_usbInterface->usbCtrlTrans(0x22, 0x04);
-    }
-    else if(range == OscVoltageRange::CR_500MV)
-    {
-        m_usbInterface->usbCtrlTrans(0x22, 0x02);
-    }
-    else if(range == OscVoltageRange::CR_1V)
-    {
-        m_ctrlByte1 |= 0x08;
-        m_usbInterface->usbCtrlTrans(0x22, 0x06);
-    }
-    else if(range == OscVoltageRange::CR_2V5)
-    {
-        m_ctrlByte1 |= 0x08;
-        m_usbInterface->usbCtrlTrans(0x22, 0x04);
-    }
-    else if(range == OscVoltageRange::CR_5V)
-    {
-        m_ctrlByte1 |= 0x08;
-        m_usbInterface->usbCtrlTrans(0x22, 0x02);
-    }
-    else if(range == OscVoltageRange::CR_8V)
-    {
-        m_ctrlByte1 |= 0x08;
-        m_usbInterface->usbCtrlTrans(0x22, 0x00);
-    }
-    m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-    
-    setZeroVoltageAndCalibration(OscChannel::CH_A, range);
-}
-
-/**
- * @brief 设置通道B输入量程
- * 
- * @param range 
- */
-void OscilloscopeData::setChannelBRange(OscVoltageRange range)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    m_ctrlByte1 &= 0xf9;
-    if(range == OscVoltageRange::CR_100MV)
-    {
-        m_ctrlByte1 |= 0x06;
-        m_usbInterface->usbCtrlTrans(0x23, 0x40);
-    }
-    else if(range == OscVoltageRange::CR_250MV)
-    {
-        m_ctrlByte1 |= 0x04;
-        m_usbInterface->usbCtrlTrans(0x23, 0x40);
-    }
-    else if(range == OscVoltageRange::CR_500MV)
-    {
-        m_ctrlByte1 |= 0x02;
-        m_usbInterface->usbCtrlTrans(0x23, 0x40);
-    }
-    else if(range == OscVoltageRange::CR_1V)
-    {
-        m_ctrlByte1 |= 0x06;
-        m_usbInterface->usbCtrlTrans(0x23, 0x00);
-    }
-    else if(range == OscVoltageRange::CR_2V5)
-    {
-        m_ctrlByte1 |= 0x04;
-        m_usbInterface->usbCtrlTrans(0x23, 0x00);
-    }
-    else if(range == OscVoltageRange::CR_5V)
-    {
-        m_ctrlByte1 |= 0x02;
-        m_usbInterface->usbCtrlTrans(0x23, 0x00);
-    }
-    else if(range == OscVoltageRange::CR_8V)
-    {
-        m_usbInterface->usbCtrlTrans(0x23, 0x00);
-    }
-    else
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "输入量程设置错误!");
-        return;
-    }
-    m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-
-    setZeroVoltageAndCalibration(OscChannel::CH_B, range);
-}
-
-/**
- * @brief 设置通道耦合方式
- * 
- * @param channel 通道
- * @param coupling 耦合方式,DC或者AC
- */
-void OscilloscopeData::setChannelCoupling(OscChannel channel, OscChannelCoupling coupling)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    if(channel == OscChannel::CH_A)
-    {
-        m_ctrlByte0 &= 0xef;
-        if(coupling == OscChannelCoupling::DC) {
-            m_ctrlByte0 |= 0x10;
-        }
-        else if(coupling == OscChannelCoupling::AC) {}
-        else {
-            SPDLOG_LOGGER_ERROR(m_logger, "耦合方式设置错误!");
-            return;
-        }
-        m_usbInterface->usbCtrlTrans(0x94, m_ctrlByte0);
-    }
-    else if(channel == OscChannel::CH_B)
-    {
-        m_ctrlByte1 &= 0xef;
-        if(coupling == OscChannelCoupling::AC) {
-            m_ctrlByte1 |= 0x10;
-        }
-        else if(coupling == OscChannelCoupling::DC) {}
-        else {
-            SPDLOG_LOGGER_ERROR(m_logger, "耦合方式设置错误!");
-            return;
-        }
-        m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-    }
-    else
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "通道设置错误!");
-        return;
-    }
-}
-
-/* 开启或关闭通道A触发 */
-void OscilloscopeData::setChannelATrigger(bool enable)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    if(enable)
-    {
-        m_usbInterface->usbCtrlTrans(0xE7, 0x01);
-    }
-    else
-    {
-        m_usbInterface->usbCtrlTrans(0xE7, 0x00);
-    }
-}
-
-/* 开启外触发 */
-void OscilloscopeData::setExternalTrigger(bool enable)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    if(enable)
-    {
-        m_usbInterface->usbCtrlTrans(0xE7, 0x01);
-        m_ctrlByte1 &= 0xdf;
-        m_ctrlByte1 |= 0x20;
-        m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-    }
-    else
-    {
-        m_usbInterface->usbCtrlTrans(0xE7, 0x00);
-        m_ctrlByte1 &= 0xdf;
-        m_ctrlByte1 |= 0x00;
-        m_usbInterface->usbCtrlTrans(0x24, m_ctrlByte1);
-    }
-}
-
-/* 设置触发方式 */
-void OscilloscopeData::setTriggerMode(OscTriggerMode mode)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    if(mode == OscTriggerMode::TM_RISE)
-    {
-        m_usbInterface->usbCtrlTrans(0xC5, 0x00);
-    }
-    else if (mode == OscTriggerMode::TM_DOWN)
-    {
-        m_usbInterface->usbCtrlTrans(0xC5, 0x01);
-    }
-    else if (mode == OscTriggerMode::TM_DOUBLE)
-    {
-        m_usbInterface->usbCtrlTrans(0xC5, 0x03);
-    }
-}
-
-/**
- * @brief 设置触发电平
- * 
- * @param level 0~255的值
- */
-void OscilloscopeData::setTriggerLevel(unsigned char level)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    m_usbInterface->usbCtrlTrans(0x16, level);
-}
-
-/* 设置触发灵敏度 */
-void OscilloscopeData::setTriggerSensitivity(OscTriggerSensitivity sensitivity)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    if(sensitivity == OscTriggerSensitivity::TS_LOW)
-    {
-        m_usbInterface->usbCtrlTrans(0x2b, 0);
-    }
-    else if(sensitivity == OscTriggerSensitivity::TS_HIGH)
-    {
-        m_usbInterface->usbCtrlTrans(0x2b, 1);
-    }
-    else
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "触发灵敏度设置错误!");
-        return;
-    }
-}
-
-/* 设置触发在缓冲区的哪个位置 */
-void OscilloscopeData::setTriggerPosition(unsigned char lowByte, unsigned char highByte)
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    m_usbInterface->usbCtrlTrans(0x18, lowByte);
-    m_usbInterface->usbCtrlTrans(0x17, highByte);
-}
-
-/* 获取示波器不同档位下的零电压值 */
-void OscilloscopeData::getZeroVoltage()
-{
-    if(m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    /* 获取通道A零电压值 */
-    unsigned char zeroVoltage = 0;
-    /* 2V档位,正负8V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x82);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_8V, zeroVoltage);
-    /* 1V档位,正负5V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x01);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_5V, zeroVoltage);
-    /* 500mV档位,正负2.5V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x0e);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_2V5, zeroVoltage);
-    /* 200mV档位,正负1V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x14);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_1V, zeroVoltage);
-    /* 100mV档位,正负500mV量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x12);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_500MV, zeroVoltage);
-    /* 50mV档位,正负250mV量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x10);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_250MV, zeroVoltage);
-    /* 20mV档位,正负100mV量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0xa0);
-    m_mapChAZeroVoltage.insert(OscVoltageRange::CR_100MV, zeroVoltage);
-
-    /* 获取通道B零电压值 */
-    /* 2V档位,正负8V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x72);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_8V, zeroVoltage);
-    /* 1V档位,正负5V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x02);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_5V, zeroVoltage);
-    /* 500mV档位,正负2.5V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x0f);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_2V5, zeroVoltage);
-    /* 200mV档位,正负1V量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x15);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_1V, zeroVoltage);
-    /* 100mV档位,正负500mV量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x13);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_500MV, zeroVoltage);
-    /* 50mV档位,正负250mV量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0x11);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_250MV, zeroVoltage);
-    /* 20mV档位,正负100mV量程 */
-    zeroVoltage = m_usbInterface->usbCtrlTrans(0x90, 0xa1);
-    m_mapChBZeroVoltage.insert(OscVoltageRange::CR_100MV, zeroVoltage);
-}
-
-/* 打印出零电压值 */
-void OscilloscopeData::printZeroVoltage(OscChannel channel)
-{
-    if(channel == OscChannel::CH_A)
-    {
-        for(auto it = m_mapChAZeroVoltage.begin(); it != m_mapChAZeroVoltage.end(); ++it)
-        {
-            SPDLOG_LOGGER_INFO(m_logger, "通道A {} 量程下的零电压值为: {}", static_cast<int>(it.key()), it.value());
-        }
-    }
-    else if(channel == OscChannel::CH_B)
-    {
-        for(auto it = m_mapChBZeroVoltage.begin(); it != m_mapChBZeroVoltage.end(); ++it)
-        {
-            SPDLOG_LOGGER_INFO(m_logger, "通道B {} 量程下的零电压值为: {}", static_cast<int>(it.key()), it.value());
-        }
-    }
-    else
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "通道设置错误!");
-        return;
-    }
-}
-
-/* 获取不同档位下电压校准系数 */
-void OscilloscopeData::getVoltageCalibration()
-{
-    if (m_usbInterface == nullptr)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "USBInterface指针为空!");
-        return;
-    }
-    /* 获取通道A电压校准系数 */
-    unsigned char voltageCalibration = 0;
-    /* 2V档位,正负8V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0xc2);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_8V, voltageCalibration);
-    /* 1V档位,正负5V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x03);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_5V, voltageCalibration);
-    /* 500mV档位,正负2.5V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x08);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_2V5, voltageCalibration);
-    /* 200mV档位,正负1V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x06);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_1V, voltageCalibration);
-    /* 100mV档位,正负500mV量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x09);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_500MV, voltageCalibration);
-    /* 50mV档位,正负250mV量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x0a);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_250MV, voltageCalibration);
-    /* 20mV档位,正负100mV量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x2a);
-    m_mapChAVoltageAmplitudeRatio.insert(OscVoltageRange::CR_100MV, voltageCalibration);
-
-    /* 获取通道B电压校准系数 */
-    /* 2V档位,正负8V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0xd2);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_8V, voltageCalibration);
-    /* 1V档位,正负5V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x04);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_5V, voltageCalibration);
-    /* 500mV档位,正负2.5V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x0b);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_2V5, voltageCalibration);
-    /* 200mV档位,正负1V量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x07);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_1V, voltageCalibration);
-    /* 100mV档位,正负500mV量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x0c);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_500MV, voltageCalibration);
-    /* 50mV档位,正负250mV量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x0d);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_250MV, voltageCalibration);
-    /* 20mV档位,正负100mV量程 */
-    voltageCalibration = m_usbInterface->usbCtrlTrans(0x90, 0x2d);
-    m_mapChBVoltageAmplitudeRatio.insert(OscVoltageRange::CR_100MV, voltageCalibration);
-
-}
-
-/* 打印出电压校准系数 */
-void OscilloscopeData::printVoltageCalibration(OscChannel channel)
-{
-    if(channel == OscChannel::CH_A)
-    {
-        for(auto it = m_mapChAVoltageAmplitudeRatio.begin(); it != m_mapChAVoltageAmplitudeRatio.end(); ++it)
-        {
-            SPDLOG_LOGGER_INFO(m_logger, "通道A {} 量程下的电压校准系数为: {}", static_cast<int>(it.key()), it.value());
-        }
-    }
-    else if(channel == OscChannel::CH_B)
-    {
-        for(auto it = m_mapChBVoltageAmplitudeRatio.begin(); it != m_mapChBVoltageAmplitudeRatio.end(); ++it)
-        {
-            SPDLOG_LOGGER_INFO(m_logger, "通道B {} 量程下的电压校准系数为: {}", static_cast<int>(it.key()), it.value());
-        }
-    }
-    else
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "通道设置错误!");
-        return;
-    }
-}
-
-/**
- * @brief 采集数据,这个是子线程 
- * 
- */
-void OscilloscopeData::threadCaptureData()
-{
-    SPDLOG_LOGGER_INFO(m_logger, "开始采集数据线程");
-    m_isRunCapture = true;
-    // unsigned char* buffer = nullptr;
-    while(m_runCapture)
-    {
-        // SPDLOG_LOGGER_DEBUG(m_logger, "开始采集数据");
-        /* 开始采集数据 */
-        m_usbInterface->usbCtrlTransSimple(0x33);
-        /* 清空数据缓冲区 */
-        for(uint32_t i = 0; i < BUFFER_SIZE; i++)
-        {
-            m_buffer[i] = 0;
-        }
-        /* 查询数据是否采集完成(应该是填充满128KB的SRAM)
-         * 注意,这里是十进制33,不是0x33 */
-        while(m_usbInterface->usbCtrlTransSimple(0x50) != 33)
-        {
-            std::this_thread::sleep_for(std::chrono::microseconds(10));
-        }
-        // SPDLOG_LOGGER_DEBUG(m_logger, "硬件缓冲区已满");
-        /* 将数据从示波器的SRAM中拷贝到电脑内存中,1次传输完成,设置超时时间1ms */
-        m_usbInterface->readBulkData(BUFFER_SIZE, 1, 100, m_devBuffer);
-        /* 等待传输完成 */
-        auto ret = m_usbInterface->eventCheck(100);
-        if(ret == 0x555)
-        {
-            SPDLOG_LOGGER_ERROR(m_logger, "数据传输超时!");
-            // continue;
-        }
-        // SPDLOG_LOGGER_DEBUG(m_logger, "数据通过USB传输完成");
-        /* 取出数据 */
-        // buffer = m_ringQueue.back();
-        m_mutexCaptureData.lock();
-        std::memcpy(m_buffer, m_devBuffer, BUFFER_SIZE);
-        m_isCaptureData = true;
-        m_mutexCaptureData.unlock();
-        /* 清空缓冲区 */
-        m_usbInterface->resetPipe();
-        // SPDLOG_LOGGER_DEBUG(m_logger, "count: {}", count++);
-
-    }
-    m_isRunCapture = false;
-    SPDLOG_LOGGER_INFO(m_logger, "采集数据线程结束");
-}
-
-/* 处理数据线程 */
-void OscilloscopeData::threadProcessData()
-{
-    SPDLOG_LOGGER_INFO(m_logger, "开始处理数据线程");
-    while(m_runCapture)
-    {
-        if(m_isCaptureData.load())
-        {
-            m_mutexCaptureData.lock();
-            /* 分离通道AB的数据 */
-            for(uint32_t i = 0; i < BUFFER_SIZE / 2; i++)
-            {
-                m_bufferChnA[i] = m_buffer[i * 2];
-                // m_bufferChnB[i] = m_buffer[i * 2 + 1];
-            }
-            m_isCaptureData = false;
-            m_mutexCaptureData.unlock();
-            /* 处理数据 */
-            // SPDLOG_LOGGER_DEBUG(m_logger, "开始处理数据,通道A数据: {}, 通道B数据: {}", m_bufferChnA[32000], m_bufferChnB[32000]);
-            /* 矫正零电压值 */
-            for(uint32_t i = 0; i < BUFFER_SIZE / 2; i++)
-            {
-                m_bufferChnA[i] = m_bufferChnA[i] + m_diffVoltageA;
-                // m_bufferChnB[i] = m_bufferChnB[i] + m_diffVoltageB;
-            }
-        }
-        /* 打印1000个数据 */
-        // for(uint32_t i = 0; i < BUFFER_SIZE/2; i++)
-        // {
-        //     if((m_bufferChnA[i] == 128) && (m_bufferChnB[i] == 128))
-        //         continue;
-        //     SPDLOG_LOGGER_DEBUG(m_logger, "A: {}, B: {}", m_bufferChnA[i], m_bufferChnB[i]);
-        // }
-        // SPDLOG_LOGGER_DEBUG(m_logger, "输出完成");
-
-        /* 对零电平进行矫正 */
-
-        /* 处理眼图数据 */
-        parseEyeMapData(m_bufferChnA, BUFFER_SIZE / 2);
-        std::this_thread::sleep_for(std::chrono::microseconds(10));
-    }
-    SPDLOG_LOGGER_INFO(m_logger, "处理数据线程结束");
-}
-
-/* 根据采样点数添加颜色 */
-void OscilloscopeData::threadAddColorBySample()
-{
-    SPDLOG_LOGGER_INFO(m_logger, "开始添加颜色线程");
-    while(m_runCapture)
-    {
-        g_eyeMapMatrix.mutexEyeData.lock();
-        g_eyeMapMatrix.addColorBySample();
-        g_eyeMapMatrix.mutexEyeData.unlock();
-        // SPDLOG_LOGGER_DEBUG(m_logger, "添加颜色完成");
-        /* 延时一下,让别的线程拿到锁 */
-        std::this_thread::sleep_for(std::chrono::microseconds(10));
-    }
-    SPDLOG_LOGGER_INFO(m_logger, "添加颜色线程结束");
-}
-
-/** 
- * @brief 解析数据,眼图需要的数据,从C#代码中移植过来 
- *        1、采样率为100MHz的时候,采样点间隔时间是10ns
- *          x轴时间是1000分度,当x轴整体时间是10us的时候,采样点和分辨率一一对应
- *          x轴时间大于10us,采样点比分辨率高,无需做什么操作
- *          x轴时间小于10us,采样点数量会小于1000,那么绘制的矩形小点间隔会比较长,这时候就需要进行插帧
- *        2、屏幕中显示多少波形和波形的频率及时间屏幕可以现实的时间长度有关,波形的频率未知,所以这里只能通过调整时间长度来调整波形
- *          在屏幕中显示的数目
- *        3、当时间长度变小,小到整个屏幕的采样点数目不足1000的时候,就需要进行插值,插值到1000附近
- * 
- * @param buffer 数据缓冲区 
- * @param size 缓冲区大小,单位字节 
- */ 
-void OscilloscopeData::parseEyeMapData(unsigned char* buffer, unsigned int size)
-{
-    int bufferSize = size;
-    uint8_t* array = buffer;
-
-    uint8_t vaMax = 128;
-    uint8_t vaMin = 128;
-    uint8_t tmp = 128;
-
-    /* 数据预处理,找出最大值和最小值 */
-    for (int i = 0; i < bufferSize; i++)
-    {
-        /* 取出这组数据的最大值和最小值 */
-        tmp = array[i];
-        if (tmp < vaMin)
-        {
-            vaMin = tmp;
-        }
-        if (tmp > vaMax)
-        {
-            vaMax = tmp;
-        }
-    }
-
-    /* 取绝对值,小于15丢弃,丢弃幅度小于15的数据,这部分可能不是触发的数据 */
-    int numAmp = std::abs(vaMax - vaMin);
-    if (numAmp <= 15)
-    {
-        return;
-    }
-    /* 计算最大值和最小值的中间数 */
-    uint8_t vaMid = (vaMax + vaMin) / 2;
-
-    /* ======================================================================== */
-    /* 将采样点添加bool值,如果时间很短,就进行插值,每个采样点之间插入30个值 */
-    /* 时间尺度,OscCurrentTimeScale = 100,num7 = 1.0,100MHz下每个采样点间距10ns */
-    // double num7 = OscParams.dataNumPerPixar * OscParams.OscCurrentTimeScale / 100.0;
-    // /* num7 * OscOneGridTime是一个时间格子中采样点的个数 */
-    // long oneGridTime = num7 * OscParams.OscOneGridTime;
-    // if (oneGridTime % 2 != 0L)
-    // {
-    //     oneGridTime++;
-    // }
-
-    /* 采样率为100MHz的时候,采样点间隔时间是10ns
-     * x轴时间是1000分度,当x轴整体时间是10us的时候,采样点和分辨率一一对应
-     * x轴时间大于10us,采样点比分辨率高,无需做什么操作
-     * x轴时间小于10us,采样点数量会小于1000,那么绘制的矩形小点间隔会比较长,这时候就需要进行插帧 */
-    /* 一个时间格子的采样率个数 */
-    int oneGridSa = OscParams.oneGridTime / OscParams.SampleIntervalTime;       /* 当前一个格子中采样点的数目 */
-    int saTotal = oneGridSa * 10;       /* 一个时间格子中采样点的总数 */
-    bool isNeedFrameInsertion = ( saTotal < OscParams.eyeMapWidth ) ? true : false;
-
-    int num9 = (int)((double)oneGridSa * 0.25);       /* 1/4个时间格子长度 */
-    /* 记录buffer的值,并添加bool */
-    std::vector<EyeDataT> vecData;
-    int numMulti = 0;    /* 倍率,可能是1可能是30 */
-    if (isNeedFrameInsertion == false)
-    {
-        /* 将数据放入到list中,带有bool标志位,全部启用 */
-        for (int i = 0; i < bufferSize; i++)
-        {
-            vecData.push_back(EyeDataT(true, array[i]));
-        }
-        numMulti = 1;
-    }
-    else
-    {
-        /* 缩放系数小于1.0,下面会进行插值 */
-        int numTmp = bufferSize - 1;
-        float num11 = 0.0;
-
-        uint8_t b2 = 0;
-        uint8_t b3 = 0;
-        uint8_t b = 0;
-
-        /* 进行插值,每个采样点之间插值根据实际的采样点来计算,插值后的采样点个数比1000略大 */
-        int numMulti2 = 0;
-        double numMulti1 = 1000.0 / saTotal;
-        if(numMulti1 > 1.0 && numMulti1 < 2.0)
-        {
-            numMulti2 = 1;
-        }
-        else if(numMulti1 > 2.0 && numMulti1 < 3.0)
-        {
-            numMulti2 = 2;
-        }
-        else if(numMulti1 > 3.0)
-        {
-            numMulti2 = std::round(numMulti1);
-        }
-        for(int i = 0; i < numTmp; i++)
-        {
-            b2 = array[i];
-            b3 = array[i + 1];
-            num11 = (float)(b3 - b2) / numMulti2;
-            vecData.push_back(EyeDataT(true, b2));
-            for(int j = 0; j < numMulti2; j++)
-            {
-                b = std::round((num11 * (float)j) + (int)b2);
-                vecData.push_back(EyeDataT(true, b));
-            }
-            vecData.push_back(EyeDataT(true, b3));
-        }
-
-        numMulti = numMulti2;
-    }
-    if (vecData.size() <= 0)
-    {
-        return;
-    }
-    num9 *= numMulti;          /* 1/4个时间格子长度,乘以倍数 */
-    /* 这里决定着时间的缩放关系,saTotal是整个显示区域的采样点个数 */
-    long oneJumpSa = saTotal * numMulti;
-    // long oneJumpSa = 1000;
-    /* ======================================================================== */
-    /* 寻找波形,找到上升沿和下降沿 */
-    /* 存储下标 */
-    std::vector<int> listSub;
-    size_t numDataSize = vecData.size() - num9;
-    bool flag3 = true;
-    /* 找到数组中的上升沿和下降沿,并记录其坐标
-     * 这里寻找上升沿和下降沿是检测的中间值,是每个跳变沿的中部
-     * 中间值理论上是零值 */
-    uint8_t vaPre = 0;
-    // uint8_t va = 0;
-    uint8_t vaNext = 0;
-    for (int i = 10; i < numDataSize; i++)
-    {
-        /* 取出相邻的三个值 */
-        vaPre = vecData[i - 1].value;
-        // va = vecData[i].value;
-        vaNext = vecData[i + 1].value;
-        if (flag3)
-        {
-            /* 上升沿,就是中间值 */
-            if (vaPre <= vaMid && vaNext > vaMid)
-            {
-                listSub.push_back(i);		/* 记录下标 */
-                flag3 = !flag3;			    /* 不再检测上升沿,检测下降沿 */
-            }
-        }
-        /* 下降沿 */
-        else if (vaPre >= vaMid && vaNext < vaMid)
-        {
-            listSub.push_back(i);
-            flag3 = !flag3;
-        }
-        /* 采集到600个上升沿和下降沿 */
-        if (listSub.size() >= 600)
-        {
-            break;
-        }
-    }
-    if (listSub.size() <= 0)
-    {
-        return;
-    }
-    /* ======================================================================== */
-    /* 这里应该是根据跳变沿的中间值,取出完整的跳变沿
-     * 创建一个二维数组,每一行就是一个跳变沿 */
-    std::vector<std::vector<EyeDataT>> vec2DEyeData;
-    int jumpStart = 0;      /* 跳变沿起点 */
-    size_t jumpEnd = 0;        /* 跳变沿终点 */
-    int num17 = 0;
-    size_t numSubSize = listSub.size();                 /* 跳变沿下标的个数 */
-    int oneThirdSa = (int)(oneJumpSa / 3);           /* 一个时间格子中三分之一的采样点个数 */
-    int numSub1 = 0;
-    int numSub2 = 0;
-    for (int i = 0; i < numSubSize; i++)
-    {
-        int j = 0;
-        /* 这一个数组就是一个跳变沿,num12是一个跳变沿所有的采样点的个数 */
-        std::vector<EyeDataT> vecDataTmp(oneJumpSa, EyeDataT(false, 0));
-
-        numSub1 = listSub[i];               /* 取出下标值 */
-        numSub2 = numSub1 - oneThirdSa;     /* 下标往后倒退1/3个时间格子的采样点数,当作起点 */
-        /* 判断是否小于0,这里是起点 */
-        jumpStart = numSub2;
-        if (jumpStart <= 0)
-        {
-            jumpStart = 0;
-        }
-        /* 终点往后2/3个时间格子的采样点数,当作终点 */
-        jumpEnd = numSub1 + oneThirdSa * 2;
-        if (jumpEnd >= vecData.size())
-        {
-            jumpEnd = vecData.size() - 1;
-        }
-        /* 这里为了去掉jumpStart前面的值,让vecDataTmp从0开始计数 */
-        num17 = 0;
-        if (numSub2 < 0)
-        {
-            num17 = std::abs(numSub2);
-        }
-        if (numSub2 > 0)
-        {
-            num17 = -numSub2;
-        }
-        /* num14是起点,num15是终点,num17应该是个负值,num17+j从0开始计数 */
-        for (j = jumpStart; j < jumpEnd; j++)
-        {
-            vecDataTmp[num17 + j].isEyeData = vecData[j].isEyeData;
-            vecDataTmp[num17 + j].value = vecData[j].value;
-        }
-        // for(j = 0; j < oneGridTime2; j++)
-        // {
-        //     vecDataTmp[j].isEyeData = vecData[jumpStart + j].isEyeData;
-        //     vecDataTmp[j].value = vecData[jumpStart + j].value;
-        // }
-        vec2DEyeData.push_back(vecDataTmp);
-    }
-    // listSub.clear();
-    // vecData.clear();
-    if (vec2DEyeData.size() <= 0)
-    {
-        return;
-    }
-    /* ======================================================================== */
-    int num18 = 0;
-    float num20 = 0.0;
-    /* 将数据拷贝到OscData的Matrix中 */
-    size_t numTmp = 0;
-    int ValTmp = 0;
-    /* 将跳变沿数据放入到全局变量中,并根据坐标进行排列
-     * x轴是这个跳变沿根据时间平分1000份
-     * y轴是这个值 */
-    g_eyeDataMatrix.mutexEyeData.lock();
-    for (int i = 0; i < vec2DEyeData.size(); i++)
-    {
-        /* 取出一个跳变沿,将其分布在整个 1000 * 256像素的矩阵中 */
-        std::vector<EyeDataT>& vecTmp = vec2DEyeData[i];
-        numTmp = vecTmp.size();
-        num20 = numTmp / 1000.f;    /* x轴方向1000分 */
-        for (int i = 0; i < numTmp; i++)
-        {
-            if (vecTmp[i].isEyeData)
-            {
-                ValTmp = vecTmp[i].value;
-                num18 = (int)((float)i / num20);
-                /* 将数据添加到眼图矩阵中 */
-                g_eyeDataMatrix.addData(num18, ValTmp);
-            }
-        }
-    }
-    
-
-    g_eyeDataMatrix.eyeStatisticalWeight();
-    g_eyeDataMatrix.eyeLessenTheBurden();
-    vec2DEyeData.clear();
-    auto eyeData = g_eyeDataMatrix.eyeZoomOut();
-    g_eyeDataMatrix.mutexEyeData.unlock();
-
-    g_eyeMapMatrix.mutexEyeData.lock();
-    g_eyeMapMatrix.copyDataMatrix(*eyeData);
-    g_eyeMapMatrix.mutexEyeData.unlock();
-}
-
-
-/* 设置零电压值和电压校准系数 */
-void OscilloscopeData::setZeroVoltageAndCalibration(OscChannel chn, OscVoltageRange range)
-{
-
-    if(chn == OscChannel::CH_A)
-    {
-        /* 电压幅值比 */
-        uint8_t altitudeByteA = 0;
-        m_zeroVoltageA = m_mapChAZeroVoltage.value(range);
-        altitudeByteA = m_mapChAVoltageAmplitudeRatio.value(range);
-        m_diffVoltageA = m_zeroVoltageA - 128;
-        
-
-
-        if(range == OscVoltageRange::CR_100MV)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 0.1 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_250MV)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 0.25 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_500MV)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 0.5 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_1V)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 1.0 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_2V5)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 2.5 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_5V)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 5.0 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_8V)
-        {
-            m_voltageCalibrationA = (altitudeByteA * 2) / 255.0;
-            m_rangeRatioA = 8.0 / 255.0;
-        }
-    }
-    else if(chn == OscChannel::CH_B)
-    {
-        /* 电压幅值比 */
-        uint8_t altitudeByteB = 0;      
-        m_zeroVoltageB = m_mapChBZeroVoltage.value(range);
-        altitudeByteB = m_mapChBVoltageAmplitudeRatio.value(range);
-        m_diffVoltageB = m_zeroVoltageB - 128;
-
-        if(range == OscVoltageRange::CR_100MV)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 0.1 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_250MV)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 0.25 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_500MV)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 0.5 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_1V)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 1.0 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_2V5)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 2.5 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_5V)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 5.0 / 255.0;
-        }
-        else if(range == OscVoltageRange::CR_8V)
-        {
-            m_voltageCalibrationB = (altitudeByteB * 2) / 255.0;
-            m_rangeRatioB = 8.0 / 255.0;
-        }
-    }
-
-    
-}
-
-
-/* 校准电压 */
-double OscilloscopeData::calibrationVoltageA(uint8_t& data)
-{
-    return m_voltageCalibrationA * m_rangeRatioA * (data - m_zeroVoltageA);
-}
-
-double OscilloscopeData::calibrationVoltageB(uint8_t& data)
-{
-    return m_voltageCalibrationB * m_rangeRatioB * (data - m_zeroVoltageB);
-}
-

+ 0 - 132
EyeMap/OscData/OscData.h_

@@ -1,132 +0,0 @@
-#ifndef _OscilloscopeData_H_
-#define _OscilloscopeData_H_
-
-#include <QObject>
-#include <QMap>
-
-#include "USBInterFace.h"
-#include "spdlog/spdlog.h"
-#include "GlobalInfo.h"
-#include "OscDataInfo.h"
-#include "RingQueue/RingQueue.hpp"
-
-#define OscData OscilloscopeData::getInstance()
-
-class OscilloscopeData : public QObject
-{
-    Q_OBJECT
-
-const uint32_t BUFFER_SIZE = 1024 * 128 ;    /* 缓冲区大小,OSCA02的缓冲区应该是128KB的SRAM */
-
-private:
-    OscilloscopeData();
-    OscilloscopeData(const OscilloscopeData&) = delete;
-    OscilloscopeData& operator=(const OscilloscopeData&) = delete;
-public:
-    ~OscilloscopeData();
-
-    static OscilloscopeData& getInstance()
-    {
-        static OscilloscopeData instance;
-        return instance;
-    }
-    /* 初始化示波器 */
-    void initOsc();
-    /* 打开示波器 */
-    bool openOSC();
-    /* 关闭示波器 */
-    void closeOSC();
-    /* 示波器是否打开 */
-    bool isOpen() { return m_isOpen; }
-    /* 开始采集数据 */
-    bool startCapture();
-    /* 停止采集数据 */
-    void stopCapture();
-
-    /***** 设置示波器的功能命令 *****/
-    /* 设置示波器的采样率 */
-    void setSampleRate(OscSampleRate rate);
-    /* 将示波器两个通道合并为一个通道 */
-    void setChannelMerge(bool merge);
-    /* 设置通道A输入量程 */
-    void setChannelARange(OscVoltageRange range);
-    /* 设置通道B输入量程 */
-    void setChannelBRange(OscVoltageRange range);
-    /* 设置通道耦合方式 */
-    void setChannelCoupling(OscChannel channel, OscChannelCoupling coupling);
-    /* 开启或关闭通道A触发 */
-    void setChannelATrigger(bool enable);
-    /* 开启外触发 */
-    void setExternalTrigger(bool enable);
-    /* 设置触发方式 */
-    void setTriggerMode(OscTriggerMode mode);
-    /* 设置触发电平 */
-    void setTriggerLevel(unsigned char level);
-    /* 设置触发灵敏度 */
-    void setTriggerSensitivity(OscTriggerSensitivity sensitivity);
-    /* 设置触发在缓冲区的哪个位置 */
-    void setTriggerPosition(unsigned char lowByte, unsigned char highByte);
-
-    /* 获取示波器不同档位下的零电压值 */
-    void getZeroVoltage();
-    /* 打印出零电压值 */
-    void printZeroVoltage(OscChannel channel);
-
-    /* 获取不同档位下电压校准系数 */
-    void getVoltageCalibration();
-    /* 打印出电压校准系数 */
-    void printVoltageCalibration(OscChannel channel);
-
-// private:
-public:
-    /* 采集数据,这个是子线程 */
-    void threadCaptureData();
-    /* 处理数据线程 */
-    void threadProcessData();
-    /* 根据采样点数添加颜色 */
-    void threadAddColorBySample();
-
-    /* 解析数据,眼图需要的数据 */
-    void parseEyeMapData(unsigned char* buffer, unsigned int size);
-    /* 设置零电压值和电压校准系数 */
-    void setZeroVoltageAndCalibration(OscChannel chn, OscVoltageRange range);
-    /* 校准电压 */
-    inline double calibrationVoltageA(uint8_t& data);
-    inline double calibrationVoltageB(uint8_t& data);
-
-private:
-    std::shared_ptr<spdlog::logger> m_logger = nullptr;
-    std::shared_ptr<USBInterface> m_usbInterface = nullptr;
-    std::atomic_bool m_isOpen = false;                      /* 示波器是否打开 */
-    std::atomic_bool m_runCapture = false;                  /* 采集数据的线程标志 */
-    std::atomic_bool m_isRunCapture = false;                /* 采集数据的线程运行标志,这个标志位作为线程运行的标志 */
-    std::atomic_bool m_isCaptureData = false;               /* 是否采集到数据 */
-    std::mutex m_mutexCaptureData;                          /* 互斥锁,用于保护采集到的数据 */
-    unsigned char* m_devBuffer = nullptr;                   /* 设备缓冲区指针,拷贝数据用的 */
-    unsigned char* m_buffer = nullptr;                      /* 缓冲区指针,用于存储拷贝出来的数据 */
-    unsigned char* m_bufferChnA = nullptr;                  /* 通道A的缓冲区指针 */
-    unsigned char* m_bufferChnB = nullptr;                  /* 通道B的缓冲区指针 */
-    RingQueue<unsigned char*> m_ringQueue;                  /* 环形队列,用于存储示波器采集到的数据 */
-
-    unsigned char m_ctrlByte0 = 0;                          /* 控制字节0 */
-    unsigned char m_ctrlByte1 = 0;                          /* 控制字节1 */
-
-    QMap<OscVoltageRange, unsigned char> m_mapChAZeroVoltage;   /* 通道A的零电压值 */
-    QMap<OscVoltageRange, unsigned char> m_mapChBZeroVoltage;   /* 通道B的零电压值 */
-    QMap<OscVoltageRange, unsigned char> m_mapChAVoltageAmplitudeRatio;     /* 通道A的电压校准系数 */
-    QMap<OscVoltageRange, unsigned char> m_mapChBVoltageAmplitudeRatio;     /* 通道B的电压校准系数 */
-
-    unsigned char m_zeroVoltageA = 0;                       /* 通道A零电压值 */
-    unsigned char m_zeroVoltageB = 0;                       /* 通道B零电压值 */
-    char m_diffVoltageA = 0;                                /* 通道A零电压差值 */
-    char m_diffVoltageB = 0;                                /* 通道B零电压差值 */
-    double m_voltageCalibrationA = 0;                       /* 通道A电压校准系数 */
-    double m_voltageCalibrationB = 0;                       /* 通道B电压校准系数 */
-    double m_rangeRatioA = 0.0;                             /* 通道A量程比例 */
-    double m_rangeRatioB = 0.0;                             /* 通道B量程比例 */
-};
-
-
-
-
-#endif /* _OscilloscopeData_H_ */

+ 1 - 1
EyeMap/ParameterConfig/OneParamItem/OneParamItem.qss

@@ -37,7 +37,7 @@ QComboBox::down-arrow
 {
 	height: 16px;
 	width: 16px;
-	image: url(:/Standard_ICON/DownArrow.png);
+	image: url(:/image/Resource/image/DownArrow.png);
 }
 QComboBox::drop-down
 {

+ 32 - 18
EyeMap/ParameterConfig/paramconfig.cpp

@@ -43,15 +43,16 @@ ParamConfig::ParamConfig(QWidget *parent) :
 
     /* 添加默认的时间刻度选项 */
     // ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_20NS), static_cast<int>(OscTimeGridValue::TGV_20NS));
-    // ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_50NS), static_cast<int>(OscTimeGridValue::TGV_50NS));
+    ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_50NS), static_cast<int>(OscTimeGridValue::TGV_50NS));
     ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_100NS), static_cast<int>(OscTimeGridValue::TGV_100NS));
     ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_200NS), static_cast<int>(OscTimeGridValue::TGV_200NS));
     ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_500NS), static_cast<int>(OscTimeGridValue::TGV_500NS));
     ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_1US), static_cast<int>(OscTimeGridValue::TGV_1US));
     ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_2US), static_cast<int>(OscTimeGridValue::TGV_2US));
     ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_5US), static_cast<int>(OscTimeGridValue::TGV_5US));
+    ui->comboBox_time->addItem(getTimeGridValueStr(OscTimeGridValue::TGV_10US), static_cast<int>(OscTimeGridValue::TGV_10US));
     /* 设置默认的时间值 */
-    ui->comboBox_time->setCurrentIndex(1);
+    ui->comboBox_time->setCurrentIndex(2);
 
     /* 连接信号和槽 */
     connect(ui->pBtn_close, &QPushButton::clicked, this, &ParamConfig::do_pBtn_close);
@@ -115,25 +116,38 @@ bool ParamConfig::eventFilter(QObject *watched, QEvent *event)
     return QWidget::eventFilter(watched, event);
 }
 
+/* 鼠标点击事件 */
+void ParamConfig::mousePressEvent(QMouseEvent *event)
+{
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标移动事件 */
+void ParamConfig::mouseMoveEvent(QMouseEvent *event)
+{
+    auto point = ui->widget_top->mapToGlobal(QPoint(0, 0));
+    QRect rect(point, ui->widget_top->size());
+    if(!rect.contains(m_lastPos))
+    {
+        event->accept();
+        return;
+    }
 
-// /* 初始化表格 */
-// void ParamConfig::initTable()
-// {
-//     /* 初始化tableView */
-//     m_tableView = new QTableView(ui->widget_container);
-//     m_tableView->setGeometry(0, 0, ui->widget_container->width(), ui->widget_container->height());
-//     m_tableView->setStyleSheet("background-color: rgba(0, 0, 0, 0.8);");
+    int dx = event->globalX() - m_lastPos.x();
+    int dy = event->globalY() - m_lastPos.y();
+    this->move(this->x() + dx, this->y() + dy);
+    m_lastPos = event->globalPos();
+    event->accept();
+}
 
-//     /* 初始化model,8行4列 */
-//     m_model = new QStandardItemModel(8, 4, this);
-//     m_tableView->setModel(m_model);
-// }
+/* 鼠标释放事件 */
+void ParamConfig::mouseReleaseEvent(QMouseEvent *event)
+{
+    event->accept();
+}
 
-// /* 初始化数据 */
-// void ParamConfig::initData()
-// {
 
-// }
 
 
 /* 布局item */
@@ -142,7 +156,7 @@ void ParamConfig::layoutItem()
     for(auto &item : m_listItem)
     {
         /* 计算位置,需要加上每个item之间的24间距 */
-        int dy = item->height() * item->eyeMapInfo.num + (item->eyeMapInfo.num - 1) * 24;
+        int dy = item->height() * ( item->eyeMapInfo.num - 1) + (item->eyeMapInfo.num - 1) * 24;
         item->move(0, dy);
         item->show();
     }

+ 7 - 4
EyeMap/ParameterConfig/paramconfig.h

@@ -28,12 +28,14 @@ public:
 protected:
     /* 事件过滤器 */
     bool eventFilter(QObject *watched, QEvent *event) override;
+    /* 鼠标点击事件 */
+    void mousePressEvent(QMouseEvent *event) override;
+    /* 鼠标移动事件 */
+    void mouseMoveEvent(QMouseEvent *event) override;
+    /* 鼠标释放事件 */
+    void mouseReleaseEvent(QMouseEvent *event) override;
 
 private:
-    // /* 初始化表格 */
-    // void initTable();
-    // /* 初始化数据 */
-    // void initData();
 
     /* 布局item */
     void layoutItem();
@@ -57,6 +59,7 @@ public:
 private:
     Ui::ParamConfig *ui;
     std::shared_ptr<spdlog::logger> m_logger = nullptr;
+    QPoint m_lastPos;
 
     QList<OneParamItem*> m_listItem;
 

BIN
EyeMap/Resource/icon/EyePattern_Logo.ico


BIN
EyeMap/Resource/icon/EyePattern_Logo.png


+ 17 - 1
EyeMap/SettingNum/OneItem/OneSettingItem.qss

@@ -32,12 +32,18 @@ QComboBox:hover, QComboBox:on
 {
 	border: 1px solid #438EFF;
 }
+
+QComboBox[Warn=true]
+{
+	border: 1px solid #D21F21;
+}
+
 /*下拉箭头样式*/
 QComboBox::down-arrow
 {
 	height: 16px;
 	width: 16px;
-	image: url(:/Standard_ICON/DownArrow.png);
+	image: url(:/image/Resource/image/DownArrow.png);
 }
 QComboBox::drop-down
 {
@@ -93,6 +99,16 @@ QLineEdit
 	font-style: normal;
 }
 
+QLineEdit:hover
+{
+	border: 1px solid #438EFF;
+}
+
+QLineEdit[Warn=true]
+{
+	border: 1px solid #D21F21;
+}
+
 /*****************  背景色块 ****************/
 QWidget#widget_bg
 {

+ 38 - 0
EyeMap/SettingNum/OneItem/onesettingitem.cpp

@@ -5,6 +5,7 @@
 #include <QFile>
 #include <QEvent>
 #include "colordialogapi.h"
+#include "ColorDelegate.h"
 
 OneSettingItem::OneSettingItem(QWidget *parent) :
     QWidget(parent),
@@ -31,6 +32,8 @@ OneSettingItem::OneSettingItem(QWidget *parent) :
     }
     /* 禁止comboBox滚轮滚动 */
     ui->comboBox->installEventFilter(this);
+    /* 限制自定义名称的字数 */
+    ui->lineEdit->setMaxLength(10);
 
     /* 链接信号和槽 */
     connect(ui->pBtn_background, &QPushButton::clicked, this, &OneSettingItem::do_pBtn_background);
@@ -64,6 +67,7 @@ OneEyeMapInfo& OneSettingItem::getEyeMapInfo()
     /* 更新所有的信息并返回 */
     eyeMapInfo.title = ui->lineEdit->text();
     eyeMapInfo.channelInfo = getCurrentChannel();
+    // SPDLOG_LOGGER_DEBUG(m_logger, "当前通道号: {}", eyeMapInfo.channelInfo.channelName.toStdString());
     return eyeMapInfo;
 }
 
@@ -88,6 +92,8 @@ void OneSettingItem::setChannelList(const QList<OneChannelInfo>& list)
     {
         ui->comboBox->addItem(it.channelName, static_cast<int>(it.channel));
     }
+    /* 设置自定义委托 */
+    ui->comboBox->setItemDelegate(new ColorDelegate(ui->comboBox));
     /* 设置当前选项 */
     ui->comboBox->setCurrentText(eyeMapInfo.channelInfo.channelName);
     // SPDLOG_LOGGER_DEBUG(m_logger, "---当前通道号: {}", eyeMapInfo.channelInfo.channelName.toStdString());
@@ -97,6 +103,8 @@ void OneSettingItem::setChannelList(const QList<OneChannelInfo>& list)
 void OneSettingItem::setCurrentChannel(const QString& channelName)
 {
     ui->comboBox->setCurrentText(channelName);
+    eyeMapInfo.channelInfo.channelName = channelName;
+    eyeMapInfo.channelInfo.channel = static_cast<OscChnNum>(ui->comboBox->currentData().toInt());
 }
 
 /* 获取当前通道号 */
@@ -108,6 +116,36 @@ OneChannelInfo OneSettingItem::getCurrentChannel()
     return info;
 }
 
+/* 设置自定义的通道名称栏报警 */
+void OneSettingItem::setChannelNameAlarm(bool isAlarm)
+{
+    if(isAlarm)
+    {
+        ui->lineEdit->setProperty("Warn", true);
+        ui->lineEdit->style()->unpolish(ui->lineEdit);
+        ui->lineEdit->style()->polish(ui->lineEdit);
+    }else {
+        ui->lineEdit->setProperty("Warn", false);
+        ui->lineEdit->style()->unpolish(ui->lineEdit);
+        ui->lineEdit->style()->polish(ui->lineEdit);
+    }
+}
+
+/* 设置通道选择栏报警 */
+void OneSettingItem::setChannelSelectAlarm(bool isAlarm)
+{
+    if(isAlarm)
+    {
+        ui->comboBox->setProperty("Warn", true);
+        ui->comboBox->style()->unpolish(ui->comboBox);
+        ui->comboBox->style()->polish(ui->comboBox);
+    }else {
+        ui->comboBox->setProperty("Warn", false);
+        ui->comboBox->style()->unpolish(ui->comboBox);
+        ui->comboBox->style()->polish(ui->comboBox);
+    }
+}
+
 /* 滚轮事件,禁止选择栏滚动 */
 // void OneSettingItem::wheelEvent(QWheelEvent *event)
 // {

+ 5 - 0
EyeMap/SettingNum/OneItem/onesettingitem.h

@@ -34,6 +34,11 @@ public:
     /* 获取当前通道号 */
     OneChannelInfo  getCurrentChannel();
 
+    /* 设置自定义的通道名称栏报警 */
+    void setChannelNameAlarm(bool isAlarm);
+    /* 设置通道选择栏报警 */
+    void setChannelSelectAlarm(bool isAlarm);
+
 signals:
     /* 选择了通道号信号 */
     void signal_select_channel(const OscChnNum channel, const QString& channelName);

+ 10 - 1
EyeMap/SettingNum/SettingNum.qss

@@ -48,7 +48,6 @@ QPushButton#pBtn_close:hover
 }
 
 /* 设置确定按钮 */
-
 QPushButton#pBtn_ok
 {
 	font-size:14px;
@@ -135,6 +134,16 @@ QLabel#label_x1, #label_x2
     font-style: normal;
 }
 
+QLabel#label_warn
+{
+    font-weight: 400;
+    font-size: 14px;
+    color: #D21F21;
+    line-height: 21px;
+    text-align: left;
+    font-style: normal;
+}
+
 /*****************  QComboBox下拉框 ****************/
 QComboBox
 {

+ 118 - 47
EyeMap/SettingNum/settingnum.cpp

@@ -9,6 +9,7 @@
 #include "onesettingitem.h"
 #include "oneshadow.h"
 #include "ListItem.h"
+#include "TipWidget.h"
 
 SettingNum::SettingNum(QDialog *parent) :
     QDialog(parent),
@@ -29,6 +30,7 @@ SettingNum::SettingNum(QDialog *parent) :
     /* 设置无边框和背景透明 */
     this->setWindowFlags(Qt::FramelessWindowHint);
     this->setAttribute(Qt::WA_TranslucentBackground);
+    ui->label_warn->hide();
     /* 加载QSS */
     QFile fileQss(":/qss/SettingNum/SettingNum.qss");
     if(fileQss.open(QFile::ReadOnly))
@@ -40,9 +42,7 @@ SettingNum::SettingNum(QDialog *parent) :
     {
         SPDLOG_LOGGER_ERROR(m_logger, "加载QSS文件失败");
     }
-    /* 设置阴影 */
-    m_shadow = new OneShadow(ui->widget->size(), 16);
-    ui->verticalLayout->setMargin(16);
+
 
     /* 设置QListWidget拖拽 */
     ui->listWidget->setDragDropMode(QAbstractItemView::InternalMove);
@@ -54,7 +54,7 @@ SettingNum::SettingNum(QDialog *parent) :
     // ui->listWidget->installEventFilter(this);
 
     /* 初始化变量 */
-    for(auto item : m_listItem)
+    for(auto& item : m_listItem)
     {
         item = nullptr;
     }
@@ -93,11 +93,7 @@ SettingNum::~SettingNum()
         delete item;
         item = nullptr;
     }
-    if(m_shadow != nullptr)
-    {
-        delete m_shadow;
-        m_shadow = nullptr;
-    }
+
     delete ui;
 }
 
@@ -113,13 +109,13 @@ void SettingNum::setRowAndColumn(int row, int column)
     ui->listWidget->clear();
     m_listItem.clear();
     
-    for(int i = 0; i < num; i++)
+    for(int i = 1; i <= num; i++)
     {
         OneSettingItem *item = new OneSettingItem(ui->listWidget);
-        item->setNum(i + 1);
+        item->setNum(i);
         connect(item, &OneSettingItem::signal_select_channel, this, &SettingNum::do_selectChannel);
         m_listItem.append(item);
-        /* 创建QListWidget的项和项高度 */
+        /* 创建QListWidget的项和项高度,根据编号是否显示,放置到ListWidget中 */
         QListWidgetItem *listWidgetItem = new QListWidgetItem(ui->listWidget);
         listWidgetItem->setSizeHint(QSize(0, 48));
         ui->listWidget->setItemWidget(listWidgetItem, item);
@@ -139,6 +135,7 @@ void SettingNum::setEveryEyeMapInfo(const QList<OneEyeMapInfo> &listInfo)
         {
             if(item->getNum() == info.num)
             {
+                // SPDLOG_LOGGER_DEBUG(m_logger, "序号:{}, 设置项信息: {}", info.num, info.channelInfo.channelName.toStdString());
                 item->setItemInfo(info);
                 break;
             }
@@ -173,35 +170,7 @@ bool SettingNum::eventFilter(QObject *watched, QEvent *event)
             return true;
         }
     }
-    // if(watched == ui->listWidget)
-    // {
-    //     SPDLOG_LOGGER_DEBUG(m_logger, "ui->listWidget事件");
-    //     if(event->type() == QEvent::DragEnter)
-    //     {
-    //         QDragEnterEvent *dragEnterEvent = static_cast<QDragEnterEvent*>(event);
-    //         dragEnterEvent->acceptProposedAction();
-    //         emit signal_dragComplete();
-    //         SPDLOG_LOGGER_DEBUG(m_logger, "拖拽进入");
-    //         return true;
-    //     }
-    //     else if(event->type() == QEvent::Drop)
-    //     {
-    //         QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
-    //         dropEvent->acceptProposedAction();
-    //         SPDLOG_LOGGER_DEBUG(m_logger, "拖拽完成");
-    //         return true;
-    //     }
-    //     else if (event->type() == QEvent::DragMove)
-    //     {
-    //         QDragMoveEvent *dragMoveEvent = static_cast<QDragMoveEvent*>(event);
-    //         dragMoveEvent->accept();
-    //         SPDLOG_LOGGER_DEBUG(m_logger, "拖拽移动");
-    //         return true;
-        
-    //     }else {
-    //         qDebug() << "其他事件:" << event->type();
-    //     }
-    // }
+
     return QWidget::eventFilter(watched, event);
 }
 
@@ -213,6 +182,37 @@ void SettingNum::showEvent(QShowEvent *event)
     emit signal_exec();
 }
 
+/* 鼠标点击事件 */
+void SettingNum::mousePressEvent(QMouseEvent *event)
+{
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标移动事件 */
+void SettingNum::mouseMoveEvent(QMouseEvent *event)
+{
+    auto point = ui->widget_top->mapToGlobal(QPoint(0, 0));
+    QRect rect(point, ui->widget_top->size());
+    if(!rect.contains(m_lastPos))
+    {
+        event->accept();
+        return;
+    }
+
+    int dx = event->globalX() - m_lastPos.x();
+    int dy = event->globalY() - m_lastPos.y();
+    this->move(this->x() + dx, this->y() + dy);
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标释放事件 */
+void SettingNum::mouseReleaseEvent(QMouseEvent *event)
+{
+    event->accept();
+}
+
 /* 关闭按钮槽函数 */
 void SettingNum::do_pBtn_close()
 {
@@ -222,13 +222,69 @@ void SettingNum::do_pBtn_close()
 /* 点击了OK按钮 */
 void SettingNum::do_pBtn_ok()
 {
+    /* 取消所有的报警 */
+    for(auto& it : m_listItem)
+    {
+        it->setChannelNameAlarm(false);
+        it->setChannelSelectAlarm(false);
+    }
+    ui->label_warn->hide();
+
+    /* 检查通道选择 */
+    bool isExit = false;
+    for(auto& it : m_listItem)
+    {
+        if(it->getCurrentChannel().channel == OscChnNum::Osc_None)
+        {
+            // ui->label_warn->setText("请选择示波器通道");
+            // ui->label_warn->show();
+            TipWidget::display(TipWidget::OPERATOR_FAIL, "请选择示波器通道", m_parent);
+            it->setChannelSelectAlarm(true);
+            isExit = true;
+        }
+    }
+    if(isExit)
+    {
+        return;
+    }
+    /* 检查自定义的通道名称是否存在,名字是否冲突 */
+    for(int i = 0; i < m_listItem.size(); i++)
+    {
+        /* 判断通道名称是否为空 */
+        if(m_listItem.at(i)->getEyeMapInfo().title.isEmpty())
+        {
+            m_listItem.at(i)->setChannelNameAlarm(true);
+            // ui->label_warn->setText("通道名称不能为空!");
+            // ui->label_warn->show();
+            TipWidget::display(TipWidget::OPERATOR_FAIL, "通道名称不能为空", m_parent);
+            return;
+        }
+        for(int j = i + 1; j < m_listItem.size(); j++)
+        {
+            /* 判断通道名称是否重复 */
+            if(m_listItem.at(i)->getEyeMapInfo().title == m_listItem.at(j)->getEyeMapInfo().title)
+            {
+                m_listItem.at(i)->setChannelNameAlarm(true);
+                m_listItem.at(j)->setChannelNameAlarm(true);
+                // ui->label_warn->setText("通道名称不能重复!");
+                // ui->label_warn->show();
+                TipWidget::display(TipWidget::OPERATOR_FAIL, "通道名称不能重复", m_parent);
+                return;
+            }
+        }
+    }
+
+
     isOk = true;
     m_row = ui->comboBox_rowNum->currentText().toInt();
     m_column = ui->comboBox_columnNum->currentText().toInt();
 
+    /* 先将所有的眼图模块的序号设置为0 */
+    GEyeMapInfo.clearAllNum();
     /* 更新全局信息 */
     for(auto &item : m_listItem)
     {
+        // SPDLOG_LOGGER_DEBUG(m_logger, "序号: {}, 通道号: {}", item->getNum(), item->getCurrentChannel().channelName.toStdString());
         GEyeMapInfo.updateSettingNum(item->getEyeMapInfo());
     }
 
@@ -249,7 +305,7 @@ void SettingNum::do_selectRowAndColumn(int index)
     m_column = ui->comboBox_columnNum->currentText().toInt();
     int num = m_row * m_column;
     // layoutItem(num);
-    addOrDelItem(num);
+    showOrHide(num);
 }
 
 /* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
@@ -276,6 +332,12 @@ void SettingNum::do_setItemNum()
 {
     // SPDLOG_LOGGER_DEBUG(m_logger, "重新设置序号");
     resetItemNum();
+    /* 打印listWidget和序号 */
+    for(int i = 0; i < ui->listWidget->count(); i++)
+    {
+        auto item = qobject_cast<OneSettingItem*>(ui->listWidget->itemWidget(ui->listWidget->item(i)));
+        SPDLOG_LOGGER_DEBUG(m_logger, "序号: {}, 通道: {}", item->getNum(), item->getCurrentChannel().channelName.toStdString());
+    }
 }
 
 
@@ -310,8 +372,8 @@ void SettingNum::resetItemNum()
     }
 }
 
-/* 添加或删除项 */
-void SettingNum::addOrDelItem(int num)
+/* 显示或隐藏选项 */
+void SettingNum::showOrHide(int num)
 {
     if(num > m_listItem.size())
     {
@@ -322,7 +384,7 @@ void SettingNum::addOrDelItem(int num)
             /* 设置可选通道列表 */
             item->setChannelList(m_listChannelInfo);
             /* 设置默认选项 */
-            item->setItemInfo(GEyeMapInfo.getInitEyeMapInfo(i + 1));
+            item->setItemInfo(GEyeMapInfo.getOneEyeMapInfo(i + 1));
             connect(item, &OneSettingItem::signal_select_channel, this, &SettingNum::do_selectChannel);
             m_listItem.append(item);
             /* 创建QListWidget的项和项高度 */
@@ -334,9 +396,18 @@ void SettingNum::addOrDelItem(int num)
     {
         for(int i = m_listItem.size() - 1; i >= num; i--)
         {
-            delete m_listItem.at(i);
-            m_listItem.removeAt(i);
             ui->listWidget->takeItem(i);
+            for(auto& it : m_listItem)
+            {
+                if(it->getNum() == i + 1)
+                {
+                    auto widget = it;
+                    m_listItem.removeOne(it);
+                    delete widget;
+                    break;
+                }
+            }
+
         }
     }
 }

+ 15 - 4
EyeMap/SettingNum/settingnum.h

@@ -29,6 +29,8 @@ public:
     void setChannelList(const QList<OneChannelInfo> &listChannelInfo);
     /* 刷新布局 */
     void refreshLayout();
+    /* 传入父指针 */
+    void setParentPtr(QWidget *parent) { m_parent = parent; }
 
 signals:
     /* 执行了exec信号 */
@@ -38,7 +40,13 @@ protected:
     /* 事件过滤器 */
     bool eventFilter(QObject *watched, QEvent *event) override;
     /* 显示事件 */
-    void showEvent(QShowEvent *event) override;    
+    void showEvent(QShowEvent *event) override;
+    /* 鼠标点击事件 */
+    void mousePressEvent(QMouseEvent *event) override;
+    /* 鼠标移动事件 */
+    void mouseMoveEvent(QMouseEvent *event) override;
+    /* 鼠标释放事件 */
+    void mouseReleaseEvent(QMouseEvent *event) override;
 
 private slots:
     /* 关闭按钮槽函数 */
@@ -61,8 +69,8 @@ private:
     void layoutItem(int num);
     /* 重新设置Item序号 */
     void resetItemNum();
-    /* 添加或删除项 */
-    void addOrDelItem(int num);
+    /* 显示或隐藏选项 */
+    void showOrHide(int num);
 
 public:
     int m_row = 0;          /* 行 */
@@ -71,10 +79,13 @@ public:
 private:
     Ui::SettingNum *ui;
     std::shared_ptr<spdlog::logger> m_logger = nullptr;
-    OneShadow *m_shadow = nullptr;
+
+    QPoint m_lastPos;
 
     QList<OneSettingItem*> m_listItem;
     QList<OneChannelInfo> m_listChannelInfo;    /* 可用的通道信息 */
+
+    QWidget* m_parent = nullptr;
 };
 
 #endif // SETTINGNUM_H

+ 13 - 0
EyeMap/SettingNum/settingnum.ui

@@ -251,6 +251,19 @@
        </rect>
       </property>
      </widget>
+     <widget class="QLabel" name="label_warn">
+      <property name="geometry">
+       <rect>
+        <x>44</x>
+        <y>124</y>
+        <width>701</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
     </widget>
    </item>
   </layout>

+ 50 - 0
EyeMap/app.rc

@@ -0,0 +1,50 @@
+//#include "winres.h"
+
+#ifdef UNDER_CE
+    #include <winbase.h>
+#else
+    #include <winver.h>
+#endif
+
+#include "version.h"
+
+//图标,位置是相对于本文件的位置
+IDI_ICON1               ICON    DISCARDABLE     ".\\Resource\\icon\\EyePattern_Logo.ico"
+
+//版本信息
+VS_VERSION_INFO VERSIONINFO                         //VS版本
+FILEVERSION FILE_VERSION                         //文件版本
+PRODUCTVERSION PRODUCT_VERSION                      //产品版本
+FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+    FILEFLAGS 0x1L
+#else
+    FILEFLAGS 0x0L
+#endif
+
+FILEOS 0x40004L
+FILETYPE 0x1L
+FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "080404b0"
+        BEGIN
+            VALUE "CompanyName", COMPANY_NAME
+            VALUE "FileDescription", FILE_DESCRIPTION
+            VALUE "FileVersion", FILE_VERSION_STR
+            VALUE "InternalName", INTERNAL_NAME
+            VALUE "LegalCopyright", LEGAL_COPYRIGHT
+            VALUE "OriginalFilename", ORIGINAL_FILE_NAME
+            VALUE "ProductName", PRODUCT_NAME
+            VALUE "ProductVersion", PRODUCT_VERSION_STR
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x804, 1200
+    END
+END
+
+
+

+ 4 - 0
EyeMap/eyemap.qrc

@@ -16,4 +16,8 @@
         <file>Resource/image/close_dark/close_default.png</file>
         <file>Resource/image/close_dark/close_pass.png</file>
     </qresource>
+    <qresource prefix="/ICON">
+        <file>Resource/icon/EyePattern_Logo.ico</file>
+        <file>Resource/icon/EyePattern_Logo.png</file>
+    </qresource>
 </RCC>

+ 41 - 7
EyeMap/main.cpp

@@ -2,14 +2,16 @@
 
 #include <QApplication>
 #include <QFontDatabase>
+#include <QMessageBox>
 
 #include "spdlog/spdlog.h"
 #include "logs/loginit.h"
 #include "EyeMapWidget.h"
 #include "EyeMapInfo.h"
 #include "OscDataInfo.h"
+#include "softdog.h"
 
-void addFont();
+void addFont(const QString& appPath);
 
 int main(int argc, char* argv[])
 {
@@ -25,7 +27,21 @@ int main(int argc, char* argv[])
     SPDLOG_LOGGER_INFO(logger, "★  ★  ★  ★  ★   Oscilloscope   ★  ★  ★  ★  ★");
 
     /* 加载字体 */
-    addFont();
+    auto appPath = QApplication::applicationDirPath();
+    addFont(appPath);
+
+    /* 验证加密狗 */
+#ifdef C_RELEASE
+    // QString errMsg;
+    // if(!(SoftDog::DogCheck(errMsg, 30, QLatin1String("eqmyt"))))
+    // {
+    //     SPDLOG_LOGGER_ERROR(logger, "加密狗错误信息:{}", errMsg.toStdString());
+    //     QMessageBox::critical(nullptr, "错误", errMsg);
+    //     // MessageBox::execTip(errMsg, MessageBox::ERROR, true);
+    //     return 0;
+    // }
+#endif
+
     /* 初始化数据 */
     GEyeMapInfo.initEyeMapInfo();
     /* 初始化示波器的数据内存区域 */
@@ -35,16 +51,34 @@ int main(int argc, char* argv[])
     w.show();
     w.startCapture();
 
+    // std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
+    // double a = 330.2, b = 2.2;
+    // for (long long i = 0; i < 1000000000; ++i) 
+    // {
+    //     b = a * b;
+    // }
+    // std::chrono::steady_clock::time_point end1 = std::chrono::steady_clock::now();
+
+    // long long c = 3200, d = 22;
+    // for (long long i = 0; i < 1000000000; ++i) {
+    //     d = c * d;
+    // }
+    // std::chrono::steady_clock::time_point end2 = std::chrono::steady_clock::now();
+
+    // SPDLOG_LOGGER_INFO(logger, "double time: {}", std::chrono::duration_cast<std::chrono::milliseconds>(end1 - begin).count());
+    // SPDLOG_LOGGER_INFO(logger, "long long time: {}", std::chrono::duration_cast<std::chrono::milliseconds>(end2 - end1).count());
+
     return app.exec();
 }
 
 /* 加载字体 */
-void addFont()
+void addFont(const QString& appPath)
 {
+    QString fontPath = appPath + "/Rec/SiYuanBlack_ttf";
     /* 加载字体 */
-    QFontDatabase::addApplicationFont(R"(:/font/font/SiYuanBlack_ttf/SiYuanBlack_Bold.ttf)");
-    QFontDatabase::addApplicationFont(R"(:/font/font/SiYuanBlack_ttf/SiYuanBlack_M.ttf)");
-    QFontDatabase::addApplicationFont(R"(:/font/font/SiYuanBlack_ttf/SiYuanBlack_R.ttf)");
+    QFontDatabase::addApplicationFont(appPath + "/SiYuanBlack_Bold.ttf");
+    QFontDatabase::addApplicationFont(appPath + "/SiYuanBlack_M.ttf");
+    QFontDatabase::addApplicationFont(appPath + "/SiYuanBlack_R.ttf");
     /***************************************************
      * 字体使用方式
      * id1 ("思源黑体-粗")
@@ -56,7 +90,7 @@ void addFont()
     //    qDebug() << "id2" << QFontDatabase::applicationFontFamilies(id2);
     //    qDebug() << "id3" << QFontDatabase::applicationFontFamilies(id3);
     QFont font_main;
-//    font_main.setFamily("思源黑体R");
+   font_main.setFamily("思源黑体R");
     font_main.setPixelSize(14);
     QApplication::setFont(font_main);
 }

+ 21 - 0
EyeMap/version.h

@@ -0,0 +1,21 @@
+#ifndef  VERSION_H
+#define  VERSION_H
+
+/* 设置文件版本和产品版本的时候,格式是三个逗号隔开的四位数 */ 
+#define FILE_VERSION 1,0,0,0                            /* 文件版本 */
+#define FILE_VERSION_STR "1,0,0,0"
+#define PRODUCT_VERSION 1,0,0,0                         /* 产品版本 */
+#define PRODUCT_VERSION_STR "1.0,0,0"
+#define COMPANY_NAME "杭州联汇科技股份有限公司"              /* 公司名称 */
+#define INTERNAL_NAME "EyePattern"                              /* 内部名称 */
+#define LEGAL_COPYRIGHT "杭州联汇科技股份有限公司"           /* 版权 */
+#define ORIGINAL_FILE_NAME "EyePattern.exe"                     /* 原始文件名 */
+#define PRODUCT_NAME "多通道数字信号监测站点"                     /* 产品名称 */
+#define ORGANIZATION_DOMAIN "https://www.hzlh.com"         /* 域名 */
+#if defined (MSVC)
+    #define FILE_DESCRIPTION "EyePattern based on Qt 5.12.12 (MSVC 2019, 64 bit)" /* 文件说明 */
+#elif defined (GCC)
+    #define FILE_DESCRIPTION "EyePattern based on Qt 5.12.12 (GCC 11.3, 64 bit)" /* 文件说明 */
+#endif
+
+#endif /* VERSION_H */

+ 0 - 124
oscwidget.cpp

@@ -1,124 +0,0 @@
-#include "oscwidget.h"
-#include "ui_oscwidget.h"
-
-#include "OscData.h"
-#include <QPainter>
-
-OscWidget::OscWidget(QWidget *parent) :
-    QWidget(parent),
-    ui(new Ui::OscWidget)
-{
-    ui->setupUi(this);
-
-    m_logger = spdlog::get("OSC");
-    if(m_logger == nullptr)
-    {
-        SPDLOG_ERROR("获取 OSC logger 失败");
-        return;
-    }
-    /* 自定义大小 */
-    // setFixedSize(1920, 1080);
-
-    /* 设置眼图窗口 */
-    m_eyeMap = new OneEyeMap(ui->widget_display);
-    m_eyeMap->setGeometry(0, 0, ui->widget_display->width(), ui->widget_display->height());
-    /* 添加下拉框的选项 */
-    ui->comboBox_time->addItem("0.05us");
-    ui->comboBox_time->addItem("0.1us");
-    ui->comboBox_time->addItem("0.2us");
-    ui->comboBox_time->addItem("0.5us");
-    ui->comboBox_time->addItem("1us");
-    ui->comboBox_time->addItem("2us");
-    ui->comboBox_time->addItem("5us");
-    ui->comboBox_time->addItem("10us");
-    ui->comboBox_time->addItem("20us");
-    
-    m_mapTime.insert("0.05us", 50);
-    m_mapTime.insert("0.1us", 100);
-    m_mapTime.insert("0.2us", 200);
-    m_mapTime.insert("0.5us", 500);
-    m_mapTime.insert("1us", 1000);
-    m_mapTime.insert("2us", 2000);
-    m_mapTime.insert("5us", 5000);
-    m_mapTime.insert("10us", 10000);
-    m_mapTime.insert("20us", 20000);
-    
-
-    SPDLOG_LOGGER_INFO(m_logger, "EyeMap 初始化成功");
-    OscData.initOsc();
-    if(OscData.openOSC())
-    {
-        SPDLOG_LOGGER_INFO(m_logger, "打开示波器成功");
-    } else {
-        SPDLOG_LOGGER_ERROR(m_logger, "打开示波器失败");
-        return;
-    }
-    /* 获取零电压值 */
-    OscData.printZeroVoltage(OscChannel::CH_A);
-    OscData.printZeroVoltage(OscChannel::CH_B);
-    /* 获取电压校准系数 */
-    OscData.printVoltageCalibration(OscChannel::CH_A);
-    OscData.printVoltageCalibration(OscChannel::CH_B);
-
-    /* 设置示波器参数 */
-    // OscData.setExternalTrigger(false);
-    // OscData.setTriggerPosition(0, 0);     /* 在中间位置触发 */
-    OscData.setSampleRate(OscSampleRate::SR_100MHZ);
-    OscData.setChannelARange(OscVoltageRange::CR_5V);
-    // OscData.setChannelATrigger(true);
-    // OscData.setChannelCoupling(OscChannel::CH_A, OscChannelCoupling::DC);
-    // OscData.setChannelCoupling(OscChannel::CH_B, OscChannelCoupling::DC);
-    // OscData.setTriggerMode(OscTriggerMode::TM_RISE);
-    // OscData.setTriggerLevel(150);
-    // OscData.setTriggerSensitivity(OscTriggerSensitivity::TS_HIGH);
-    
-
-    // OscData.startCapture();
-}
-
-OscWidget::~OscWidget()
-{
-    if(OscData.isOpen())
-    {
-        OscData.closeOSC();
-    }
-    delete ui;
-}
-
-
-void OscWidget::on_pBtn_startCap_clicked()
-{
-    SPDLOG_LOGGER_INFO(m_logger, "开始采集数据");
-    OscParams.oneGridTime = m_mapTime[ui->comboBox_time->currentText()];
-    OscData.startCapture();
-}
-
-void OscWidget::on_pBtn_resetCap_clicked()
-{
-    SPDLOG_LOGGER_INFO(m_logger, "重新采集数据");
-    OscData.stopCapture();
-    g_eyeMapMatrix.initEyeMapData(ui->widget_display->width(), ui->widget_display->height());
-    g_eyeDataMatrix.initEyeData();
-    update();
-    OscParams.oneGridTime = m_mapTime[ui->comboBox_time->currentText()];
-    OscData.startCapture();
-}
-
-void OscWidget::on_pBtn_stopCap_clicked()
-{
-    SPDLOG_LOGGER_INFO(m_logger, "停止采集");
-    OscData.stopCapture();
-    
-    update();
-}
-
-/**
- * @brief 绘制刻度
- * 
- */
-void OscWidget::paintEvent(QPaintEvent *event)
-{
-    QPainter painter(this);
-    
-}
-

+ 0 - 38
oscwidget.h

@@ -1,38 +0,0 @@
-#ifndef OSCWIDGET_H
-#define OSCWIDGET_H
-
-#include <QWidget>
-#include "spdlog/spdlog.h"
-#include "OneEyeMap.h"
-
-namespace Ui {
-class OscWidget;
-}
-
-class OscWidget : public QWidget
-{
-    Q_OBJECT
-
-public:
-    explicit OscWidget(QWidget *parent = nullptr);
-    ~OscWidget();
-
-private slots:
-    
-    void on_pBtn_startCap_clicked();
-    void on_pBtn_resetCap_clicked();
-    void on_pBtn_stopCap_clicked();
-
-protected:
-    void paintEvent(QPaintEvent *event) override;
-
-private:
-    Ui::OscWidget *ui;
-    std::shared_ptr<spdlog::logger> m_logger = nullptr;
-    OneEyeMap* m_eyeMap = nullptr;
-    QMap<QString, int> m_mapTime;
-
-    int m_widthScaleplate = 20;             /* 刻度板宽度 */
-};
-
-#endif // OSCWIDGET_H

+ 0 - 82
oscwidget.ui

@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OscWidget</class>
- <widget class="QWidget" name="OscWidget">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>1600</width>
-    <height>1080</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Form</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <property name="spacing">
-    <number>0</number>
-   </property>
-   <property name="leftMargin">
-    <number>0</number>
-   </property>
-   <property name="topMargin">
-    <number>0</number>
-   </property>
-   <property name="rightMargin">
-    <number>0</number>
-   </property>
-   <property name="bottomMargin">
-    <number>0</number>
-   </property>
-   <item>
-    <widget class="QWidget" name="widget_display" native="true">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="minimumSize">
-      <size>
-       <width>1600</width>
-       <height>900</height>
-      </size>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="QWidget" name="widget" native="true">
-     <layout class="QGridLayout" name="gridLayout">
-      <item row="3" column="1">
-       <widget class="QComboBox" name="comboBox_time"/>
-      </item>
-      <item row="2" column="1">
-       <widget class="QPushButton" name="pBtn_resetCap">
-        <property name="text">
-         <string>重新采集</string>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="0">
-       <widget class="QPushButton" name="pBtn_stopCap">
-        <property name="text">
-         <string>停止采集</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0">
-       <widget class="QPushButton" name="pBtn_startCap">
-        <property name="text">
-         <string>开始采集</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>

+ 20 - 0
说明.md

@@ -0,0 +1,20 @@
+
+# 眼图设计说明
+
+## 数据模块
+1. `OneOscilloscope`调用示波器的SDK,获取示波器数据,并解析数据
+2. `OscDataInfo.h`文件中存储示波器获取到的数据,以及一些数据类型
+3. `OscDataInfo.h`中的`OscilloscopeData`存储8个通道的数据指针
+    `QMap<OscChnNum, EyeDataMatrix*>`, `QMap<OscChnNum, EyeMapMatrix*>`, `QMap<int, OneOscilloscope*>`
+    `OneOscilloscope`中的数据矩阵从`OscilloscopeData`中获取
+
+## 显示模块
+1. `OneEyeMap`是单个的眼图,根据传入的通道号从`OscilloscopeData`中获取颜色矩阵
+2. 
+
+
+## 颜色映射
+ 1. #003590
+ 2. #DEE2E6
+ 3. 
+

+ 2 - 0
问题.txt

@@ -0,0 +1,2 @@
+3、加密狗还未打开成功
+6、未打开的示波器下拉框后面添加上未打开字样

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov