1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #pragma once
- //#include "MWareInterface.h"
- #include "taos.h"
- #include <QtCore/QObject>
- #include <QtCore/QDebug>
- #include "libaray_symbols.h"
- #include <functional>
- #include <QFuture>
- #include <set>
- class TDENGINECLIENT_EXPORT TDengineClient : public QObject
- {
- Q_OBJECT
- public:
- explicit TDengineClient(QObject *parent = 0);
- TDengineClient(QString password,
- std::function<void(const char *, const char *, void*)>& callback)
- : password(std::move(password)), callback(callback) {}
- ~TDengineClient();
- 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 = "192.168.9.6";
- uint16_t port = 6030;
- QString user = "root";
- QString dbName = "lanpengdb";
- QString password = "x=gheLw7QMAD4zjQh3d9";
- TAOS* pConn = NULL;
- std::function<void(const char* topic, const char* data, void*usr)> callback;
- //TAOS* pConn = NULL;
- //EventSubInterface* g_pSubCB; // 订阅回调
- std::set<std::string> topicList;
- void * usrData;
- QFuture<void> future;
- public:
- //void Setup(tagSetup ts);
- void Setup(const char* host, const char* user, const char* passwd, uint16_t port);
- void subscribe(QString ch, std::function<void(const char* topic, const char* data, void*usr)>& fn, void* usrdata); // 订阅
- void psubscribe(QString ch, std::function<void(const char* topic, const char* data, void*usr)>& fn, void*usrdata); // 订阅:模式匹配
- void start();
- };
|