Added system item support, support for RGBControlers with multiple item backends, and item settings widgets
This commit is contained in:
parent
a761eb4317
commit
5fb9ca7cc0
56 changed files with 635 additions and 210 deletions
|
|
@ -91,23 +91,23 @@ void Actor::onValueChanged(uint8_t value)
|
|||
|
||||
}
|
||||
|
||||
Actor* Actor::createActor(const QString& type)
|
||||
std::shared_ptr<Actor> Actor::createActor(const QString& type)
|
||||
{
|
||||
Actor* actor = nullptr;
|
||||
if(type == "Alarm") actor = new AlarmTime();
|
||||
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();
|
||||
std::shared_ptr<Actor> actor;
|
||||
if(type == "Alarm") actor = std::shared_ptr<Actor>(new AlarmTime());
|
||||
else if(type == "Sensor") actor = std::shared_ptr<Actor>(new SensorActor());
|
||||
else if(type == "Timer") actor = std::shared_ptr<Actor>(new TimerActor());
|
||||
else if(type == "Regulator") actor = std::shared_ptr<Actor>(new Regulator());
|
||||
else if(type == "Polynomal") actor = std::shared_ptr<Actor>(new PolynomalActor());
|
||||
else if(type == "MultiFactor") actor = std::shared_ptr<Actor>(new MultiFactorActor());
|
||||
else if(type == "Actor") actor = std::shared_ptr<Actor>(new Actor());
|
||||
return actor;
|
||||
}
|
||||
|
||||
Actor* Actor::loadActor(const QJsonObject &json)
|
||||
std::shared_ptr<Actor> Actor::loadActor(const QJsonObject &json)
|
||||
{
|
||||
QString type = json["Type"].toString("Actor");
|
||||
Actor* actor = createActor(type);
|
||||
std::shared_ptr<Actor> actor = createActor(type);
|
||||
if(actor) actor->load(json);
|
||||
return actor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ public:
|
|||
|
||||
uint8_t getTriggerValue();
|
||||
|
||||
static Actor* createActor(const QString& type);
|
||||
static std::shared_ptr<Actor> createActor(const QString& type);
|
||||
|
||||
virtual void store(QJsonObject& json);
|
||||
virtual void load(const QJsonObject& json, const bool preserve = false);
|
||||
static Actor* loadActor(const QJsonObject& json);
|
||||
static std::shared_ptr<Actor> loadActor(const QJsonObject& json);
|
||||
};
|
||||
|
||||
#endif // ACTOR_H
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ void AlarmTime::run()
|
|||
|
||||
active = true;
|
||||
timer.start();
|
||||
|
||||
qDebug()<<"Start Alarm Time Manager\n";
|
||||
}
|
||||
|
||||
void AlarmTime::makeActive()
|
||||
|
|
@ -64,6 +62,7 @@ QString AlarmTime::getName() const
|
|||
void AlarmTime::setRepeat(const uint8_t repeat)
|
||||
{
|
||||
repeat_=repeat;
|
||||
exausted = false;
|
||||
}
|
||||
|
||||
uint8_t AlarmTime::getRepeat()
|
||||
|
|
@ -112,6 +111,7 @@ void AlarmTime::doTick()
|
|||
void AlarmTime::changeTime(const QDateTime& time)
|
||||
{
|
||||
time_=time;
|
||||
exausted = false;
|
||||
qDebug()<<"time: "<<time_;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,10 @@ QString MultiFactorActor::getName() const
|
|||
}
|
||||
}
|
||||
|
||||
void MultiFactorActor::setFactorActor(Actor* factorActor)
|
||||
void MultiFactorActor::setFactorActor(std::shared_ptr<Actor> factorActor)
|
||||
{
|
||||
if(factorActor_) delete factorActor_;
|
||||
factorActor_=factorActor;
|
||||
connect(factorActor_, &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
|
||||
connect(factorActor_.get(), &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
|
||||
}
|
||||
|
||||
void MultiFactorActor::store(QJsonObject &json)
|
||||
|
|
@ -73,7 +72,7 @@ void MultiFactorActor::load(const QJsonObject &json, bool preserve)
|
|||
}
|
||||
if(factorActor_)
|
||||
{
|
||||
connect(factorActor_, &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
|
||||
connect(factorActor_.get(), &Actor::sigValue, this, &MultiFactorActor::factorActorSlot);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class MultiFactorActor: public Actor
|
|||
{
|
||||
private:
|
||||
|
||||
Actor* factorActor_;
|
||||
std::shared_ptr<Actor> factorActor_;
|
||||
QDateTime activationTime;
|
||||
uint preCancleMin_;
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ public:
|
|||
|
||||
virtual QString getName() const;
|
||||
|
||||
void setFactorActor(Actor* factorActor);
|
||||
Actor* getFactorActor(){return factorActor_;}
|
||||
void setFactorActor(std::shared_ptr<Actor> factorActor);
|
||||
std::shared_ptr<Actor> getFactorActor(){return factorActor_;}
|
||||
void setFactorDirection(const bool direction){factorDirection = direction;}
|
||||
bool getFactorDirection(){return factorDirection;}
|
||||
uint getPreCancleTime(){return preCancleMin_;}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ QString PolynomalActor::getName() const
|
|||
else
|
||||
{
|
||||
QString string;
|
||||
string = QString::number(pow3_) + "x^2 + " + QString::number(pow2_) + "x^2 + " + QString::number(pow1_) + "x + " + QString::number(pow0_) + " (x: " + sensor_.name + ")";
|
||||
string = QString::number(pow3_) + "x^3 + " + QString::number(pow2_) + "x^2 + " + QString::number(pow1_) + "x + " + QString::number(pow0_) + " (x: " + sensor_.name + ")";
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ void Regulator::sensorEvent(Sensor sensor)
|
|||
{
|
||||
if(active && sensor == sensor_)
|
||||
{
|
||||
qDebug()<<"got sensor: "<<sensor.type<<" "<<sensor.id<<" want: "<<sensor_.type<<" "<<sensor_.id;
|
||||
if( sensor.field < setPoint_-band_ && (sensor.field < sensor_.field || sensor_.field > setPoint_-band_ || first) )
|
||||
{
|
||||
sigValue(triggerValue);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ void SensorActor::sensorEvent(Sensor sensor)
|
|||
{
|
||||
if(sensor == sensor_)
|
||||
{
|
||||
qDebug()<<"got sensor: "<<sensor.type<<" "<<sensor.id<<" want: "<<sensor_.type<<" "<<sensor_.id;
|
||||
if((sloap_ == SLOPE_UP || sloap_ == SLOPE_BOTH) && sensor_.field < threshold_ && sensor.field >= threshold_ ) performAction();
|
||||
else if((sloap_ == SLOPE_DOWN || sloap_ == SLOPE_BOTH) && sensor_.field > threshold_ && sensor.field <= threshold_) performAction();
|
||||
sensor_ = sensor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue