#ifndef RELAY_H
#define RELAY_H

#include<stdint.h>
#include<QObject>

#include "item.h"

class Microcontroller;

class Relay : public Item
{
	Q_OBJECT
private:
	static Microcontroller* micro_;

	uint8_t id_;
	uint16_t address_;

protected:
	virtual void enactValue(uint8_t value) override;

public:
	Relay(uint8_t id = 0, QString name = "", uint16_t address = 0, bool state = false, QObject* parent = nullptr);

	uint16_t getAddress() const;
	uint8_t getId() const;
	void setId(uint8_t id);

	inline static void setMicrocontroller(Microcontroller* micro)
	{
		micro_ = micro;
	}

	virtual void store(QJsonObject& json) override;
	virtual void load(const QJsonObject& json, const bool preserve = false) override;
};
#endif // RELAY_H
