Skip to content

Commit

Permalink
various: make type aliases private
Browse files Browse the repository at this point in the history
  • Loading branch information
s-t-a-n committed Oct 12, 2024
1 parent f958735 commit 3ea63b9
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 53 deletions.
14 changes: 9 additions & 5 deletions src/kaskas/io/controllers/heater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -130,6 +128,8 @@ class Heater {
};

public:
using PID = spn::controller::PID;

struct Config {
PID::Config pid_cfg;
double max_heater_setpoint = 40.0;
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/kaskas/io/peripheral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace kaskas::io {

using spn::core::time::IntervalTimer;

/// Encapsalates a single hardware peripheral
class Peripheral {
public:
Expand All @@ -34,6 +32,8 @@ class Peripheral {
}

private:
using IntervalTimer = spn::structure::time::IntervalTimer;

std::optional<IntervalTimer> _timer;
};

Expand Down
4 changes: 2 additions & 2 deletions src/kaskas/io/peripherals/SHT31_TempHumidityProbe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions src/kaskas/io/peripherals/analogue_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ 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<double>();
}

/// Stop creeping to target.
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
5 changes: 3 additions & 2 deletions src/kaskas/io/peripherals/relay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <spine/platform/hal.hpp>

namespace kaskas::io {
using spn::core::Exception;
using spn::core::time::Timer;

class Relay : public Peripheral {
public:
Expand Down Expand Up @@ -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<Timer> _backoff_timer = std::nullopt;
Expand Down
5 changes: 3 additions & 2 deletions src/kaskas/io/providers/pump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <cstdint>

namespace kaskas::io {
using spn::core::Exception;
using spn::core::time::Timer;

struct Pump {
private:
Expand Down Expand Up @@ -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();
Expand Down
32 changes: 14 additions & 18 deletions src/kaskas/subsystems/climatecontrol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,22 @@
#include <spine/eventsystem/eventsystem.hpp>
#include <spine/filter/implementations/bandpass.hpp>
#include <spine/filter/implementations/ewma.hpp>
#include <spine/io/sensor.hpp>
#include <spine/platform/hal.hpp>
#include <spine/structure/time/schedule.hpp>

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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/kaskas/subsystems/data_acquisition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataProviders> active_dataproviders; // dataproviders for which to print timeseries
Expand Down
20 changes: 9 additions & 11 deletions src/kaskas/subsystems/fluidsystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,18 @@
#include <spine/core/utils/string.hpp>
#include <spine/eventsystem/eventsystem.hpp>
#include <spine/filter/implementations/ewma.hpp>
#include <spine/io/sensor.hpp>
#include <spine/platform/hal.hpp>
#include <spine/structure/time/timers.hpp>

#include <cstdint>

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<double>;

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";

Expand Down Expand Up @@ -266,6 +258,12 @@ class Fluidsystem final : public Component {
}

private:
using Component = kaskas::Component;
using EWMA = spn::filter::EWMA<double>;

using Events = kaskas::Events;
using EventSystem = spn::core::EventSystem;

const Config _cfg;
Status _status;

Expand Down
15 changes: 7 additions & 8 deletions src/kaskas/subsystems/growlights.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@
#include <cstdint>

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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3ea63b9

Please sign in to comment.