docs: fill missing XML docs and strip tracking IDs from src comments

Clears CommentChecker findings in src/ (3,280 -> 209, the remainder being false
positives like PLC-5/IEEE-754/M0.0) by adding missing summaries/params/returns,
normalising inheritdoc usage, and removing Gitea/review tracking IDs while keeping
the rationale they annotated. Comment-only: comment-stripped sources are identical
to the parent commit.
This commit is contained in:
Joseph Doherty
2026-10-15 06:14:58 -04:00
parent ebcbd81fca
commit 826312befe
430 changed files with 4434 additions and 3923 deletions
@@ -15,7 +15,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.MTConnect;
/// <remarks>
/// <para>
/// <b>The constructor opens nothing and builds nothing.</b> It does not even call
/// <c>agentClientFactory</c> — the Wave-0 universal discovery browser constructs a throwaway
/// <c>agentClientFactory</c> — the universal discovery browser constructs a throwaway
/// instance purely to ask whether the driver can browse, and a constructor that materialized
/// a client would open a connection pool per browse probe against a possibly-unreachable
/// Agent. Every connection is owned by <see cref="InitializeAsync"/>.
@@ -25,21 +25,21 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.MTConnect;
/// and <see cref="ReinitializeAsync"/> both take the document, and the contract is that the driver
/// serves it — a driver that read only its constructor options would turn an in-place config
/// change into a silent no-op. (The runtime itself now applies a config change by respawning,
/// #516/#665.) This class therefore
/// .) This class therefore
/// re-parses the document (<see cref="ParseOptions"/>) whenever it carries a real body,
/// matching S7/AbCip/TwinCAT/Galaxy rather than the Modbus/FOCAS/OpcUaClient drivers that
/// ignore the argument. A blank / <c>{}</c> / <c>[]</c> document means "no config supplied"
/// and keeps the constructor options, which is what unit tests and the factory path rely on.
/// </para>
/// <para>
/// <b>Failure is never dressed as success (#485).</b> A failed initialize disposes whatever
/// <b>Failure is never dressed as success.</b> A failed initialize disposes whatever
/// client it built, drops the probe cache and the observation index, publishes
/// <see cref="DriverState.Faulted"/> with the error text, and rethrows — the runtime's
/// retry/backoff loop is the recovery path. In particular a <c>/probe</c> that succeeds while
/// the priming <c>/current</c> fails is Faulted, not "Healthy with no data": the index IS the
/// read surface, so serving that state would render every tag
/// <c>BadWaitingForInitialData</c> indefinitely behind a green driver, and the
/// <c>/sample</c> cursor (Task 11) only exists because <c>/current</c> reported a
/// <c>/sample</c> cursor only exists because <c>/current</c> reported a
/// <c>nextSequence</c>.
/// </para>
/// <para>
@@ -47,7 +47,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.MTConnect;
/// <see cref="IWritable"/>, <see cref="ISubscribable"/>, <see cref="ITagDiscovery"/>,
/// <see cref="IHostConnectivityProbe"/> and <see cref="IRediscoverable"/> — the last two
/// built on state this class already caches (the Agent <c>instanceId</c> and the probe
/// model) — plus <see cref="IAlarmSource"/> for CONDITION data items (#626, in
/// model) — plus <see cref="IAlarmSource"/> for CONDITION data items (in
/// <c>MTConnectDriver.Alarms.cs</c>).
/// </para>
/// <para>
@@ -67,7 +67,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.MTConnect;
/// <b>The read path never writes the shared observation index</b> — see
/// <see cref="ReadAsync"/>. That index has exactly one writer: the <c>/sample</c> pump
/// (<see cref="RunSampleStreamAsync"/>). The same single-writer discipline covers the two
/// Task-13 fields: the <b>connectivity probe loop</b> is the sole writer of
/// connectivity-probe fields: the <b>connectivity probe loop</b> is the sole writer of
/// <see cref="HostState"/>, and it publishes <b>nothing</b> into
/// <see cref="AgentSession.ProbeModel"/> (see <see cref="RunProbeLoopAsync"/>).
/// </para>
@@ -76,7 +76,7 @@ public sealed partial class MTConnectDriver
: IDriver, IReadable, IWritable, ISubscribable, ITagDiscovery, IHostConnectivityProbe, IRediscoverable,
ISkippedTagReporter
{
/// <summary>Authored tags this driver could not bind to an Agent DataItem (Gitea #541).</summary>
/// <summary>Authored tags this driver could not bind to an Agent DataItem.</summary>
private readonly SkippedTagLedger _skippedTags = new();
/// <inheritdoc />
@@ -93,7 +93,7 @@ public sealed partial class MTConnectDriver
// ---- Write status codes ----
//
// NAMED constants, never inline literals: StatusCodeParityTests checks each against the pinned SDK
// by reflection and can only see a named const (Gitea #497/#519). The names must match
// by reflection and can only see a named const. The names must match
// Opc.Ua.StatusCodes members exactly. Spelled WITHOUT the "Status" prefix MqttDriver uses, to match
// the two this file already declares (the parity guard strips either spelling).
@@ -209,7 +209,7 @@ public sealed partial class MTConnectDriver
/// no log line to diagnose it from.
/// </para>
/// <para>
/// <b>This is aimed squarely at the <c>/sample</c> pump (Task 11).</b> Its ring-buffer
/// <b>This is aimed squarely at the <c>/sample</c> pump.</b> Its ring-buffer
/// re-baseline ("on a sequence gap, re-<c>/current</c> and resume") is naturally written
/// as "just call the existing re-init logic" — and
/// <see cref="ReinitializeAsync"/>/<see cref="InitializeAsync"/> both take this
@@ -223,7 +223,7 @@ public sealed partial class MTConnectDriver
/// <para>
/// The inverse direction is already safe: the lifecycle methods call
/// <see cref="StopSampleStreamAsync"/> while holding this, so that method — and whatever
/// Task 11 fills it with — must never re-enter the lifecycle either.
/// the sample pump fills it with — must never re-enter the lifecycle either.
/// </para>
/// </remarks>
private readonly SemaphoreSlim _lifecycle = new(1, 1);
@@ -304,7 +304,7 @@ public sealed partial class MTConnectDriver
/// takes this field BEFORE it takes <see cref="_binding"/> — which both <c>ReadAsync</c>
/// and <c>WriteAsync</c> do — has the ordering that stops it judging a batch against the
/// previous document's <c>Write.Enabled</c> / <c>RequestTimeoutMs</c> paired with the new
/// tag table (Driver.MTConnect-005). Pinned by
/// tag table. Pinned by
/// <c>MTConnectOptionsPublicationTests</c>, which fails on any unfenced touch.
/// </para>
/// </summary>
@@ -329,7 +329,7 @@ public sealed partial class MTConnectDriver
private Task? _pumpTask;
/// <summary>
/// The <see cref="_sessionGeneration"/> the running pump was started against (STAB-20), guarded by
/// The <see cref="_sessionGeneration"/> the running pump was started against, guarded by
/// <see cref="_subscriptionLock"/> like the rest of the control block. A pump whose generation is
/// not the current one is bound to a client a lifecycle restart has retired.
/// </summary>
@@ -344,7 +344,7 @@ public sealed partial class MTConnectDriver
/// <summary>
/// Pumps retired by <see cref="StartSampleStreamCore"/> because they were bound to a replaced
/// session (STAB-20), kept so <see cref="StopSampleStreamAsync"/> can join them — a pump nobody
/// session, kept so <see cref="StopSampleStreamAsync"/> can join them — a pump nobody
/// awaits can still run its default-verdict arm (<c>Degrade</c>, the reconnect counter) after
/// the new session has written Healthy. Guarded by <see cref="_subscriptionLock"/>.
/// </summary>
@@ -394,11 +394,11 @@ public sealed partial class MTConnectDriver
/// <para>
/// <b>Why one field instead of several.</b> These values are read <i>outside</i>
/// <see cref="_lifecycle"/> — by <see cref="ReadAsync"/> and by
/// <see cref="GetOrFetchProbeModelAsync"/> (Task 12's browse) — while every write
/// <see cref="GetOrFetchProbeModelAsync"/> (the browse) — while every write
/// happens under it. As separate fields they could be observed mid-update, pairing one
/// initialize's client with the previous one's model. Packing them makes every
/// observation internally consistent by construction, with no lock on the read path.
/// (A third value, a cached data-item count, lived here until Gitea #525 deleted its
/// (A third value, a cached data-item count, lived here until it was deleted when its
/// only reader — <c>GetMemoryFootprint</c> — along with the rest of that dead surface.)
/// </para>
/// <para>
@@ -459,7 +459,7 @@ public sealed partial class MTConnectDriver
Volatile.Write(ref _options, options);
_binding = BuildBinding(options, probeModel: null);
// Never null, so every consumer (Task 10's ReadAsync included) can ask it for a snapshot
// Never null, so every consumer (ReadAsync included) can ask it for a snapshot
// without a null check: an un-primed index answers BadWaitingForInitialData for an authored
// tag and BadNodeIdUnknown otherwise, which is exactly the truth before Initialize runs.
_index = new MTConnectObservationIndex(_binding.IndexTags);
@@ -468,18 +468,16 @@ public sealed partial class MTConnectDriver
/// <inheritdoc/>
public string DriverInstanceId => _driverInstanceId;
/// <inheritdoc/>
/// <remarks>
/// Sourced from the <see cref="DriverTypeNames"/> constant rather than a literal — the
/// repo-wide fix for the historical <c>TwinCat</c>/<c>Focas</c> drift, where a driver's own
/// spelling diverged from the constant every dispatch map keys off.
/// </remarks>
/// <inheritdoc />
// Sourced from the constant rather than a literal — the
// repo-wide fix for the historical TwinCat/Focas drift, where a driver's own
// spelling diverged from the constant every dispatch map keys off.
public string DriverType => DriverTypeNames.MTConnect;
/// <summary>
/// The live <c>dataItemId → snapshot</c> map that backs the <b>subscription</b> surface:
/// primed by <see cref="InitializeAsync"/> and thereafter written only by the <c>/sample</c>
/// pump (Task 11). Exposed to tests as the observable proof that initialize actually primed
/// pump. Exposed to tests as the observable proof that initialize actually primed
/// it — and, in <c>MTConnectReadTests</c>, that <see cref="ReadAsync"/> leaves it alone.
/// </summary>
/// <remarks>
@@ -498,7 +496,7 @@ public sealed partial class MTConnectDriver
/// <summary>
/// The Agent's <c>instanceId</c> as of the last successful <c>/current</c> — including the
/// re-baseline the <c>/sample</c> pump runs when it sees the id change mid-stream. Task 13
/// re-baseline the <c>/sample</c> pump runs when it sees the id change mid-stream. The driver
/// watches this for change to raise rediscovery (an Agent restart invalidates every cached
/// id).
/// </summary>
@@ -546,15 +544,13 @@ public sealed partial class MTConnectDriver
/// <summary>The options currently in force — the constructor's, or the last document applied.</summary>
internal MTConnectDriverOptions EffectiveOptions => Volatile.Read(ref _options);
/// <inheritdoc/>
/// <remarks>
/// Builds the Agent client from the effective options, runs one deadline-bounded
/// <c>/probe</c> (caching the device model and its data-item count), then one
/// deadline-bounded <c>/current</c> to prime the observation index and record the Agent's
/// <c>instanceId</c>. Publishes <see cref="DriverState.Healthy"/> on success; on any failure
/// disposes the client, clears the caches, publishes <see cref="DriverState.Faulted"/> with
/// the error text, and rethrows.
/// </remarks>
/// <inheritdoc />
// Builds the Agent client from the effective options, runs one deadline-bounded
// /probe (caching the device model and its data-item count), then one
// deadline-bounded /current to prime the observation index and record the Agent's
// instanceId. Publishes on success; on any failure
// disposes the client, clears the caches, publishes with
// the error text, and rethrows.
public async Task InitializeAsync(string driverConfigJson, CancellationToken cancellationToken)
{
await _lifecycle.WaitAsync(cancellationToken).ConfigureAwait(false);
@@ -583,30 +579,22 @@ public sealed partial class MTConnectDriver
}
}
/// <inheritdoc/>
/// <remarks>
/// <para>
/// Stops the <c>/sample</c> stream, then takes one of two paths depending on whether the
/// new document changes anything the <see cref="IMTConnectAgentClient"/> reads at
/// <b>construction</b>:
/// </para>
/// <para>
/// <b>Endpoint/transport changed</b> (<c>AgentUri</c>, <c>DeviceName</c>,
/// <c>RequestTimeoutMs</c>, <c>HeartbeatMs</c>, <c>SampleIntervalMs</c>,
/// <c>SampleCount</c>) ⇒ full teardown and rebuild. The plan names only the first two,
/// but the other four are baked into the client's deadlines, its watchdog window, and its
/// <c>/sample</c> query string, so keeping the old client because the URI happened not to
/// change would silently discard the operator's edit — the same class of defect as
/// ignoring the config document altogether.
/// </para>
/// <para>
/// <b>Otherwise</b> ("config-only": authored tags, probe cadence, reconnect backoff) ⇒
/// the live client and its connection pool are kept, and everything derived from config
/// is rebuilt: the probe model is re-fetched, the observation index is recreated against
/// the new tag types, and one <c>/current</c> re-primes it. Nothing config-derived
/// survives, so a retyped tag cannot keep coercing to its old type.
/// </para>
/// </remarks>
/// <inheritdoc />
// Stops the /sample stream, then takes one of two paths depending on whether the
// new document changes anything the reads at
// construction:
// Endpoint/transport changed (AgentUri, DeviceName,
// RequestTimeoutMs, HeartbeatMs, SampleIntervalMs,
// SampleCount) ⇒ full teardown and rebuild. The plan names only the first two,
// but the other four are baked into the client's deadlines, its watchdog window, and its
// /sample query string, so keeping the old client because the URI happened not to
// change would silently discard the operator's edit — the same class of defect as
// ignoring the config document altogether.
// Otherwise ("config-only": authored tags, probe cadence, reconnect backoff) ⇒
// the live client and its connection pool are kept, and everything derived from config
// is rebuilt: the probe model is re-fetched, the observation index is recreated against
// the new tag types, and one /current re-primes it. Nothing config-derived
// survives, so a retyped tag cannot keep coercing to its old type.
public async Task ReinitializeAsync(string driverConfigJson, CancellationToken cancellationToken)
{
await _lifecycle.WaitAsync(cancellationToken).ConfigureAwait(false);
@@ -635,13 +623,11 @@ public sealed partial class MTConnectDriver
}
}
/// <inheritdoc/>
/// <remarks>
/// Stops the <c>/sample</c> stream, disposes the Agent client, and drops the probe cache and
/// the observation index — values sourced from a torn-down connection must never keep
/// reading Good. <c>LastSuccessfulRead</c> is retained because it is diagnostic ("when did
/// this driver last hear from the Agent"), not served data. Idempotent.
/// </remarks>
/// <inheritdoc />
// Stops the /sample stream, disposes the Agent client, and drops the probe cache and
// the observation index — values sourced from a torn-down connection must never keep
// reading Good. LastSuccessfulRead is retained because it is diagnostic ("when did
// this driver last hear from the Agent"), not served data. Idempotent.
public async Task ShutdownAsync(CancellationToken cancellationToken)
{
await _lifecycle.WaitAsync(cancellationToken).ConfigureAwait(false);
@@ -664,51 +650,39 @@ public sealed partial class MTConnectDriver
/// <inheritdoc/>
public DriverHealth GetHealth() => ReadHealth();
/// <inheritdoc/>
/// <remarks>
/// <para>
/// <b>One <c>/current</c> per batch, whatever the batch size.</b> MTConnect's
/// <c>/current</c> answers for the whole device (or the whole Agent), so N references
/// cost one deadline-bounded round-trip and are answered out of that one document. There
/// is no per-reference request to make and none is made.
/// </para>
/// <para>
/// <b>The response is indexed into a per-call snapshot, NOT into the driver's shared
/// observation index.</b> That index is written by the <c>/sample</c> pump (Task 11) and
/// is deliberately last-write-wins with no timestamp arbitration. A read that folded its
/// <c>/current</c> into it would be a second writer racing the first, and the
/// <c>/current</c> document is frequently the <i>older</i> of the two — the Agent
/// composes it while the pump's newer delta is already in flight. Losing that race rolls
/// a subscribed value backwards and <b>leaves it there until the data item next
/// changes</b>, which for an EVENT such as <c>Execution</c> can be hours. Keeping the
/// read path a pure function of (document, authored tags) costs one index construction
/// per batch — negligible beside the HTTP round-trip that precedes it — and makes it
/// impossible for a read to corrupt subscription state. The reference source-of-truth is
/// unchanged either way: both paths coerce through the same
/// <see cref="MTConnectObservationIndex"/> logic, so a read and a subscription report a
/// given observation identically.
/// </para>
/// <para>
/// <b>Nothing but genuine caller cancellation crosses this boundary.</b> An unreachable
/// Agent, a blown deadline, an unusable answer — each fails the batch's <i>values</i>
/// (every reference codes <see cref="BadCommunicationError"/>) rather than the batch: an
/// exception here would also fail the references that were perfectly readable, and the
/// node-manager cannot tell a thrown read from a broken driver. This is the opposite
/// posture to <see cref="InitializeAsync"/>, which is specified to throw so the
/// runtime's retry/backoff loop can own recovery.
/// </para>
/// <para>
/// The status-code distinctions the index draws — <c>BadWaitingForInitialData</c> for an
/// authored-but-unreported id, <c>BadNodeIdUnknown</c> for an unknown one,
/// <c>BadNoCommunication</c> for the Agent's <c>UNAVAILABLE</c> — are passed through
/// unmodified. They tell an operator three different things.
/// </para>
/// </remarks>
/// <exception cref="ArgumentNullException">
/// <paramref name="fullReferences"/> is <c>null</c> — a caller bug, not device data, and the
/// one thing this method is loud about (matching <see cref="MTConnectObservationIndex"/>'s
/// documented posture).
/// </exception>
/// <inheritdoc />
// One /current per batch, whatever the batch size. MTConnect's
// /current answers for the whole device (or the whole Agent), so N references
// cost one deadline-bounded round-trip and are answered out of that one document. There
// is no per-reference request to make and none is made.
// The response is indexed into a per-call snapshot, NOT into the driver's shared
// observation index. That index is written by the /sample pump and
// is deliberately last-write-wins with no timestamp arbitration. A read that folded its
// /current into it would be a second writer racing the first, and the
// /current document is frequently the older of the two — the Agent
// composes it while the pump's newer delta is already in flight. Losing that race rolls
// a subscribed value backwards and leaves it there until the data item next
// changes, which for an EVENT such as Execution can be hours. Keeping the
// read path a pure function of (document, authored tags) costs one index construction
// per batch — negligible beside the HTTP round-trip that precedes it — and makes it
// impossible for a read to corrupt subscription state. The reference source-of-truth is
// unchanged either way: both paths coerce through the same
// logic, so a read and a subscription report a
// given observation identically.
// Nothing but genuine caller cancellation crosses this boundary. An unreachable
// Agent, a blown deadline, an unusable answer — each fails the batch's values
// (every reference codes ) rather than the batch: an
// exception here would also fail the references that were perfectly readable, and the
// node-manager cannot tell a thrown read from a broken driver. This is the opposite
// posture to , which is specified to throw so the
// runtime's retry/backoff loop can own recovery.
// The status-code distinctions the index draws — BadWaitingForInitialData for an
// authored-but-unreported id, BadNodeIdUnknown for an unknown one,
// BadNoCommunication for the Agent's UNAVAILABLE — are passed through
// unmodified. They tell an operator three different things.
// is null — a caller bug, not device data, and the
// one thing this method is loud about (matching 's
// documented posture).
public async Task<IReadOnlyList<DataValueSnapshot>> ReadAsync(
IReadOnlyList<string> fullReferences, CancellationToken cancellationToken)
{
@@ -780,45 +754,34 @@ public sealed partial class MTConnectDriver
// ---- IWritable: observation injection through the Agent's AllowPut surface ----
/// <summary>
/// Sets the Agent's reported observation for each requested reference, through its
/// <c>AllowPut</c> surface. Returns one status per request, in request order.
/// </summary>
/// <param name="writes">The requested writes.</param>
/// <param name="cancellationToken">Cancellation for the batch.</param>
/// <returns>One <see cref="WriteResult"/> per request, in request order.</returns>
/// <remarks>
/// <para>
/// <b>This writes the Agent, not the machine</b> — see the class remarks. Good here means
/// "the Agent took the observation", which is a stronger statement than MQTT's optimistic
/// "published" (the Agent answers) and a weaker one than a device acknowledgement (no
/// MTConnect Agent speaks for the machine). The next adapter update for that DataItem
/// overwrites what was written, and the ordinary <c>/sample</c> ingest path is what
/// corrects the node.
/// </para>
/// <para>
/// <b>Never throws, and one bad slot never fails the batch</b> — matching
/// <see cref="ReadAsync"/>. Failing the whole call would let one stale reference reject
/// every other write in the same OPC UA request. Even cancellation returns a full-length
/// batch rather than propagating, so the node-manager can tell which slots were attempted.
/// </para>
/// <para>
/// <b>Refusal order is fixed, and each step answers a different operator question:</b>
/// writing switched off ⇒ <c>BadNotWritable</c>; no live client ⇒ <c>BadNotConnected</c>
/// (this driver is not running — <see cref="ReadAsync"/>'s convention); the reference
/// resolves to no DataItem, or to one whose owning device cannot be named ⇒
/// <c>BadNodeIdUnknown</c>; CONDITION category ⇒ <c>BadNotWritable</c>; no invariant string
/// form ⇒ <c>BadTypeMismatch</c>; and only then the Agent, whose refusal <b>or</b> whose
/// unreachability ⇒ <c>BadCommunicationError</c>.
/// </para>
/// <para>
/// <b>The Agent's refusal text is logged, never stored.</b> It goes to a Warning line and
/// nowhere near <see cref="DriverHealth.LastError"/>, which is type-only by repo-wide
/// discipline — and a refused write is not evidence the read path degraded, so health is
/// left exactly as it is (unlike <see cref="DegradeAfterReadFailure"/>).
/// </para>
/// </remarks>
/// <exception cref="ArgumentNullException"><paramref name="writes"/> is <c>null</c> — a caller bug.</exception>
/// <inheritdoc />
// Sets the Agent's reported observation for each requested reference, through its
// AllowPut surface. Returns one status per request, in request order.
// The requested writes.
// Cancellation for the batch.
// One per request, in request order.
// This writes the Agent, not the machine — see the class remarks. Good here means
// "the Agent took the observation", which is a stronger statement than MQTT's optimistic
// "published" (the Agent answers) and a weaker one than a device acknowledgement (no
// MTConnect Agent speaks for the machine). The next adapter update for that DataItem
// overwrites what was written, and the ordinary /sample ingest path is what
// corrects the node.
// Never throws, and one bad slot never fails the batch — matching
// . Failing the whole call would let one stale reference reject
// every other write in the same OPC UA request. Even cancellation returns a full-length
// batch rather than propagating, so the node-manager can tell which slots were attempted.
// Refusal order is fixed, and each step answers a different operator question:
// writing switched off ⇒ BadNotWritable; no live client ⇒ BadNotConnected
// (this driver is not running — 's convention); the reference
// resolves to no DataItem, or to one whose owning device cannot be named ⇒
// BadNodeIdUnknown; CONDITION category ⇒ BadNotWritable; no invariant string
// form ⇒ BadTypeMismatch; and only then the Agent, whose refusal or whose
// unreachability ⇒ BadCommunicationError.
// The Agent's refusal text is logged, never stored. It goes to a Warning line and
// nowhere near , which is type-only by repo-wide
// discipline — and a refused write is not evidence the read path degraded, so health is
// left exactly as it is (unlike ).
// is null — a caller bug.
public async Task<IReadOnlyList<WriteResult>> WriteAsync(
IReadOnlyList<WriteRequest> writes, CancellationToken cancellationToken)
{
@@ -941,7 +904,7 @@ public sealed partial class MTConnectDriver
/// The guard is therefore written against that property itself rather than against
/// <see cref="Array"/>, the one type it was first noticed on: an
/// <c>Opc.Ua.ExtensionObject</c>, an <c>XmlElement</c> or a <c>List&lt;T&gt;</c> from a
/// non-SDK caller corrupts an observation in exactly the same way (Driver.MTConnect-006).
/// non-SDK caller corrupts an observation in exactly the same way.
/// <c>string</c>, <c>bool</c>, <see cref="DateTime"/> and every numeric type ARE
/// <see cref="IConvertible"/>, so the accepted set is unchanged. TIME_SERIES / DATA_SET
/// writes are out of scope for v1.
@@ -1002,49 +965,37 @@ public sealed partial class MTConnectDriver
// ---- ISubscribable: ONE shared /sample long poll behind every handle ----
/// <inheritdoc/>
/// <summary>Raised when a subscribed data item's value changes.</summary>
public event EventHandler<DataChangeEventArgs>? OnDataChange;
/// <inheritdoc/>
/// <remarks>
/// <para>
/// <b>Initial data comes from the primed <c>/current</c>, not from the wire.</b> Every
/// subscribed reference gets one callback immediately (the OPC UA Part 4 convention),
/// answered out of the observation index — including the references with no value yet,
/// which report <c>BadWaitingForInitialData</c>. Waiting for the Agent's next chunk
/// instead would leave a fresh subscription silent for up to a whole <c>heartbeat</c>,
/// and permanently silent for any data item that simply is not changing.
/// </para>
/// <para>
/// <b>Subscribe does not wait for the stream.</b> The first subscription starts the
/// shared pump; the pump then opens <c>/sample</c> on its own task under its own
/// cancellation token. This is deliberate on both counts. The opening handshake cannot
/// be awaited inside the caller's Subscribe timeout in any useful sense — the first
/// chunk may legitimately be a heartbeat away — and the long-lived poll must NOT run
/// under the caller's token, which belongs to one Subscribe call and is disposed the
/// moment it returns. What bounds the running stream is the client's own heartbeat
/// watchdog, and what stops it is <see cref="UnsubscribeAsync"/> or the lifecycle.
/// </para>
/// <para>
/// <b><paramref name="publishingInterval"/> is not honoured per subscription</b>, and
/// cannot be: MTConnect's publish cadence is the Agent-side <c>interval</c> query
/// parameter of the single shared <c>/sample</c> request
/// (<see cref="MTConnectDriverOptions.SampleIntervalMs"/>), fixed when the client is
/// built. Honouring a per-handle interval would mean one stream per subscription — the
/// Agent load this driver exists to avoid — or client-side throttling that would drop
/// transient EVENT values the Agent bothered to send. The parameter is accepted and
/// ignored, which is also what the natively-subscribing sibling drivers do.
/// </para>
/// <para>
/// Subscribing before <see cref="InitializeAsync"/> is legal: the interest is recorded,
/// every reference reports "no value yet", and the initialize that follows starts the
/// pump for it. It does not throw and it does not dial an Agent that is not there yet.
/// </para>
/// </remarks>
/// <exception cref="ArgumentNullException">
/// <paramref name="fullReferences"/> is <c>null</c> — a caller bug, and the only thing this
/// method is loud about, matching <see cref="ReadAsync"/>'s posture.
/// </exception>
/// <inheritdoc />
// Initial data comes from the primed /current, not from the wire. Every
// subscribed reference gets one callback immediately (the OPC UA Part 4 convention),
// answered out of the observation index — including the references with no value yet,
// which report BadWaitingForInitialData. Waiting for the Agent's next chunk
// instead would leave a fresh subscription silent for up to a whole heartbeat,
// and permanently silent for any data item that simply is not changing.
// Subscribe does not wait for the stream. The first subscription starts the
// shared pump; the pump then opens /sample on its own task under its own
// cancellation token. This is deliberate on both counts. The opening handshake cannot
// be awaited inside the caller's Subscribe timeout in any useful sense — the first
// chunk may legitimately be a heartbeat away — and the long-lived poll must NOT run
// under the caller's token, which belongs to one Subscribe call and is disposed the
// moment it returns. What bounds the running stream is the client's own heartbeat
// watchdog, and what stops it is or the lifecycle.
// is not honoured per subscription, and
// cannot be: MTConnect's publish cadence is the Agent-side interval query
// parameter of the single shared /sample request
// (), fixed when the client is
// built. Honouring a per-handle interval would mean one stream per subscription — the
// Agent load this driver exists to avoid — or client-side throttling that would drop
// transient EVENT values the Agent bothered to send. The parameter is accepted and
// ignored, which is also what the natively-subscribing sibling drivers do.
// Subscribing before is legal: the interest is recorded,
// every reference reports "no value yet", and the initialize that follows starts the
// pump for it. It does not throw and it does not dial an Agent that is not there yet.
// is null — a caller bug, and the only thing this
// method is loud about, matching 's posture.
public Task<ISubscriptionHandle> SubscribeAsync(
IReadOnlyList<string> fullReferences, TimeSpan publishingInterval, CancellationToken cancellationToken)
{
@@ -1088,14 +1039,12 @@ public sealed partial class MTConnectDriver
return Task.FromResult<ISubscriptionHandle>(handle);
}
/// <inheritdoc/>
/// <remarks>
/// Drops the handle's references and stops the shared stream when the last subscription
/// goes. An unknown handle — already unsubscribed, or issued by a different driver — is a
/// no-op rather than an error: this runs on teardown paths, including failure paths, where
/// throwing would mask whatever prompted the teardown.
/// </remarks>
/// <exception cref="ArgumentNullException"><paramref name="handle"/> is <c>null</c>.</exception>
/// <inheritdoc />
// Drops the handle's references and stops the shared stream when the last subscription
// goes. An unknown handle — already unsubscribed, or issued by a different driver — is a
// no-op rather than an error: this runs on teardown paths, including failure paths, where
// throwing would mask whatever prompted the teardown.
// is null.
public async Task UnsubscribeAsync(ISubscriptionHandle handle, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(handle);
@@ -1132,112 +1081,88 @@ public sealed partial class MTConnectDriver
// ---- ITagDiscovery: the /probe device model, streamed as folders + variables ----
/// <inheritdoc/>
/// <remarks>
/// <b>This one member is the whole browse opt-in.</b> The Wave-0 universal
/// <c>DiscoveryDriverBrowser</c> turns any driver that answers <c>true</c> here into a live
/// address picker by capturing <see cref="DiscoverAsync"/> — so this driver ships no browser
/// code, no per-driver picker component, and no entry in the browser's browse-patch table
/// (its discovery is unconditional; there is no "enable browse" option to turn on first).
/// It is answered on an <b>un-initialized</b> instance without dialling anything, because
/// <c>CanBrowse</c> constructs a throwaway driver purely to read it — which is also why the
/// constructor opens nothing.
/// </remarks>
/// <inheritdoc />
// This one member is the whole browse opt-in. The universal
// DiscoveryDriverBrowser turns any driver that answers true here into a live
// address picker by capturing — so this driver ships no browser
// code, no per-driver picker component, and no entry in the browser's browse-patch table
// (its discovery is unconditional; there is no "enable browse" option to turn on first).
// It is answered on an un-initialized instance without dialling anything, because
// CanBrowse constructs a throwaway driver purely to read it — which is also why the
// constructor opens nothing.
public bool SupportsOnlineDiscovery => true;
/// <inheritdoc/>
/// <remarks>
/// <c>Once</c>, not the default <c>UntilStable</c>: <see cref="DiscoverAsync"/> streams the
/// complete device model within the single call — <c>/probe</c> is one synchronous request
/// that either answers with the whole hierarchy or fails — so nothing fills in asynchronously
/// after connect and a settle loop would only re-fetch an identical answer. (The one thing
/// that <i>does</i> change the model is an Agent restart, and that is
/// <c>IRediscoverable</c>'s job in Task 13, not a retry cadence's.)
/// </remarks>
/// <inheritdoc />
// Once, not the default UntilStable: streams the
// complete device model within the single call — /probe is one synchronous request
// that either answers with the whole hierarchy or fails — so nothing fills in asynchronously
// after connect and a settle loop would only re-fetch an identical answer. (The one thing
// that does change the model is an Agent restart, and that is
// IRediscoverable's job, not a retry cadence's.)
public DiscoveryRediscoverPolicy RediscoverPolicy => DiscoveryRediscoverPolicy.Once;
/// <inheritdoc/>
/// <remarks>
/// <para>
/// Streams the Agent's <c>/probe</c> hierarchy verbatim: one folder per <c>Device</c>,
/// one per nested <c>Component</c> to arbitrary depth, and one variable per
/// <c>DataItem</c> under whichever container declares it — <b>including the data items a
/// device declares directly</b>, outside any component (an availability item almost
/// always lives there, and a walker that only recursed <c>Components</c> would silently
/// drop it).
/// </para>
/// <para>
/// <b><see cref="DriverAttributeInfo.FullName"/> is the <c>DataItem@id</c>, never the
/// browse name.</b> The universal browser commits a browsed leaf's <c>FullName</c>
/// straight into <c>TagConfig.FullName</c>, and that is the key
/// <see cref="ReadAsync"/> and the <c>/sample</c> pump resolve an observation against
/// (<see cref="MTConnectObservationIndex"/> is keyed by <c>DataItem@id</c>). Committing
/// the <c>name</c> instead would produce a picker that looks right and authors tags that
/// can never report a value. The browse <i>name</i> — cosmetic — prefers the DataItem's
/// <c>name</c> and falls back to its <c>id</c>, which for this protocol is the common
/// case rather than an edge case.
/// </para>
/// <para>
/// <b>The type shape comes from <see cref="MTConnectDataTypeInference.Infer"/>'s returned
/// record, in full</b> — <see cref="MTConnectInferredType.IsArray"/> and
/// <see cref="MTConnectInferredType.ArrayDim"/> included. Recomputing the array shape
/// locally from <c>representation</c>/<c>sampleCount</c> is the tempting shortcut and it
/// is wrong: the inference also demotes <c>DATA_SET</c>/<c>TABLE</c> to
/// <see cref="DriverDataType.String"/> even on a <c>SAMPLE</c>, and honours
/// <c>TIME_SERIES</c> only on a <c>SAMPLE</c>. The AdminUI typed editor calls the same
/// function, so any divergence here makes the picker and the editor disagree about one
/// data item. The <c>type</c> attribute is passed <b>verbatim</b> for the same reason:
/// the probe document spells it UPPER_SNAKE (<c>PART_COUNT</c>) where the streams
/// document uses PascalCase, and the inference is separator-insensitive precisely to
/// bridge the two — pre-normalising it here would defeat that.
/// </para>
/// <para>
/// <b><see cref="DriverAttributeInfo.IsAlarm"/> is this seam's job</b>, deliberately not
/// the inference's: a <c>CONDITION</c> data item is an alarm.
/// <c>IVariableHandle.MarkAsAlarmCondition</c> is <i>not</i> called — that annotation
/// needs the driver-side refs of an alarm's sibling attributes (in-alarm flag, priority,
/// ack target), and an MTConnect condition has none: it is one text observation whose
/// value is the state word. Core's generic node manager enriches on the flag alone.
/// </para>
/// <para>
/// <b>The model comes from <see cref="GetOrFetchProbeModelAsync"/>, never from
/// <see cref="CachedProbeModel"/>.</b> <see cref="InvalidateProbeModel"/> may have
/// dropped the cache after an Agent restart; reading the field directly would make such
/// a driver browse as an Agent with no data items, permanently.
/// </para>
/// <para>
/// <b>This throws, and that is the opposite of <see cref="ReadAsync"/>'s posture on
/// purpose.</b> A read has a per-reference Bad status code to report a failure in-band; a
/// discovery stream has no such channel, so the only way to "fail quietly" would be to
/// emit an empty tree — indistinguishable from an Agent that genuinely declares nothing,
/// and read by an operator in the picker as a working connection to an empty machine
/// (#485: empty is not an answer).
/// </para>
/// <para>
/// <b>What the callers actually do with the throw</b> — worth stating precisely, because
/// the reassuring version ("it is logged and retried") is not true here. The live
/// consumer is the <c>/raw</c> browse-commit path
/// (<c>DiscoveryDriverBrowser</c>/<c>BrowserSessionService</c>), which surfaces it to the
/// operator as a <i>failed browse</i> — that is the case this posture is chosen for.
/// <c>DriverInstanceActor.HandleRediscoverAsync</c> catches it, logs a Warning, and
/// publishes an EMPTY node set; it does <b>not</b> reschedule, because retrying is a
/// <see cref="DiscoveryRediscoverPolicy.UntilStable"/> behaviour and this driver is
/// <see cref="DiscoveryRediscoverPolicy.Once"/>. And that publish currently reaches
/// nothing: <c>DriverHostActor.HandleDiscoveredNodes</c> short-circuits unconditionally
/// (discovered-node injection is dormant in v3 — raw tags are authored through
/// browse-commit instead), so at that seam the throw-versus-empty choice has no runtime
/// effect today. It is made for the browse path, and for whatever re-enables injection.
/// </para>
/// <para>
/// <b>Nothing here writes the observation index.</b> Discovery is a pure read of the
/// device model — the <c>/sample</c> pump remains its sole writer.
/// </para>
/// </remarks>
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
/// <exception cref="InvalidOperationException">
/// The driver is not initialized, or it was torn down while the <c>/probe</c> fetch was in
/// flight (see <see cref="GetOrFetchProbeModelAsync"/>).
/// </exception>
/// <inheritdoc />
// Streams the Agent's /probe hierarchy verbatim: one folder per Device,
// one per nested Component to arbitrary depth, and one variable per
// DataItem under whichever container declares it — including the data items a
// device declares directly, outside any component (an availability item almost
// always lives there, and a walker that only recursed Components would silently
// drop it).
// is the DataItem@id, never the
// browse name. The universal browser commits a browsed leaf's FullName
// straight into TagConfig.FullName, and that is the key
// and the /sample pump resolve an observation against
// ( is keyed by DataItem@id). Committing
// the name instead would produce a picker that looks right and authors tags that
// can never report a value. The browse name — cosmetic — prefers the DataItem's
// name and falls back to its id, which for this protocol is the common
// case rather than an edge case.
// The type shape comes from 's returned
// record, in full — and
// included. Recomputing the array shape
// locally from representation/sampleCount is the tempting shortcut and it
// is wrong: the inference also demotes DATA_SET/TABLE to
// even on a SAMPLE, and honours
// TIME_SERIES only on a SAMPLE. The AdminUI typed editor calls the same
// function, so any divergence here makes the picker and the editor disagree about one
// data item. The type attribute is passed verbatim for the same reason:
// the probe document spells it UPPER_SNAKE (PART_COUNT) where the streams
// document uses PascalCase, and the inference is separator-insensitive precisely to
// bridge the two — pre-normalising it here would defeat that.
// is this seam's job, deliberately not
// the inference's: a CONDITION data item is an alarm.
// IVariableHandle.MarkAsAlarmCondition is not called — that annotation
// needs the driver-side refs of an alarm's sibling attributes (in-alarm flag, priority,
// ack target), and an MTConnect condition has none: it is one text observation whose
// value is the state word. Core's generic node manager enriches on the flag alone.
// The model comes from , never from
// . may have
// dropped the cache after an Agent restart; reading the field directly would make such
// a driver browse as an Agent with no data items, permanently.
// This throws, and that is the opposite of 's posture on
// purpose. A read has a per-reference Bad status code to report a failure in-band; a
// discovery stream has no such channel, so the only way to "fail quietly" would be to
// emit an empty tree — indistinguishable from an Agent that genuinely declares nothing,
// and read by an operator in the picker as a working connection to an empty machine
// (empty is not an answer).
// What the callers actually do with the throw — worth stating precisely, because
// the reassuring version ("it is logged and retried") is not true here. The live
// consumer is the /raw browse-commit path
// (DiscoveryDriverBrowser/BrowserSessionService), which surfaces it to the
// operator as a failed browse — that is the case this posture is chosen for.
// DriverInstanceActor.HandleRediscoverAsync catches it, logs a Warning, and
// publishes an EMPTY node set; it does not reschedule, because retrying is a
// behaviour and this driver is
// . And that publish currently reaches
// nothing: DriverHostActor.HandleDiscoveredNodes short-circuits unconditionally
// (discovered-node injection is dormant in v3 — raw tags are authored through
// browse-commit instead), so at that seam the throw-versus-empty choice has no runtime
// effect today. It is made for the browse path, and for whatever re-enables injection.
// Nothing here writes the observation index. Discovery is a pure read of the
// device model — the /sample pump remains its sole writer.
// is null.
// The driver is not initialized, or it was torn down while the /probe fetch was in
// flight (see ).
public async Task DiscoverAsync(IAddressSpaceBuilder builder, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(builder);
@@ -1453,7 +1378,7 @@ public sealed partial class MTConnectDriver
// ---- IHostConnectivityProbe: one host per Agent, on its own cheap tick ----
/// <inheritdoc/>
/// <summary>Raised when the Agent host connectivity state changes.</summary>
/// <remarks>
/// <b>Raised from the probe loop's task, never under a lock and never under
/// <see cref="_lifecycle"/>.</b> A handler is arbitrary caller code: one that blocks forever
@@ -1470,14 +1395,12 @@ public sealed partial class MTConnectDriver
/// </summary>
public string HostName => Volatile.Read(ref _options).AgentUri;
/// <inheritdoc/>
/// <remarks>
/// One entry, always — an Agent is a single host, and the driver knows of it whether or not
/// it has been reached. Before the first probe tick (and for the whole life of an instance
/// with <c>Probe.Enabled = false</c>) that entry reads <see cref="HostState.Unknown"/>, which
/// is the truth: nothing has measured it. See <see cref="_hostState"/> for why a successful
/// initialize does not seed it <see cref="HostState.Running"/>.
/// </remarks>
/// <inheritdoc />
// One entry, always — an Agent is a single host, and the driver knows of it whether or not
// it has been reached. Before the first probe tick (and for the whole life of an instance
// with Probe.Enabled = false) that entry reads , which
// is the truth: nothing has measured it. See for why a successful
// initialize does not seed it .
public IReadOnlyList<HostConnectivityStatus> GetHostStatuses()
{
lock (_probeLock)
@@ -1716,7 +1639,7 @@ public sealed partial class MTConnectDriver
// ---- IRediscoverable: the Agent instanceId watch ----
/// <inheritdoc/>
/// <summary>Raised when the Agent instance id changes, so the host should rediscover.</summary>
/// <remarks>
/// <para>
/// <b>This event is what makes <see cref="RediscoverPolicy"/> =
@@ -1795,7 +1718,7 @@ public sealed partial class MTConnectDriver
/// than a courtesy: losing the race must not leave a model from a dead Agent installed.
/// (The courtesy version, <c>FlushOptionalCachesAsync</c>, took the same lock-free
/// approach but gave up on a lost race; it went with the rest of the unconsumed
/// memory-pressure surface in Gitea #525.)
/// memory-pressure surface.)
/// </summary>
internal void InvalidateProbeModel()
{
@@ -1863,7 +1786,7 @@ public sealed partial class MTConnectDriver
return;
}
// STAB-20: a Subscribe can land between StopSampleStreamAsync clearing the registry slots and
// A Subscribe can land between StopSampleStreamAsync clearing the registry slots and
// the teardown that retires the client — StopSampleStreamAsync is still awaiting the OLD pump
// then — and starts a pump on the session about to be disposed. Treating that pump as "the
// running stream" would leave the freshly-installed session with no live stream at all
@@ -1894,7 +1817,7 @@ public sealed partial class MTConnectDriver
// Unsubscribe-then-Subscribe with NO re-initialize, and the unsubscribe stops a stream
// that is not running; without this, the resubscribe returns a handle, the caller is
// told SubscriptionEstablished, and the next successful read reports a perfectly green
// driver over a subscription that can never deliver a value (#485).
// driver over a subscription that can never deliver a value.
var agentUri = Volatile.Read(ref _options).AgentUri;
_streamDegraded = true;
@@ -1983,7 +1906,7 @@ public sealed partial class MTConnectDriver
{
FanOut(SubscribedReferences(), ObservationIndex);
// #626: and the conditions, diffed against what the server was last told — so a restart
// and the conditions, diffed against what the server was last told — so a restart
// delivers what changed while the driver was down and re-raises nothing that did not.
EmitConditionTransitions(touchedDataItemIds: null, resync: false);
}
@@ -2182,7 +2105,7 @@ public sealed partial class MTConnectDriver
// The seam contracts that cancellation is the ONLY way this enumeration ends quietly, so
// a quiet end under a live token is a non-conforming client — reported as the lost
// stream it is rather than treated as "the subscription is simply idle" (#485).
// stream it is rather than treated as "the subscription is simply idle".
return ct.IsCancellationRequested
? new StreamOutcome(StreamVerdict.Cancelled, expected, instanceId, delivered, null)
: new StreamOutcome(
@@ -2339,7 +2262,7 @@ public sealed partial class MTConnectDriver
var index = ObservationIndex;
index.Apply(document, baseline);
// #626: CONDITION observations also feed the alarm path, which keeps its own multi-condition state
// CONDITION observations also feed the alarm path, which keeps its own multi-condition state
// (a /sample Normal for one nativeCode is not a return to normal while another code is active).
var touchedConditions = ConditionTracker.Apply(document, baseline);
EmitConditionTransitions(touchedConditions, resync: false);
@@ -2520,7 +2443,7 @@ public sealed partial class MTConnectDriver
/// </summary>
private bool HasSubscribedReferencesCore()
{
// #626: a CONDITION alarm subscription needs the same stream — a driver whose only authored tags are
// a CONDITION alarm subscription needs the same stream — a driver whose only authored tags are
// alarms would otherwise never hear a condition change.
if (HasAlarmReferencesCore())
{
@@ -2587,7 +2510,7 @@ public sealed partial class MTConnectDriver
/// <summary>
/// The <c>/probe</c> device model: the cached copy when warm, otherwise a fresh
/// deadline-bounded <c>/probe</c> that re-populates the cache. This is the accessor every
/// model consumer (Task 12's <c>DiscoverAsync</c>) must use, so that
/// model consumer (<c>DiscoverAsync</c>) must use, so that
/// <see cref="InvalidateProbeModel"/> can never leave browse permanently disabled.
/// </summary>
/// <remarks>
@@ -2644,7 +2567,7 @@ public sealed partial class MTConnectDriver
/// </summary>
/// <remarks>
/// Lives here rather than on the factory because the driver itself needs it: the runtime
/// delivers config changes as JSON to a live instance (see the class remarks). Task 15's
/// delivers config changes as JSON to a live instance (see the class remarks). The
/// <c>MTConnectDriverFactoryExtensions.CreateInstance</c> should <b>delegate to this method</b>
/// rather than deserializing a second DTO — two parsers for one document drift.
/// </remarks>
@@ -2744,7 +2667,7 @@ public sealed partial class MTConnectDriver
RequirePositive(options.SampleIntervalMs, nameof(MTConnectDriverOptions.SampleIntervalMs));
RequirePositive(options.SampleCount, nameof(MTConnectDriverOptions.SampleCount));
// Same 01/S-6 guard for Task 13's two knobs, gated on the feature that reads them. A 0
// Same guard for the probe's two knobs, gated on the feature that reads them. A 0
// interval turns the "periodic" probe into an unthrottled hot loop against the Agent, and
// a 0 (or negative) timeout cancels every probe before it can be answered — pinning the
// host to Stopped forever and reporting an outage that does not exist. Checked only when
@@ -2804,7 +2727,7 @@ public sealed partial class MTConnectDriver
index.Apply(current, baseline: true);
Volatile.Write(ref _index, index);
// #626: the CONDITION tracker is per-session state like the index. Nothing is RAISED here — the
// the CONDITION tracker is per-session state like the index. Nothing is RAISED here — the
// lifecycle semaphore is held; the restarted pump delivers the diff as its first act.
var conditions = new MTConnectConditionTracker();
conditions.Apply(current, baseline: true);
@@ -2841,7 +2764,7 @@ public sealed partial class MTConnectDriver
}
catch (Exception ex)
{
// Gitea #517 — land Faulted BEFORE anything is disposed, not after.
// land Faulted BEFORE anything is disposed, not after.
//
// A successful connect writes Healthy above, and the steps that follow it (stream start, probe
// loop) can still throw. Without this first write the driver would report Healthy for the whole
@@ -3019,7 +2942,7 @@ public sealed partial class MTConnectDriver
// Nothing to be degraded about once the stream is gone — UNLESS the endpoint is latched as
// unable to stream at all, in which case there is no prospect of one coming back, and
// clearing this would let the next successful read report a green driver over a subscription
// that can never deliver (#485). See StartSampleStreamCore.
// that can never deliver. See StartSampleStreamCore.
lock (_subscriptionLock)
{
if (!_streamUnsupported)
@@ -3153,7 +3076,7 @@ public sealed partial class MTConnectDriver
/// Runs one unary agent call under a deadline linked to the caller's token. Belt-and-braces
/// over the production client's own per-call deadline: the seam does not oblige an
/// implementation to bound itself, and an unbounded initialize would wedge the driver-host
/// actor (arch-review R2-01).
/// actor.
/// </summary>
private async Task<T> BoundedAsync<T>(
Func<CancellationToken, Task<T>> call, string request, int timeoutMs, CancellationToken ct)
@@ -3193,7 +3116,7 @@ public sealed partial class MTConnectDriver
}
/// <summary>
/// Routes a read failure to the health surface (05/STAB-9's fleet-wide shape): log it and
/// Routes a read failure to the health surface (the fleet-wide shape): log it and
/// degrade, preserving <c>LastSuccessfulRead</c> — the "when did this driver last hear from
/// the Agent" diagnostic. Never downgrades <see cref="DriverState.Faulted"/>, which is a
/// stronger, config-level signal that a transient read failure must not paper over.
@@ -3364,7 +3287,7 @@ public sealed partial class MTConnectDriver
/// <summary>
/// Names the distinct, non-blank <see cref="RawTagEntry.DeviceName"/> values when there are two or
/// more, else <c>null</c> (#613). The driver never routes by that field — one instance owns one
/// more, else <c>null</c>. The driver never routes by that field — one instance owns one
/// Agent client — so differing values mean the author expects a split the driver silently does
/// not perform. A single value is NOT reported: it is the <c>/raw</c> Device's own name, which
/// routinely differs from the Agent's device name and would make the warning noise.
@@ -3410,12 +3333,12 @@ public sealed partial class MTConnectDriver
/// The MTConnect branch of <c>RawBrowseCommitMapper.BuildTagConfig</c> emits a whole
/// <c>MTConnectTagConfigModel</c>, whose <c>ToJson</c> unconditionally writes
/// <c>"dataType"</c> — always a non-blank authored type, so step 1 always wins. Since
/// Gitea #560 the value it writes is the browsed leaf's own inferred
/// the value it writes is the browsed leaf's own inferred
/// <see cref="DriverDataType"/>, i.e. what this step would have computed, so it agrees
/// with the raw-tag node's OPC UA type (taken from the same inference by
/// <c>RawBrowseCommitMapper.MapLeaf</c>). Historically it wrote the model's
/// <see cref="DriverDataType.String"/> default instead, and every browse-committed tag
/// coerced to text inside a <c>Double</c>/<c>Int64</c> node — <c>Driver.MTConnect-003</c>.
/// coerced to text inside a <c>Double</c>/<c>Int64</c> node.
/// The step remains the rescue for a blob authored by hand, by CSV or by API that states
/// no type at all.
/// </para>
@@ -3853,12 +3776,19 @@ public sealed partial class MTConnectDriver
/// </summary>
private sealed class MTConnectDriverConfigDto
{
/// <summary>The Agent base URI.</summary>
public string? AgentUri { get; init; }
/// <summary>The Agent device name to bind.</summary>
public string? DeviceName { get; init; }
/// <summary>Per-request timeout in milliseconds.</summary>
public int? RequestTimeoutMs { get; init; }
/// <summary>The /sample interval in milliseconds.</summary>
public int? SampleIntervalMs { get; init; }
/// <summary>The /sample count per request.</summary>
public int? SampleCount { get; init; }
/// <summary>The /sample heartbeat in milliseconds.</summary>
public int? HeartbeatMs { get; init; }
/// <summary>The authored tags.</summary>
public List<MTConnectTagDto>? Tags { get; init; }
/// <summary>
@@ -3867,43 +3797,61 @@ public sealed partial class MTConnectDriver
/// collection a deployed instance's data plane is keyed by.
/// </summary>
public List<RawTagEntry>? RawTags { get; init; }
/// <summary>Connectivity-probe settings.</summary>
public MTConnectProbeDto? Probe { get; init; }
/// <summary>Reconnect-backoff settings.</summary>
public MTConnectReconnectDto? Reconnect { get; init; }
/// <summary>Write-back settings.</summary>
public MTConnectWriteDto? Write { get; init; }
}
/// <summary>One authored tag. <c>DriverDataType</c> stays a string — see <see cref="ParseEnum{T}"/>.</summary>
private sealed class MTConnectTagDto
{
/// <summary>The tag's full name.</summary>
public string? FullName { get; init; }
/// <summary>The coercion type name.</summary>
public string? DriverDataType { get; init; }
/// <summary>Whether the tag is an array.</summary>
public bool? IsArray { get; init; }
/// <summary>The array length when <c>IsArray</c> is set.</summary>
public int? ArrayDim { get; init; }
/// <summary>The MTConnect DataItem category.</summary>
public string? MtCategory { get; init; }
/// <summary>The MTConnect DataItem type.</summary>
public string? MtType { get; init; }
/// <summary>The MTConnect DataItem sub-type.</summary>
public string? MtSubType { get; init; }
/// <summary>The engineering units.</summary>
public string? Units { get; init; }
}
/// <summary>Background connectivity-probe knobs (Task 13 consumes them).</summary>
/// <summary>Background connectivity-probe knobs (consumed by the probe loop).</summary>
private sealed class MTConnectProbeDto
{
/// <summary>Whether the probe loop runs.</summary>
public bool? Enabled { get; init; }
/// <summary>Probe interval in milliseconds.</summary>
public int? IntervalMs { get; init; }
/// <summary>Probe timeout in milliseconds.</summary>
public int? TimeoutMs { get; init; }
}
/// <summary>Reconnect-backoff knobs (Task 11's pump consumes them).</summary>
/// <summary>Reconnect-backoff knobs (consumed by the /sample pump).</summary>
private sealed class MTConnectReconnectDto
{
/// <summary>Minimum reconnect backoff in milliseconds.</summary>
public int? MinBackoffMs { get; init; }
/// <summary>Maximum reconnect backoff in milliseconds.</summary>
public int? MaxBackoffMs { get; init; }
/// <summary>Backoff growth multiplier.</summary>
public double? BackoffMultiplier { get; init; }
}
/// <summary>Write-back knobs — the driver-side half of the two-layer opt-in on observation injection.</summary>
private sealed class MTConnectWriteDto
{
/// <summary>Whether write-back to the Agent is enabled.</summary>
public bool? Enabled { get; init; }
}
}