Sensors now work over broadcast pipe

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

View File

@ -0,0 +1,80 @@
#include "factoractor.h"
MultiFactorActor::MultiFactorActor(Actor* factorActor, const uint preCancleMin, QObject *parent):
Actor(parent),
factorActor_(factorActor),
preCancleMin_(preCancleMin)
{
activationTime.setMSecsSinceEpoch(0);
if(factorActor) connect(factorActor, &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
}
void MultiFactorActor::factorActorSlot(uint8_t value)
{
if(value == factorDirection)
{
activationTime = QDateTime::currentDateTime();
}
}
void MultiFactorActor::setValue(uint8_t value)
{
if(value)
{
QDateTime current = QDateTime::currentDateTime();
if(current.addSecs(-preCancleMin_*60) > activationTime )
{
performAction();
}
bool exausted = true;
for(size_t i = 0; i < getActors().size(); ++i) if(!getActors()[i]->isExausted()) exausted = false;
}
}
QString MultiFactorActor::getName() const
{
if(name_.size() > 0) return name_;
else
{
QString string;
string = "Multi Factor \"" + (factorActor_ ? factorActor_->getName() : "NULL") + "\"";
return string;
}
}
void MultiFactorActor::setFactorActor(Actor* factorActor)
{
if(factorActor_) delete factorActor_;
factorActor_=factorActor;
connect(factorActor_, &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
}
void MultiFactorActor::store(QJsonObject &json)
{
json["Type"] = "MultiFactor";
Actor::store(json);
json["PreCancleMinutes"] = static_cast<int>(preCancleMin_);
json["FactorDirection"] = factorDirection;
QJsonObject factorActorObject;
if(factorActor_)
{
factorActor_->store(factorActorObject);
}
}
void MultiFactorActor::load(const QJsonObject &json, bool preserve)
{
Actor::load(json, preserve);
preCancleMin_ = static_cast<uint>(json["PreCancleMinutes"].toInt(10));
factorDirection = json["FacotorDirection"].toBool(true);
if(json["FactorActor"].isObject())
{
factorActor_ = Actor::loadActor(json["FactorActor"].toObject());
}
if(factorActor_)
{
connect(factorActor_, &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
}
}