#pragma once

#include "MWareInterface.h"
#include "taos.h"
#include <QtCore/QObject>
#include <QtCore/QDebug>

class TDengine : public QObject
{
    Q_OBJECT

public:
    explicit TDengine(QObject *parent = 0);
    ~TDengine();

    void exec(QString sql);

public:
    int32_t msgProcess(TAOS_RES* msg);  //消息处理
    tmq_t* buildConsumer();             //构建消费者
    tmq_list_t* buildTopicList();       //构建主题
    void topicLoop();                   //轮询主题

signals:
public slots:

private:
    QString host = "localhost";
    uint    m_nPort = 0;
    QString user = "root";
    QString dbName = "taosdata";
    QString password;

    TAOS* pConn = NULL;

public:
    void Setup(tagSetup ts);
    void subscribe(QString ch, EventSubInterface *fn);      // 订阅
    void psubscribe(QString ch, EventSubInterface *fn);     // 订阅：模式匹配
    void start();
};
