2019-01-10 20:44:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-14 02:10:17 +00:00
|
|
|
#include "EventArgs.h"
|
|
|
|
#include "Signal.h"
|
|
|
|
|
2019-01-10 20:44:16 +00:00
|
|
|
namespace EightBit {
|
|
|
|
class Device {
|
|
|
|
public:
|
|
|
|
enum class PinLevel {
|
|
|
|
Low, High
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr auto raised(const PinLevel line) { return line == PinLevel::High; }
|
|
|
|
static void raise(PinLevel& line) noexcept { line = PinLevel::High; }
|
|
|
|
static constexpr auto lowered(const PinLevel line) { return line == PinLevel::Low; }
|
|
|
|
static void lower(PinLevel& line) noexcept { line = PinLevel::Low; }
|
|
|
|
|
|
|
|
virtual ~Device() {};
|
|
|
|
|
2019-01-14 02:10:17 +00:00
|
|
|
Signal<EventArgs> RaisedPOWER;
|
|
|
|
Signal<EventArgs> LoweredPOWER;
|
|
|
|
|
2019-01-10 20:44:16 +00:00
|
|
|
[[nodiscard]] auto& POWER() noexcept { return m_powerLine; }
|
|
|
|
|
|
|
|
[[nodiscard]] auto powered() noexcept { return raised(POWER()); }
|
2019-01-14 02:10:17 +00:00
|
|
|
virtual void raisePOWER();
|
|
|
|
virtual void lowerPOWER();
|
2019-01-10 20:44:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Device() {};
|
|
|
|
|
|
|
|
private:
|
2019-01-14 02:10:17 +00:00
|
|
|
PinLevel m_powerLine = PinLevel::Low; // In
|
2019-01-10 20:44:16 +00:00
|
|
|
};
|
|
|
|
}
|