Parking Garage Control System
ESP32 Parking Garage – ESP-IDF/FreeRTOS
Loading...
Searching...
No Matches
hal_state_machine.h
Go to the documentation of this file.
1#ifndef HAL_STATE_MACHINE_H
2#define HAL_STATE_MACHINE_H
3
4// --- 1. Hardware Abstraction Layer (HAL) ---
5
6// Abstract Interface for GPIO Output
7class IGpioOutput {
8 public:
9 virtual void setLevel(bool level) = 0;
10 virtual bool getLevel() const = 0;
11 virtual ~IGpioOutput() = default;
12};
13
14// --- 2. Event System ---
15
20
21struct Event {
23};
24
25// --- 3. Logic / State Machine ---
26
28 public:
29 enum class State { Closed,
30 Opening,
31 Open };
32
33 // Dependency Injection: Logic depends on Interface, not concrete Hardware
34 explicit GateController(IGpioOutput& motorGpio);
35
36 void handleEvent(const Event& event);
37 State getCurrentState() const { return currentState; }
38
39 private:
40 IGpioOutput& motor; // Reference to abstract hardware
41 State currentState;
42};
43
44#endif // HAL_STATE_MACHINE_H
EventType
Event types in the parking system.
Definition Event.h:9
Definition hal_state_machine.h:27
void handleEvent(const Event &event)
Definition hal_state_machine.cpp:11
State getCurrentState() const
Definition hal_state_machine.h:37
State
Definition hal_state_machine.h:29
Interface for GPIO output abstraction.
Definition IGpioOutput.h:9
virtual bool getLevel() const =0
virtual ~IGpioOutput()=default
virtual void setLevel(bool level)=0
@ LimitSwitchReached
Event structure.
Definition Event.h:45
EventType type
Definition Event.h:46
Coverage