Skip to content

Commit 2d82e6d

Browse files
committed
docs(http): document Devices accessor and DeviceReceived in narrative pages
Closes the §19 docs-completeness invariant gap CONVENTIONS §1.0d-vicies- quinquies names — every new public surface ships with matching narrative docs in the same PR. The Devices accessor and the now-firing DeviceReceived event landed in feat/issue-176 with XML doc comments only; the auto-generated docfx API page picks those up, but the consumer-facing example and configure pages did not mention either surface. Adds: - docs/examples/client-http.md — a 'Subscribing to the wired device model' subsection under the document-client example, showing a DeviceReceived handler walking the wired DataItems and a Devices snapshot read after the first probe completes. Cites issue #176 and the 2026-06-01 approval. - docs/configure/consumer.md — a paragraph in the .NET-HTTP-client subsection naming Devices and DeviceReceived alongside the existing CurrentReceived guidance, plus a note that throwing handlers route through InternalError without breaking the cache fill. Resolves F-006 + F-007 in the §19 ledger at extra-files.user/plans/23-issue-176/review-findings.md.
1 parent 4228ad1 commit 2d82e6d

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

docs/configure/consumer.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ client.Start();
8282

8383
`CurrentReceived` fires once on stream initialization—`Start()` drives the `/sample` long-poll, not periodic `/current` polling. For periodic snapshots, call `GetCurrent()` directly on a timer; for the streaming case, subscribe to `SampleReceived`.
8484

85-
The client handles reconnects on the consumer's behalf; the `ConnectionError` event fires on transport failures and the client backs off and retries. Parsing or dispatch failures surface through `InternalError`.
85+
The client also exposes the post-probe device model. `DeviceReceived` fires once per parsed device for every `/probe` response, carrying the fully wired [`IDevice`](/api/MTConnect.Devices.IDevice) instance with its DataItems' `Container` and `Device` back-pointers set. The `Devices` property returns a read-only snapshot of every device the most recent probe yielded, keyed by UUID; entries are replaced wholesale on each probe and devices the agent no longer advertises are evicted at the start of the next probe. Both surfaces were added per [issue #176](https://github.com/TrakHound/MTConnect.NET/issues/176).
86+
87+
The client handles reconnects on the consumer's behalf; the `ConnectionError` event fires on transport failures and the client backs off and retries. Parsing or dispatch failures surface through `InternalError`. A `DeviceReceived` handler that throws is isolated: the exception is routed through `InternalError` and the cache fill plus the rest of the per-device fan-out continue normally.
8688

8789
## MQTT—the cppagent-parity broker / relay tree
8890

docs/examples/client-http.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,35 @@ client.CurrentReceived += (s, response) => { /* iterate response.Streams */ };
5050
client.Start();
5151
```
5252

53-
`MTConnectHttpClient` wraps the agent's HTTP endpoints (`/probe`, `/current`, `/sample`, `/asset`) and exposes them as a long-polling subscription with event hooks. The `Interval` property is the consumer-side sample interval — the client requests `/sample?interval=100` and receives each sequence batch through `CurrentReceived` (or `SampleReceived` if you wire that hook up instead).
53+
`MTConnectHttpClient` wraps the agent's HTTP endpoints (`/probe`, `/current`, `/sample`, `/asset`) and exposes them as a long-polling subscription with event hooks. The `Interval` property is the consumer-side sample interval—the client requests `/sample?interval=100` and receives each sequence batch through `CurrentReceived` (or `SampleReceived` if you wire that hook up instead).
54+
55+
### Subscribing to the wired device model
56+
57+
The client maintains a wired snapshot of every device it sees from `/probe` responses, keyed by UUID. Subscribe to `DeviceReceived` to react per-device while the snapshot is filling, and read the `Devices` accessor at any point to consult the post-probe model:
58+
59+
```csharp
60+
client.DeviceReceived += (s, device) =>
61+
{
62+
Console.WriteLine($"Device Received : {device.Uuid} : {device.Name}");
63+
foreach (var dataItem in device.GetDataItems())
64+
{
65+
// Container + Device back-pointers are wired in by the parser.
66+
Console.WriteLine($" {dataItem.Id} : {dataItem.Type} : container={dataItem.Container?.Id}");
67+
}
68+
};
69+
70+
client.Start();
71+
72+
// At any point after the first probe completes:
73+
foreach (var (uuid, device) in client.Devices)
74+
{
75+
Console.WriteLine($"Cached device : {uuid} : {device.Name}");
76+
}
77+
```
78+
79+
`DeviceReceived` fires once per parsed device for every Probe response, carrying the fully wired `IDevice` instance—the same one the `Devices` snapshot accessor returns for that UUID—with the agent's `InstanceId` stamped on each DataItem. A handler that throws is isolated by the client: the exception is forwarded through `InternalError` and the cache fill continues. `Devices` returns a fresh read-only snapshot on every read; cache the reference if you read repeatedly between probes. Devices that disappear between probes are evicted at the start of the next probe, so the snapshot never carries entries the agent no longer advertises.
80+
81+
The `Devices` accessor and the `DeviceReceived` fan-out were added per [issue #176](https://github.com/TrakHound/MTConnect.NET/issues/176) (approved 2026-06-01 by @PatrickRitchie).
5482

5583
### Per-observation validation
5684

0 commit comments

Comments
 (0)