Răsfoiți Sursa

完善操作逻辑

JonYang 3 săptămâni în urmă
părinte
comite
93993a0965

+ 1 - 1
Output/inc/Control/CViewInterface.h

@@ -185,7 +185,7 @@ namespace ns_module
 		LONG SetIoStatus(string strIoName, short nOutput);
 		//»ñÈ¡IO״̬
 		LONG GetIoStatus(string strIoName, ns_db::DIGIT_IO_LEVEL &nOutput);
-		LONG GetIoStatus(string strIoName, short &nOutput);
+		LONG GetIoStatus(string strIoName, short &nOutput); //0~255
 		//ÒÆ¶¯Öá
 		long ModuleMove(string ModuleType, string AxisType, double pos);
 		long ModuleMoveTo(string ModuleType, string AxisType, double pos);

+ 14 - 14
View/die-bonder-ui/OriginalWnd/DbTreeViewManager.cpp

@@ -2035,20 +2035,20 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
             {
                 //先创建label
                 //int fieldId = control.iId;
-                QString fieldName = QString::fromStdString(control.strName);
-                QString fieldDescribe = QString::fromStdString(control.strDescribe);
+                QString fieldName           = QString::fromStdString(control.strName);
+                QString fieldDescribe       = QString::fromStdString(control.strDescribe);
                 //QString fieldDescribe_Eng = QString::fromStdString(control.strDescribe_Eng);
-                QString fieldDescribe_Eng = "111";
-                int fieldUserGrade = control.iUserGrade;
-                QString fieldType = QString::fromStdString(control.strType);
-                QString fieldValue = QString::fromStdString(control.strValue);
-                QString fieldDefult = QString::fromStdString(control.strDefult);
-                QString fieldUpLimit = QString::fromStdString(control.strUpperLimit);
-                QString fieldDownLimit = QString::fromStdString(control.strLowerLimit);
-                QString fieldUnits = QString::fromStdString(control.strUnit);
-                QString strAxisType = QString::fromStdString(control.strAxisType);
-                QString strstrModuleType = m_str2DirModuleType;
-                int groupId = control.iGroupId;
+                QString fieldDescribe_Eng   = "111";
+                int fieldUserGrade          = control.iUserGrade;
+                QString fieldType           = QString::fromStdString(control.strType);
+                QString fieldValue          = QString::fromStdString(control.strValue);
+                QString fieldDefult         = QString::fromStdString(control.strDefult);
+                QString fieldUpLimit        = QString::fromStdString(control.strUpperLimit);
+                QString fieldDownLimit      = QString::fromStdString(control.strLowerLimit);
+                QString fieldUnits          = QString::fromStdString(control.strUnit);
+                QString strAxisType         = QString::fromStdString(control.strAxisType);
+                QString strstrModuleType    = m_str2DirModuleType;
+                int groupId                 = control.iGroupId;
 
                 QString fieldTableName = extractBeforeComma(tableData.tableName);
 
@@ -3213,7 +3213,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                 } 
                 else if (fieldType == "IoPage")
                 {
-                    rightLayout->addWidget(JIoMapPage::CreateIoPage());
+                    rightLayout->addWidget(JIoMapPage::CreateIoPage(control));
                 }
                 else
                 {

+ 29 - 4
View/die-bonder-ui/OriginalWnd/TreeViewManager/JIoMapPage.cpp

@@ -2,17 +2,42 @@
 
 JIoMapPage::JIoMapPage() {}
 
-QWidget* JIoMapPage::CreateIoPage()
+QWidget* JIoMapPage::CreateIoPage(const CONFIG_BASE_STRUCT& control)
 {
-    // 创建垂直布局
+    // 1.用到表中的变量
+    QString strName = control.strName.c_str();
+
+    // 2. 创建垂直布局
     QHBoxLayout* pHLayout = new QHBoxLayout();
 
     ClickCircleLabel* pIoState = new ClickCircleLabel();
-    QLabel* pAxisNmae = new QLabel(tr("AxisNmae","轴名称"));
+    pIoState->setIoName(strName);
+    QLabel* pAxisNmae = new QLabel();
+    QString strAxisName = tr("AxisNmae:", "轴名称:");
+    strAxisName += strName;
+    pAxisNmae->setText(strAxisName);
+
+    //QLabel* pLow = new QLabel();
+    //pLow->setText(tr("Voltage status", "电压状态"));
+    //QComboBox* pComBox = new QComboBox();
+    //pComBox->addItem(tr("Low", "低电平"));
+    //pComBox->addItem(tr("High","高电平"));
+    //pComBox->setCurrentIndex(1);
+    //// 连接信号和槽
+    //connect(pComBox, &QComboBox::currentTextChanged, []() {
+
+
+    //    });
 
+    // 轴名称
     pHLayout->addWidget(pAxisNmae);
-    pHLayout->addWidget(pIoState);
 
+    //// 电平组合
+    //pHLayout->addWidget(pLow);
+    //pHLayout->addWidget(pComBox);
+
+    // 改变状态标记
+    pHLayout->addWidget(pIoState);
     QWidget* pWidget = new QWidget;
     pWidget->setLayout(pHLayout);
     return pWidget;

+ 49 - 5
View/die-bonder-ui/OriginalWnd/TreeViewManager/JIoMapPage.h

@@ -1,6 +1,7 @@
 #ifndef JIOMAPPAGE_H
 #define JIOMAPPAGE_H
 #include "TreeViewManagerHead.h"
+#include "Src/common/JLogAllOutput.h"
 #include <QMouseEvent>
 
 class ClickCircleLabel : public QLabel {
@@ -8,11 +9,46 @@ class ClickCircleLabel : public QLabel {
 
 public:
     ClickCircleLabel(QWidget* parent = nullptr)
-        : QLabel(parent), m_bClicked(false) 
+        : QLabel(parent) 
     {
         setFixedSize(30, 30);
     }
 
+public:
+    /**设置io 轴名称
+     */
+    void setIoName(const QString& strName) 
+    {
+        m_strName = strName;
+        UpDataIoStatus(true);
+    }
+
+    void UpDataIoStatus(bool isInit)
+    {
+        if (m_pCamera == nullptr)
+        {
+            m_pCamera = ns_module::CViewInterface::GetInstance();
+            if (m_pCamera == nullptr)
+            {
+                // 为了调试准备的
+                JLogAllOutput::cmd_error("io 轴设置失败");
+                return;
+            }
+        }
+
+        if (isInit)
+        {
+            // 信号量
+            ns_db::DIGIT_IO_LEVEL nOutput;
+            m_pCamera->GetIoStatus(m_strName.toStdString(), nOutput);
+            m_bClicked = nOutput;
+        }
+        else
+        {
+            m_pCamera->SetIoStatus(m_strName.toStdString(), m_bClicked);
+        }
+    }
+
 protected:
     void paintEvent(QPaintEvent* event) override 
     {
@@ -25,7 +61,7 @@ protected:
         int y = (height() - 2 * radius) / 2;
 
         painter.setPen(Qt::NoPen);
-        painter.setBrush(m_bClicked ? Qt::red : Qt::gray);
+        painter.setBrush(m_bClicked ? Qt::green : Qt::red);
         painter.drawEllipse(x, y, 2 * radius, 2 * radius);
     }
 
@@ -33,14 +69,20 @@ protected:
     {
         if (event->button() == Qt::LeftButton) 
         {
-            m_bClicked = !m_bClicked; 
+            m_bClicked = !m_bClicked;
+            UpDataIoStatus(false);
+
             update(); 
         }
         QLabel::mousePressEvent(event);
     }
 
 private:
-    bool m_bClicked; // 当前状态
+    bool                       m_bClicked; // 当前状态
+
+    QString                    m_strName;
+
+    ns_module::CViewInterface* m_pCamera = nullptr;
 };
 
 class JIoMapPage :public QObject
@@ -49,7 +91,9 @@ class JIoMapPage :public QObject
 public:
     JIoMapPage();
 
-    static QWidget* CreateIoPage();
+    /**io 界面,先获取全部,后续可用,没用到的后续修改
+     */
+    static QWidget* CreateIoPage(const CONFIG_BASE_STRUCT& control);
 };
 
 #include <QApplication>