ocupancy sensor now uses libnl to collect connected devices
fixed regulator saving values as int instead of double
This commit is contained in:
parent
772d21a982
commit
b0b4a985e9
15 changed files with 93 additions and 44 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#include "mainobject.h"
|
||||
#include "mainobject.h"
|
||||
|
||||
MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const bool masterIn, QObject *parent) :
|
||||
QObject(parent),
|
||||
|
|
@ -20,6 +20,8 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
|
|||
QObject::connect(&globalSensors, &SensorStore::sensorChangedState, &ocupancySensor, &OcupancySensorSource::sensorEvent);
|
||||
QObject::connect(&ocupancySensor, &OcupancySensorSource::stateChanged, &globalSensors, &SensorStore::sensorGotState);
|
||||
|
||||
sunSensorSource.run();
|
||||
|
||||
//connect item store
|
||||
QObject::connect(µ, &Microcontroller::gotRelayList, &items, &ItemStore::addItems);
|
||||
QObject::connect(µ, &Microcontroller::itemChanged, &items, &ItemStore::itemStateChanged);
|
||||
|
|
@ -30,6 +32,8 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
|
|||
items.addItem(rgbItem);
|
||||
items.addItem(auxItem);
|
||||
|
||||
Relay::setMicrocontroller(µ);
|
||||
|
||||
connect(&broadCast, &BroadCast::gotJson, this, &MainObject::recivedJson);
|
||||
QObject::connect(&broadCast, &BroadCast::gotSensorState, &globalSensors, &SensorStore::sensorGotState);
|
||||
if(master)connect(&broadCast, &BroadCast::jsonRequested, this, &MainObject::sendJson);
|
||||
|
|
@ -60,6 +64,9 @@ void MainObject::store(QJsonObject &json)
|
|||
items.store(json);
|
||||
QJsonObject powerObject;
|
||||
powerItem.store(powerObject);
|
||||
QJsonObject ocupancyObject;
|
||||
ocupancySensor.store(ocupancyObject);
|
||||
json.insert("Ocupancy", ocupancyObject);
|
||||
json.insert("Power", powerObject);
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +78,9 @@ void MainObject::load(const QJsonObject& json)
|
|||
powerItem.removeAllActors();
|
||||
items.addItem(rgbItem);
|
||||
items.addItem(auxItem);
|
||||
items.load(json, µ);
|
||||
items.load(json);
|
||||
powerItem.load(json["Power"].toObject());
|
||||
ocupancySensor.load(json["Ocupancy"].toObject());
|
||||
qDebug()<<"aray size: "<<json.isEmpty();
|
||||
if(json["Items"].toArray().size() >= 2)
|
||||
{
|
||||
|
|
@ -84,7 +92,7 @@ void MainObject::load(const QJsonObject& json)
|
|||
|
||||
void MainObject::recivedJson(const QJsonObject json)
|
||||
{
|
||||
if(master)storeJsonObjectToDisk(json, settingsPath);
|
||||
if(master && !noSave)storeJsonObjectToDisk(json, settingsPath);
|
||||
load(json);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue