move from tabs to spaces
This commit is contained in:
		
							parent
							
								
									a6aad07f05
								
							
						
					
					
						commit
						fa45072998
					
				
					 86 changed files with 2611 additions and 2486 deletions
				
			
		| 
						 | 
					@ -29,13 +29,28 @@ public:
 | 
				
			||||||
	virtual QString getName() const;
 | 
						virtual QString getName() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void setFactorActor(std::shared_ptr<Actor> factorActor);
 | 
						void setFactorActor(std::shared_ptr<Actor> factorActor);
 | 
				
			||||||
    std::shared_ptr<Actor> getFactorActor(){return factorActor_;}
 | 
						std::shared_ptr<Actor> getFactorActor()
 | 
				
			||||||
    void setFactorDirection(const bool direction){factorDirection = direction;}
 | 
						{
 | 
				
			||||||
    bool getFactorDirection(){return factorDirection;}
 | 
							return factorActor_;
 | 
				
			||||||
    uint getPreCancleTime(){return preCancleMin_;}
 | 
						}
 | 
				
			||||||
    void setPreCancleTime(uint minutes){preCancleMin_ = minutes;}
 | 
						void setFactorDirection(const bool direction)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							factorDirection = direction;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						bool getFactorDirection()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return factorDirection;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						uint getPreCancleTime()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return preCancleMin_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						void setPreCancleTime(uint minutes)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							preCancleMin_ = minutes;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual ~MultiFactorActor(){}
 | 
						virtual ~MultiFactorActor() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
	virtual void load(const QJsonObject& json, bool preserve);
 | 
						virtual void load(const QJsonObject& json, bool preserve);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,8 @@ void PolynomalActor::sensorEvent(Sensor sensor)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(active && sensor == sensor_)
 | 
						if(active && sensor == sensor_)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
        double result = pow3_*(sensor.field*sensor.field*sensor.field)+pow2_*(sensor.field*sensor.field)+pow1_*sensor.field+pow0_;
 | 
							double result = pow3_*(sensor.field*sensor.field*sensor.field)+pow2_*(sensor.field*sensor.field)+pow1_*sensor.field
 | 
				
			||||||
 | 
							                +pow0_;
 | 
				
			||||||
		if(result < 0) result = 0;
 | 
							if(result < 0) result = 0;
 | 
				
			||||||
		else if(result > 254) result = 255;
 | 
							else if(result > 254) result = 255;
 | 
				
			||||||
		if(result != prevValue)sigValue(static_cast<uint8_t>(result));
 | 
							if(result != prevValue)sigValue(static_cast<uint8_t>(result));
 | 
				
			||||||
| 
						 | 
					@ -76,7 +77,8 @@ QString PolynomalActor::getName() const
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		QString string;
 | 
							QString string;
 | 
				
			||||||
        string = QString::number(pow3_) + "x^3 + " + 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;
 | 
							return string;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,9 +28,12 @@ public:
 | 
				
			||||||
	PolynomalActor(const Sensor sensor, QObject* parent = nullptr);
 | 
						PolynomalActor(const Sensor sensor, QObject* parent = nullptr);
 | 
				
			||||||
	PolynomalActor(QObject* parent = nullptr);
 | 
						PolynomalActor(QObject* parent = nullptr);
 | 
				
			||||||
	void setSensor(const Sensor sensor);
 | 
						void setSensor(const Sensor sensor);
 | 
				
			||||||
    Sensor getSensor(){return sensor_;}
 | 
						Sensor getSensor()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sensor_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	virtual QString getName() const;
 | 
						virtual QString getName() const;
 | 
				
			||||||
    virtual ~PolynomalActor(){}
 | 
						virtual ~PolynomalActor() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
	virtual void load(const QJsonObject& json, bool preserve);
 | 
						virtual void load(const QJsonObject& json, bool preserve);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,13 +25,22 @@ public slots:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    float getBand() {return  band_;}
 | 
						float getBand()
 | 
				
			||||||
    float getSetPoint() {return  setPoint_;}
 | 
						{
 | 
				
			||||||
 | 
							return  band_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						float getSetPoint()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return  setPoint_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	Regulator(const Sensor sensor, QObject* parent = nullptr);
 | 
						Regulator(const Sensor sensor, QObject* parent = nullptr);
 | 
				
			||||||
	Regulator(QObject* parent = nullptr);
 | 
						Regulator(QObject* parent = nullptr);
 | 
				
			||||||
    Sensor getSensor(){return sensor_;}
 | 
						Sensor getSensor()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sensor_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	virtual QString getName() const;
 | 
						virtual QString getName() const;
 | 
				
			||||||
    virtual ~Regulator(){}    
 | 
						virtual ~Regulator() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
	virtual void load(const QJsonObject& json, bool preserve);
 | 
						virtual void load(const QJsonObject& json, bool preserve);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,8 +21,10 @@ void SensorActor::sensorEvent(Sensor sensor)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(sensor == sensor_)
 | 
						if(sensor == sensor_)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
        if((sloap_ == SLOPE_UP || sloap_ == SLOPE_BOTH) && sensor_.field < threshold_ && sensor.field >= threshold_ )  performAction();
 | 
							if((sloap_ == SLOPE_UP || sloap_ == SLOPE_BOTH) && sensor_.field < threshold_
 | 
				
			||||||
        else if((sloap_ == SLOPE_DOWN || sloap_ == SLOPE_BOTH) && sensor_.field > threshold_ && sensor.field <= threshold_)  performAction();
 | 
							        && sensor.field >= threshold_ )  performAction();
 | 
				
			||||||
 | 
							else if((sloap_ == SLOPE_DOWN || sloap_ == SLOPE_BOTH) && sensor_.field > threshold_
 | 
				
			||||||
 | 
							        && sensor.field <= threshold_)  performAction();
 | 
				
			||||||
		sensor_ = sensor;
 | 
							sensor_ = sensor;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,9 +28,12 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SensorActor(const Sensor sensor, QObject* parent = nullptr);
 | 
						SensorActor(const Sensor sensor, QObject* parent = nullptr);
 | 
				
			||||||
	SensorActor(QObject* parent = nullptr);
 | 
						SensorActor(QObject* parent = nullptr);
 | 
				
			||||||
    Sensor getSensor(){return sensor_;}
 | 
						Sensor getSensor()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sensor_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	virtual QString getName() const;
 | 
						virtual QString getName() const;
 | 
				
			||||||
    virtual ~SensorActor(){}
 | 
						virtual ~SensorActor() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	float getThreshold();
 | 
						float getThreshold();
 | 
				
			||||||
	uint8_t getSloap();
 | 
						uint8_t getSloap();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,8 @@
 | 
				
			||||||
#include "alarmactions.h"
 | 
					#include "alarmactions.h"
 | 
				
			||||||
#include <QProcess>
 | 
					#include <QProcess>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AlarmActions::AlarmActions(QApplication* a, Microcontroller* micro, QObject *parent) : QObject(parent), _micro(micro), a_(a)
 | 
					AlarmActions::AlarmActions(QApplication* a, Microcontroller* micro, QObject *parent) : QObject(parent), _micro(micro),
 | 
				
			||||||
 | 
						a_(a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -150,7 +150,7 @@ std::vector<uint64_t> connectedDevices(const std::string& ifDevice, int& error)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    nla_put_failure:
 | 
					nla_put_failure:
 | 
				
			||||||
	nl_cb_put(cb);
 | 
						nl_cb_put(cb);
 | 
				
			||||||
	nl_cb_put(s_cb);
 | 
						nl_cb_put(s_cb);
 | 
				
			||||||
	nlmsg_free(msg);
 | 
						nlmsg_free(msg);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,14 +6,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace ap
 | 
					namespace ap
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    enum ERRORS
 | 
					enum ERRORS
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
	SUCESS,
 | 
						SUCESS,
 | 
				
			||||||
	ERR_INIT,
 | 
						ERR_INIT,
 | 
				
			||||||
	ERR_NO_DEV,
 | 
						ERR_NO_DEV,
 | 
				
			||||||
	ERR_ALLOC,
 | 
						ERR_ALLOC,
 | 
				
			||||||
	ERR_GENERAL
 | 
						ERR_GENERAL
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
    std::vector<uint64_t> connectedDevices(const std::string& ifDevice, int& error);
 | 
					std::vector<uint64_t> connectedDevices(const std::string& ifDevice, int& error);
 | 
				
			||||||
    std::string macAddrToString(uint64_t macAddr);
 | 
					std::string macAddrToString(uint64_t macAddr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,8 @@ void BroadCast::decodeMaster(const QByteArray& buffer)
 | 
				
			||||||
void BroadCast::decode(QByteArray buffer)
 | 
					void BroadCast::decode(QByteArray buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qDebug()<<"decodeing: "<<buffer;
 | 
						qDebug()<<"decodeing: "<<buffer;
 | 
				
			||||||
    if(buffer.size() >= 6 && buffer[0] == 'J' && buffer[1] == 'S' && buffer[2] == 'O' && buffer[3] == 'N' && buffer[4] == ':')
 | 
						if(buffer.size() >= 6 && buffer[0] == 'J' && buffer[1] == 'S' && buffer[2] == 'O' && buffer[3] == 'N'
 | 
				
			||||||
 | 
						        && buffer[4] == ':')
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		qDebug()<<"got json";
 | 
							qDebug()<<"got json";
 | 
				
			||||||
		buffer.remove(0,6);
 | 
							buffer.remove(0,6);
 | 
				
			||||||
| 
						 | 
					@ -104,7 +105,8 @@ void BroadCast::decode(QByteArray buffer)
 | 
				
			||||||
			qDebug()<<error.errorString();
 | 
								qDebug()<<error.errorString();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    else if(buffer.size() >= 6 && buffer[0] == 'S' && buffer[1] == 'E' && buffer[2] == 'N' && buffer[3] == 'S' && buffer[4] == 'O' && buffer[5] == 'R')
 | 
						else if(buffer.size() >= 6 && buffer[0] == 'S' && buffer[1] == 'E' && buffer[2] == 'N' && buffer[3] == 'S'
 | 
				
			||||||
 | 
						        && buffer[4] == 'O' && buffer[5] == 'R')
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Sensor sensor = Sensor::sensorFromString(buffer);
 | 
							Sensor sensor = Sensor::sensorFromString(buffer);
 | 
				
			||||||
		if(sensor.type != Sensor::TYPE_DUMMY) gotSensorState(sensor);
 | 
							if(sensor.type != Sensor::TYPE_DUMMY) gotSensorState(sensor);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#include "auxitem.h"
 | 
					#include "auxitem.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AuxItem::AuxItem(Microcontroller* micro, uint32_t itemIdIn, QString name,  uint8_t value, QObject* parent): Item(itemIdIn, name, value, parent), micro_(micro)
 | 
					AuxItem::AuxItem(Microcontroller* micro, uint32_t itemIdIn, QString name,  uint8_t value,
 | 
				
			||||||
 | 
					                 QObject* parent): Item(itemIdIn, name, value, parent), micro_(micro)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,8 @@ public slots:
 | 
				
			||||||
	virtual void setValue(uint8_t value);
 | 
						virtual void setValue(uint8_t value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    AuxItem(Microcontroller* micro, uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",  uint8_t value = 0, QObject* parent = nullptr);
 | 
						AuxItem(Microcontroller* micro, uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",
 | 
				
			||||||
 | 
						        uint8_t value = 0, QObject* parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,8 @@ uint32_t ItemData::id() const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Item::secondaryFlag = false;
 | 
					bool Item::secondaryFlag = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Item::Item(uint32_t itemIdIn, QString name, uint8_t value,  QObject *parent): QObject(parent), ItemData (itemIdIn, name, value)
 | 
					Item::Item(uint32_t itemIdIn, QString name, uint8_t value,  QObject *parent): QObject(parent), ItemData (itemIdIn, name,
 | 
				
			||||||
 | 
						        value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -122,7 +123,8 @@ void Item::addActor(std::shared_ptr<Actor> actor)
 | 
				
			||||||
	if(regulator)connect(&globalSensors, &SensorStore::sensorChangedState, regulator.get(), &Regulator::sensorEvent);
 | 
						if(regulator)connect(&globalSensors, &SensorStore::sensorChangedState, regulator.get(), &Regulator::sensorEvent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::shared_ptr<PolynomalActor> polynomalActor = std::dynamic_pointer_cast<PolynomalActor>(actor);
 | 
						std::shared_ptr<PolynomalActor> polynomalActor = std::dynamic_pointer_cast<PolynomalActor>(actor);
 | 
				
			||||||
    if(polynomalActor != nullptr )connect(&globalSensors, &SensorStore::sensorChangedState, polynomalActor.get(), &PolynomalActor::sensorEvent);
 | 
						if(polynomalActor != nullptr )connect(&globalSensors, &SensorStore::sensorChangedState, polynomalActor.get(),
 | 
				
			||||||
 | 
							                                      &PolynomalActor::sensorEvent);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Item::removeActor(std::shared_ptr<Actor> actor)
 | 
					bool Item::removeActor(std::shared_ptr<Actor> actor)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,8 +19,14 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ItemData(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0);
 | 
						ItemData(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline bool operator==(const ItemData& in) const{ return itemId_==in.itemId_; }
 | 
						inline bool operator==(const ItemData& in) const
 | 
				
			||||||
    inline bool operator!=(const ItemData& in) const{ return itemId_!=in.itemId_; }
 | 
						{
 | 
				
			||||||
 | 
							return itemId_==in.itemId_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						inline bool operator!=(const ItemData& in) const
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return itemId_!=in.itemId_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t id() const;
 | 
						uint32_t id() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +61,8 @@ public slots:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Item(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,  QObject *parent = nullptr);
 | 
						Item(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,
 | 
				
			||||||
 | 
						     QObject *parent = nullptr);
 | 
				
			||||||
	Item(const ItemData& itemData,  QObject *parent = nullptr);
 | 
						Item(const ItemData& itemData,  QObject *parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual ~Item();
 | 
						virtual ~Item();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,9 +15,12 @@ private:
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ItemStore(QObject *parent = nullptr);
 | 
						ItemStore(QObject *parent = nullptr);
 | 
				
			||||||
    virtual ~ItemStore(){}
 | 
						virtual ~ItemStore() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline std::vector< std::shared_ptr<Item> >* getItems(){ return &items_; }
 | 
						inline std::vector< std::shared_ptr<Item> >* getItems()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return &items_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void store(QJsonObject &json);
 | 
						void store(QJsonObject &json);
 | 
				
			||||||
	void load(const QJsonObject &json);
 | 
						void load(const QJsonObject &json);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MessageItem : public Item
 | 
					class MessageItem : public Item
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
Q_OBJECT
 | 
						Q_OBJECT
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QString message_;
 | 
						QString message_;
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,8 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MessageItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,  QObject *parent = nullptr);
 | 
						MessageItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,
 | 
				
			||||||
 | 
						            QObject *parent = nullptr);
 | 
				
			||||||
	MessageItem(const ItemData& itemData,  QObject *parent = nullptr);
 | 
						MessageItem(const ItemData& itemData,  QObject *parent = nullptr);
 | 
				
			||||||
	~MessageItem();
 | 
						~MessageItem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,8 @@
 | 
				
			||||||
#include <QApplication>
 | 
					#include <QApplication>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PowerItem::PowerItem(uint32_t itemIdIn, QString name,  uint8_t value, QObject* parent): Item(itemIdIn, name, value, parent)
 | 
					PowerItem::PowerItem(uint32_t itemIdIn, QString name,  uint8_t value, QObject* parent): Item(itemIdIn, name, value,
 | 
				
			||||||
 | 
						        parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true));
 | 
						stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true));
 | 
				
			||||||
	setValue(true);
 | 
						setValue(true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,11 @@ public slots:
 | 
				
			||||||
	virtual void setValue(uint8_t value);
 | 
						virtual void setValue(uint8_t value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    PowerItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",  uint8_t value = 0, QObject* parent = nullptr);
 | 
						PowerItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",  uint8_t value = 0,
 | 
				
			||||||
    void emmitSensor(){stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true));}
 | 
						          QObject* parent = nullptr);
 | 
				
			||||||
 | 
						void emmitSensor()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Microcontroller* Relay::micro_ = nullptr;
 | 
					Microcontroller* Relay::micro_ = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Relay::Relay(uint8_t id, QString name, uint16_t address, bool state, QObject* parent): Item(0, name, state, parent), id_(id), address_(address)
 | 
					Relay::Relay(uint8_t id, QString name, uint16_t address, bool state, QObject* parent): Item(0, name, state, parent),
 | 
				
			||||||
 | 
						id_(id), address_(address)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	itemId_ = address | ((uint32_t)id << 16);
 | 
						itemId_ = address | ((uint32_t)id << 16);
 | 
				
			||||||
	qDebug()<<"Relay "<<id_<<"Name "<<name<<" id "<<itemId_<<" state "<<state<<" addr: "<<address;
 | 
						qDebug()<<"Relay "<<id_<<"Name "<<name<<" id "<<itemId_<<" state "<<state<<" addr: "<<address;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,10 @@ public:
 | 
				
			||||||
	uint8_t getId() const;
 | 
						uint8_t getId() const;
 | 
				
			||||||
	void setId(uint8_t id);
 | 
						void setId(uint8_t id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline static void setMicrocontroller(Microcontroller* micro){ micro_ = micro; }
 | 
						inline static void setMicrocontroller(Microcontroller* micro)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							micro_ = micro;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
	virtual void load(const QJsonObject& json, const bool preserve = false);
 | 
						virtual void load(const QJsonObject& json, const bool preserve = false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#include "rgbitem.h"
 | 
					#include "rgbitem.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RgbItem::RgbItem(Microcontroller* micro, uint32_t itemIdIn, QString name,  uint8_t value, QObject* parent): Item(itemIdIn, name, value, parent), micro_(micro)
 | 
					RgbItem::RgbItem(Microcontroller* micro, uint32_t itemIdIn, QString name,  uint8_t value,
 | 
				
			||||||
 | 
					                 QObject* parent): Item(itemIdIn, name, value, parent), micro_(micro)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,8 @@ public slots:
 | 
				
			||||||
	virtual void setValue(uint8_t value);
 | 
						virtual void setValue(uint8_t value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    RgbItem(Microcontroller* micro, uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",  uint8_t value = 0, QObject* parent = nullptr);
 | 
						RgbItem(Microcontroller* micro, uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "",
 | 
				
			||||||
 | 
						        uint8_t value = 0, QObject* parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,13 +7,13 @@ void SystemItem::setValue(uint8_t value)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SystemItem::SystemItem(uint32_t itemIdIn, QString name, uint8_t value,  QObject *parent):
 | 
					SystemItem::SystemItem(uint32_t itemIdIn, QString name, uint8_t value,  QObject *parent):
 | 
				
			||||||
Item(itemIdIn, name, value, parent)
 | 
						Item(itemIdIn, name, value, parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SystemItem::SystemItem(const ItemData& itemData,  QObject *parent):
 | 
					SystemItem::SystemItem(const ItemData& itemData,  QObject *parent):
 | 
				
			||||||
Item(itemData, parent)
 | 
						Item(itemData, parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SystemItem : public Item
 | 
					class SystemItem : public Item
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
Q_OBJECT
 | 
						Q_OBJECT
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QString onCommand_;
 | 
						QString onCommand_;
 | 
				
			||||||
| 
						 | 
					@ -18,14 +18,21 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SystemItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,  QObject *parent = nullptr);
 | 
						SystemItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,
 | 
				
			||||||
 | 
						           QObject *parent = nullptr);
 | 
				
			||||||
	SystemItem(const ItemData& itemData,  QObject *parent = nullptr);
 | 
						SystemItem(const ItemData& itemData,  QObject *parent = nullptr);
 | 
				
			||||||
	~SystemItem() = default;
 | 
						~SystemItem() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void setOnCommand(const QString& in);
 | 
						void setOnCommand(const QString& in);
 | 
				
			||||||
	void setOffCommand(const QString& in);
 | 
						void setOffCommand(const QString& in);
 | 
				
			||||||
    QString getOnCommand(){return onCommand_;}
 | 
						QString getOnCommand()
 | 
				
			||||||
    QString getOffCommand(){return offCommand_;}
 | 
						{
 | 
				
			||||||
 | 
							return onCommand_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						QString getOffCommand()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return offCommand_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void store(QJsonObject& json);
 | 
						virtual void store(QJsonObject& json);
 | 
				
			||||||
	virtual void load(const QJsonObject& json, const bool preserve = false);
 | 
						virtual void load(const QJsonObject& json, const bool preserve = false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										34
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								src/main.cpp
									
										
									
									
									
								
							| 
						 | 
					@ -41,31 +41,36 @@ int main(int argc, char *argv[])
 | 
				
			||||||
	QDir::setCurrent(a.applicationDirPath());
 | 
						QDir::setCurrent(a.applicationDirPath());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//parse comand line
 | 
						//parse comand line
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	QCommandLineParser parser;
 | 
						QCommandLineParser parser;
 | 
				
			||||||
	parser.setApplicationDescription("Smart Home Interface");
 | 
						parser.setApplicationDescription("Smart Home Interface");
 | 
				
			||||||
	parser.addHelpOption();
 | 
						parser.addHelpOption();
 | 
				
			||||||
	parser.addVersionOption();
 | 
						parser.addVersionOption();
 | 
				
			||||||
	QCommandLineOption tcpOption(QStringList() << "t" << "tcp", QCoreApplication::translate("main", "Use Tcp connection"));
 | 
						QCommandLineOption tcpOption(QStringList() << "t" << "tcp", QCoreApplication::translate("main", "Use Tcp connection"));
 | 
				
			||||||
	parser.addOption(tcpOption);
 | 
						parser.addOption(tcpOption);
 | 
				
			||||||
    QCommandLineOption hostOption(QStringList() << "H" << "host", QCoreApplication::translate("main", "Set server host ip addres"), "adress");
 | 
						QCommandLineOption hostOption(QStringList() << "H" << "host", QCoreApplication::translate("main",
 | 
				
			||||||
 | 
						                              "Set server host ip addres"), "adress");
 | 
				
			||||||
	parser.addOption(hostOption);
 | 
						parser.addOption(hostOption);
 | 
				
			||||||
    QCommandLineOption portOption(QStringList() << "p" << "port", QCoreApplication::translate("main", "Set server Port in TCP mode or Serial port in serial mode"), "port");
 | 
						QCommandLineOption portOption(QStringList() << "p" << "port", QCoreApplication::translate("main",
 | 
				
			||||||
 | 
						                              "Set server Port in TCP mode or Serial port in serial mode"), "port");
 | 
				
			||||||
	parser.addOption(portOption);
 | 
						parser.addOption(portOption);
 | 
				
			||||||
    QCommandLineOption serialOption(QStringList() << "s" << "serial", QCoreApplication::translate("main", "Use serial connection"));
 | 
						QCommandLineOption serialOption(QStringList() << "s" << "serial", QCoreApplication::translate("main",
 | 
				
			||||||
 | 
						                                "Use serial connection"));
 | 
				
			||||||
	parser.addOption(serialOption);
 | 
						parser.addOption(serialOption);
 | 
				
			||||||
	QCommandLineOption baudOption(QStringList() << "b" << "baud", QCoreApplication::translate("main", "Set Baud Rate"));
 | 
						QCommandLineOption baudOption(QStringList() << "b" << "baud", QCoreApplication::translate("main", "Set Baud Rate"));
 | 
				
			||||||
	parser.addOption(baudOption);
 | 
						parser.addOption(baudOption);
 | 
				
			||||||
    QCommandLineOption settingsPathOption(QStringList() << "c" << "config", QCoreApplication::translate("main", "Set config file"), "configFilePath");
 | 
						QCommandLineOption settingsPathOption(QStringList() << "c" << "config", QCoreApplication::translate("main",
 | 
				
			||||||
 | 
						                                      "Set config file"), "configFilePath");
 | 
				
			||||||
	parser.addOption(settingsPathOption);
 | 
						parser.addOption(settingsPathOption);
 | 
				
			||||||
    QCommandLineOption secondaryOption(QStringList() << "e" << "secondary", QCoreApplication::translate("main", "Set if instance is not main instance"));
 | 
						QCommandLineOption secondaryOption(QStringList() << "e" << "secondary", QCoreApplication::translate("main",
 | 
				
			||||||
 | 
						                                   "Set if instance is not main instance"));
 | 
				
			||||||
	parser.addOption(secondaryOption);
 | 
						parser.addOption(secondaryOption);
 | 
				
			||||||
	parser.process(a);
 | 
						parser.process(a);
 | 
				
			||||||
    #endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QIODevice* masterIODevice = nullptr;
 | 
						QIODevice* masterIODevice = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	if(parser.isSet(tcpOption))
 | 
						if(parser.isSet(tcpOption))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		QTcpSocket* microSocket = new QTcpSocket;
 | 
							QTcpSocket* microSocket = new QTcpSocket;
 | 
				
			||||||
| 
						 | 
					@ -94,13 +99,15 @@ int main(int argc, char *argv[])
 | 
				
			||||||
		if(parser.isSet(portOption)) microPort->setBaudRate(parser.value(baudOption).toInt());
 | 
							if(parser.isSet(portOption)) microPort->setBaudRate(parser.value(baudOption).toInt());
 | 
				
			||||||
		else microPort->setBaudRate(BAUD);
 | 
							else microPort->setBaudRate(BAUD);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!microPort->open(QIODevice::ReadWrite)) std::cout<<"Can not open serial port "<<microPort->portName().toStdString()<<". Continueing in demo mode"<<'\n';
 | 
							if(!microPort->open(QIODevice::ReadWrite)) std::cout<<"Can not open serial port "<<microPort->portName().toStdString()
 | 
				
			||||||
 | 
								        <<". Continueing in demo mode"<<'\n';
 | 
				
			||||||
		masterIODevice = microPort;
 | 
							masterIODevice = microPort;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MainObject mainObject(masterIODevice, parser.isSet(settingsPathOption) ? parser.value(settingsPathOption) : "", !parser.isSet(secondaryOption));
 | 
						MainObject mainObject(masterIODevice, parser.isSet(settingsPathOption) ? parser.value(settingsPathOption) : "",
 | 
				
			||||||
 | 
						                      !parser.isSet(secondaryOption));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #else
 | 
					#else
 | 
				
			||||||
	QTcpSocket* microSocket = new QTcpSocket;
 | 
						QTcpSocket* microSocket = new QTcpSocket;
 | 
				
			||||||
	microSocket->connectToHost("10.0.0.1", 6856, QIODevice::ReadWrite);
 | 
						microSocket->connectToHost("10.0.0.1", 6856, QIODevice::ReadWrite);
 | 
				
			||||||
	if(!microSocket->waitForConnected(1000))
 | 
						if(!microSocket->waitForConnected(1000))
 | 
				
			||||||
| 
						 | 
					@ -110,8 +117,9 @@ int main(int argc, char *argv[])
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	masterIODevice = microSocket;
 | 
						masterIODevice = microSocket;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MainObject mainObject(masterIODevice, parser.isSet(settingsPathOption) ? parser.value(settingsPathOption) : "", !parser.isSet(secondaryOption));
 | 
						MainObject mainObject(masterIODevice, parser.isSet(settingsPathOption) ? parser.value(settingsPathOption) : "",
 | 
				
			||||||
    #endif
 | 
						                      !parser.isSet(secondaryOption));
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//mainwindow
 | 
						//mainwindow
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,9 +49,9 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
 | 
				
			||||||
		broadCast.requestSensors();
 | 
							broadCast.requestSensors();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	Item::secondaryFlag = !master;
 | 
						Item::secondaryFlag = !master;
 | 
				
			||||||
    #endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MainObject::~MainObject()
 | 
					MainObject::~MainObject()
 | 
				
			||||||
| 
						 | 
					@ -120,10 +120,10 @@ QJsonObject MainObject::getJsonObjectFromDisk(const QString& filePath, bool* err
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QFile file;
 | 
						QFile file;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	if(filePath.size() > 0) file.setFileName(filePath);
 | 
						if(filePath.size() > 0) file.setFileName(filePath);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
    #endif
 | 
					#endif
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		file.setFileName(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/shinterface.json");
 | 
							file.setFileName(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/shinterface.json");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -147,9 +147,9 @@ QJsonObject MainObject::getJsonObjectFromDisk(const QString& filePath, bool* err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool MainObject::storeJsonObjectToDisk(const QJsonObject& json, QString filePath)
 | 
					bool MainObject::storeJsonObjectToDisk(const QJsonObject& json, QString filePath)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	if(filePath.size() == 0)
 | 
						if(filePath.size() == 0)
 | 
				
			||||||
    #endif
 | 
					#endif
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		filePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/shinterface.json";
 | 
							filePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/shinterface.json";
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,10 +41,10 @@ void Microcontroller::changeRgbColor(const QColor color)
 | 
				
			||||||
	int length = sprintf(buffer, "rgb set %03d %03d %03d\n", color.red(), color.green(), color.blue());
 | 
						int length = sprintf(buffer, "rgb set %03d %03d %03d\n", color.red(), color.green(), color.blue());
 | 
				
			||||||
	write(buffer, length);
 | 
						write(buffer, length);
 | 
				
			||||||
	std::cout<<buffer;
 | 
						std::cout<<buffer;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void Microcontroller::setAuxPwm(int duty)
 | 
					void Microcontroller::setAuxPwm(int duty)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
	char buffer[64];
 | 
						char buffer[64];
 | 
				
			||||||
	int length = sprintf(buffer, "aux set %03d\n", duty );
 | 
						int length = sprintf(buffer, "aux set %03d\n", duty );
 | 
				
			||||||
	write(buffer, length);
 | 
						write(buffer, length);
 | 
				
			||||||
| 
						 | 
					@ -52,9 +52,9 @@ void Microcontroller::changeRgbColor(const QColor color)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Microcontroller::write(const QByteArray& buffer)
 | 
					void Microcontroller::write(const QByteArray& buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	if constexpr(debug) std::cerr<<buffer.data();
 | 
						if constexpr(debug) std::cerr<<buffer.data();
 | 
				
			||||||
    #endif
 | 
					#endif
 | 
				
			||||||
	if(_port != nullptr)
 | 
						if(_port != nullptr)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		_port->write(buffer);
 | 
							_port->write(buffer);
 | 
				
			||||||
| 
						 | 
					@ -65,9 +65,9 @@ void Microcontroller::write(const QByteArray& buffer)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Microcontroller::write(char* buffer, const size_t length)
 | 
					void Microcontroller::write(char* buffer, const size_t length)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    #ifndef Q_OS_ANDROID
 | 
					#ifndef Q_OS_ANDROID
 | 
				
			||||||
	if constexpr(debug) std::cerr<<buffer;
 | 
						if constexpr(debug) std::cerr<<buffer;
 | 
				
			||||||
    #endif
 | 
					#endif
 | 
				
			||||||
	if(_port != nullptr)
 | 
						if(_port != nullptr)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		_port->write(buffer, length);
 | 
							_port->write(buffer, length);
 | 
				
			||||||
| 
						 | 
					@ -130,7 +130,8 @@ std::shared_ptr<Relay> Microcontroller::processRelayLine(const QString& buffer)
 | 
				
			||||||
		for(int i = 10; i < bufferList.size(); i++) name.append(bufferList[i] + ' ');
 | 
							for(int i = 10; i < bufferList.size(); i++) name.append(bufferList[i] + ' ');
 | 
				
			||||||
		if(name.size() > 1)name.remove(name.size()-1, 1);
 | 
							if(name.size() > 1)name.remove(name.size()-1, 1);
 | 
				
			||||||
		else name = "Relay " + QString::number(bufferList[1].toInt(nullptr, 2));
 | 
							else name = "Relay " + QString::number(bufferList[1].toInt(nullptr, 2));
 | 
				
			||||||
        return std::shared_ptr<Relay>( new Relay(bufferList[2].toInt(), name, bufferList[4].toInt(nullptr, 2), bufferList[8].toInt()));
 | 
							return std::shared_ptr<Relay>( new Relay(bufferList[2].toInt(), name, bufferList[4].toInt(nullptr, 2),
 | 
				
			||||||
 | 
							                               bufferList[8].toInt()));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return  nullptr;
 | 
						return  nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include "../apgetconnected.h"
 | 
					#include "../apgetconnected.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OcupancySensorSource::OcupancySensorSource(QObject *parent,  const QString& device, const QString& deviceMac): QObject (parent), deviceMac_(deviceMac), device_(device)
 | 
					OcupancySensorSource::OcupancySensorSource(QObject *parent,  const QString& device,
 | 
				
			||||||
 | 
					        const QString& deviceMac): QObject (parent), deviceMac_(deviceMac), device_(device)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QTimer::singleShot(timeoutMs, this, &OcupancySensorSource::Timeout);
 | 
						QTimer::singleShot(timeoutMs, this, &OcupancySensorSource::Timeout);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,8 @@ private:
 | 
				
			||||||
	static constexpr unsigned timeoutMs = (15 * 60) * 1000;
 | 
						static constexpr unsigned timeoutMs = (15 * 60) * 1000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit OcupancySensorSource(QObject *parent = nullptr, const QString& device = "wlan0", const QString& deviceMac = "60:BE:B5:25:8C:E0");
 | 
						explicit OcupancySensorSource(QObject *parent = nullptr, const QString& device = "wlan0",
 | 
				
			||||||
 | 
						                              const QString& deviceMac = "60:BE:B5:25:8C:E0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void store(QJsonObject& json);
 | 
						void store(QJsonObject& json);
 | 
				
			||||||
	void load(const QJsonObject& json);
 | 
						void load(const QJsonObject& json);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,8 @@ public:
 | 
				
			||||||
	QDateTime lastSeen;
 | 
						QDateTime lastSeen;
 | 
				
			||||||
	bool hidden;
 | 
						bool hidden;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Sensor(uint8_t typeIn, uint8_t idIn, float fieldIn = 0, QString nameIn = "", bool hiddenIn = false): type(typeIn), id(idIn), field(fieldIn), name(nameIn), hidden(hiddenIn)
 | 
						Sensor(uint8_t typeIn, uint8_t idIn, float fieldIn = 0, QString nameIn = "", bool hiddenIn = false): type(typeIn),
 | 
				
			||||||
 | 
							id(idIn), field(fieldIn), name(nameIn), hidden(hiddenIn)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		lastSeen = QDateTime::currentDateTime();
 | 
							lastSeen = QDateTime::currentDateTime();
 | 
				
			||||||
		if(nameIn == "") generateName();
 | 
							if(nameIn == "") generateName();
 | 
				
			||||||
| 
						 | 
					@ -39,9 +40,18 @@ public:
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		lastSeen = QDateTime::currentDateTime();
 | 
							lastSeen = QDateTime::currentDateTime();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    inline bool operator==(const Sensor& in) const{ return type==in.type && id == in.id; }
 | 
						inline bool operator==(const Sensor& in) const
 | 
				
			||||||
    inline bool operator!=(const Sensor& in) const{ return !(*this==in); }
 | 
						{
 | 
				
			||||||
    inline void updateSeen(){lastSeen = QDateTime::currentDateTime();}
 | 
							return type==in.type && id == in.id;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						inline bool operator!=(const Sensor& in) const
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return !(*this==in);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						inline void updateSeen()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							lastSeen = QDateTime::currentDateTime();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	static Sensor sensorFromString(const QString& str)
 | 
						static Sensor sensorFromString(const QString& str)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		QStringList bufferList = str.split(' ');
 | 
							QStringList bufferList = str.split(' ');
 | 
				
			||||||
| 
						 | 
					@ -80,9 +90,12 @@ private:
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SensorStore(QObject *parent = nullptr);
 | 
						SensorStore(QObject *parent = nullptr);
 | 
				
			||||||
    virtual ~SensorStore(){}
 | 
						virtual ~SensorStore() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline std::vector<Sensor>* getSensors(){ return &sensors_; }
 | 
						inline std::vector<Sensor>* getSensors()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return &sensors_;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								src/sun.cpp
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								src/sun.cpp
									
										
									
									
									
								
							| 
						 | 
					@ -63,7 +63,8 @@ std::time_t Sun::JdTime::toStdTime()
 | 
				
			||||||
	return millenniumTime;
 | 
						return millenniumTime;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Sun::Sun(double latitude, double longitude, double altitude): latitude_(latitude), longetude_(longitude), altitude_(altitude)
 | 
					Sun::Sun(double latitude, double longitude, double altitude): latitude_(latitude), longetude_(longitude),
 | 
				
			||||||
 | 
						altitude_(altitude)
 | 
				
			||||||
{}
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double Sun::nextMeanSolarNoonJD(const JdTime& time)
 | 
					double Sun::nextMeanSolarNoonJD(const JdTime& time)
 | 
				
			||||||
| 
						 | 
					@ -78,7 +79,8 @@ double Sun::meanSolarAnomaly(double meanSolarNoon)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double Sun::eqOfCenter(double meanSolarAnomaly)
 | 
					double Sun::eqOfCenter(double meanSolarAnomaly)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return 1.9148*sin(meanSolarAnomaly*TO_RADS) + 0.0200*sin(2*meanSolarAnomaly*TO_RADS) + 0.0003*sin(3*meanSolarAnomaly*TO_RADS);
 | 
						return 1.9148*sin(meanSolarAnomaly*TO_RADS) + 0.0200*sin(2*meanSolarAnomaly*TO_RADS) + 0.0003*sin(
 | 
				
			||||||
 | 
						           3*meanSolarAnomaly*TO_RADS);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double Sun::eclipticLongitude(double eqOfCenter, double meanSolarAnomaly)
 | 
					double Sun::eclipticLongitude(double eqOfCenter, double meanSolarAnomaly)
 | 
				
			||||||
| 
						 | 
					@ -108,7 +110,8 @@ double Sun::hourAngle(double localSolarTime)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double Sun::hourAngleAtSunset(double solarDeclination)
 | 
					double Sun::hourAngleAtSunset(double solarDeclination)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return TO_DEGS*acos((sin((-0.83-(2.076*sqrt(altitude_)/60.0))*TO_RADS) - sin(solarDeclination*TO_RADS)*sin(latitude_*TO_RADS))/(cos(latitude_*TO_RADS)*cos(solarDeclination*TO_RADS)));
 | 
						return TO_DEGS*acos((sin((-0.83-(2.076*sqrt(altitude_)/60.0))*TO_RADS) - sin(solarDeclination*TO_RADS)*sin(
 | 
				
			||||||
 | 
						                         latitude_*TO_RADS))/(cos(latitude_*TO_RADS)*cos(solarDeclination*TO_RADS)));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double Sun::altitude()
 | 
					double Sun::altitude()
 | 
				
			||||||
| 
						 | 
					@ -120,7 +123,8 @@ double Sun::altitude()
 | 
				
			||||||
	double localSolarTimeValue    = localSolarTime(time, equationOfTime(meanSolarAnomalyValue, eclipticLongitudeValue));
 | 
						double localSolarTimeValue    = localSolarTime(time, equationOfTime(meanSolarAnomalyValue, eclipticLongitudeValue));
 | 
				
			||||||
	double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
						double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double cosZenithAngle = sin(latitude_*TO_RADS)*sin(declinationValue*TO_RADS)+cos(latitude_*TO_RADS)*cos(declinationValue*TO_RADS)*cos(hourAngle(localSolarTimeValue)*TO_RADS);
 | 
						double cosZenithAngle = sin(latitude_*TO_RADS)*sin(declinationValue*TO_RADS)+cos(latitude_*TO_RADS)*cos(
 | 
				
			||||||
 | 
						                            declinationValue*TO_RADS)*cos(hourAngle(localSolarTimeValue)*TO_RADS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return TO_DEGS*asin(cosZenithAngle);
 | 
						return TO_DEGS*asin(cosZenithAngle);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -133,7 +137,8 @@ double Sun::maximumAltitude()
 | 
				
			||||||
	double eclipticLongitudeValue = eclipticLongitude(eqOfCenter(meanSolarAnomalyValue), meanSolarAnomalyValue);
 | 
						double eclipticLongitudeValue = eclipticLongitude(eqOfCenter(meanSolarAnomalyValue), meanSolarAnomalyValue);
 | 
				
			||||||
	double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
						double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double cosZenithAngle = sin(latitude_*TO_RADS)*sin(declinationValue*TO_RADS)+cos(latitude_*TO_RADS)*cos(declinationValue*TO_RADS);
 | 
						double cosZenithAngle = sin(latitude_*TO_RADS)*sin(declinationValue*TO_RADS)+cos(latitude_*TO_RADS)*cos(
 | 
				
			||||||
 | 
						                            declinationValue*TO_RADS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return TO_DEGS*asin(cosZenithAngle);
 | 
						return TO_DEGS*asin(cosZenithAngle);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -153,7 +158,8 @@ std::time_t Sun::riseTime()
 | 
				
			||||||
	double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
						double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
				
			||||||
	double hourAngleValue         = hourAngleAtSunset(declinationValue);
 | 
						double hourAngleValue         = hourAngleAtSunset(declinationValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	time.julianDate = meanSolarNoonValue + equationOfTime(meanSolarAnomalyValue, eclipticLongitudeValue) - hourAngleValue/360.0;
 | 
						time.julianDate = meanSolarNoonValue + equationOfTime(meanSolarAnomalyValue,
 | 
				
			||||||
 | 
						                  eclipticLongitudeValue) - hourAngleValue/360.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return time.toStdTime();
 | 
						return time.toStdTime();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -166,7 +172,8 @@ std::time_t Sun::setTime()
 | 
				
			||||||
	double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
						double declinationValue       = solarDeclination(eclipticLongitudeValue);
 | 
				
			||||||
	double hourAngleValue         = hourAngleAtSunset(declinationValue);
 | 
						double hourAngleValue         = hourAngleAtSunset(declinationValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	time.julianDate = meanSolarNoonValue + equationOfTime(meanSolarAnomalyValue, eclipticLongitudeValue) + hourAngleValue/360.0;
 | 
						time.julianDate = meanSolarNoonValue + equationOfTime(meanSolarAnomalyValue,
 | 
				
			||||||
 | 
						                  eclipticLongitudeValue) + hourAngleValue/360.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return time.toStdTime();
 | 
						return time.toStdTime();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,9 +16,9 @@ ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<AlarmTime> alarm, QWidg
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<SensorActor> actor, QWidget *parent) :
 | 
					ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<SensorActor> actor, QWidget *parent) :
 | 
				
			||||||
QDialog(parent),
 | 
						QDialog(parent),
 | 
				
			||||||
actor_(actor),
 | 
						actor_(actor),
 | 
				
			||||||
ui(new Ui::ActorSettingsDialog)
 | 
						ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	init();
 | 
						init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,9 +38,9 @@ ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<Regulator> actor, QWidg
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<TimerActor> actor, QWidget *parent) :
 | 
					ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<TimerActor> actor, QWidget *parent) :
 | 
				
			||||||
QDialog(parent),
 | 
						QDialog(parent),
 | 
				
			||||||
actor_(actor),
 | 
						actor_(actor),
 | 
				
			||||||
ui(new Ui::ActorSettingsDialog)
 | 
						ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	init();
 | 
						init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,9 +49,9 @@ ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<PolynomalActor> actor, QWidget *parent) :
 | 
					ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<PolynomalActor> actor, QWidget *parent) :
 | 
				
			||||||
QDialog(parent),
 | 
						QDialog(parent),
 | 
				
			||||||
actor_(actor),
 | 
						actor_(actor),
 | 
				
			||||||
ui(new Ui::ActorSettingsDialog)
 | 
						ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	init();
 | 
						init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,9 +60,9 @@ ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<MultiFactorActor> actor, QWidget *parent) :
 | 
					ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<MultiFactorActor> actor, QWidget *parent) :
 | 
				
			||||||
QDialog(parent),
 | 
						QDialog(parent),
 | 
				
			||||||
actor_(actor),
 | 
						actor_(actor),
 | 
				
			||||||
ui(new Ui::ActorSettingsDialog)
 | 
						ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	init();
 | 
						init();
 | 
				
			||||||
	widget = new FactorActorWidget(actor, this);
 | 
						widget = new FactorActorWidget(actor, this);
 | 
				
			||||||
| 
						 | 
					@ -70,9 +70,9 @@ ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<Actor> actor, QWidget *parent) :
 | 
					ActorSettingsDialog::ActorSettingsDialog(std::shared_ptr<Actor> actor, QWidget *parent) :
 | 
				
			||||||
QDialog(parent),
 | 
						QDialog(parent),
 | 
				
			||||||
actor_(actor),
 | 
						actor_(actor),
 | 
				
			||||||
ui(new Ui::ActorSettingsDialog)
 | 
						ui(new Ui::ActorSettingsDialog)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	init();
 | 
						init();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,8 @@
 | 
				
			||||||
#include "actorwidgets/polynomalactorwidget.h"
 | 
					#include "actorwidgets/polynomalactorwidget.h"
 | 
				
			||||||
#include "actorwidgets/factoractorwidget.h"
 | 
					#include "actorwidgets/factoractorwidget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class ActorSettingsDialog;
 | 
					class ActorSettingsDialog;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include "../../actors/alarmtime.h"
 | 
					#include "../../actors/alarmtime.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class AlarmWidget;
 | 
					class AlarmWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
#include <QWidget>
 | 
					#include <QWidget>
 | 
				
			||||||
#include "../../actors/factoractor.h"
 | 
					#include "../../actors/factoractor.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class FactorActorWidget;
 | 
					class FactorActorWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,8 @@
 | 
				
			||||||
#include "polynomalactorwidget.h"
 | 
					#include "polynomalactorwidget.h"
 | 
				
			||||||
#include "ui_polynomalactorwidget.h"
 | 
					#include "ui_polynomalactorwidget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PolynomalActorWidget::PolynomalActorWidget(std::shared_ptr<PolynomalActor> actor, SensorStore* sensors, QWidget *parent):
 | 
					PolynomalActorWidget::PolynomalActorWidget(std::shared_ptr<PolynomalActor> actor, SensorStore* sensors,
 | 
				
			||||||
 | 
					        QWidget *parent):
 | 
				
			||||||
	QWidget(parent),
 | 
						QWidget(parent),
 | 
				
			||||||
	sensors_(sensors),
 | 
						sensors_(sensors),
 | 
				
			||||||
	actor_(actor),
 | 
						actor_(actor),
 | 
				
			||||||
| 
						 | 
					@ -39,7 +40,8 @@ PolynomalActorWidget::~PolynomalActorWidget()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PolynomalActorWidget::setPow()
 | 
					void PolynomalActorWidget::setPow()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    actor_->setCoeffiancts(ui->doubleSpinBox_pow3->value(), ui->doubleSpinBox_pow2->value(), ui->doubleSpinBox_pow1->value(), ui->doubleSpinBox_pow0->value());
 | 
						actor_->setCoeffiancts(ui->doubleSpinBox_pow3->value(), ui->doubleSpinBox_pow2->value(),
 | 
				
			||||||
 | 
						                       ui->doubleSpinBox_pow1->value(), ui->doubleSpinBox_pow0->value());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PolynomalActorWidget::setSensor(const QModelIndex &index)
 | 
					void PolynomalActorWidget::setSensor(const QModelIndex &index)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
#include <QWidget>
 | 
					#include <QWidget>
 | 
				
			||||||
#include "../../actors/polynomalactor.h"
 | 
					#include "../../actors/polynomalactor.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class PolynomalActorWidget;
 | 
					class PolynomalActorWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +16,8 @@ class PolynomalActorWidget : public QWidget
 | 
				
			||||||
	std::shared_ptr<PolynomalActor> actor_;
 | 
						std::shared_ptr<PolynomalActor> actor_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit PolynomalActorWidget(std::shared_ptr<PolynomalActor> regulator, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
 | 
						explicit PolynomalActorWidget(std::shared_ptr<PolynomalActor> regulator, SensorStore* sensors = nullptr,
 | 
				
			||||||
 | 
						                              QWidget *parent = nullptr);
 | 
				
			||||||
	~PolynomalActorWidget();
 | 
						~PolynomalActorWidget();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
#include <QWidget>
 | 
					#include <QWidget>
 | 
				
			||||||
#include "../../actors/regulator.h"
 | 
					#include "../../actors/regulator.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class RegulatorWdiget;
 | 
					class RegulatorWdiget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +17,8 @@ class RegulatorWdiget : public QWidget
 | 
				
			||||||
	SensorStore* sensors_;
 | 
						SensorStore* sensors_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit RegulatorWdiget(std::shared_ptr<Regulator> regulator, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
 | 
						explicit RegulatorWdiget(std::shared_ptr<Regulator> regulator, SensorStore* sensors = nullptr,
 | 
				
			||||||
 | 
						                         QWidget *parent = nullptr);
 | 
				
			||||||
	~RegulatorWdiget();
 | 
						~RegulatorWdiget();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include <QItemSelection>
 | 
					#include <QItemSelection>
 | 
				
			||||||
#include "../../actors/sensoractor.h"
 | 
					#include "../../actors/sensoractor.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class SensorActorWidget;
 | 
					class SensorActorWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +18,8 @@ class SensorActorWidget : public QWidget
 | 
				
			||||||
	SensorStore* sensors_;
 | 
						SensorStore* sensors_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit SensorActorWidget(std::shared_ptr<SensorActor> sensorActor, SensorStore* sensors = nullptr, QWidget *parent = nullptr);
 | 
						explicit SensorActorWidget(std::shared_ptr<SensorActor> sensorActor, SensorStore* sensors = nullptr,
 | 
				
			||||||
 | 
						                           QWidget *parent = nullptr);
 | 
				
			||||||
	~SensorActorWidget();
 | 
						~SensorActorWidget();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
#include <QWidget>
 | 
					#include <QWidget>
 | 
				
			||||||
#include "../../actors/timeractor.h"
 | 
					#include "../../actors/timeractor.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class TimerActorWidget;
 | 
					class TimerActorWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include "../items/item.h"
 | 
					#include "../items/item.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class ItemCreationDialog;
 | 
					class ItemCreationDialog;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,8 @@
 | 
				
			||||||
#include "../items/itemstore.h"
 | 
					#include "../items/itemstore.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class RelayScrollBox;
 | 
					class RelayScrollBox;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
 #include "itemsettingsdialog.h"
 | 
					#include "itemsettingsdialog.h"
 | 
				
			||||||
#include "ui_itemsettingsdialog.h"
 | 
					#include "ui_itemsettingsdialog.h"
 | 
				
			||||||
#include "actorsettingsdialog.h"
 | 
					#include "actorsettingsdialog.h"
 | 
				
			||||||
#include "../actors/alarmtime.h"
 | 
					#include "../actors/alarmtime.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,8 @@
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include "../items/relay.h"
 | 
					#include "../items/relay.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class ItemSettingsDialog;
 | 
					class ItemSettingsDialog;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,10 @@ MessageItemSettingsWidget::MessageItemSettingsWidget(std::weak_ptr<MessageItem>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	connect(ui->lineEdit, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setText);
 | 
						connect(ui->lineEdit, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setText);
 | 
				
			||||||
	connect(ui->lineEdit_alert, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setAlert);
 | 
						connect(ui->lineEdit_alert, &QLineEdit::textChanged, this, &MessageItemSettingsWidget::setAlert);
 | 
				
			||||||
    connect(ui->pushButton, &QPushButton::pressed, [this](){ui->lineEdit_alert->setText(QFileDialog::getOpenFileName(this, "Choose File"));});
 | 
						connect(ui->pushButton, &QPushButton::pressed, [this]()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							ui->lineEdit_alert->setText(QFileDialog::getOpenFileName(this, "Choose File"));
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include "../../items/messageitem.h"
 | 
					#include "../../items/messageitem.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class MessageItemSettingsWidget;
 | 
					class MessageItemSettingsWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include "../../items/relay.h"
 | 
					#include "../../items/relay.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class RelayItemSettingsWidget;
 | 
					class RelayItemSettingsWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,8 @@
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include "../../items/systemitem.h"
 | 
					#include "../../items/systemitem.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class SystemItemSettingsWidget;
 | 
					class SystemItemSettingsWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,8 @@
 | 
				
			||||||
#include "itemsettingsdialog.h"
 | 
					#include "itemsettingsdialog.h"
 | 
				
			||||||
#include "../items/item.h"
 | 
					#include "../items/item.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
class ItemWidget;
 | 
					class ItemWidget;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
#include <QHeaderView>
 | 
					#include <QHeaderView>
 | 
				
			||||||
#include <QScroller>
 | 
					#include <QScroller>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTableWidget(parent), showHidden_(showHidden)
 | 
					SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTableWidget(parent),
 | 
				
			||||||
 | 
						showHidden_(showHidden)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	setColumnCount(2);
 | 
						setColumnCount(2);
 | 
				
			||||||
	setSelectionBehavior(QAbstractItemView::SelectRows);
 | 
						setSelectionBehavior(QAbstractItemView::SelectRows);
 | 
				
			||||||
| 
						 | 
					@ -16,7 +17,8 @@ SensorListWidget::SensorListWidget(const bool showHidden, QWidget *parent): QTab
 | 
				
			||||||
	setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
 | 
						setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SensorListWidget::SensorListWidget(SensorStore& sensorStore, const bool showHidden, QWidget* parent): QTableWidget (parent), showHidden_(showHidden)
 | 
					SensorListWidget::SensorListWidget(SensorStore& sensorStore, const bool showHidden,
 | 
				
			||||||
 | 
					                                   QWidget* parent): QTableWidget (parent), showHidden_(showHidden)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	sensorsChanged(*(sensorStore.getSensors()));
 | 
						sensorsChanged(*(sensorStore.getSensors()));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ 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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue