Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
mm::node::NotificationBus::Source Struct Reference

One feature's contribution: when to speak, and what to say. More...

#include <notification_bus.h>

Public Attributes

std::function< std::uint64_t()> revision
 
std::function< std::optional< nlohmann::json >()> render
 
std::chrono::milliseconds interval {20}
 

Detailed Description

One feature's contribution: when to speak, and what to say.

Member Data Documentation

◆ interval

std::chrono::milliseconds mm::node::NotificationBus::Source::interval {20}

How often this source is looked at, which is both its latency floor and its ceiling on messages. The two are the same thing: a source read once a second cannot speak more often than that, so a producer bumping its counter every real-time cycle needs no separate rate limit. Nothing is lost to a slow cadence — the counter is cumulative and the last-seen mark advances only when a message is sent, so a change is reported whole at the next reading.

Pick it from what the event is, and from how fast its producer bumps the counter. A lifecycle change a person is waiting on wants tens of milliseconds; a counter the real-time loop raises every cycle wants about a second, or it reports at the rate of the fault. Each source pays only for its own cadence: the bus sleeps until the earliest one is due.

◆ render

std::function<std::optional<nlohmann::json>()> mm::node::NotificationBus::Source::render

Builds the data object of the message, off the RT thread. Called only when revision has changed and the quiet window has passed, so it may do real work — including logging what it found, which is how a source reaches a support log as well as a client.

Returns
The payload, or nullopt to say nothing after all. A source that has gone idle between the counter read and this call answers nullopt rather than inventing an event.

◆ revision

std::function<std::uint64_t()> mm::node::NotificationBus::Source::revision

Cheap read of the producer's version counter. Called every poll, so it must not lock or allocate. Only compared for inequality against the previous reading.


The documentation for this struct was generated from the following file: