#ifndef BATTERYCONTROLLER_H
#define BATTERYCONTROLLER_H

#include <QObject>
#include <QVariant>

class BatteryController : public QObject
{
	Q_OBJECT

	Q_PROPERTY(int batteryIndex READ batteryIndex WRITE setBatteryIndex NOTIFY batteryIndexChanged)

	Q_PROPERTY(int chargeType READ chargeType WRITE setChargeType NOTIFY chargeTypeChanged)
	Q_PROPERTY(int workingMode READ workingMode WRITE setWorkingMode NOTIFY workingModeChanged)

	Q_PROPERTY(QVariant controlVoltage READ controlVoltage WRITE setControlVoltage NOTIFY controlVoltageChanged)
	Q_PROPERTY(QVariant controlCurrent READ controlCurrent WRITE setControlCurrent NOTIFY controlCurrentChanged)
	Q_PROPERTY(QVariant controlTemperature READ controlTemperature WRITE setControlTemperature NOTIFY controlTemperatureChanged)
	Q_PROPERTY(QVariant controlCapacity READ controlCapacity WRITE setControlCapacity NOTIFY controlCapacityChanged)

	Q_PROPERTY(QVariant measuredVoltage READ measuredVoltage WRITE setMeasuredVoltage NOTIFY measuredVoltageChanged)
	Q_PROPERTY(QVariant measuredCurrent READ measuredCurrent WRITE setMeasuredCurrent NOTIFY measuredCurrentChanged)
	Q_PROPERTY(QVariant measuredTemperature READ measuredTemperature WRITE setMeasuredTemperature NOTIFY measuredTemperatureChanged)
	Q_PROPERTY(QVariant measuredCapacity READ measuredCapacity WRITE setMeasuredCapacity NOTIFY measuredCapacityChanged)

	Q_PROPERTY(QVariantList statues READ statuses WRITE setStatuses NOTIFY statusesChanged)

public:
	explicit BatteryController(QObject *parent = nullptr);
	~BatteryController();

	int batteryIndex() const;
	void setBatteryIndex(int index);

	int chargeType() const;
	void setChargeType(int type);

	int workingMode() const;
	void setWorkingMode(int mode);

	QVariant controlVoltage() const;
	void setControlVoltage(const QVariant &value);

	QVariant controlCurrent() const;
	void setControlCurrent(const QVariant &value);

	QVariant controlTemperature() const;
	void setControlTemperature(const QVariant &value);

	QVariant controlCapacity() const;
	void setControlCapacity(const QVariant &value);

	QVariant measuredVoltage() const;
	void setMeasuredVoltage(const QVariant &value);

	QVariant measuredCurrent() const;
	void setMeasuredCurrent(const QVariant &value);

	QVariant measuredTemperature() const;
	void setMeasuredTemperature(const QVariant &value);

	QVariant measuredCapacity() const;
	void setMeasuredCapacity(const QVariant &value);

	QVariantList statuses() const;
	void setStatuses(const QVariantList &statuses);
	void addStatus(const quint16 status);

signals:
	void batteryIndexChanged();

	void chargeTypeChanged();
	void workingModeChanged();
	void actionButtonClicked();

	void controlVoltageChanged();
	void controlCurrentChanged();
	void controlTemperatureChanged();
	void controlCapacityChanged();

	void measuredVoltageChanged();
	void measuredCurrentChanged();
	void measuredTemperatureChanged();
	void measuredCapacityChanged();

	void statusesChanged();

private:
	int batteryIndex_ = 0;

	int chargeType_ = 0;
	int workingMode_ = 0;

	QVariant controlVoltage_;
	QVariant controlCurrent_;
	QVariant controlTemperature_;
	QVariant controlCapacity_;

	QVariant measuredVoltage_;
	QVariant measuredCurrent_;
	QVariant measuredTemperature_;
	QVariant measuredCapacity_;

	QVariantList statuses_;
};

#endif // BATTERYCONTROLLER_H
