Compare commits
3 commits
d8471789b7
...
d30c9546b1
| Author | SHA1 | Date | |
|---|---|---|---|
| d30c9546b1 | |||
| 0c5603ca44 | |||
| 271330d5fd |
13 changed files with 225 additions and 37 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui widgets network multimedia
|
QT += core gui widgets network multimedia
|
||||||
|
|
||||||
QT += serialport
|
QT += serialport
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@
|
||||||
|
|
||||||
Regulator::Regulator(const Sensor sensor, QObject* parent): Actor(parent), sensor_(sensor)
|
Regulator::Regulator(const Sensor sensor, QObject* parent): Actor(parent), sensor_(sensor)
|
||||||
{
|
{
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
timer.start(timeout_*1000);
|
||||||
|
connect(&timer, &QTimer::timeout, this, &Regulator::timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
Regulator::Regulator(QObject* parent): Actor(parent)
|
Regulator::Regulator(QObject* parent): Actor(parent)
|
||||||
{
|
{
|
||||||
|
timer.setSingleShot(true);
|
||||||
|
timer.start(timeout_*1000);
|
||||||
|
connect(&timer, &QTimer::timeout, this, &Regulator::timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Regulator::setSensor(const Sensor sensor)
|
void Regulator::setSensor(const Sensor sensor)
|
||||||
|
|
@ -21,6 +25,7 @@ void Regulator::sensorEvent(Sensor sensor)
|
||||||
{
|
{
|
||||||
if(active && sensor == sensor_)
|
if(active && sensor == sensor_)
|
||||||
{
|
{
|
||||||
|
timer.start(timeout_*1000);
|
||||||
if( sensor.field < setPoint_-band_ && (sensor.field < sensor_.field || sensor_.field > setPoint_-band_ || first) )
|
if( sensor.field < setPoint_-band_ && (sensor.field < sensor_.field || sensor_.field > setPoint_-band_ || first) )
|
||||||
{
|
{
|
||||||
sigValue(triggerValue);
|
sigValue(triggerValue);
|
||||||
|
|
@ -39,9 +44,15 @@ void Regulator::makeInactive()
|
||||||
first = true;
|
first = true;
|
||||||
if(active)
|
if(active)
|
||||||
sigValue(!triggerValue);
|
sigValue(!triggerValue);
|
||||||
|
timer.stop();
|
||||||
Actor::makeInactive();
|
Actor::makeInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Regulator::timeout()
|
||||||
|
{
|
||||||
|
sigValue(safeValue_);
|
||||||
|
}
|
||||||
|
|
||||||
void Regulator::setPoint(float setPoint)
|
void Regulator::setPoint(float setPoint)
|
||||||
{
|
{
|
||||||
setPoint_ = setPoint;
|
setPoint_ = setPoint;
|
||||||
|
|
@ -57,12 +68,25 @@ void Regulator::setInvert( bool invert )
|
||||||
invert_ = invert;
|
invert_ = invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Regulator::setSafeValue(int value)
|
||||||
|
{
|
||||||
|
safeValue_ = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Regulator::setTimeout(int value)
|
||||||
|
{
|
||||||
|
timeout_ = value;
|
||||||
|
timer.start(timeout_*1000);
|
||||||
|
}
|
||||||
|
|
||||||
void Regulator::store(QJsonObject& json)
|
void Regulator::store(QJsonObject& json)
|
||||||
{
|
{
|
||||||
json["Type"] = "Regulator";
|
json["Type"] = "Regulator";
|
||||||
Actor::store(json);
|
Actor::store(json);
|
||||||
json["Band"] = band_;
|
json["Band"] = band_;
|
||||||
json["SetPoint"] = setPoint_;
|
json["SetPoint"] = setPoint_;
|
||||||
|
json["SafeValue"] = safeValue_;
|
||||||
|
json["Timeout"] = timeout_;
|
||||||
json["SensorType"] = static_cast<int>(sensor_.type);
|
json["SensorType"] = static_cast<int>(sensor_.type);
|
||||||
json["SensorId"] = static_cast<int>(sensor_.id);
|
json["SensorId"] = static_cast<int>(sensor_.id);
|
||||||
json["SensorField"] = sensor_.field;
|
json["SensorField"] = sensor_.field;
|
||||||
|
|
@ -74,15 +98,21 @@ void Regulator::load(const QJsonObject& json, bool preserve)
|
||||||
Actor::load(json, preserve);
|
Actor::load(json, preserve);
|
||||||
band_ = json["Band"].toDouble(1);
|
band_ = json["Band"].toDouble(1);
|
||||||
setPoint_ = json["SetPoint"].toDouble(22);
|
setPoint_ = json["SetPoint"].toDouble(22);
|
||||||
|
safeValue_ = json["SafeValue"].toDouble(0);
|
||||||
|
timeout_ = json["Timeout"].toDouble(1800);
|
||||||
sensor_.type = json["SensorType"].toInt(0);
|
sensor_.type = json["SensorType"].toInt(0);
|
||||||
sensor_.id = json["SensorId"].toInt(0);
|
sensor_.id = json["SensorId"].toInt(0);
|
||||||
sensor_.field = json["SensorField"].toInt(0);
|
sensor_.field = json["SensorField"].toInt(0);
|
||||||
sensor_.name = json["SensorName"].toString("Sensor");
|
sensor_.name = json["SensorName"].toString("Sensor");
|
||||||
|
timer.start(timeout_*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Regulator::getName() const
|
QString Regulator::getName() const
|
||||||
{
|
{
|
||||||
if(name_.size() > 0) return name_;
|
if(name_.size() > 0)
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString string;
|
QString string;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "actor.h"
|
#include "actor.h"
|
||||||
#include "../sensors/sensor.h"
|
#include "../sensors/sensor.h"
|
||||||
|
|
||||||
|
|
@ -11,17 +14,26 @@ private:
|
||||||
float setPoint_ = 0;
|
float setPoint_ = 0;
|
||||||
float band_ = 1;
|
float band_ = 1;
|
||||||
bool invert_ = false;
|
bool invert_ = false;
|
||||||
|
int timeout_ = 1800;
|
||||||
|
int safeValue_ = 0;
|
||||||
|
QTimer timer;
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void timeout();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void sensorEvent(Sensor sensor);
|
void sensorEvent(Sensor sensor);
|
||||||
|
|
||||||
void setSensor(const Sensor sensor);
|
void setSensor(const Sensor sensor);
|
||||||
void setPoint( float setPoint );
|
void setPoint(float setPoint );
|
||||||
void setBand ( float band );
|
void setBand (float band );
|
||||||
void setInvert( bool invert );
|
void setInvert(bool invert );
|
||||||
|
void setSafeValue(int value);
|
||||||
|
void setTimeout(int value);
|
||||||
virtual void makeInactive() override;
|
virtual void makeInactive() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -34,6 +46,14 @@ public:
|
||||||
{
|
{
|
||||||
return setPoint_;
|
return setPoint_;
|
||||||
}
|
}
|
||||||
|
int getSafeValue()
|
||||||
|
{
|
||||||
|
return safeValue_;
|
||||||
|
}
|
||||||
|
int getTimeout()
|
||||||
|
{
|
||||||
|
return timeout_;
|
||||||
|
}
|
||||||
Regulator(const Sensor sensor, QObject* parent = nullptr);
|
Regulator(const Sensor sensor, QObject* parent = nullptr);
|
||||||
Regulator(QObject* parent = nullptr);
|
Regulator(QObject* parent = nullptr);
|
||||||
Sensor getSensor()
|
Sensor getSensor()
|
||||||
|
|
|
||||||
|
|
@ -127,11 +127,16 @@ std::shared_ptr<Relay> Microcontroller::processRelayLine(const QString& buffer)
|
||||||
if(bufferList.size() >= 9 && buffer.startsWith("ITEM NUMBER:"))
|
if(bufferList.size() >= 9 && buffer.startsWith("ITEM NUMBER:"))
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
for(int i = 10; i < bufferList.size(); i++) name.append(bufferList[i] + ' ');
|
for(int i = 10; i < bufferList.size(); i++)
|
||||||
if(name.size() > 1)name.remove(name.size()-1, 1);
|
name.append(bufferList[i] + ' ');
|
||||||
else name = "Relay " + QString::number(bufferList[1].toInt(nullptr, 2));
|
if(name.size() > 1)
|
||||||
return std::shared_ptr<Relay>( new Relay(bufferList[2].toInt(), name, bufferList[4].toInt(nullptr, 2),
|
name.remove(name.size()-1, 1);
|
||||||
bufferList[8].toInt()));
|
else
|
||||||
|
name = "Relay " + QString::number(bufferList[1].toInt(nullptr, 2));
|
||||||
|
return std::shared_ptr<Relay>(new Relay(bufferList[2].toInt(),
|
||||||
|
name,
|
||||||
|
bufferList[6].toInt(nullptr, 2),
|
||||||
|
bufferList[8].toInt()));
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,20 @@ void ActorSettingsDialog::init()
|
||||||
connect(ui->comboBox_action, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAction(int)));
|
connect(ui->comboBox_action, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAction(int)));
|
||||||
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
|
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
|
||||||
connect(ui->pushButton_editItem, &QPushButton::clicked, this, &ActorSettingsDialog::editAsItem);
|
connect(ui->pushButton_editItem, &QPushButton::clicked, this, &ActorSettingsDialog::editAsItem);
|
||||||
|
connect(ui->pushButton_enable, &QPushButton::clicked, this, &ActorSettingsDialog::setEnabled);
|
||||||
ui->spinBox->hide();
|
ui->spinBox->hide();
|
||||||
|
|
||||||
ui->spinBox->setValue(actor_->getTriggerValue());
|
ui->spinBox->setValue(actor_->getTriggerValue());
|
||||||
if(actor_->getTriggerValue() == 0) ui->comboBox_action->setCurrentIndex(0);
|
if(actor_->getTriggerValue() == 0)
|
||||||
else if(actor_->getTriggerValue() == 1) ui->comboBox_action->setCurrentIndex(1);
|
ui->comboBox_action->setCurrentIndex(0);
|
||||||
else ui->comboBox_action->setCurrentIndex(2);
|
else if(actor_->getTriggerValue() == 1)
|
||||||
|
ui->comboBox_action->setCurrentIndex(1);
|
||||||
|
else
|
||||||
|
ui->comboBox_action->setCurrentIndex(2);
|
||||||
|
|
||||||
ui->label_Exausted->setText(actor_->isExausted() ? "True" : "False");
|
ui->label_Exausted->setText(actor_->isExausted() ? "True" : "False");
|
||||||
|
ui->label_Enabled->setText(actor_->isActive() ? "True" : "False");
|
||||||
|
ui->pushButton_enable->setText(actor_->isActive() ? "Disable" : "Enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorSettingsDialog::~ActorSettingsDialog()
|
ActorSettingsDialog::~ActorSettingsDialog()
|
||||||
|
|
@ -104,6 +110,13 @@ void ActorSettingsDialog::editAsItem()
|
||||||
itemSettingsDiag.exec();
|
itemSettingsDiag.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActorSettingsDialog::setEnabled()
|
||||||
|
{
|
||||||
|
actor_->setActive(!actor_->isActive());
|
||||||
|
ui->label_Enabled->setText(actor_->isActive() ? "True" : "False");
|
||||||
|
ui->pushButton_enable->setText(actor_->isActive() ? "Disable" : "Enable");
|
||||||
|
}
|
||||||
|
|
||||||
void ActorSettingsDialog::valueChanged(int value)
|
void ActorSettingsDialog::valueChanged(int value)
|
||||||
{
|
{
|
||||||
actor_->setTriggerValue(value);
|
actor_->setTriggerValue(value);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ private slots:
|
||||||
void changeAction(int index);
|
void changeAction(int index);
|
||||||
void valueChanged(int value);
|
void valueChanged(int value);
|
||||||
void editAsItem();
|
void editAsItem();
|
||||||
|
void setEnabled();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,63 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enabled:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_Enabled">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>True</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_enable">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,5 @@ void PolynomalActorWidget::setPow()
|
||||||
|
|
||||||
void PolynomalActorWidget::setSensor(const QModelIndex &index)
|
void PolynomalActorWidget::setSensor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
actor_->setSensor(sensors_->getSensors()->at(index.row()));
|
actor_->setSensor(ui->listView->getSensorForIndex(index));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,17 @@ RegulatorWdiget::RegulatorWdiget(std::shared_ptr<Regulator> regulator, SensorSto
|
||||||
}
|
}
|
||||||
ui->doubleSpinBox_setPoint->setValue(regulator->getSetPoint());
|
ui->doubleSpinBox_setPoint->setValue(regulator->getSetPoint());
|
||||||
ui->doubleSpinBox_band->setValue(regulator->getBand());
|
ui->doubleSpinBox_band->setValue(regulator->getBand());
|
||||||
|
ui->spinBox_safe->setValue(regulator_->getSafeValue());
|
||||||
|
ui->spinBox_timeout->setValue(regulator_->getTimeout());
|
||||||
|
|
||||||
connect(ui->listView, &SensorListWidget::clicked, this, &RegulatorWdiget::setSensor);
|
connect(ui->listView, &SensorListWidget::clicked, this, &RegulatorWdiget::setSensor);
|
||||||
connect(ui->doubleSpinBox_setPoint, SIGNAL(valueChanged(double)), this, SLOT(setPoint(double)));
|
connect(ui->doubleSpinBox_setPoint, SIGNAL(valueChanged(double)), this, SLOT(setPoint(double)));
|
||||||
connect(ui->doubleSpinBox_band, SIGNAL(valueChanged(double)), this, SLOT(setBand(double)));
|
connect(ui->doubleSpinBox_band, SIGNAL(valueChanged(double)), this, SLOT(setBand(double)));
|
||||||
|
connect(ui->spinBox_safe, SIGNAL(valueChanged(int)), regulator_.get(), SLOT(setSafeValue(int)));
|
||||||
|
connect(ui->spinBox_timeout, SIGNAL(valueChanged(int)), regulator_.get(), SLOT(setTimeout(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RegulatorWdiget::setPoint(double in)
|
void RegulatorWdiget::setPoint(double in)
|
||||||
{
|
{
|
||||||
regulator_->setPoint(in);
|
regulator_->setPoint(in);
|
||||||
|
|
@ -42,7 +47,7 @@ void RegulatorWdiget::setBand(double band)
|
||||||
|
|
||||||
void RegulatorWdiget::setSensor(const QModelIndex &index)
|
void RegulatorWdiget::setSensor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
regulator_->setSensor(sensors_->getSensors()->at(index.row()));
|
regulator_->setSensor(ui->listView->getSensorForIndex(index));
|
||||||
setPoint(sensors_->getSensors()->at(index.row()).field);
|
setPoint(ui->listView->getSensorForIndex(index).field);
|
||||||
ui->doubleSpinBox_setPoint->setValue(sensors_->getSensors()->at(index.row()).field);
|
ui->doubleSpinBox_setPoint->setValue(ui->listView->getSensorForIndex(index).field);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,8 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Set Point</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_setPoint">
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_setPoint">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>-9999.989999999999782</double>
|
<double>-9999.989999999999782</double>
|
||||||
|
|
@ -56,7 +49,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
|
@ -69,9 +62,46 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="2">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Timeout</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Set Point</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_band"/>
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_band"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Safety Value</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox_safe"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QSpinBox" name="spinBox_timeout">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> s</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1800</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,12 @@ SensorActorWidget::SensorActorWidget(std::shared_ptr<SensorActor> sensorActor, S
|
||||||
ui->label->hide();
|
ui->label->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sensorActor_->getSloap() == SensorActor::SLOPE_UP) ui->comboBox_slope->setCurrentIndex(0);
|
if(sensorActor_->getSloap() == SensorActor::SLOPE_UP)
|
||||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_DOWN) ui->comboBox_slope->setCurrentIndex(1);
|
ui->comboBox_slope->setCurrentIndex(0);
|
||||||
else if(sensorActor_->getSloap() == SensorActor::SLOPE_BOTH) ui->comboBox_slope->setCurrentIndex(2);
|
else if(sensorActor_->getSloap() == SensorActor::SLOPE_DOWN)
|
||||||
|
ui->comboBox_slope->setCurrentIndex(1);
|
||||||
|
else if(sensorActor_->getSloap() == SensorActor::SLOPE_BOTH)
|
||||||
|
ui->comboBox_slope->setCurrentIndex(2);
|
||||||
|
|
||||||
ui->doubleSpinBox_threshold->setValue(sensorActor_->getThreshold());
|
ui->doubleSpinBox_threshold->setValue(sensorActor_->getThreshold());
|
||||||
|
|
||||||
|
|
@ -47,6 +50,5 @@ void SensorActorWidget::setSlope(int index)
|
||||||
|
|
||||||
void SensorActorWidget::setSensor(const QModelIndex &index)
|
void SensorActorWidget::setSensor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
sensorActor_->setSensor(sensors_->getSensors()->at(index.row()));
|
sensorActor_->setSensor(ui->listView->getSensorForIndex(index));
|
||||||
qDebug()<<"Selected "<<sensors_->getSensors()->at(index.row()).name;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void SensorListWidget::sensorsChanged(std::vector<Sensor> sensors)
|
||||||
else itemString.append("\"Silent\"");
|
else itemString.append("\"Silent\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
setItem(static_cast<int>(row), 0, new QTableWidgetItem(sensors[i].name + (sensors[i].hidden ? " (H)" : "")));
|
setItem(static_cast<int>(row), 0, new SensorListItem(sensors[i].name + (sensors[i].hidden ? " (H)" : ""), sensors[i]));
|
||||||
setItem(static_cast<int>(row), 1, new QTableWidgetItem(itemString));
|
setItem(static_cast<int>(row), 1, new QTableWidgetItem(itemString));
|
||||||
if(sensors[i].type <= 128)
|
if(sensors[i].type <= 128)
|
||||||
setItem(static_cast<int>(row), 2, new QTableWidgetItem(sensors[i].lastSeen.time().toString("hh:mm")));
|
setItem(static_cast<int>(row), 2, new QTableWidgetItem(sensors[i].lastSeen.time().toString("hh:mm")));
|
||||||
|
|
@ -67,8 +67,23 @@ void SensorListWidget::sensorsChanged(std::vector<Sensor> sensors)
|
||||||
resizeColumnsToContents();
|
resizeColumnsToContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Sensor& SensorListWidget::getSensorForIndex(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
return static_cast<SensorListItem*>(item(index.row(), 0))->getSensor();
|
||||||
|
}
|
||||||
|
|
||||||
void SensorListWidget::setShowHidden(const bool showHidden)
|
void SensorListWidget::setShowHidden(const bool showHidden)
|
||||||
{
|
{
|
||||||
showHidden_=showHidden;
|
showHidden_=showHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Sensor& SensorListItem::getSensor()
|
||||||
|
{
|
||||||
|
return sensor;
|
||||||
|
}
|
||||||
|
|
||||||
|
SensorListItem::SensorListItem(const QString& text, const Sensor& sensor):
|
||||||
|
QTableWidgetItem(text, 1001), sensor(sensor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,15 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../sensors/sensor.h"
|
#include "../sensors/sensor.h"
|
||||||
|
|
||||||
|
class SensorListItem : public QTableWidgetItem
|
||||||
|
{
|
||||||
|
Sensor sensor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
const Sensor& getSensor();
|
||||||
|
SensorListItem(const QString& text, const Sensor& sensor);
|
||||||
|
};
|
||||||
|
|
||||||
class SensorListWidget : public QTableWidget
|
class SensorListWidget : public QTableWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -11,10 +20,11 @@ class SensorListWidget : public QTableWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SensorListWidget(const bool showHidden = true, QWidget *parent = nullptr);
|
SensorListWidget(const bool showHidden = true, QWidget* parent = nullptr);
|
||||||
SensorListWidget(SensorStore& sensorStore, const bool showHidden = true, QWidget* parent = nullptr);
|
SensorListWidget(SensorStore& sensorStore, const bool showHidden = true, QWidget* parent = nullptr);
|
||||||
virtual ~SensorListWidget() {}
|
virtual ~SensorListWidget() {}
|
||||||
void setShowHidden(const bool showHidden);
|
void setShowHidden(const bool showHidden);
|
||||||
|
const Sensor& getSensorForIndex(const QModelIndex &index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue