FemaLocalSoftware/alarm_r.h

55 lines
1.8 KiB
C
Raw Normal View History

2024-12-28 17:15:48 +00:00
#ifndef ALARM_R_H
#define ALARM_R_H
#include <QString>
#include <QJsonObject>
#include <QJsonDocument>
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.contains("end_time") && json["end_time"].isString()) {
end_time = json["end_time"].toString();
}
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();
}
if (json.contains("start_time") && json["start_time"].isString()) {
start_time = json["start_time"].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