|
@@ -1,12 +1,21 @@
|
|
|
#include "writecore.h"
|
|
|
+#include "../DataWriteDog/writeshm.h"
|
|
|
|
|
|
WriteCore::WriteCore(QObject *parent) : QObject(parent)
|
|
|
{
|
|
|
+ timer = new QTimer(this);
|
|
|
+ connect(timer,&QTimer::timeout,this,&WriteCore::time_out);
|
|
|
+ timer->start(1000);
|
|
|
+
|
|
|
dbthread = new DatabaseThread(this);
|
|
|
dbthread->start();
|
|
|
connect(dbthread,&DatabaseThread::mqtt_conf,this,&WriteCore::mqtt_data);
|
|
|
connect(dbthread,&DatabaseThread::dbdata_log,this,&WriteCore::dbdata_log);
|
|
|
|
|
|
+ dbeventthread = new DatabaseEventThread(this);
|
|
|
+ dbeventthread->start();
|
|
|
+ connect(dbthread,&DatabaseThread::dbdata_log,this,&WriteCore::dbdata_log);
|
|
|
+
|
|
|
logthread = new LogThread(this);
|
|
|
logthread->start();
|
|
|
|
|
@@ -17,25 +26,55 @@ WriteCore::WriteCore(QObject *parent) : QObject(parent)
|
|
|
dealmqthread = new DealMqttThread(this);
|
|
|
connect(dealmqthread,&DealMqttThread::dmq_log,this,&WriteCore::dmq_log);
|
|
|
connect(dealmqthread,&DealMqttThread::dmqSql,this,&WriteCore::appendSql);
|
|
|
- connect(dealmqthread,&DealMqttThread::dmqAlarm,this,&WriteCore::appendAlarm);
|
|
|
+
|
|
|
+ mqeventthread = new MqttEventDataThread(this);
|
|
|
+ connect(mqeventthread,&MqttEventDataThread::mq_log,this,&WriteCore::mq_log);
|
|
|
+ connect(mqeventthread,&MqttEventDataThread::sendMqttData,this,&WriteCore::sendMqttEventData);
|
|
|
+
|
|
|
+ dealmqeventthread = new DealMqttEventThread(this);
|
|
|
+ connect(dealmqeventthread,&DealMqttEventThread::dmq_log,this,&WriteCore::dmq_log);
|
|
|
+ connect(dealmqeventthread,&DealMqttEventThread::dmqSql,this,&WriteCore::appendEventSql);
|
|
|
+
|
|
|
+ mqalarmthread = new MqttAlarmDataThread(this);
|
|
|
+ connect(mqalarmthread,&MqttAlarmDataThread::mq_log,this,&WriteCore::mq_log);
|
|
|
+ connect(mqalarmthread,&MqttAlarmDataThread::sendMqttData,this,&WriteCore::sendMqttAlarmData);
|
|
|
+
|
|
|
+ dealmqalarmthread = new DealMqttAlarmThread(this);
|
|
|
+ connect(dealmqalarmthread,&DealMqttAlarmThread::dmq_log,this,&WriteCore::dmq_log);
|
|
|
+ connect(dealmqalarmthread,&DealMqttAlarmThread::dmqSql,this,&WriteCore::appendEventSql);
|
|
|
}
|
|
|
|
|
|
WriteCore::~WriteCore()
|
|
|
{
|
|
|
dbthread->stop();
|
|
|
+ dbeventthread->stop();
|
|
|
logthread->stop();
|
|
|
dealmqthread->stop();
|
|
|
+ dealmqeventthread->stop();
|
|
|
+ dealmqalarmthread->stop();
|
|
|
}
|
|
|
|
|
|
void WriteCore::start()
|
|
|
{
|
|
|
mqthread->start();
|
|
|
dealmqthread->start();
|
|
|
+ mqeventthread->start();
|
|
|
+ dealmqeventthread->start();
|
|
|
+ mqalarmthread->start();
|
|
|
+ dealmqalarmthread->start();
|
|
|
+}
|
|
|
+
|
|
|
+void WriteCore::time_out()
|
|
|
+{
|
|
|
+ dataWriteShm->processStatus[1].t_time = QDateTime::currentDateTime().toTime_t();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void WriteCore::mqtt_data(QString ip,QString port,QString username,QString password)
|
|
|
{
|
|
|
mqthread->mqtt_conf(ip,port,username,password);
|
|
|
+ mqeventthread->mqtt_conf(ip,port,username,password);
|
|
|
+ mqalarmthread->mqtt_conf(ip,port,username,password);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -54,6 +93,16 @@ void WriteCore::sendMqttData(QString topic,QByteArray data)
|
|
|
dealmqthread->appendMqttData(MqttData(topic,data));
|
|
|
}
|
|
|
|
|
|
+void WriteCore::sendMqttEventData(QString topic,QByteArray data)
|
|
|
+{
|
|
|
+ dealmqeventthread->appendMqttData(MqttEventData(topic,data));
|
|
|
+}
|
|
|
+
|
|
|
+void WriteCore::sendMqttAlarmData(QString topic,QByteArray data)
|
|
|
+{
|
|
|
+ dealmqalarmthread->appendMqttData(MqttAlarmData(topic,data));
|
|
|
+}
|
|
|
+
|
|
|
void WriteCore::dmq_log(QString log)
|
|
|
{
|
|
|
logthread->appendData(log);
|
|
@@ -64,9 +113,9 @@ void WriteCore::appendSql(QString sql)
|
|
|
dbthread->appendSql(sql);
|
|
|
}
|
|
|
|
|
|
-void WriteCore::appendAlarm(QString sql)
|
|
|
+void WriteCore::appendEventSql(QString sql)
|
|
|
{
|
|
|
- dbthread->appendAlarm(sql);
|
|
|
+ dbeventthread->appendSql(sql);
|
|
|
}
|
|
|
|
|
|
|