Getting Started
Add the Extension to Your Project
Add the package reference to your application project:
<PackageReference Include="Ahsoka.Extensions.Diagnostics" />
And register the extension in your application's package/target definition (*.PackageInfo.json)
so the OpenPV Developer Toolkit deploys DiagnosticService alongside your application:
"extensionInfo": [
{ "packageName": "Ahsoka.Extensions.Diagnostics" }
]
DiagnosticService is AutoStart — you do not launch it yourself.
Configure Events
Events are declared in a DiagnosticConfiguration.json deployed with your package. Each entry is
an origin/name pair with a debounce mode:
{
"name": "",
"diagnosticEvents": [
{
"state": "None",
"origin": "User Defined Events",
"id": 396942227,
"name": "UserTestEvent",
"mode": "Manual",
"counterSettings": { "count": 0, "failedValue": 0, "passedValue": 0, "stepUp": 0, "jumpUp": 0, "stepDown": 0, "jumpDown": 0 },
"timerSettings": { "timerState": "None", "timeoutPassed": 0, "timeoutFailed": 0 },
"description": "",
"userDefined": true
}
],
"generatorEnabled": false,
"generatorNamespace": "YourApp.Diagnostic",
"generatorOutputFile": "obj\\GeneratedDiagnosticObjects.cs",
"version": "1.0"
}
See Core Concepts for what mode, counterSettings, and timerSettings
actually do.
Reporting and Watching Events
using Ahsoka.Core.Dispatch;
using Ahsoka.Services.Diagnostic;
var diagnosticClient = new DiagnosticServiceClient();
diagnosticClient.EnableEvents();
Dispatcher.Default.RegisterCallback<DiagnosticServiceClient.AhsokaNotificationArgs>(
OnDiagnosticNotification, diagnosticClient);
void OnDiagnosticNotification(object sender, DiagnosticServiceClient.AhsokaNotificationArgs args)
{
if (args.TransportId != DiagnosticMessageTypes.Ids.NotifyEventChanged)
return;
if (args.NotificationObject is DiagnosticEvent evt)
Console.WriteLine($"{evt.Name}: {evt.State}");
}
// Report a new state for an event — the service applies the configured debounce mode before
// deciding whether the event's State actually changes and a notification fires.
diagnosticClient.SetEventStatus(new DiagnosticEvent { Id = 396942227, State = EventState.Failed });
// Query current state directly, e.g. on a timer, rather than only reacting to notifications.
var active = diagnosticClient.SearchEvents();
var failed = active.DiagnosticEvents.Where(e => e.State == EventState.Failed);
Demos/Ahsoka.CS.CAN (DiagnosticsControl.cs) is a complete, runnable reference for this pattern,
including a timer-driven poll of active faults.
Where to Go Next
Read Core Concepts for event states and debounce modes, then browse the API Reference for the full client surface.