Support different Sensor update types
This commit is contained in:
parent
ff07551a59
commit
09f7e55b4e
20 changed files with 258 additions and 41 deletions
|
|
@ -98,7 +98,7 @@ public:
|
|||
QString::number((type == Sensor::TYPE_HUMIDITY || type == Sensor::TYPE_TEMPERATURE) ? field*10 : field) +
|
||||
" TIME: " + QString::number(lastSeen.toSecsSinceEpoch());
|
||||
}
|
||||
inline void store(QJsonObject& json)
|
||||
inline void store(QJsonObject& json) const
|
||||
{
|
||||
json["Type"] = "Sensor";
|
||||
json["SensorType"] = static_cast<int>(type);
|
||||
|
|
@ -127,7 +127,7 @@ public:
|
|||
name = "Shutdown Imminent";
|
||||
else name = "Sensor Type " + QString::number(type) + " Id " + QString::number(id);
|
||||
}
|
||||
QString getUnit()
|
||||
QString getUnit() const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
|
@ -160,11 +160,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SENSOR_UPDATE_USER = 0,
|
||||
SENSOR_UPDATE_BACKEND,
|
||||
SENSOR_UPDATE_REMOTE,
|
||||
SENSOR_UPDATE_INVALID
|
||||
} sensor_update_type_t;
|
||||
|
||||
class SensorStore: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::vector<Sensor> sensors_;
|
||||
std::vector<Sensor> knownSensors_;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -176,15 +184,17 @@ public:
|
|||
return &sensors_;
|
||||
}
|
||||
|
||||
void store(QJsonObject& json);
|
||||
void load(const QJsonObject& json);
|
||||
|
||||
public slots:
|
||||
|
||||
void sensorGotState(const Sensor& sensor);
|
||||
void sensorGotState(const Sensor& sensor, sensor_update_type_t type = SENSOR_UPDATE_BACKEND);
|
||||
|
||||
signals:
|
||||
|
||||
void stateChenged(std::vector<Sensor> sensors);
|
||||
void sensorChangedState(Sensor sensor);
|
||||
void sensorChangedState(Sensor sensor, sensor_update_type_t type);
|
||||
void sensorDeleted(Sensor sensor);
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue