feat:完成电力系统事件公共模型的建模和解析
This commit is contained in:
parent
1907ec8e61
commit
b2fb1932c3
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QJsonObject>
|
||||
|
||||
enum AlarmDataMode
|
||||
{
|
||||
|
|
@ -15,7 +16,7 @@ struct EventData
|
|||
QString id;
|
||||
QString name;
|
||||
int type;
|
||||
int priority;
|
||||
int priority; //1告知、4预警、7事故
|
||||
int status;
|
||||
qint64 timestamp;
|
||||
QString stationName; //场站名称
|
||||
|
|
@ -30,8 +31,34 @@ struct EventData
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue