74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
#ifndef ALARM_R_H
|
|
#define ALARM_R_H
|
|
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QString>
|
|
|
|
class AlarmR
|
|
{
|
|
public:
|
|
AlarmR() = default;
|
|
|
|
AlarmR(const QString &endTime,
|
|
const QString &mark,
|
|
const QString &sensorGroup,
|
|
const QString &sensorId,
|
|
const QString &serial,
|
|
const QString &startTime)
|
|
: end_time(endTime)
|
|
, mark(mark)
|
|
, sensor_group(sensorGroup)
|
|
, sensor_id(sensorId)
|
|
, serial(serial)
|
|
, start_time(startTime)
|
|
{}
|
|
|
|
void parseResponse(const QJsonObject &json)
|
|
{
|
|
if (json["start_time"].isDouble()) {
|
|
start_time = QString::number(static_cast<qint64>(json["start_time"].toDouble()));
|
|
qint64 unixTime = static_cast<qint64>(json["start_time"].toDouble());
|
|
QDateTime dateTime = QDateTime::fromSecsSinceEpoch(unixTime);
|
|
start_time = dateTime.toString("dd.MM.yyyy HH:mm");
|
|
}
|
|
if (json.contains("end_time") && json["end_time"].isDouble()) {
|
|
end_time = QString::number(static_cast<qint64>(json["end_time"].toDouble()));
|
|
qint64 unixTime = static_cast<qint64>(json["end_time"].toDouble());
|
|
QDateTime dateTime = QDateTime::fromSecsSinceEpoch(unixTime);
|
|
end_time = dateTime.toString("dd.MM.yyyy HH:mm");
|
|
} else {
|
|
end_time.clear();
|
|
}
|
|
if (json.contains("mark") && json["mark"].isString()) {
|
|
mark = json["mark"].toString();
|
|
}
|
|
if (json.contains("sensor_group") && json["sensor_group"].isString()) {
|
|
sensor_group = json["sensor_group"].toString();
|
|
}
|
|
if (json.contains("sensor_id") && json["sensor_id"].isString()) {
|
|
sensor_id = json["sensor_id"].toString();
|
|
}
|
|
if (json.contains("serial") && json["serial"].isString()) {
|
|
serial = json["serial"].toString();
|
|
}
|
|
}
|
|
|
|
QString getEndTime() const { return end_time; }
|
|
QString getMark() const { return mark; }
|
|
QString getSensorGroup() const { return sensor_group; }
|
|
QString getSensorId() const { return sensor_id; }
|
|
QString getSerial() const { return serial; }
|
|
QString getStartTime() const { return start_time; }
|
|
|
|
private:
|
|
QString end_time;
|
|
QString mark;
|
|
QString sensor_group;
|
|
QString sensor_id;
|
|
QString serial;
|
|
QString start_time;
|
|
};
|
|
|
|
#endif // ALARM_R_H
|