diff --git a/src/kaskas/io/controllers/heater.hpp b/src/kaskas/io/controllers/heater.hpp index f9df21a..9ab24de 100644 --- a/src/kaskas/io/controllers/heater.hpp +++ b/src/kaskas/io/controllers/heater.hpp @@ -13,11 +13,6 @@ namespace kaskas::io { -using spn::controller::PID; -using spn::core::time::AlarmTimer; -using spn::core::time::IntervalTimer; -using spn::core::time::Timer; - // todo: put this in a configuration file constexpr double MIN_INSIDE_TEMPERATURE = 12.0; constexpr double MAX_INSIDE_TEMPERATURE = 40.0; @@ -116,6 +111,9 @@ class Heater { } private: + using IntervalTimer = spn::structure::time::IntervalTimer; + using Timer = spn::structure::time::Timer; + const Config _cfg; Timer _current_state_duration; @@ -130,6 +128,8 @@ class Heater { }; public: + using PID = spn::controller::PID; + struct Config { PID::Config pid_cfg; double max_heater_setpoint = 40.0; @@ -337,6 +337,10 @@ class Heater { } private: + using AlarmTimer = spn::structure::time::AlarmTimer; + using IntervalTimer = spn::structure::time::IntervalTimer; + using Timer = spn::structure::time::Timer; + const Config _cfg; HardwareStack& _hws; diff --git a/src/kaskas/io/peripheral.hpp b/src/kaskas/io/peripheral.hpp index 433abfc..bf72a35 100644 --- a/src/kaskas/io/peripheral.hpp +++ b/src/kaskas/io/peripheral.hpp @@ -9,8 +9,6 @@ namespace kaskas::io { -using spn::core::time::IntervalTimer; - /// Encapsalates a single hardware peripheral class Peripheral { public: @@ -34,6 +32,8 @@ class Peripheral { } private: + using IntervalTimer = spn::structure::time::IntervalTimer; + std::optional _timer; }; diff --git a/src/kaskas/io/peripherals/SHT31_TempHumidityProbe.hpp b/src/kaskas/io/peripherals/SHT31_TempHumidityProbe.hpp index 64c8445..91745ce 100644 --- a/src/kaskas/io/peripherals/SHT31_TempHumidityProbe.hpp +++ b/src/kaskas/io/peripherals/SHT31_TempHumidityProbe.hpp @@ -14,8 +14,6 @@ namespace kaskas::io { -using spn::core::time::AlarmTimer; - constexpr bool SHT31_USE_CRC = false; // false, means 'not fast' for Tillaart's SHT31 library; i.e. read with CRC class SHT31TempHumidityProbe : public Peripheral { @@ -107,6 +105,8 @@ class SHT31TempHumidityProbe : public Peripheral { bool is_ready() { return _sht31.isConnected() && _sht31.getError() == SHT31_OK; } private: + using AlarmTimer = spn::structure::time::AlarmTimer; + const Config _cfg; SHT31 _sht31; diff --git a/src/kaskas/io/peripherals/analogue_output.hpp b/src/kaskas/io/peripherals/analogue_output.hpp index 47072d3..f677f96 100644 --- a/src/kaskas/io/peripherals/analogue_output.hpp +++ b/src/kaskas/io/peripherals/analogue_output.hpp @@ -56,7 +56,7 @@ class AnalogueOutputPeripheral : public HAL::AnalogueOutput, public Peripheral { _is_creeping = true; _creep_target_value = setpoint; - _creep_time_on_target = spn::core::time::AlarmTimer(travel_time); + _creep_time_on_target = AlarmTimer(travel_time); _creep_target_increment = (setpoint - value()) / (travel_time / update_interval()).raw(); } @@ -64,10 +64,12 @@ class AnalogueOutputPeripheral : public HAL::AnalogueOutput, public Peripheral { void creep_stop() { _is_creeping = false; } private: + using AlarmTimer = spn::structure::time::AlarmTimer; + bool _is_creeping = false; double _creep_target_value = 0; double _creep_target_increment = 0; - spn::core::time::AlarmTimer _creep_time_on_target; + AlarmTimer _creep_time_on_target; }; } // namespace kaskas::io \ No newline at end of file diff --git a/src/kaskas/io/peripherals/relay.hpp b/src/kaskas/io/peripherals/relay.hpp index dc2f4ec..2c434c1 100644 --- a/src/kaskas/io/peripherals/relay.hpp +++ b/src/kaskas/io/peripherals/relay.hpp @@ -6,8 +6,6 @@ #include namespace kaskas::io { -using spn::core::Exception; -using spn::core::time::Timer; class Relay : public Peripheral { public: @@ -57,6 +55,9 @@ class Relay : public Peripheral { } private: + using Timer = spn::structure::time::Timer; + using Exception = spn::core::Exception; + const Config _cfg; DigitalOutput _pin; std::optional _backoff_timer = std::nullopt; diff --git a/src/kaskas/io/providers/pump.hpp b/src/kaskas/io/providers/pump.hpp index d5928a4..76fb9f3 100644 --- a/src/kaskas/io/providers/pump.hpp +++ b/src/kaskas/io/providers/pump.hpp @@ -12,8 +12,6 @@ #include namespace kaskas::io { -using spn::core::Exception; -using spn::core::time::Timer; struct Pump { private: @@ -105,6 +103,9 @@ struct Pump { } private: + using Exception = spn::core::Exception; + using Timer = spn::structure::time::Timer; + void attach_interrupt(); void detach_interrupt(); static uint32_t interrupt_counter(); diff --git a/src/kaskas/subsystems/climatecontrol.hpp b/src/kaskas/subsystems/climatecontrol.hpp index eb4a493..ed63107 100644 --- a/src/kaskas/subsystems/climatecontrol.hpp +++ b/src/kaskas/subsystems/climatecontrol.hpp @@ -17,35 +17,22 @@ #include #include #include -#include #include #include namespace kaskas::component { -using kaskas::Component; -using spn::controller::PID; -using spn::core::Exception; -using spn::core::time::Schedule; -using spn::core::time::Timer; -using Events = kaskas::Events; -using spn::eventsystem::Event; -using spn::eventsystem::EventHandler; -using EventSystem = spn::core::EventSystem; -using spn::core::time::AlarmTimer; - -using kaskas::io::DS18B20TempProbe; -using Heater = kaskas::io::Heater; -using kaskas::io::SHT31TempHumidityProbe; -using spn::controller::SRLatch; -using spn::core::time::IntervalTimer; - namespace detail { inline double inverted(double value, double base = 100.0) { return base - value; } } // namespace detail class ClimateControl final : public kaskas::Component { public: + using PID = spn::controller::PID; + using Schedule = spn::structure::time::Schedule; + using Heater = kaskas::io::Heater; + using Event = spn::eventsystem::Event; + struct Config { static constexpr std::string_view name = "ClimateControl"; io::HardwareStack::Idx hws_power_idx; @@ -384,6 +371,15 @@ class ClimateControl final : public kaskas::Component { } private: + using Component = kaskas::Component; + using Events = kaskas::Events; + using EventSystem = spn::core::EventSystem; + using IntervalTimer = spn::structure::time::IntervalTimer; + + using DS18B20TempProbe = kaskas::io::DS18B20TempProbe; + using SHT31TempHumidityProbe = kaskas::io::SHT31TempHumidityProbe; + using SRLatch = spn::controller::SRLatch; + const Config _cfg; const io::Clock& _clock; diff --git a/src/kaskas/subsystems/data_acquisition.hpp b/src/kaskas/subsystems/data_acquisition.hpp index 5abd7a6..80091ea 100644 --- a/src/kaskas/subsystems/data_acquisition.hpp +++ b/src/kaskas/subsystems/data_acquisition.hpp @@ -17,6 +17,8 @@ namespace meta = spn::core::meta; class DataAcquisition : public Component { public: + using Event = spn::eventsystem::Event; + struct Config { time_s initial_warm_up_time = time_s(30); // don't allow timeseries access immediately after startup std::initializer_list active_dataproviders; // dataproviders for which to print timeseries diff --git a/src/kaskas/subsystems/fluidsystem.hpp b/src/kaskas/subsystems/fluidsystem.hpp index 84fa478..2849c59 100644 --- a/src/kaskas/subsystems/fluidsystem.hpp +++ b/src/kaskas/subsystems/fluidsystem.hpp @@ -11,26 +11,18 @@ #include #include #include -#include #include #include #include namespace kaskas::component { -using kaskas::Component; -using kaskas::io::Pump; -using spn::core::Exception; -using spn::core::time::Timer; -using spn::eventsystem::Event; -using spn::eventsystem::EventHandler; -using EWMA = spn::filter::EWMA; - -using Events = kaskas::Events; -using EventSystem = spn::core::EventSystem; class Fluidsystem final : public Component { public: + using Pump = kaskas::io::Pump; + using Event = spn::eventsystem::Event; + struct Config { static constexpr std::string_view name = "Fluids"; @@ -266,6 +258,12 @@ class Fluidsystem final : public Component { } private: + using Component = kaskas::Component; + using EWMA = spn::filter::EWMA; + + using Events = kaskas::Events; + using EventSystem = spn::core::EventSystem; + const Config _cfg; Status _status; diff --git a/src/kaskas/subsystems/growlights.hpp b/src/kaskas/subsystems/growlights.hpp index a6dcf7f..b58af58 100644 --- a/src/kaskas/subsystems/growlights.hpp +++ b/src/kaskas/subsystems/growlights.hpp @@ -16,17 +16,12 @@ #include namespace kaskas::component { -using spn::core::Exception; -using spn::core::time::Timer; -using spn::eventsystem::Event; -using spn::eventsystem::EventHandler; - -using Events = kaskas::Events; -using EventSystem = spn::core::EventSystem; -using kaskas::Component; class Growlights final : public Component { public: + using Event = spn::eventsystem::Event; + using Schedule = spn::structure::time::Schedule; + struct Config { io::HardwareStack::Idx redblue_spectrum_actuator_idx; Schedule::Config redblue_spectrum_schedule; @@ -219,6 +214,10 @@ class Growlights final : public Component { void sideload_providers(io::VirtualStackFactory& ssf) override {} private: + using Events = kaskas::Events; + using EventSystem = spn::core::EventSystem; + using Component = kaskas::Component; + using LogicalState = spn::core::LogicalState; const Config _cfg; diff --git a/src/main.cpp b/src/main.cpp index 0a06033..af6bb59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,8 +29,8 @@ using kaskas::io::SHT31TempHumidityProbe; using kaskas::io::clock::DS3231Clock; using spn::controller::PID; using spn::controller::SRLatch; -using spn::core::time::Schedule; using spn::eventsystem::EventSystem; +using spn::structure::time::Schedule; namespace meta = spn::core::meta;