diff --git a/src/actors/sensoractor.cpp b/src/actors/sensoractor.cpp index cc15418..5e083ef 100644 --- a/src/actors/sensoractor.cpp +++ b/src/actors/sensoractor.cpp @@ -4,12 +4,12 @@ SensorActor::SensorActor(const Sensor sensor, QObject* parent): Actor(parent), sensor_(sensor) { - connect(&timer_, &QTimer::timeout, this, &SensorActor::delayTimeout); + } SensorActor::SensorActor(QObject* parent): Actor(parent) { - connect(&timer_, &QTimer::timeout, this, &SensorActor::delayTimeout); + } void SensorActor::setSensor(const Sensor sensor) @@ -17,25 +17,14 @@ void SensorActor::setSensor(const Sensor sensor) sensor_ = sensor; } -void SensorActor::delayTimeout() -{ - performAction(); -} - void SensorActor::sensorEvent(Sensor sensor, sensor_update_type_t type) { if(sensor == sensor_) { if((sloap_ == SLOPE_UP || sloap_ == SLOPE_BOTH) && sensor_.field < threshold_ - && sensor.field >= threshold_ ) - { - timer_.start(delayMs_); - } + && sensor.field >= threshold_ ) performAction(); else if((sloap_ == SLOPE_DOWN || sloap_ == SLOPE_BOTH) && sensor_.field > threshold_ - && sensor.field <= threshold_) - { - timer_.start(delayMs_); - } + && sensor.field <= threshold_) performAction(); sensor_ = sensor; } } @@ -50,33 +39,21 @@ void SensorActor::setThreshold(float threshold) threshold_ = threshold; } -void SensorActor::setDelayMs(int ms) -{ - delayMs_ = ms; -} - float SensorActor::getThreshold() { return threshold_; } - uint8_t SensorActor::getSloap() { return sloap_; } -int SensorActor::getDelayMs() -{ - return delayMs_; -} - void SensorActor::store(QJsonObject& json) { json["Type"] = "Sensor"; Actor::store(json); json["Sloap"] = sloap_; json["Threshold"] = threshold_; - json["Delay"] = delayMs_; json["SensorType"] = static_cast(sensor_.type); json["SensorId"] = static_cast(sensor_.id); json["SensorField"] = sensor_.field; @@ -88,7 +65,6 @@ void SensorActor::load(const QJsonObject& json, bool preserve) Actor::load(json, preserve); sloap_ = json["Sloap"].toInt(0); threshold_ = json["Threshold"].toDouble(0); - delayMs_ = json["Delay"].toInt(0); sensor_.type = static_cast(json["SensorType"].toInt(0)); sensor_.id = json["SensorId"].toInt(0); sensor_.field = json["SensorField"].toInt(0); @@ -108,9 +84,6 @@ QString SensorActor::getName() const else if (sloap_ == SLOPE_BOTH) string.append(" passes "); string.append(QString::number(threshold_) + " "); - - if(delayMs_ > 0) string.append("(+" + QString::number(delayMs_) + "ms) "); - return string; } } diff --git a/src/actors/sensoractor.h b/src/actors/sensoractor.h index a233541..99e2865 100644 --- a/src/actors/sensoractor.h +++ b/src/actors/sensoractor.h @@ -1,7 +1,6 @@ #pragma once #include "actor.h" #include "sensors/sensor.h" -#include class SensorActor : public Actor { @@ -16,11 +15,6 @@ private: Sensor sensor_; uint8_t sloap_ = SLOPE_UP; float threshold_ = 0; - int delayMs_ = 0; - QTimer timer_; - -private slots: - void delayTimeout(); public slots: @@ -28,9 +22,7 @@ public slots: void setSloap(uint8_t sloap); void setSensor(const Sensor sensor); - void setThreshold(float threshold); - void setDelayMs(int ms); - int getDelayMs(); + void setThreshold( float threshold ); public: diff --git a/src/ui/actorwidgets/sensoractorwidget.cpp b/src/ui/actorwidgets/sensoractorwidget.cpp index 58d64bc..2718b1b 100644 --- a/src/ui/actorwidgets/sensoractorwidget.cpp +++ b/src/ui/actorwidgets/sensoractorwidget.cpp @@ -26,12 +26,9 @@ SensorActorWidget::SensorActorWidget(std::shared_ptr sensorActor, S ui->doubleSpinBox_threshold->setValue(sensorActor_->getThreshold()); - ui->spinBox_delay->setValue(sensorActor_->getDelayMs()); - connect(ui->listView, &SensorListWidget::clicked, this, &SensorActorWidget::setSensor); connect(ui->doubleSpinBox_threshold, SIGNAL(valueChanged(double)), this, SLOT(setThreshold(double))); connect(ui->comboBox_slope, SIGNAL(currentIndexChanged(int)), this, SLOT(setSlope(int))); - connect(ui->spinBox_delay, SIGNAL(valueChanged(int)), this, SLOT(setDelay(int))); } SensorActorWidget::~SensorActorWidget() @@ -55,8 +52,3 @@ void SensorActorWidget::setSensor(const QModelIndex &index) { sensorActor_->setSensor(ui->listView->getSensorForIndex(index)); } - -void SensorActorWidget::setDelay(int ms) -{ - sensorActor_->setDelayMs(ms); -} diff --git a/src/ui/actorwidgets/sensoractorwidget.h b/src/ui/actorwidgets/sensoractorwidget.h index 3552769..3501977 100644 --- a/src/ui/actorwidgets/sensoractorwidget.h +++ b/src/ui/actorwidgets/sensoractorwidget.h @@ -27,7 +27,6 @@ private slots: void setThreshold(double in); void setSlope(int index); void setSensor(const QModelIndex &index); - void setDelay(int ms); private: Ui::SensorActorWidget *ui; diff --git a/src/ui/actorwidgets/sensoractorwidget.ui b/src/ui/actorwidgets/sensoractorwidget.ui index e489d52..5f49c96 100644 --- a/src/ui/actorwidgets/sensoractorwidget.ui +++ b/src/ui/actorwidgets/sensoractorwidget.ui @@ -13,8 +13,8 @@ Form - - + + @@ -27,7 +27,7 @@ - + @@ -37,90 +37,51 @@ - - - - Threshold - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - + + - - > = - + + + Threshold + + - - < = - + + + + 0 + 0 + + + + + > = + + + + + < = + + + + + Passes + + + - - Passes - + + + -9999.989999999999782 + + + 9999.989999999999782 + + - - - - - - -9999.989999999999782 - - - 9999.989999999999782 - - - - - - - Delay - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - ms - - - 9999999 - - + @@ -128,7 +89,7 @@ SensorListWidget QListView -
ui/sensorlistwidget.h
+
ui/sensorlistwidget.h