Browse Source

新增研讨室B1层设备采集、修改房间设备采集频率改为一小时采集一次

james 1 year ago
parent
commit
c41ba091f2
2 changed files with 8 additions and 37 deletions
  1. 7 37
      agFreshAirProcess/httpthread.cpp
  2. 1 0
      agFreshAirProcess/ytmqttsub.cpp

+ 7 - 37
agFreshAirProcess/httpthread.cpp

@@ -17,7 +17,7 @@ HttpThread::HttpThread(QObject *parent) : QObject(parent)
 
     timer = new QTimer(this);
     connect(timer,&QTimer::timeout,this,&HttpThread::time_out);
-    timer->start(5000);
+    timer->start(1000);
 
 }
 
@@ -42,8 +42,7 @@ void  HttpThread::finishedSlot(QNetworkReply *reply)
             double wd=0.00,sd=0.00,pm2_5=0.00,co2=0.00;
             int voc= 0;
             int fan_status = 0;
-//            int ts = (QDateTime::fromString(QDateTime::currentDateTime().toString("yyyy-MM-dd HH")+":00:00","yyyy-MM-dd HH:mm:ss")).toTime_t();
-            int ts = QDateTime::currentDateTime().toTime_t();
+            int ts = (QDateTime::fromString(QDateTime::currentDateTime().toString("yyyy-MM-dd HH")+":00:00","yyyy-MM-dd HH:mm:ss")).toTime_t();
             for(int i=0;i<list_array.size();i++){
                 QJsonObject list_object = list_array.at(i).toObject();
                 device_code = list_object.value("roomNo").toString();
@@ -179,35 +178,13 @@ void HttpThread::time_out()
 {
     agBoxShm->processStatus[11].t_time=QDateTime::currentDateTime().toTime_t();
 
-//    if(hour != QDateTime::currentDateTime().time().hour()){
-//        hour = QDateTime::currentDateTime().time().hour();
-//        for(int i=0;i<1024;i++){
-//            if(QString("http").compare(QString(agBoxShm->device[i].device_gateway))==0){
-//                roomList.append(QString(agBoxShm->device[i].device_code));
-//            }
-//        }
-
-//        //每小时获取一次阿里天气数据
-//        if(!isWaiting1){
-//            isWaiting1 = true;
-//            QNetworkRequest *req = new QNetworkRequest();
-//            QString url = QString("https://weather01.market.alicloudapi.com/area-to-weather?area=历城区");
-//            req->setUrl(QUrl(url));
-//            req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
-//            req->setRawHeader("Accept","*/*");
-//            req->setRawHeader("Connection","keep-alive");
-//            req->setRawHeader("Cache-Control"," no-cache");
-//            req->setRawHeader("Authorization","APPCODE 0f2b7fce6e104ba8835358b7b59b4fb6");
-//            QNetworkReply *reply = networkManager1->get(*req);
-//            QReplayTimeout *pTimeout = new QReplayTimeout(reply,10000);
-//            connect(pTimeout, SIGNAL(net_timeout()),this,SLOT(reply_timeout1()));
-
-//        }
-
-//    }
-
     if(hour != QDateTime::currentDateTime().time().hour()){
         hour = QDateTime::currentDateTime().time().hour();
+        for(int i=0;i<1024;i++){
+            if(QString("http").compare(QString(agBoxShm->device[i].device_gateway))==0){
+                roomList.append(QString(agBoxShm->device[i].device_code));
+            }
+        }
 
         //每小时获取一次阿里天气数据
         if(!isWaiting1){
@@ -228,13 +205,6 @@ void HttpThread::time_out()
 
     }
 
-    if(QDateTime::currentDateTime().time().minute()%10 == 0){
-        for(int i=0;i<1024;i++){
-            if(QString("http").compare(QString(agBoxShm->device[i].device_gateway))==0){
-                roomList.append(QString(agBoxShm->device[i].device_code));
-            }
-        }
-    }
 
     if(!isWaiting && roomList.length() > 0){  //每小时获取3-12层每个房间设备列表心跳数据一次
         isWaiting = true;

+ 1 - 0
agFreshAirProcess/ytmqttsub.cpp

@@ -40,6 +40,7 @@ void YTMqttSub::mqtt_conf(QString ip, QString port, QString username, QString pa
 void YTMqttSub::onConnected()
 {
     printf("xfyt mqtt onConnected\n");
+    m_client->subscribe("/edge/baInfo/818DBB40CD2D4494936A75C76E89542C/rtg",0);
     m_client->subscribe("/edge/baInfo/B3E523F1D0E8402F818C30833C4F1C6F/rtg",0);
     m_client->subscribe("/edge/baInfo/E68D8A289878474D963D43F5FC624E34/rtg",0);
     m_client->subscribe("/edge/baInfo/3CC454CC33B74714BB7B8D8C83C72304/rtg",0);