12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #pragma once
- //#include "MWareInterface.h"
- #include "taos.h"
- #include <QtCore/QObject>
- #include <QtCore/QDebug>
- #include "libaray_symbols.h"
- #include <functional>
- 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(std::move(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";
- uint port = 6041;
- 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::list<std::string> topicList;
- void * usrData;
- public:
- //void Setup(tagSetup ts);
- void Setup(const char* host, const char* user, const char* passwd, uint 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();
- };
|