111 lines
3.2 KiB
C++
111 lines
3.2 KiB
C++
#ifndef CHISDATAMANAGE_H
|
|
#define CHISDATAMANAGE_H
|
|
|
|
#include <QMutex>
|
|
#include <QObject>
|
|
#include "CTrendGraph.h"
|
|
#include "plot/qcustomplot.h"
|
|
#include "tsdb_api/TsdbApi.h"
|
|
#include "db_his_query_api/DbHisQueryBase.h"
|
|
|
|
enum E_Data_Type
|
|
{
|
|
E_REALTIME,
|
|
E_HISTORY
|
|
};
|
|
|
|
enum E_His_Type
|
|
{
|
|
E_Invalid = -1,
|
|
E_ORIGINAL,
|
|
E_POLYMERIC
|
|
};
|
|
|
|
struct MeasurementPoint
|
|
{
|
|
iot_dbms::EnMeasPiontType type; //< 测点类型
|
|
const QString strTagName; //< 测点TAG名
|
|
};
|
|
|
|
struct TsdbCommand
|
|
{
|
|
TsdbCommand()
|
|
{
|
|
type = E_Invalid;
|
|
pVecMpKey = nullptr;
|
|
lower = -1.;
|
|
upper = -1.;
|
|
nGroupByMinute = -1;
|
|
method = iot_dbms::CM_NULL;
|
|
}
|
|
E_His_Type type;
|
|
std::vector<iot_dbms::SMeasPointKey> * pVecMpKey;
|
|
double lower;
|
|
double upper;
|
|
int nGroupByMinute;
|
|
iot_dbms::EnComputeMethod method;
|
|
};
|
|
|
|
class CHisDataManage : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit CHisDataManage(QObject *parent = nullptr);
|
|
~CHisDataManage();
|
|
|
|
bool isTsdbExuting();
|
|
|
|
signals:
|
|
void sigupdateHisOriginalData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
std::vector<std::vector<iot_dbms::SVarHisSamplePoint> *> *vecResult,
|
|
E_Data_Type type = E_HISTORY);
|
|
|
|
void sigHistoryPolymericData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
std::vector<std::vector<iot_dbms::SVarHisValue> *> *vecResult,
|
|
int nGroupByMinute);
|
|
|
|
void sigHistoryEvent(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
std::vector<std::vector<iot_dbms::SHisEventPoint> *> *vecResult,
|
|
const QString &tag);
|
|
|
|
public slots:
|
|
void release();
|
|
|
|
void postTsdbCommandQueue(E_His_Type type, std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
double lower, double upper,
|
|
int nGroupByMinute = -1,
|
|
iot_dbms::EnComputeMethod method = iot_dbms::CM_NULL);
|
|
|
|
void queryHistoryOriginalData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
double lower, double upper,
|
|
E_Data_Type type = E_HISTORY);
|
|
|
|
void queryHistoryPolymericData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
double lower, double upper,
|
|
int nGroupByMinute,
|
|
iot_dbms::EnComputeMethod method);
|
|
|
|
void queryHistoryEvents(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
|
|
double lower, double upper,
|
|
std::vector<std::vector<iot_dbms::SHisEventPoint> *> *vecResult,
|
|
const QString &tag);
|
|
|
|
protected:
|
|
bool getValidTsdbConnPtr(iot_dbms::CTsdbConnPtr &ptr);
|
|
void checkTsdbCommandQueue();
|
|
|
|
private:
|
|
bool m_TsdbExcuting;
|
|
bool m_bHasPendingCommand;
|
|
iot_dbms::CTsdbConnPtr m_tsdbConnPtr;
|
|
|
|
QList<TsdbCommand> m_listCommand;
|
|
QMutex m_mutex;
|
|
};
|
|
|
|
|
|
template <class T>
|
|
inline bool compareVarPoint(const T &a, const T &b) { return a.m_nTime < b.m_nTime; }
|
|
|
|
#endif // CHISDATAMANAGE_H
|