59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
|
|
#ifndef ALARMEVENTDATASERVICE_H
|
||
|
|
#define ALARMEVENTDATASERVICE_H
|
||
|
|
|
||
|
|
#include "alarmEventGlobal.h"
|
||
|
|
#include "alarmEventUtils.h"
|
||
|
|
#include "qamqpclient.h"
|
||
|
|
#include "qamqpexchange.h"
|
||
|
|
#include "qamqpqueue.h"
|
||
|
|
|
||
|
|
class QAmqpClient;
|
||
|
|
class QAmqpQueue;
|
||
|
|
class QAmqpExchange;
|
||
|
|
|
||
|
|
class AlarmEventDataService : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
static AlarmEventDataService* instance();
|
||
|
|
bool initialize(const ServiceConfig& config);
|
||
|
|
void start();
|
||
|
|
void stop();
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void realTimeEventReceived(const EventData& event);
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void onRabbitMQConnected();
|
||
|
|
void onRabbitMQDisconnected();
|
||
|
|
void onRabbitMQError(QAMQP::Error error);
|
||
|
|
void onMessageReceived();
|
||
|
|
|
||
|
|
private:
|
||
|
|
explicit AlarmEventDataService();
|
||
|
|
~AlarmEventDataService();
|
||
|
|
|
||
|
|
//连接管理
|
||
|
|
void startRealTimeDataService();
|
||
|
|
void cleanupRabbitMQConnection();
|
||
|
|
//实时信息处理
|
||
|
|
MessageHandleResult processMessage(const QAmqpMessage& message);
|
||
|
|
EventData parseEventFromMessage(const QByteArray& data, QString& errorString);
|
||
|
|
bool validateEvent(const EventData& event);
|
||
|
|
|
||
|
|
ServiceConfig m_config;
|
||
|
|
ServiceStatus m_serviceStatus;
|
||
|
|
//ConnectionStatus m_realTimeConnectionStatus;
|
||
|
|
//ConnectionStatus m_historicalConnectionStatus;
|
||
|
|
|
||
|
|
//RabbitMQ通信相关组件
|
||
|
|
QAmqpClient* m_amqpClient;
|
||
|
|
QAmqpQueue* m_amqpQueue;
|
||
|
|
QAmqpExchange* m_amqpExchange;
|
||
|
|
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|