Sensors now work over broadcast pipe
Added Polynomal actor Added Item adding dialog Added Factor Actor
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
SensorStore globalSensors;
|
||||
|
||||
SensorStore::SensorStore(QObject *parent): QObject(parent)
|
||||
{
|
||||
sensors_.push_back(Sensor(0,1,0,"Front door"));
|
||||
@ -43,3 +45,5 @@ void SensorStore::sensorGotState(const Sensor& sensor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
static constexpr uint8_t TYPE_HUMIDITY = 2;
|
||||
static constexpr uint8_t TYPE_PRESSURE = 3;
|
||||
static constexpr uint8_t TYPE_BRIGHTNESS = 4;
|
||||
static constexpr uint8_t TYPE_BUTTON = 5;
|
||||
static constexpr uint8_t TYPE_LOWBATTERY = 128;
|
||||
static constexpr uint8_t TYPE_SHUTDOWN_IMMINENT = 251;
|
||||
static constexpr uint8_t TYPE_OCUPANCY = 252;
|
||||
@ -26,23 +27,36 @@ public:
|
||||
float field;
|
||||
QString name;
|
||||
QDateTime lastSeen;
|
||||
bool hidden;
|
||||
|
||||
Sensor(uint8_t typeIn, uint8_t idIn, float fieldIn = 0, QString nameIn = ""): type(typeIn), id(idIn), field(fieldIn), name(nameIn)
|
||||
Sensor(uint8_t typeIn, uint8_t idIn, float fieldIn = 0, QString nameIn = "", bool hiddenIn = false): type(typeIn), id(idIn), field(fieldIn), name(nameIn), hidden(hiddenIn)
|
||||
{
|
||||
lastSeen = QDateTime::currentDateTime();
|
||||
if(nameIn == "") generateName();
|
||||
}
|
||||
Sensor(QString nameIn = "dummy"): type(TYPE_DUMMY), id(0), field(0), name(nameIn)
|
||||
Sensor(QString nameIn = "dummy"): type(TYPE_DUMMY), id(0), field(0), name(nameIn), hidden(false)
|
||||
{
|
||||
lastSeen = QDateTime::currentDateTime();
|
||||
}
|
||||
inline bool operator==(const Sensor& in){ return type==in.type && id == in.id; }
|
||||
inline bool operator!=(const Sensor& in){ return !(*this==in); }
|
||||
inline bool operator==(const Sensor& in) const{ return type==in.type && id == in.id; }
|
||||
inline bool operator!=(const Sensor& in) const{ return !(*this==in); }
|
||||
inline void updateSeen(){lastSeen = QDateTime::currentDateTime();}
|
||||
static Sensor sensorFromString(const QString& str)
|
||||
{
|
||||
QStringList bufferList = str.split(' ');
|
||||
if(bufferList.size() >= 7)
|
||||
{
|
||||
Sensor sensor(bufferList[2].toUInt(), bufferList[4].toUInt(), bufferList[6].toUInt());
|
||||
if(sensor.type == Sensor::TYPE_HUMIDITY || sensor.type == Sensor::TYPE_TEMPERATURE) sensor.field = sensor.field/10;
|
||||
return sensor;
|
||||
}
|
||||
else return Sensor(TYPE_DUMMY, 0, 0, "", true);
|
||||
}
|
||||
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";
|
||||
@ -64,6 +78,7 @@ public:
|
||||
|
||||
inline std::vector<Sensor>* getSensors(){ return &sensors_; }
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
void sensorGotState(const Sensor& sensor);
|
||||
@ -75,3 +90,5 @@ signals:
|
||||
void sensorDeleted(Sensor sensor);
|
||||
|
||||
};
|
||||
|
||||
extern SensorStore globalSensors;
|
||||
|
Reference in New Issue
Block a user