50 lines
1.0 KiB
C++
50 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <config.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#include "relay.hpp"
|
|
#include "thermometer.hpp"
|
|
|
|
#include <ranczo-io/utils/mqtt_client.hpp>
|
|
|
|
namespace boost::asio {
|
|
class any_io_executor;
|
|
}
|
|
|
|
namespace ranczo {
|
|
|
|
class TemperatureController {
|
|
public:
|
|
template < typename T >
|
|
using awaitable = boost::asio::awaitable< T >;
|
|
|
|
virtual ~TemperatureController() = default;
|
|
|
|
virtual awaitable_expected< void > start() noexcept = 0;
|
|
virtual void stop() noexcept = 0;
|
|
};
|
|
|
|
class RelayThermostat : public TemperatureController {
|
|
struct Impl;
|
|
std::unique_ptr< Impl > _impl;
|
|
|
|
using executor = boost::asio::any_io_executor;
|
|
|
|
public:
|
|
RelayThermostat(executor & executor,
|
|
AsyncMqttClient & mqtt,
|
|
SettingsStore & setup,
|
|
std::unique_ptr< Relay > relay,
|
|
std::unique_ptr< Thermometer > thermometer,
|
|
std::string_view room,
|
|
int zone_id = 1);
|
|
~RelayThermostat();
|
|
|
|
awaitable_expected< void > start() noexcept override;
|
|
void stop() noexcept override;
|
|
};
|
|
|
|
} // namespace ranczo
|