Core Concepts
Events and States
Every diagnostic event has an Id (a stable numeric identifier), a Name, an Origin (a
free-text grouping label, e.g. "User Defined Events"), and a State:
| State | Meaning |
|---|---|
None |
No opinion reported yet |
Passed |
Committed passing |
Prepassed |
Trending toward passing, not yet committed (debounce in progress) |
Prefailed |
Trending toward failing, not yet committed (debounce in progress) |
Failed |
Committed failing |
Application and service code reports a candidate state via DiagnosticServiceClient.SetEventStatus
(typically Prepassed/Prefailed, or Failed/Passed directly for events with no debounce). The
service decides — based on the event's configured DebounceMode — whether that candidate actually
changes the event's committed State, and only raises NotifyEventChanged when it does.
Debounce Modes
Configured per event in DiagnosticConfiguration.json (mode):
- Manual — the reported state becomes the committed state immediately, with no debounce.
Reporting
FailedcommitsFailedon the next call. - Counter — a running counter moves toward
FailedValue(byStepUp, orJumpUpwhen crossing from the passed side) each timePrefailed/Failed-range states are reported, and towardPassedValue(byStepDown/JumpDown) onPrepassed/passed-range reports. The committed state only flips toFailedonce the counter reachesFailedValue, or toPassedonce it reachesPassedValue— isolated blips don't commit a state change. - Timer — the first
PrepassedorPrefailedreport starts a hold timer (TimeoutPassed/TimeoutFailedmilliseconds). If the same trend is still being reported when the timer elapses, the state commits toPassed/Failed; a report of the opposite trend before the timer elapses cancels it. A report of an unrelated state (notPrepassed/Prefailed) while a timer is pending commits immediately.
Both Counter and Timer exist so a single noisy or transient report doesn't flip a fault light —
only a sustained trend does.
The Client/Service Relationship
DiagnosticService is AutoStart, so it is already running by the time your application code
executes. DiagnosticServiceClient.EnableEvents() is effectively a handshake call — it ensures the
service instance backing your events exists and is ready, and is only necessary if you are not
already relying on another component's AutoStart sequencing to have done so.
Once connected, a client can:
- Report a state with
SetEventStatus - Query one event's current state with
GetEventStatus, or search/filter across all configured events withSearchEvents(byOriginFilter/NameFilter, optionally inverted) - React to state changes as they happen via the
NotifyEventChangednotification, delivered throughAhsoka.Core.Dispatchlike any other Ahsoka service notification
Because DiagnosticService is shared across every service and application component in the
package, it is the common place other extensions (e.g. a CAN diagnostic trouble code decoder) can
report a fault without every component needing its own ad hoc status tracking.