Skip to content

Feat(backend, pipeline): pipeline module - #684

Draft
GaziH wants to merge 94 commits into
backend/netfrom
backend/pipeline
Draft

GaziH wants to merge 94 commits into
backend/netfrom
backend/pipeline

Conversation

@GaziH

@GaziH GaziH commented Dec 1, 2026

Copy link
Copy Markdown

What pipeline is

station::pipeline consumes ToPipeline items from station::event, packs them into station::payload models, and publishes them to the frontend through station::websocket::broker::BrokerClient.

  • Immediate events: board connections, triggered protections, board messages, backend problems, and order outcomes are formatted and published as soon as they arrive.
  • 100 ms telemetry aggregation: Packet::Data frames are accumulated in memory per packet ID and flushed on a fixed 100 ms interval (podData/update) with cumulative count, averaged cycleTime, and per-measurement last + window average.

The full design and topic mapping are documented in backend/crates/station/src/pipeline/README.md.

Changes

station::pipeline

crates/station/src/
├── pipeline.rs              # Config, spawn, biased select! loop, routing
└── pipeline/
    ├── accumulator.rs       # 100 ms DataPacket windowing (count, cycle_time, last, average)
    ├── message.rs           # MessageUpdate builders (board messages, problems, order outcomes)
    ├── timestamp.rs         # Zero-dependency UTC SystemTime / ShortTimestamp -> MessageTimestamp
    ├── tests.rs             # Unit tests against a real Broker (no sockets)
    └── README.md
  • Topic mapping:
    • Event::Connected / Event::Disconnected → connection/update (publish_connection)
    • Packet::Data → podData/update (publish_data, batched every 100 ms)
    • Packet::Protection → protection/update (publish_protection)
    • Packet::Message → message/update (publish_message)
    • ToPipeline::Problem → message/update (Shown → warning, Fatal → fault, Silent ignored)
    • ToPipeline::OrderSent / OrderFailed → message/update (info / warning)
    • Frontend-to-backend topics (order/send, logger/enable, logger/variables, connection/heartbeat) and logger/response are intentionally excluded.
  • Starvation & backpressure:
    • Polls the 100 ms flush timer first (biased; in tokio::select!) so sustained high-rate UDP traffic cannot starve telemetry publication.
    • Waits for BrokerClient capacity instead of dropping decoded events; flushes any dirty telemetry when channels.pipeline closes on shutdown.
  • Telemetry windowing (accumulator.rs):
    • Pre-allocated positional slots per packet ID avoid per-packet HashMap/String allocations on the UDP hot path.
    • Idle packets are skipped on flush; count and last_at persist across windows while measurement averages and inter-arrival samples reset each tick.

Supporting changes

  • crates/station/src/payload.rs: re-exported MeasurementUpdate, MessageKind, MessagePayload, and MessageTimestamp so pipeline can construct payload structs cleanly.
  • crates/station/src/lib.rs & src/main.rs: exposed pub mod event; and pub mod pipeline; from the library crate (switching main.rs to use station::event;) so station modules share crate:: imports.
  • Removed the earlier pipeline draft from software-core (if applicable on this branch).

Open points for review

  1. Double 100 ms tick (pipeline + Broker): Both pipeline and Broker::run currently flush DataPacketUpdate on a 100 ms interval (up to 100–200 ms end-to-end). Worth confirming whether Broker should keep its own batching timer or publish Update::Data immediately now that pipeline aggregates per window.
  2. hexValue in DataPacketUpdate: Left empty ("") because Notification carries decoded Values rather than raw UDP bytes.
  3. order/stateOrders: Not published yet since software_core::model::Packet has no state-orders variant.
  4. Backend message/update labels: Confirm "backend" (general problems), "all" (fault broadcast / board = None), and order.id.0.to_string() (order name) match what the frontend expects.

Testing

cargo test -p station
cargo clippy -p station --all-targets
  • All station unit tests pass, including 3 new pipeline::tests covering:
    • Immediate forwarding of connections, protections, board messages, problems, OrderSent, and OrderFailed.
    • 100 ms telemetry windowing (count, mean cycleTime, last, window average) and flush-on-shutdown using paused Tokio time.
    • UTC calendar timestamp conversion across Unix epoch and leap-day boundaries.
  • Zero Clippy warnings in pipeline.

Merge Order

Important

This PR must be merged after both the event and websocket / payload PRs.

station::pipeline depends directly on types and interfaces introduced by both branches:

  • event (#<event-pr>): consumes ToPipeline, Problem, and ProblemKind.
  • websocket / payload (#680): formats station::payload models and publishes them through BrokerClient.

Rebase or merge the base branch once both PRs are in before merging this one.

JavierRibaldelRio and others added 30 commits September 29, 2026 09:34
- Header and empty state use the team mark (outreach/main/logo_icon.svg)
  through a TeamLogo component that crops the SVG's empty canvas.
- Header wraps on narrow screens: title + theme toggle, then a full-width
  row of load controls; single row from lg.
- Tab bar scrolls by itself instead of widening the page; board stats wrap;
  the Sockets table keeps a min width and scrolls inside its container.
- New "Count bytes as" switch in the Throughput scenario panel, replacing
  the preamble/inter-frame gap checkbox.
- Wireshark mode counts the frame length a capture on the backend shows:
  no preamble, gap or FCS; received frames padded (60 B min), sent frames
  unpadded (keep-alive 56 B, ACK 54 B).
- Flow breakdowns, table headers and the help sheet follow the mode; the
  help adds a "Matching Wireshark" section.
Native number spinners ignored the theme and overlapped right-aligned values. StepperInput hides them and draws themed up/down buttons (±1, never below 0); arrow keys still step the value.
[ADJ Viewer]: enhancements & throughtput calculator
[ADJ Viewer] throughput calculator enhancements
[Testing View] feat(testing-view): new colour theme Twight
feat(competition-view): terminal-style message log, font-size control and mock backend
pminmic and others added 20 commits November 25, 2026 01:38
…ories

feat(testing-view): categorize messages and add icons
# Conflicts:
#	backend/crates/core/src/lib.rs
# Conflicts:
#	backend/crates/core/src/lib.rs
#	backend/crates/station/src/main.rs
…oads" -m "- Move pipeline from software-core into station (crates/station/src/pipeline.rs)

 - Map ToPipeline variants (connections, protections, board messages, problems, order outcomes) to payload types and publish immediately via BrokerClient
 - Aggregate Packet::Data telemetry per packet ID over 100 ms windows (cumulative count, mean cycle_time, per-measurement last and window average) and flush on shutdown
  - Re-export MeasurementUpdate, MessageKind, MessagePayload, and MessageTimestamp from station::payload
  - Expose event and pipeline from station::lib so station modules share crate-level imports
  - Add unit tests for immediate event forwarding, 100 ms data windowing, and UTC calendar timestamp conversion
…ar format as rest of station. Created README
@GaziH
GaziH changed the base branch from develop to backend/net December 1, 2026 21:09
@GaziH
GaziH marked this pull request as draft December 3, 2026 16:20
@GaziH GaziH changed the title Feat(backend, pipeline): implement station::pipeline for event-to-WebSocket payload routing and 100 ms telemetry aggregation Feat(backend, pipeline): pipeline module Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants