Explorar o código

MOD:CO2功能增加

chenyuanjie hai 1 ano
pai
achega
621336cdd8

+ 9 - 0
Qt/Qt_Test/dataupdatethread.cpp

@@ -56,10 +56,12 @@ void DataUpdateThread::run()
 
         if(pwidget)
         {
+
             if(nReadType==0)
             {
                 int nMode=pwidget->getShowModeIndex();
                 int nPage=pwidget->getShowPagIndex();
+               // qDebug() <<"ReadType=0 nMode:"<<nMode<<";nPage"<<nPage;
                 if(nMode==0&&nPage!=0)
                 {
                     int nSubPag=pwidget->getShowSubIndex();
@@ -82,6 +84,7 @@ void DataUpdateThread::run()
             {
                 int nMode=pwidget->getShowModeIndex();
                 int nPage=pwidget->getShowPagIndex();
+                //qDebug() <<"ReadType=1 nMode:"<<nMode<<";nPage"<<nPage;
                 ReadShmMaxch();
                 if(nMode==0&&nPage!=0)
                 {
@@ -98,6 +101,7 @@ void DataUpdateThread::run()
                     pwidget->setCH(nSubPag);
                     pwidget->SetT(strT);
                     pwidget->SetH(strH);
+                    pwidget->SetCO2(strCO2);
                     pwidget->update();
                     //qDebug() <<"V:"<<strV<<";A"<<strA<<";W:"<<strW;
                 }
@@ -269,6 +273,11 @@ void DataUpdateThread::ReadShmData()
         }
         strT = QString::number(m_shmData->fT,'f',2);
         strH = QString::number(m_shmData->fH,'f',2);
+        QString strShow=QString::number(m_shmData->fCO2,'f',2);
+        //qDebug()<< "Update CO2:"+strShow;
+        strCO2 = strShow;//QString::number(m_shmData->fCO2,'f',2);
+
+
     }
 }
 

+ 2 - 0
Qt/Qt_Test/dataupdatethread.h

@@ -25,6 +25,7 @@ struct smartPDU_shm_data
     int nSelectSensor;
     float fT;//温度
     float fH;//湿度
+    float fCO2;//co2
     //三项数据
     int bT_ACType;//三相类型
     int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
@@ -67,6 +68,7 @@ public:
     QString strS;
     QString strT;
     QString strH;
+    QString strCO2;
     QString strStatus;
     int nMaxCh;
 

+ 2 - 0
Qt/Qt_Test/widget.cpp

@@ -40,6 +40,7 @@ Widget::Widget(QWidget *parent) :
     ui->label_modbus_Addr->hide();
 #endif
     ui->stackedWidget_Main->setCurrentIndex(0);
+    //ui->stackedWidget_Main->setCurrentWidget(ui->page_7);
 }
 
 Widget::~Widget()
@@ -147,6 +148,7 @@ void Widget::SetSUM(QString strShow){SetData(ui->label_14,strShow);SetData(ui->l
 
 void Widget::SetT(QString strShow){SetData(ui->label_Temp,strShow);}
 void Widget::SetH(QString strShow){SetData(ui->label_Humidity,strShow+"%");}
+void Widget::SetCO2(QString strShow){SetData(ui->label_CO2,strShow+"%");}
 void Widget::SetStatus(QString strShow){SetData(ui->label_V,strShow);}
 
 void Widget::SetIP(QString strIP)

+ 2 - 0
Qt/Qt_Test/widget.h

@@ -58,6 +58,8 @@ public:
     void SetIP(QString strIP);
     void SetT(QString strShow);
     void SetH(QString strShow);
+    void SetCO2(QString strShow);
+
     void setCH(int nIndex);
     void setPH(int nIndex,int nPhID);
     void SetStatus(QString strShow);

+ 26 - 2
Qt/Qt_Test/widget.ui

@@ -95,7 +95,7 @@ QLabel
           <item>
            <widget class="QStackedWidget" name="stackedWidget_Main">
             <property name="currentIndex">
-             <number>0</number>
+             <number>3</number>
             </property>
             <widget class="QWidget" name="page_4">
              <layout class="QVBoxLayout" name="verticalLayout_6">
@@ -620,7 +620,7 @@ QLabel
                 </property>
                </widget>
               </item>
-              <item row="3" column="0">
+              <item row="4" column="0">
                <spacer name="verticalSpacer_3">
                 <property name="orientation">
                  <enum>Qt::Vertical</enum>
@@ -633,6 +633,30 @@ QLabel
                 </property>
                </spacer>
               </item>
+              <item row="3" column="0">
+               <widget class="QLabel" name="label_17">
+                <property name="font">
+                 <font>
+                  <pointsize>10</pointsize>
+                 </font>
+                </property>
+                <property name="text">
+                 <string>CO2</string>
+                </property>
+               </widget>
+              </item>
+              <item row="3" column="1">
+               <widget class="QLabel" name="label_CO2">
+                <property name="font">
+                 <font>
+                  <pointsize>10</pointsize>
+                 </font>
+                </property>
+                <property name="text">
+                 <string>0%</string>
+                </property>
+               </widget>
+              </item>
              </layout>
             </widget>
             <widget class="QWidget" name="page_8">

+ 5 - 0
pro/src/app.c

@@ -2134,6 +2134,7 @@ static void* sensor_thread(void* arg)
                     _globalSensorMangerTemp->sensor_check_count = 0;
                 }
                 _globalSensorMangerTemp->Cur_sensor_info = _globalSensorInfo;
+                _globalDeviceManager->g_modebus_read.fCO2=CO2*100;
                 for(int i = 0 ; i < NOARTH_MAX_SENSOR;i++)           //最多4个
                 {
                     if(_globalSensorMangerTemp->sensor_addr == sen.serser_addr[i])
@@ -2397,6 +2398,7 @@ static void* shm_thread(void *arg)
                                 _globalDeviceManager->g_shm_Data->nStatus = _pTreeACPowerPhData->_PowerInfo.status;
                                 _globalDeviceManager->g_shm_Data->fT = _globalDeviceManager->g_modebus_read.temprature/100.0f;
                                 _globalDeviceManager->g_shm_Data->fH = _globalDeviceManager->g_modebus_read.humidity/100.0f;
+                                _globalDeviceManager->g_shm_Data->fCO2 = _globalDeviceManager->g_modebus_read.fCO2/100.0f;
                             }
                         }
                         else
@@ -2410,6 +2412,7 @@ static void* shm_thread(void *arg)
                             _globalDeviceManager->g_shm_Data->nStatus = _globalDeviceManager->_globalPowerManger._PowerInfo.status;
                             _globalDeviceManager->g_shm_Data->fT = _globalDeviceManager->g_modebus_read.temprature/100.0f;
                             _globalDeviceManager->g_shm_Data->fH = _globalDeviceManager->g_modebus_read.humidity/100.0f;
+                            _globalDeviceManager->g_shm_Data->fCO2 = _globalDeviceManager->g_modebus_read.fCO2/100.0f;
                         }
                     }
                     else
@@ -2446,6 +2449,7 @@ static void* shm_thread(void *arg)
                                 _globalDeviceManager->g_shm_Data->nStatus = _pTreeACPowerPhData->_PowerInfo.status;
                                 _globalDeviceManager->g_shm_Data->fT = _globalDeviceManager->g_modebus_read.temprature/100.0f;
                                 _globalDeviceManager->g_shm_Data->fH = _globalDeviceManager->g_modebus_read.humidity/100.0f;
+                                _globalDeviceManager->g_shm_Data->fCO2 = _globalDeviceManager->g_modebus_read.fCO2/100.0f;
                             }
                         }
                         else
@@ -2458,6 +2462,7 @@ static void* shm_thread(void *arg)
                             _globalDeviceManager->g_shm_Data->nStatus = _globalPowerMangerTemp->_PowerInfo.status;
                             _globalDeviceManager->g_shm_Data->fT = _globalDeviceManager->g_modebus_read.temprature/100.0f;
                             _globalDeviceManager->g_shm_Data->fH = _globalDeviceManager->g_modebus_read.humidity/100.0f;
+                            _globalDeviceManager->g_shm_Data->fCO2 = _globalDeviceManager->g_modebus_read.fCO2/100.0f;
                         }
                     }
                     lock_s_release(LOCK_ID_POWER_UPDATE);

+ 3 - 0
pro/src/common.h

@@ -492,6 +492,7 @@ typedef struct
     int nSelectSensor;
     float fT;//温度
     float fH;//湿度
+    float fCO2;//co2
     //三项数据
     int bT_ACType;//三相类型
     int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
@@ -1042,6 +1043,8 @@ struct modbus_slave_read_reg{
     uint16_t power_supplay_status;      //供电状态
     uint16_t sencor_status;             //传感器状态
     uint32_t temprature2;                //温度值2
+    uint32_t fCO2;                     //CO2
+
 //    uint32_t Warinfo;
 //    uint16_t sercor_type;
 };