Ver código fonte

上传qt读取Monway参数功能

chenyuanjie 1 ano atrás
pai
commit
f31aadfb0f

+ 3 - 3
Qt/Qt_Test/dataupdatethread.cpp

@@ -171,7 +171,7 @@ void DataUpdateThread::ReadMaxCh()
             nMaxCh = sql_query.value("maxCh").toInt();
             if(pwidget)
             {
-                pwidget->nMAXChildIndex=nMaxCh;
+                pwidget->setMAXChildIndex(nMaxCh);
             }
         }
     }else
@@ -299,7 +299,7 @@ void DataUpdateThread::ReadShmMaxch()
     {
         if(pwidget)
         {
-            pwidget->nMAXChildIndex=0;
+            pwidget->setMAXChildIndex(0);
         }
         return;
     }
@@ -307,7 +307,7 @@ void DataUpdateThread::ReadShmMaxch()
     {
         if(pwidget->nMAXChildIndex!=m_shmData->nMaxCh)
         {
-           pwidget->nMAXChildIndex=m_shmData->nMaxCh;
+           pwidget->setMAXChildIndex(m_shmData->nMaxCh);
         }
     }
 }

+ 5 - 0
Qt/Qt_Test/pdu_ctrl.cpp

@@ -29,6 +29,7 @@ pdu_Ctrl::pdu_Ctrl(QObject *parent) : QObject(parent)
     m_nAngle=0;
     isT_ACType=0;
     m_nSaveAngle=0;
+    nMonway=2;
     memset(nButtonStatus,0,sizeof(nButtonStatus));
     //
 }
@@ -223,7 +224,10 @@ void pdu_Ctrl::ReadPDUinit()
     QString appPath = QCoreApplication::applicationDirPath();
     QSettings settings(appPath+"/smartPDU.ini",QSettings::IniFormat);
     QString strRotate=READ_INI_STR("misc/rotate","0");
+    QString strMonway=READ_INI_STR("webcfg/monway","2");
+    nMonway=strMonway.toInt();
     qDebug()<<"misc/rotate="<<strRotate;
+    qDebug()<<"webcfg/monway="<<strMonway;
     if(!strRotate.isEmpty())
     {
         m_nSaveAngle=strRotate.toInt();
@@ -235,6 +239,7 @@ void pdu_Ctrl::ReadPDUinit()
     {
         qDebug()<<"InitAngleStr="<<strRotate;
     }
+    if(m_pWidget)m_pWidget->setMonwayType(nMonway);
 }
 
 void pdu_Ctrl::SetPDUInit()

+ 1 - 0
Qt/Qt_Test/pdu_ctrl.h

@@ -153,6 +153,7 @@ public:
 
     int isT_ACType;
     int lastACIndex;
+    int nMonway;//1:总检测 2:分监分控 3:分监不控
 };
 
 #endif // PDU_CTRL_H

+ 57 - 2
Qt/Qt_Test/widget.cpp

@@ -144,7 +144,14 @@ void Widget::SetData(QLabel *pLab, QString strShow)
     }
 }
 
-void Widget::SetV(QString strShow){SetData(ui->label_8,strShow);SetData(ui->label_phV,strShow);}
+void Widget::SetV(QString strShow)
+{
+    SetData(ui->label_8,strShow);SetData(ui->label_phV,strShow);
+    if(m_nMonwayType==3)
+    {
+       SetData(ui->label_V,strShow);
+    }
+}
 
 void Widget::SetA(QString strShow){SetData(ui->label_13,strShow);SetData(ui->label_A,strShow);SetData(ui->label_phA,strShow);}
 
@@ -160,7 +167,13 @@ void Widget::SetCO2(QString strShow){SetData(ui->label_CO2,strShow+" PPM");}
 
 void Widget::SetVer(QString strShow){SetData(ui->label_2,"Version:"+strShow);}
 
-void Widget::SetStatus(QString strShow){SetData(ui->label_V,strShow);}
+void Widget::SetStatus(QString strShow){
+    if(m_nMonwayType==2)
+    {
+       SetData(ui->label_V,strShow);
+    }
+
+}
 
 void Widget::SetIP(QString strIP)
 {
@@ -437,6 +450,18 @@ void Widget::CtrlBtnSet(int nIndex, int nData)
     }
 }
 
+void Widget::setMAXChildIndex(int nIndex)
+{
+    if(m_nMonwayType==1)
+    {
+        nMAXChildIndex=0;
+    }else
+    {
+        nMAXChildIndex=nIndex;
+    }
+
+}
+
 void Widget::ShowMSGWidget(QString strShowData)
 {
     if(strShowData.isEmpty())
@@ -516,6 +541,36 @@ void Widget::adjustMSGWidgetPosition(bool isAuto)
     qDebug() << "MSGWidget geometry:" << m_pMSGWidget->geometry();
 }
 
+void Widget::setMonwayType(int nType)
+{
+    m_nMonwayType= nType;
+    switch (m_nMonwayType) {
+    case 1://总监控
+    {
+        nMAXChildIndex=0;
+    }
+        break;
+    case 3://分监视不控制
+    {
+        ui->label_34->setText("Volt(V):");
+        ui->label_V->setStyleSheet("");
+        SetData(ui->label_V,"0.00");
+    }
+        break;
+    default:
+    {
+        ui->label_34->setText("Switch");
+        SetData(ui->label_V,"OFF");
+#ifdef RS485Type
+        ui->label_V->setStyleSheet("QLabel {color: rgb(0,255,255);}");
+#else
+        ui->label_V->setStyleSheet("QLabel {color: rgb(0,0,255);}");
+#endif
+    }
+        break;
+    }
+}
+
 void Widget::resizeEvent(QResizeEvent *event)
 {
     if(m_pMSGWidget&&!m_pMSGWidget->isHidden())

+ 6 - 0
Qt/Qt_Test/widget.h

@@ -76,6 +76,7 @@ public:
     //modbus设置
     void setSelectStatus(int nIndex);
     void CtrlBtnSet(int nIndex,int nData);
+    void setMAXChildIndex(int nIndex);
     int nMAXChildIndex;
 
 
@@ -89,6 +90,9 @@ public:
     void ClickMSGBtn();
     //
     void adjustMSGWidgetPosition(bool isAuto=true);
+
+    //设置显示方式
+    void setMonwayType(int nType);
 protected:
     void resizeEvent(QResizeEvent *event) override;
 signals:
@@ -119,6 +123,8 @@ private:
     int nIndexShow;
 public:
     int m_nAngle;
+
+    int m_nMonwayType;//1:总检测 2:分监分控 3:分监不控
 };
 
 #endif // WIDGET_H

+ 0 - 5
Qt/Qt_Test/widget.ui

@@ -402,11 +402,6 @@ QLabel
                   <pointsize>10</pointsize>
                  </font>
                 </property>
-                <property name="styleSheet">
-                 <string notr="true">QLabel {
-    color: red;
-}</string>
-                </property>
                 <property name="text">
                  <string>OFF</string>
                 </property>

BIN
cust_data/qt/IP/Qt_Test


BIN
cust_data/qt/Qt_Test