111 lines
3.2 KiB
C
Raw Normal View History

2025-03-17 15:06:54 +08:00
#ifndef CHISDATAMANAGE_H
2025-03-14 17:05:48 +08:00
#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
{
2025-03-17 09:23:17 +08:00
iot_dbms::EnMeasPiontType type; //< 测点类型
2025-03-14 17:05:48 +08:00
const QString strTagName; //< 测点TAG名
};
struct TsdbCommand
{
TsdbCommand()
{
type = E_Invalid;
pVecMpKey = nullptr;
lower = -1.;
upper = -1.;
nGroupByMinute = -1;
2025-03-17 09:23:17 +08:00
method = iot_dbms::CM_NULL;
2025-03-14 17:05:48 +08:00
}
E_His_Type type;
2025-03-17 09:23:17 +08:00
std::vector<iot_dbms::SMeasPointKey> * pVecMpKey;
2025-03-14 17:05:48 +08:00
double lower;
double upper;
int nGroupByMinute;
2025-03-17 09:23:17 +08:00
iot_dbms::EnComputeMethod method;
2025-03-14 17:05:48 +08:00
};
class CHisDataManage : public QObject
{
Q_OBJECT
public:
explicit CHisDataManage(QObject *parent = nullptr);
~CHisDataManage();
bool isTsdbExuting();
signals:
2025-03-17 09:23:17 +08:00
void sigupdateHisOriginalData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
std::vector<std::vector<iot_dbms::SVarHisSamplePoint> *> *vecResult,
2025-03-14 17:05:48 +08:00
E_Data_Type type = E_HISTORY);
2025-03-17 09:23:17 +08:00
void sigHistoryPolymericData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
std::vector<std::vector<iot_dbms::SVarHisValue> *> *vecResult,
2025-03-14 17:05:48 +08:00
int nGroupByMinute);
2025-03-17 09:23:17 +08:00
void sigHistoryEvent(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
std::vector<std::vector<iot_dbms::SHisEventPoint> *> *vecResult,
2025-03-14 17:05:48 +08:00
const QString &tag);
public slots:
void release();
2025-03-17 09:23:17 +08:00
void postTsdbCommandQueue(E_His_Type type, std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
2025-03-14 17:05:48 +08:00
double lower, double upper,
int nGroupByMinute = -1,
2025-03-17 09:23:17 +08:00
iot_dbms::EnComputeMethod method = iot_dbms::CM_NULL);
2025-03-14 17:05:48 +08:00
2025-03-17 09:23:17 +08:00
void queryHistoryOriginalData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
2025-03-14 17:05:48 +08:00
double lower, double upper,
E_Data_Type type = E_HISTORY);
2025-03-17 09:23:17 +08:00
void queryHistoryPolymericData(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
2025-03-14 17:05:48 +08:00
double lower, double upper,
int nGroupByMinute,
2025-03-17 09:23:17 +08:00
iot_dbms::EnComputeMethod method);
2025-03-14 17:05:48 +08:00
2025-03-17 09:23:17 +08:00
void queryHistoryEvents(std::vector<iot_dbms::SMeasPointKey> *vecMpKey,
2025-03-14 17:05:48 +08:00
double lower, double upper,
2025-03-17 09:23:17 +08:00
std::vector<std::vector<iot_dbms::SHisEventPoint> *> *vecResult,
2025-03-14 17:05:48 +08:00
const QString &tag);
protected:
2025-03-17 09:23:17 +08:00
bool getValidTsdbConnPtr(iot_dbms::CTsdbConnPtr &ptr);
2025-03-14 17:05:48 +08:00
void checkTsdbCommandQueue();
private:
bool m_TsdbExcuting;
bool m_bHasPendingCommand;
2025-03-17 09:23:17 +08:00
iot_dbms::CTsdbConnPtr m_tsdbConnPtr;
2025-03-14 17:05:48 +08:00
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