#ifndef WRITECORE_H
#define WRITECORE_H

#include <QObject>
#include <QTimer>
#include <QDateTime>
#include "databasethread.h"
#include "databaseeventthread.h"
#include "logthread.h"
#include "mqttdatathread.h"
#include "dealmqttthread.h"
#include "mqtteventdatathread.h"
#include "dealmqtteventthread.h"
#include "mqttalarmdatathread.h"
#include "dealmqttalarmthread.h"

class WriteCore : public QObject
{
    Q_OBJECT
public:
    explicit WriteCore(QObject *parent = nullptr);
    ~WriteCore();
    void start();

signals:

public slots:
    void time_out();
    void mqtt_data(QString ip,QString port,QString username,QString password);
    void dbdata_log(QString log);
    void mq_log(QString log);
    void sendMqttData(QString topic,QByteArray data);
    void sendMqttEventData(QString topic,QByteArray data);
    void sendMqttAlarmData(QString topic,QByteArray data);
    void dmq_log(QString log);
    void appendSql(QString sql);
    void appendEventSql(QString sql);

private:
    QTimer *timer;
    DatabaseThread *dbthread;
    DatabaseEventThread *dbeventthread;
    LogThread *logthread;
    MqttDataThread *mqthread;
    DealMqttThread *dealmqthread;
    MqttEventDataThread *mqeventthread;
    DealMqttEventThread *dealmqeventthread;
    MqttAlarmDataThread *mqalarmthread;
    DealMqttAlarmThread *dealmqalarmthread;
};

#endif // WRITECORE_H
