Major wip refactor
Allow running without gui Remove serialPortMultiplexer broadcast use Add TcpServer and TcpClient Introduce the concept of an item source
This commit is contained in:
parent
cbeb8d49a7
commit
6d742e60db
38 changed files with 928 additions and 825 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include<QDateTime>
|
||||
#include<QObject>
|
||||
#include<vector>
|
||||
#include<QJsonObject>
|
||||
|
||||
class Sensor
|
||||
{
|
||||
|
|
@ -41,6 +42,15 @@ public:
|
|||
{
|
||||
lastSeen = QDateTime::currentDateTime();
|
||||
}
|
||||
Sensor(const QJsonObject& json)
|
||||
{
|
||||
type = json["SensorType"].toInt(0);
|
||||
id = json["Id"].toInt(0);
|
||||
field = json["Field"].toInt(0);
|
||||
name = json["Name"].toString("Sensor");
|
||||
lastSeen = QDateTime::fromString(json["LastSeen"].toString(""));
|
||||
hidden = json["Hidden"].toBool(false);
|
||||
}
|
||||
inline bool operator==(const Sensor& in) const
|
||||
{
|
||||
return type==in.type && id == in.id;
|
||||
|
|
@ -77,15 +87,32 @@ public:
|
|||
QString::number((type == Sensor::TYPE_HUMIDITY || type == Sensor::TYPE_TEMPERATURE) ? field*10 : field) +
|
||||
" TIME: " + QString::number(lastSeen.toSecsSinceEpoch());
|
||||
}
|
||||
inline void store(QJsonObject& json)
|
||||
{
|
||||
json["Type"] = "Sensor";
|
||||
json["SensorType"] = static_cast<int>(type);
|
||||
json["Id"] = static_cast<int>(id);
|
||||
json["Field"] = field;
|
||||
json["Name"] = name;
|
||||
json["LastSeen"] = lastSeen.toString();
|
||||
json["Hidden"] = hidden;
|
||||
}
|
||||
inline void generateName()
|
||||
{
|
||||
if(type == TYPE_TEMPERATURE) name = "Temperature " + QString::number(id);
|
||||
else if(type == TYPE_DOOR) name = "Door " + QString::number(id);
|
||||
else if(type == TYPE_BUTTON) name = "Button " + QString::number(id);
|
||||
else if(type == TYPE_AUDIO_OUTPUT) name = "Speakers " + QString::number(id);
|
||||
else if(type == TYPE_HUMIDITY) name = "Humidity " + QString::number(id);
|
||||
else if(type == TYPE_SUN_ALTITUDE) name = "Solar Altitude";
|
||||
else if(type == TYPE_SHUTDOWN_IMMINENT) name = "Shutdown Imminent";
|
||||
if(type == TYPE_TEMPERATURE)
|
||||
name = "Temperature " + QString::number(id);
|
||||
else if(type == TYPE_DOOR)
|
||||
name = "Door " + QString::number(id);
|
||||
else if(type == TYPE_BUTTON)
|
||||
name = "Button " + QString::number(id);
|
||||
else if(type == TYPE_AUDIO_OUTPUT)
|
||||
name = "Speakers " + QString::number(id);
|
||||
else if(type == TYPE_HUMIDITY)
|
||||
name = "Humidity " + QString::number(id);
|
||||
else if(type == TYPE_SUN_ALTITUDE)
|
||||
name = "Solar Altitude";
|
||||
else if(type == TYPE_SHUTDOWN_IMMINENT)
|
||||
name = "Shutdown Imminent";
|
||||
else name = "Sensor Type " + QString::number(type) + " Id " + QString::number(id);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue