# thanhnguyen-tien/ed-fsm-library architecture

> Architecture diagram of the GitHub repository thanhnguyen-tien/ed-fsm-library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thanhnguyen-tien/ed-fsm-library
- Repository: https://github.com/thanhnguyen-tien/ed-fsm-library

## Overview

This repository combines an event-driven MCU runtime with application components for Hydra control, oscilloscope modes, and telemetry. The principal documented runtime flow is producers posting events to a queue, then the Engine dispatching work in its main loop; timers and framework components participate there. The test-hydra entry point registers the Engine and Hydra Controller before running the Engine. README documentation supports the runtime relationships; application-component wiring is limited to what the entry-point excerpt shows, so uncertain links are omitted.

Main entry points: [`mStack-5/Components/core/engine.cpp`](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/engine.cpp) (Engine), [`mStack-5/Components/core/event-queue.h`](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/event-queue.h) (Event Queue), [`mStack-5/Components/core/event.h`](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/event.h) (Event Types), [`mStack-5/Components/core/signal.cpp`](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/signal.cpp) (Signals)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Event Runtime"]
  node_engine["Engine<br/>[engine.cpp]"]
  node_event_queue["Event Queue<br/>[event-queue.h]"]
  node_event["Event Types<br/>[event.h]"]
  node_memory_pool["Memory Pool<br/>[mem-pool.h]"]
  node_machine["State Machines<br/>[machine.h]"]
  node_strand["Strand<br/>[strand.h]"]
  node_signal["Signals<br/>[signal.cpp]"]
  node_timer["Timers<br/>[timer.cpp]"]
  node_system["System Services<br/>[system.cpp]"]
end

subgraph group_hydra["Hydra Control"]
  node_controller["Hydra Controller<br/>[controller.cpp]"]
  node_driver["Hydra Driver<br/>[driver.cpp]"]
  node_hal["Hydra HAL<br/>[hal.cpp]"]
  node_command["Hydra Commands<br/>[command.h]"]
  node_plot["Hydra Plot<br/>[plot.cpp]"]
end

subgraph group_scope["Oscilloscope"]
  node_scope_single["Single Scope<br/>[single.cpp]"]
  node_scope_dual["Dual Scope<br/>[dual.cpp]"]
  node_scope_triple["Triple Scope<br/>[triple.cpp]"]
  node_scope_quad["Quad Scope<br/>[quad.cpp]"]
  node_telemetry["Telemetry<br/>[telematry.cpp]"]
end

subgraph group_platform["MCU Platform"]
  node_test_main["Component Entry<br/>[main.cpp]"]
  node_mcu_setup["MCU Setup<br/>[main.c]"]
  node_mcu_config["Peripheral Defines<br/>[main.h]"]
end

node_startup(("Firmware Startup"))

node_startup -->|"starts"| node_test_main
node_test_main -->|"registers and runs"| node_engine
node_test_main -->|"registers"| node_controller
node_startup -.->|"initializes MCU"| node_mcu_setup
node_startup -.->|"uses definitions"| node_mcu_config
node_startup -->|"posts events"| node_event_queue
node_event_queue -->|"provides events"| node_engine
node_engine -->|"dispatches"| node_event
node_engine -->|"dispatches to"| node_machine
node_engine -->|"runs serialized work"| node_strand
node_engine -->|"runs callbacks"| node_signal
node_engine -->|"runs timers"| node_timer
node_event -->|"posts slots"| node_event_queue
node_event -->|"allocates payloads"| node_memory_pool
node_signal -->|"posts events"| node_event_queue
node_signal -->|"uses subscribers"| node_memory_pool
node_machine -->|"posts transitions"| node_event_queue

click node_test_main "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/test-hydra/main.cpp"
click node_engine "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/engine.cpp"
click node_event_queue "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/event-queue.h"
click node_event "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/event.h"
click node_memory_pool "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/mem-pool.h"
click node_machine "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/machine.h"
click node_strand "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/strand.h"
click node_signal "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/signal.cpp"
click node_timer "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/timer.cpp"
click node_system "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/system.cpp"
click node_controller "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/controller.cpp"
click node_driver "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/driver.cpp"
click node_hal "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/hal.cpp"
click node_command "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/command.h"
click node_plot "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/plot.cpp"
click node_scope_single "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/single.cpp"
click node_scope_dual "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/dual.cpp"
click node_scope_triple "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/triple.cpp"
click node_scope_quad "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/quad.cpp"
click node_telemetry "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/telematry/telematry.cpp"
click node_mcu_setup "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Core/Src/main.c"
click node_mcu_config "https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Core/Inc/main.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_engine,node_event_queue,node_event,node_memory_pool,node_machine,node_strand,node_signal,node_timer,node_system toneBlue
class node_controller,node_driver,node_hal,node_command,node_plot toneAmber
class node_scope_single,node_scope_dual,node_scope_triple,node_scope_quad,node_telemetry toneMint
class node_test_main,node_mcu_setup,node_mcu_config toneRose
class node_startup toneIndigo
```

## Components

### Event Runtime

- [Engine](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/engine.cpp): `mStack-5/Components/core/engine.cpp`
- [Event Queue](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/event-queue.h): `mStack-5/Components/core/event-queue.h`
- [Event Types](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/event.h): `mStack-5/Components/core/event.h`
- [Memory Pool](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/mem-pool.h): `mStack-5/Components/core/mem-pool.h`
- [State Machines](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/machine.h): `mStack-5/Components/core/machine.h`
- [Strand](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/strand.h): `mStack-5/Components/core/strand.h`
- [Signals](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/signal.cpp): `mStack-5/Components/core/signal.cpp`
- [Timers](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/timer.cpp): `mStack-5/Components/core/timer.cpp`
- [System Services](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/core/system.cpp): `mStack-5/Components/core/system.cpp`

### Hydra Control

- [Hydra Controller](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/controller.cpp): `mStack-5/Components/hydra/controller.cpp`
- [Hydra Driver](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/driver.cpp): `mStack-5/Components/hydra/driver.cpp`
- [Hydra HAL](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/hal.cpp): `mStack-5/Components/hydra/hal.cpp`
- [Hydra Commands](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/command.h): `mStack-5/Components/hydra/command.h`
- [Hydra Plot](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/hydra/plot.cpp): `mStack-5/Components/hydra/plot.cpp`

### Oscilloscope

- [Single Scope](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/single.cpp): `mStack-5/Components/oscilloscope/single.cpp`
- [Dual Scope](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/dual.cpp): `mStack-5/Components/oscilloscope/dual.cpp`
- [Triple Scope](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/triple.cpp): `mStack-5/Components/oscilloscope/triple.cpp`
- [Quad Scope](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/oscilloscope/quad.cpp): `mStack-5/Components/oscilloscope/quad.cpp`
- [Telemetry](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/telematry/telematry.cpp): `mStack-5/Components/telematry/telematry.cpp`

### MCU Platform

- [Component Entry](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Components/test-hydra/main.cpp): `mStack-5/Components/test-hydra/main.cpp`
- [MCU Setup](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Core/Src/main.c): `mStack-5/Core/Src/main.c`
- [Peripheral Defines](https://github.com/thanhnguyen-tien/ed-fsm-library/blob/mStack-5/mStack-5/Core/Inc/main.h): `mStack-5/Core/Inc/main.h`

### Other components

- **Firmware Startup**

## Connections

- Firmware Startup → Component Entry: starts (evidence: `mStack-5/Components/test-hydra/main.cpp`)
- Component Entry → Engine: registers and runs (evidence: `mStack-5/Components/test-hydra/main.cpp`)
- Component Entry → Hydra Controller: registers (evidence: `mStack-5/Components/test-hydra/main.cpp`)
- Firmware Startup → MCU Setup: initializes MCU
- Firmware Startup → Peripheral Defines: uses definitions
- Firmware Startup → Event Queue: posts events (evidence: `README.md`)
- Event Queue → Engine: provides events (evidence: `README.md`)
- Engine → Event Types: dispatches (evidence: `README.md`)
- Engine → State Machines: dispatches to (evidence: `README.md`)
- Engine → Strand: runs serialized work (evidence: `README.md`)
- Engine → Signals: runs callbacks (evidence: `README.md`)
- Engine → Timers: runs timers (evidence: `README.md`)
- Event Types → Event Queue: posts slots (evidence: `README.md`)
- Event Types → Memory Pool: allocates payloads (evidence: `README.md`)
- Signals → Event Queue: posts events (evidence: `README.md`)
- Signals → Memory Pool: uses subscribers (evidence: `README.md`)
- State Machines → Event Queue: posts transitions (evidence: `README.md`)
