Sensors now work over broadcast pipe

Added Polynomal actor
Added Item adding dialog
Added Factor Actor
This commit is contained in:
Carl Klemm 2020-02-04 22:56:10 +01:00
parent f6aaebafc6
commit 772d21a982
63 changed files with 1450 additions and 225 deletions

View file

@ -5,8 +5,10 @@
#include "sensoractor.h"
#include "timeractor.h"
#include "regulator.h"
#include "polynomalactor.h"
#include "factoractor.h"
Actor::Actor(QObject *parent): QObject(parent)
Actor::Actor(QObject *parent): Item(QRandomGenerator::global()->generate(), "", 0, parent)
{
}
@ -19,7 +21,6 @@ void Actor::performAction()
{
if(active)
{
trigger();
sigValue(triggerValue);
}
}
@ -61,17 +62,17 @@ bool Actor::isExausted()
void Actor::store(QJsonObject& json)
{
Item::store(json);
json["Active"] = active;
json["Exausted"] = exausted;
if(!name.isEmpty()) json["Name"] = name;
json["TriggerValue"] = triggerValue;
}
void Actor::load(const QJsonObject& json)
void Actor::load(const QJsonObject& json, const bool preserve)
{
Item::load(json, preserve);
active = json["Active"].toBool();
exausted = json["Exausted"].toBool();
name = json["Name"].toString("");
triggerValue = json["TriggerValue"].toInt();
}
@ -85,12 +86,6 @@ uint8_t Actor::getTriggerValue()
return triggerValue;
}
QString Actor::getName()
{
if(name.size() > 0) return name;
else return "Actor";
}
void Actor::onValueChanged(uint8_t value)
{
@ -103,6 +98,8 @@ Actor* Actor::createActor(const QString& type)
else if(type == "Sensor") actor = new SensorActor();
else if(type == "Timer") actor = new TimerActor();
else if(type == "Regulator") actor = new Regulator();
else if(type == "Polynomal") actor = new PolynomalActor();
else if(type == "MultiFactor") actor = new MultiFactorActor();
else if(type == "Actor") actor = new Actor();
return actor;
}
@ -114,3 +111,10 @@ Actor* Actor::loadActor(const QJsonObject &json)
if(actor) actor->load(json);
return actor;
}
void Actor::setValue(uint8_t value)
{
Item::setValue(value);
setActive(value);
}