#pragma once

#include "item.h"
#include "sensors/sensor.h"
#include "microcontroller.h"

#include <QTimer>

class PowerItem: public Item
{
	Q_OBJECT
private:

signals:
	void stateChanged(Sensor sensor, sensor_update_type_t type = SENSOR_UPDATE_BACKEND);

private slots:
	void timeout();

protected:
	virtual void enactValue(uint8_t value) override;

public:
	PowerItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Power",  uint8_t value = 0,
	          QObject* parent = nullptr);
	void emmitSensor()
	{
		stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0, "Shutdown Imminent", true));
	}
	virtual void store(QJsonObject& json) override;
};
