99 lines
3.0 KiB
C
99 lines
3.0 KiB
C
#ifndef ALARMEVENTGLOBAL_H
|
|
#define ALARMEVENTGLOBAL_H
|
|
|
|
#include <QString>
|
|
#include <QDateTime>
|
|
#include <QJsonObject>
|
|
|
|
enum AlarmDataMode
|
|
{
|
|
RealTime = 0,
|
|
Historical_All, //所有事件
|
|
Historical_Unconfirmed //未确认事件(查看所有实时报警事件时用)
|
|
};
|
|
|
|
struct PaginationInfo
|
|
{
|
|
int totalEntries;
|
|
int entriesPerPage;
|
|
int totalPages;
|
|
int currentPage;
|
|
};
|
|
|
|
struct EventData
|
|
{
|
|
QString id;
|
|
QString name;
|
|
int type;
|
|
int priority; //1告知、4预警、7事故
|
|
int status;
|
|
qint64 timestamp;
|
|
QString stationName; //场站名称
|
|
QString bayName; //间隔名称
|
|
QString severity;//严重性(等级)
|
|
QString from; //'station'、'platform'、'msa'
|
|
QString category; //存放订阅数据的标识,它和 timestamp 一起构成订阅从的requst
|
|
QString description;
|
|
QVariantMap condition; //事件发生时的简单场景描述,如{'up_limitaion': 40, 'low_limitation': 10, value: 45}
|
|
QVariantMap alarmInfo; //{"driver_name":"ssu_driver_name","device_no":"ssu000","alarm_code":1,"alarm_time":2516666461000,"alarm_status":0}
|
|
|
|
static EventData fromJson(const QJsonObject& json)
|
|
{
|
|
EventData event;
|
|
event.id = json.value("event_uuid").toString();
|
|
event.name = json.value("event").toString();
|
|
event.type = json.value("type").toInt();
|
|
event.priority = json.value("priority").toInt();
|
|
if(event.priority == 1)
|
|
event.severity = QString("告知");
|
|
else if(event.priority == 4)
|
|
event.severity = QString("预警");
|
|
else if(event.priority == 7)
|
|
event.severity = QString("事故");
|
|
else
|
|
event.severity = QString("未定义");
|
|
event.status = json.value("status").toInt();
|
|
event.timestamp = json.value("timestamp").toVariant().toLongLong();
|
|
event.from = json.value("from").toString();
|
|
event.category = json.value("category").toString();
|
|
QJsonValue conditionJValue = json.value("condition");
|
|
if(conditionJValue.isObject())
|
|
{
|
|
QJsonObject conditionObj = conditionJValue.toObject();
|
|
event.condition = conditionObj.toVariantMap();
|
|
}
|
|
QJsonValue alarmJValue = json.value("alarm");
|
|
if(alarmJValue.isObject())
|
|
{
|
|
QJsonObject alarmObj = alarmJValue.toObject();
|
|
event.alarmInfo = alarmObj.toVariantMap();
|
|
}
|
|
|
|
return event;
|
|
}
|
|
};
|
|
|
|
struct AlarmConfigurationResults
|
|
{
|
|
//级别选择
|
|
bool level_notify = true;
|
|
bool level_warining = true;
|
|
bool level_abnormal = true;
|
|
bool level_accident = true;
|
|
//类型选择
|
|
bool type_hard = true;
|
|
bool type_platformSoft = true;
|
|
bool type_appSoft = true;
|
|
//提示行为
|
|
bool notify_sound = true;
|
|
bool notify_autoPop = true;
|
|
//自动弹窗级别
|
|
bool autoPop_nofity = false;
|
|
bool autoPop_warining = false;
|
|
bool autoPop_abnormal = false;
|
|
bool autoPop_accident = true;
|
|
};
|
|
extern AlarmConfigurationResults g_alarmCfgResults;
|
|
|
|
#endif
|