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:
@@ -22,15 +22,14 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery, IBatchSubscribable,
|
||||
IHostConnectivityProbe, IPerCallHostResolver, IAlarmSource, ISkippedTagReporter, IDisposable, IAsyncDisposable
|
||||
{
|
||||
/// <summary>Authored tags this driver could not build into its poll table (Gitea #541). FOCAS has three
|
||||
/// skip paths — an unmappable TagConfig, an unparseable address, and a capability-matrix rejection — and
|
||||
/// #540 was caused by the second of them going unreported while the driver read Healthy.</summary>
|
||||
/// <summary>Authored tags this driver could not build into its poll table. FOCAS has three
|
||||
/// skip paths — an unmappable TagConfig, an unparseable address, and a capability-matrix rejection — and the second of them once went unreported while the driver read Healthy.</summary>
|
||||
private readonly SkippedTagLedger _skippedTags = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public SkippedTagReport? GetSkippedTags() => _skippedTags.Snapshot();
|
||||
|
||||
/// <summary>Mutable so <see cref="InitializeAsync"/> can adopt a re-parsed config (#516). Written only
|
||||
/// <summary>Mutable so <see cref="InitializeAsync"/> can adopt a re-parsed config. Written only
|
||||
/// on the init path, together with <see cref="_clientFactory"/>, before either is used.</summary>
|
||||
private FocasDriverOptions _options;
|
||||
private readonly string _driverInstanceId;
|
||||
@@ -47,7 +46,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
private readonly Dictionary<string, DeviceState> _devices = new(StringComparer.OrdinalIgnoreCase);
|
||||
// v3: RawPath → definition, case-sensitive ordinal. Built in InitializeAsync from _options.RawTags
|
||||
// via the pure FocasTagDefinitionFactory mapper (the reference is always a RawPath).
|
||||
// Built whole in InitializeAsync and SWAPPED in (Gitea #647 review): the #630-retained poll engine keeps calling
|
||||
// Built whole in InitializeAsync and SWAPPED in: the retained poll engine keeps calling
|
||||
// ReadAsync during a re-initialise, and a table cleared and refilled in place reads BadNodeIdUnknown in between.
|
||||
private Dictionary<string, FocasTagDefinition> _tagsByRawPath = new(StringComparer.Ordinal);
|
||||
// Resolves a read/write fullReference (always a RawPath in v3) to a tag definition by a single
|
||||
@@ -76,14 +75,14 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// </remarks>
|
||||
private bool _fixedTreeActive;
|
||||
/// <summary>
|
||||
/// The alarm projection (Gitea #647). Lives as long as the driver — NOT re-created per initialise — because
|
||||
/// The alarm projection. Lives as long as the driver — NOT re-created per initialise — because
|
||||
/// it holds what the server was last told about every condition, and the server's condition nodes outlive
|
||||
/// a re-initialise; re-creating it would re-raise (and so un-acknowledge) every active alarm.
|
||||
/// </summary>
|
||||
private readonly FocasAlarmProjection _alarmProjection;
|
||||
|
||||
/// <summary>
|
||||
/// RawPath → authored <c>ALARM:</c> tag (Gitea #647). Built in <see cref="InitializeAsync"/> and swapped in
|
||||
/// RawPath → authored <c>ALARM:</c> tag. Built in <see cref="InitializeAsync"/> and swapped in
|
||||
/// whole, so the alarm poll loop always sees one consistent table. Alarm tags never enter
|
||||
/// <see cref="_tagsByRawPath"/>: they have no value to read.
|
||||
/// </summary>
|
||||
@@ -156,11 +155,11 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
return trimmed is not "{}" and not "[]";
|
||||
}
|
||||
|
||||
/// <summary>Upper bound on the poll-loop failure backoff — adopts the S7-proven 30 s cap fleet-wide (05/STAB-8).</summary>
|
||||
/// <summary>Upper bound on the poll-loop failure backoff — adopts the S7-proven 30 s cap fleet-wide.</summary>
|
||||
private static readonly TimeSpan PollBackoffCap = TimeSpan.FromSeconds(30);
|
||||
|
||||
/// <summary>
|
||||
/// 05/STAB-9 — routes a poll-loop reader failure to the driver health surface: logs it and
|
||||
/// Routes a poll-loop reader failure to the driver health surface: logs it and
|
||||
/// degrades to <see cref="DriverState.Degraded"/> preserving <c>LastSuccessfulRead</c>.
|
||||
/// Never downgrades a <see cref="DriverState.Faulted"/> state (a stronger, config-level signal).
|
||||
/// </summary>
|
||||
@@ -179,24 +178,22 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// <inheritdoc />
|
||||
public string DriverType => "FOCAS";
|
||||
|
||||
/// <summary>
|
||||
/// Opens the configured CNC handles and builds the authored tag table.
|
||||
/// <para><paramref name="driverConfigJson"/> <b>is</b> re-parsed here when the driver was built by
|
||||
/// the factory (Gitea #516), and the re-parse is <b>all-or-nothing</b>: the typed options and the
|
||||
/// <c>IFocasClientFactory</c> the <c>Backend</c> key selects come from one <c>ParseBinding</c> call
|
||||
/// and are adopted together. That pairing is the point — adopting options alone would poll a NEW
|
||||
/// device/tag set through the OLD backend, which is why this driver was excluded from the first
|
||||
/// #516 pass.</para>
|
||||
/// <para>A driver constructed directly (every unit test, or a caller supplying its own backend) gets
|
||||
/// no rebinder and keeps its constructor-supplied pair. <c>DriverSpawnPlanner</c>'s stop + respawn
|
||||
/// remains the outer guarantee.</para>
|
||||
/// </summary>
|
||||
/// <param name="driverConfigJson">The driver configuration JSON (see remarks — not re-parsed).</param>
|
||||
/// <param name="cancellationToken">Cancellation token for the operation.</param>
|
||||
/// <returns>A completed task.</returns>
|
||||
// <remarks>
|
||||
// Opens the configured CNC handles and builds the authored tag table.
|
||||
// <para><paramref name="driverConfigJson"/> <b>is</b> re-parsed here when the driver was built by
|
||||
// the factory, and the re-parse is <b>all-or-nothing</b>: the typed options and the
|
||||
// <c>IFocasClientFactory</c> the <c>Backend</c> key selects come from one <c>ParseBinding</c> call
|
||||
// and are adopted together. That pairing is the point — adopting options alone would poll a NEW
|
||||
// device/tag set through the OLD backend, which is why this driver was excluded from the first
|
||||
// respawn pass.</para>
|
||||
// <para>A driver constructed directly (every unit test, or a caller supplying its own backend) gets
|
||||
// no rebinder and keeps its constructor-supplied pair. <c>DriverSpawnPlanner</c>'s stop + respawn
|
||||
// remains the outer guarantee.</para>
|
||||
// </remarks>
|
||||
/// <inheritdoc />
|
||||
public async Task InitializeAsync(string driverConfigJson, CancellationToken cancellationToken)
|
||||
{
|
||||
// #630: release the previous device states' loops + clients BEFORE they are overwritten (a live driver can be
|
||||
// release the previous device states' loops + clients BEFORE they are overwritten (a live driver can be
|
||||
// re-initialised without a teardown first). Not ShutdownAsync: that also drops _poll
|
||||
// and subscriptions, which are owned by the shutdown path (the actor re-subscribes after every successful init).
|
||||
await ReleaseDeviceStatesAsync().ConfigureAwait(false);
|
||||
@@ -204,7 +201,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
Volatile.Write(ref _health, new DriverHealth(DriverState.Initializing, null, null));
|
||||
try
|
||||
{
|
||||
// #516: adopt a changed config. Options and the backend client factory are re-derived by ONE
|
||||
// adopt a changed config. Options and the backend client factory are re-derived by ONE
|
||||
// parse and assigned together — a partial adoption would poll a new device/tag set through the
|
||||
// old backend. A null rebinder (direct construction) or an empty/placeholder document keeps the
|
||||
// constructor-supplied pair, which is what every lifecycle test passing "{}" relies on.
|
||||
@@ -233,10 +230,10 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// are tolerant (skipped + logged → BadNodeIdUnknown at read, "a miss is a miss") — a single
|
||||
// bad tag must not fail the whole driver init. The ONE hard failure is an unknown device
|
||||
// segment: a tag routed to a device not in the Devices list is a driver-level config error
|
||||
// that fails fast (Driver.FOCAS-003).
|
||||
// that fails fast.
|
||||
_skippedTags.BeginRebuild(_options.RawTags.Count);
|
||||
// A re-initialise without teardown (#630) rebuilds the tables from scratch: a tag the new config
|
||||
// removed — or moved between the value and alarm tables (#647) — must not survive in the old one.
|
||||
// A re-initialise without teardown rebuilds the tables from scratch: a tag the new config
|
||||
// removed — or moved between the value and alarm tables — must not survive in the old one.
|
||||
// Built into fresh tables and swapped in below, never cleared in place under a live reader.
|
||||
var tagsByRawPath = new Dictionary<string, FocasTagDefinition>(StringComparer.Ordinal);
|
||||
var parsedAddresses = new ConcurrentDictionary<string, FocasAddress>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -265,7 +262,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
$"which is not in the Devices list. Check for a typo (e.g. wrong port or hostname).");
|
||||
// Per-tag address / capability-matrix validation is tolerant: an unparseable address or a
|
||||
// capability-matrix violation skips the tag (→ BadNodeIdUnknown at read) rather than failing
|
||||
// the whole init (R2-11 05/UNDER-6 — the same pre-flight, surfacing a resolver miss).
|
||||
// the whole init (the same pre-flight, surfacing a resolver miss).
|
||||
var parsed = FocasAddress.TryParse(def.Address);
|
||||
if (parsed is null)
|
||||
{
|
||||
@@ -283,7 +280,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
entry.RawPath, def.Address, reason, _driverInstanceId);
|
||||
continue;
|
||||
}
|
||||
// Gitea #647: an ALARM: address and the cross-driver alarm object only work together — the object
|
||||
// an ALARM: address and the cross-driver alarm object only work together — the object
|
||||
// is what makes the host materialise a condition at this RawPath, the address is the only thing
|
||||
// this driver can drive one from. Either alone does nothing, so it is skipped and reported.
|
||||
if (parsed.Kind == FocasAreaKind.Alarm || def.Alarm is not null)
|
||||
@@ -355,7 +352,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
}
|
||||
}
|
||||
|
||||
// Restart the alarm poll a re-initialise paused, against the tables just rebuilt (Gitea #647). A
|
||||
// Restart the alarm poll a re-initialise paused, against the tables just rebuilt. A
|
||||
// driver with no subscription yet starts nothing — the actor subscribes once it is Connected.
|
||||
await _alarmProjection.ResumeAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -375,7 +372,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// </summary>
|
||||
private async Task ReleaseDeviceStatesAsync()
|
||||
{
|
||||
// Pause, not dispose (Gitea #647): the subscription and what the server was told survive the rebuild.
|
||||
// Pause, not dispose: the subscription and what the server was told survive the rebuild.
|
||||
await _alarmProjection.PauseAsync().ConfigureAwait(false);
|
||||
if (_devices.Count == 0) return;
|
||||
var loops = new List<Task>();
|
||||
@@ -429,9 +426,9 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
public async Task ShutdownAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await _poll.DisposeAsync().ConfigureAwait(false);
|
||||
// Pause, not dispose (Gitea #647) — see _alarmProjection. A later InitializeAsync resumes it.
|
||||
// Pause, not dispose — see _alarmProjection. A later InitializeAsync resumes it.
|
||||
await _alarmProjection.PauseAsync().ConfigureAwait(false);
|
||||
// STAB-23: cancel every loop first, JOIN them (bounded), and only then dispose the CTSs and the
|
||||
// cancel every loop first, JOIN them (bounded), and only then dispose the CTSs and the
|
||||
// client. Fire-and-forget loops used to outlive shutdown: one parked in EnsureConnectedAsync could
|
||||
// finish its connect AFTER DisposeClient and leave a live socket on a shut-down driver.
|
||||
var loops = new List<Task>();
|
||||
@@ -481,12 +478,10 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// The worst of the value path (<see cref="_health"/>) and the alarm path (<see cref="_alarmTransportFailures"/>),
|
||||
/// computed together (Gitea #647 re-review R3). <see cref="DriverHealth.LastSuccessfulRead"/> is the later of
|
||||
/// the two paths' last successes: while either path still reads, the comms-loss watchdog stays quiet; when both
|
||||
/// have stopped it is frozen. Faulted / Unknown / Initializing come from the value (lifecycle) path unchanged.
|
||||
/// </remarks>
|
||||
// The worst of the value path (_health) and the alarm path (_alarmTransportFailures),
|
||||
// computed together. LastSuccessfulRead is the later of the two paths' last successes: while either
|
||||
// path still reads, the comms-loss watchdog stays quiet; when both have stopped it is frozen.
|
||||
// Faulted / Unknown / Initializing come from the value (lifecycle) path unchanged.
|
||||
public DriverHealth GetHealth()
|
||||
{
|
||||
var value = Volatile.Read(ref _health);
|
||||
@@ -524,7 +519,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// Recovers the host by matching the RawTagEntry's DeviceName against the configured Devices list (which
|
||||
// DriverDeviceConfigMerger fills from each Device row's DeviceConfig). By DeviceName, falling back to
|
||||
// HostAddress (the Client CLI passes the host as the DeviceName); for a single-device driver an empty
|
||||
// DeviceName routes to the sole device. Returns null when no device matches — the caller fails the tag fast (Driver.FOCAS-003).
|
||||
// DeviceName routes to the sole device. Returns null when no device matches — the caller fails the tag fast.
|
||||
private string? ResolveDeviceHost(string deviceName)
|
||||
{
|
||||
foreach (var d in _options.Devices)
|
||||
@@ -560,7 +555,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
var now = DateTime.UtcNow;
|
||||
var results = new DataValueSnapshot[fullReferences.Count];
|
||||
|
||||
// #266 — merge adjacent / near PMC reads of one device into fewer pmc_rdpmcrng calls. Indices it
|
||||
// Merge adjacent / near PMC reads of one device into fewer pmc_rdpmcrng calls. Indices it
|
||||
// serves are marked here and skipped by the per-tag loop below; everything else (including every
|
||||
// single-tag range and any range the CNC rejected) takes the unchanged per-tag path.
|
||||
var served = _options.PmcCoalesce.Enabled
|
||||
@@ -578,14 +573,14 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
//
|
||||
// This branch matches a reference that IS a "{host}/{path}" fixed-tree key. Authored
|
||||
// tags do not take it — their reference is a RawPath — and are served further down by
|
||||
// their FIXED: address instead (Gitea #540).
|
||||
// their FIXED: address instead.
|
||||
if (_fixedTreeActive && TryReadFixedTree(reference, now) is { } fx)
|
||||
{
|
||||
results[i] = fx;
|
||||
continue;
|
||||
}
|
||||
|
||||
// An ALARM: tag is a Part 9 condition, not a value (Gitea #647) — there is nothing to read.
|
||||
// An ALARM: tag is a Part 9 condition, not a value — there is nothing to read.
|
||||
if (Volatile.Read(ref _alarmTags).ContainsKey(reference))
|
||||
{
|
||||
results[i] = new DataValueSnapshot(null, FocasStatusMapper.BadNotSupported, null, now);
|
||||
@@ -659,7 +654,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PMC coalescing pre-pass (Gitea #266). Groups the batch's PMC tags by device, plans merged ranges
|
||||
/// PMC coalescing pre-pass. Groups the batch's PMC tags by device, plans merged ranges
|
||||
/// (<see cref="FocasPmcCoalescer"/>) and serves every multi-member range with ONE
|
||||
/// <c>pmc_rdpmcrng</c>, slicing each tag's value out of the returned slots.
|
||||
/// </summary>
|
||||
@@ -791,7 +786,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
for (var i = 0; i < writes.Count; i++)
|
||||
{
|
||||
var w = writes[i];
|
||||
// An ALARM: tag is a condition, and this driver never writes to the CNC's alarm state (#647).
|
||||
// An ALARM: tag is a condition, and this driver never writes to the CNC's alarm state.
|
||||
if (Volatile.Read(ref _alarmTags).ContainsKey(w.FullReference))
|
||||
{
|
||||
results[i] = new WriteResult(FocasStatusMapper.BadNotWritable);
|
||||
@@ -873,10 +868,13 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// node set is non-empty and stable.
|
||||
public DiscoveryRediscoverPolicy RediscoverPolicy => DiscoveryRediscoverPolicy.UntilStable;
|
||||
|
||||
/// <summary>The FixedTree device folder is real enumeration — config-gated on FixedTree.Enabled,
|
||||
/// which the universal browser's PatchForBrowse turns on. FOCAS is the UntilStable driver: the
|
||||
/// FixedTree cache fills a couple of seconds post-connect, so the browser's settle loop re-captures
|
||||
/// until the node set is non-empty and stable.</summary>
|
||||
// <remarks>
|
||||
// The FixedTree device folder is real enumeration — config-gated on FixedTree.Enabled,
|
||||
// which the universal browser's PatchForBrowse turns on. FOCAS is the UntilStable driver: the
|
||||
// FixedTree cache fills a couple of seconds post-connect, so the browser's settle loop re-captures
|
||||
// until the node set is non-empty and stable.
|
||||
// </remarks>
|
||||
/// <inheritdoc />
|
||||
public bool SupportsOnlineDiscovery => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -908,7 +906,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
{
|
||||
// The disambiguated segment, not the raw Display — a CNC reporting two
|
||||
// axes both named AA gets AA_1 / AA_2 folders instead of two identical
|
||||
// siblings the commit gate must refuse (#548).
|
||||
// siblings the commit gate must refuse.
|
||||
var segment = cache.AxisSegments[a];
|
||||
var axisFolder = axesFolder.Folder(segment, segment);
|
||||
EmitAxisVariable(axisFolder, segment, "AbsolutePosition");
|
||||
@@ -955,7 +953,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
EmitFixedVariable(opMode, "OperationMode", "ModeText", DriverDataType.String);
|
||||
}
|
||||
|
||||
// Fixed-tree T2.5 — Status subtree (cnc_statinfo flags, #257), gated on its own probe.
|
||||
// Fixed-tree T2.5 — Status subtree (cnc_statinfo flags), gated on its own probe.
|
||||
if (cache.Capabilities.Status)
|
||||
{
|
||||
var status = deviceFolder.Folder("Status", "Status");
|
||||
@@ -1012,7 +1010,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// <c>TagConfig.address</c>. Emitting the host-prefixed cache key therefore authored an
|
||||
/// address no FOCAS parser accepts: the driver skipped every such tag at init and each one
|
||||
/// read <c>BadNodeIdUnknown</c> forever, while the deploy sealed green and driver health
|
||||
/// stayed Healthy (Gitea #540).
|
||||
/// stayed Healthy.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The host is dropped rather than stripped later because a tag's device is already carried
|
||||
@@ -1067,7 +1065,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FocasDataType"/> name a fixed-tree node binds by, for the browse-commit
|
||||
/// path (Gitea #536). The fixed tree only ever emits these three, and each has an
|
||||
/// path. The fixed tree only ever emits these three, and each has an
|
||||
/// identically-named <see cref="FocasDataType"/> member — the driver-agnostic
|
||||
/// <see cref="DriverDataType"/> cannot be reversed (Byte/Int16/Int32 all collapse to
|
||||
/// <see cref="DriverDataType.Int32"/>), so the native name is carried rather than derived.
|
||||
@@ -1117,8 +1115,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <b>This is an internal key, not an authorable address</b> — see
|
||||
/// <see cref="EmitIdentityVariable"/> for why the two are deliberately different strings
|
||||
/// (Gitea #540).
|
||||
/// <see cref="EmitIdentityVariable"/> for why the two are deliberately different strings.
|
||||
/// </remarks>
|
||||
/// <param name="deviceHost">The host address of the device.</param>
|
||||
/// <param name="path">The path within the fixed tree.</param>
|
||||
@@ -1240,7 +1237,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// Published LAST (release write): LastStatus is the field callers watch for "the first
|
||||
// answer is in", and an authored FIXED:Status/* read is only servable once
|
||||
// FixedTreeCache and LastFixedPollUtc are set (TryReadFixedTreeOnDevice). Publishing it
|
||||
// first let a reader see a status while the read still returned BadCommunicationError (#673).
|
||||
// first let a reader see a status while the read still returned BadCommunicationError.
|
||||
state.LastStatus = statusProbe;
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested) { return; }
|
||||
@@ -1287,7 +1284,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
var axisIndex = i + 1; // FOCAS uses 1-based axis indexing
|
||||
var snap = await client.ReadDynamicAsync(axisIndex, ct).ConfigureAwait(false);
|
||||
// Keyed by the disambiguated segment, matching what DiscoverAsync emitted —
|
||||
// two same-named axes must not share (and overwrite) one cache slot (#548).
|
||||
// two same-named axes must not share (and overwrite) one cache slot.
|
||||
PublishAxisSnapshot(state, cache.AxisSegments[i], snap);
|
||||
if (i == 0) { firstAxisSnap = snap; PublishRateSnapshot(state, snap); }
|
||||
}
|
||||
@@ -1349,7 +1346,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
programPollDue = DateTime.UtcNow + programInterval;
|
||||
}
|
||||
|
||||
// Status flags (cnc_statinfo, #257) — same cadence as program/mode: run/emergency/alarm
|
||||
// Status flags (cnc_statinfo) — same cadence as program/mode: run/emergency/alarm
|
||||
// transitions are operator-timescale events and one call returns all of them.
|
||||
if (cache.Capabilities.Status
|
||||
&& programInterval > TimeSpan.Zero && DateTime.UtcNow >= statusPollDue)
|
||||
@@ -1446,8 +1443,8 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// servo-load read path resolves by axis segment.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The device-reported load names run through the same disambiguation as the axis list
|
||||
/// (#548): <c>cnc_rdsvmeter</c> answers per-axis in slot order, so the k-th load named
|
||||
/// The device-reported load names run through the same disambiguation as the axis list:
|
||||
/// <c>cnc_rdsvmeter</c> answers per-axis in slot order, so the k-th load named
|
||||
/// <c>AA</c> belongs to the k-th axis named <c>AA</c> and lands under the same
|
||||
/// <c>AA_k</c> segment the emitter published — without this, two same-named axes
|
||||
/// collapsed onto one dictionary entry and the second overwrote the first.
|
||||
@@ -1583,7 +1580,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
var idx = -1;
|
||||
for (var i = 0; i < spindleCache.SpindleSegments.Count; i++)
|
||||
{
|
||||
// Match on the disambiguated segment the emitter published (#548) — matching
|
||||
// Match on the disambiguated segment the emitter published — matching
|
||||
// raw Display would resolve every duplicate name to the first spindle.
|
||||
if (string.Equals(spindleCache.SpindleSegments[i], spindleName, StringComparison.OrdinalIgnoreCase)) { idx = i; break; }
|
||||
}
|
||||
@@ -1691,12 +1688,10 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// ---- IAlarmSource ----
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// <paramref name="sourceNodeIds"/> are the RawPaths of the alarm-bearing raw tags (the host's alarm
|
||||
/// subscription set), and each becomes ONE Part 9 condition whose ConditionId is that RawPath (Gitea #647).
|
||||
/// Never throws for a disabled flag: authoring an <c>ALARM:</c> tag is the opt-in, and a RawPath that is
|
||||
/// not an <c>ALARM:</c> tag of this driver is simply never raised.
|
||||
/// </remarks>
|
||||
// sourceNodeIds are the RawPaths of the alarm-bearing raw tags (the host's alarm subscription set), and
|
||||
// each becomes ONE Part 9 condition whose ConditionId is that RawPath. Never throws for a disabled flag:
|
||||
// authoring an ALARM: tag is the opt-in, and a RawPath that is not an ALARM: tag of this driver is simply
|
||||
// never raised.
|
||||
public Task<IAlarmSubscriptionHandle> SubscribeAlarmsAsync(
|
||||
IReadOnlyList<string> sourceNodeIds, CancellationToken cancellationToken) =>
|
||||
_alarmProjection.SubscribeAsync(sourceNodeIds);
|
||||
@@ -1706,7 +1701,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
_alarmProjection.UnsubscribeAsync(handle);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>Read-only: nothing is written to the CNC. See <see cref="FocasAlarmProjection.AcknowledgeAsync"/>.</remarks>
|
||||
// Read-only: nothing is written to the CNC. See FocasAlarmProjection.AcknowledgeAsync.
|
||||
public Task AcknowledgeAsync(
|
||||
IReadOnlyList<AlarmAcknowledgeRequest> acknowledgements, CancellationToken cancellationToken) =>
|
||||
FocasAlarmProjection.AcknowledgeAsync(acknowledgements);
|
||||
@@ -1725,7 +1720,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The ALARM-path half of driver health (Gitea #647 re-review R3): device host → why its alarm read is failing
|
||||
/// The ALARM-path half of driver health: device host → why its alarm read is failing
|
||||
/// at the TRANSPORT. Kept apart from <see cref="_health"/> (the value path) and combined with it in
|
||||
/// <see cref="GetHealth"/>, so neither path can overwrite the other: a good value read cannot mask a failing
|
||||
/// alarm read (and flip /hosts back and forth every poll), and a good alarm read cannot mask a value-path
|
||||
@@ -1756,8 +1751,8 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
|
||||
/// <summary>
|
||||
/// A TRANSPORT failure of an alarm read: the alarm path is Degraded until the device's next good read, and its
|
||||
/// LastSuccessfulRead stays frozen — the conjunction the comms-loss watchdog (#527) trips on, which a driver
|
||||
/// whose only tags are <c>ALARM:</c> tags otherwise never reached (Gitea #647 review).
|
||||
/// LastSuccessfulRead stays frozen — the conjunction the comms-loss watchdog trips on, which a driver
|
||||
/// whose only tags are <c>ALARM:</c> tags otherwise never reached.
|
||||
/// </summary>
|
||||
/// <param name="hostAddress">The device whose alarm read failed.</param>
|
||||
/// <param name="error">Why.</param>
|
||||
@@ -1774,7 +1769,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// <summary>
|
||||
/// Reads one device's active-alarm list. <b>Throws on any failure</b> — an unknown device, a connect that
|
||||
/// fails, a read the CNC refuses — because the projection must never mistake a failed read for an empty
|
||||
/// list (Gitea #647).
|
||||
/// list.
|
||||
/// </summary>
|
||||
/// <param name="hostAddress">The device host address.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
@@ -1789,17 +1784,16 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
|
||||
// ---- IPerCallHostResolver ----
|
||||
|
||||
/// <summary>
|
||||
/// Resolve a reference to the device host that keys its per-host resilience
|
||||
/// (bulkhead / circuit breaker). CONV-4: routes through
|
||||
/// <see cref="EquipmentTagRefResolver{TDef}"/> so an equipment-tag reference (raw TagConfig
|
||||
/// JSON) resolves to its OWN authored device rather than the first-device fallback. The
|
||||
/// empty-host guard covers FOCAS's <c>?? ""</c> default so an address-less equipment tag
|
||||
/// falls back rather than keying an empty host. The resolver caches parses, so this adds no
|
||||
/// per-call cost after first use.
|
||||
/// </summary>
|
||||
/// <param name="fullReference">The tag reference (authored name or equipment-tag JSON).</param>
|
||||
/// <returns>The device host key.</returns>
|
||||
// <remarks>
|
||||
// Resolves a reference to the device host that keys its per-host resilience
|
||||
// (bulkhead / circuit breaker). It routes through
|
||||
// <see cref="EquipmentTagRefResolver{TDef}"/> so an equipment-tag reference (raw TagConfig
|
||||
// JSON) resolves to its OWN authored device rather than the first-device fallback. The
|
||||
// empty-host guard covers FOCAS's <c>?? ""</c> default so an address-less equipment tag
|
||||
// falls back rather than keying an empty host. The resolver caches parses, so this adds no
|
||||
// per-call cost after first use.
|
||||
// </remarks>
|
||||
/// <inheritdoc />
|
||||
public string ResolveHost(string fullReference)
|
||||
{
|
||||
if (_resolver.TryResolve(fullReference, out var def) && !string.IsNullOrEmpty(def.DeviceHostAddress))
|
||||
@@ -1808,7 +1802,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thrown when a per-device <see cref="ConnectionBackoff"/> window is still open (05/STAB-8)
|
||||
/// Thrown when a per-device <see cref="ConnectionBackoff"/> window is still open
|
||||
/// — a fail-fast that costs no wire traffic. Read/write map it to <c>BadCommunicationError</c>
|
||||
/// via their generic catch, exactly as a real connect failure.
|
||||
/// </summary>
|
||||
@@ -1831,7 +1825,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// Another caller may have connected while this one waited.
|
||||
if (device.Client is { IsConnected: true } connected) return connected;
|
||||
|
||||
// 05/STAB-8: inside an open backoff window a data-path / per-tick-loop caller fails fast — no
|
||||
// Inside an open backoff window a data-path / per-tick-loop caller fails fast — no
|
||||
// socket create, no wire connect. The probe loop bypasses this and drives failure/success.
|
||||
if (!bypassBackoff && !device.Backoff.ShouldAttempt(DateTime.UtcNow))
|
||||
throw new ConnectionThrottledException(
|
||||
@@ -1866,10 +1860,10 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
// The caller's OWN cancellation says nothing about the CNC: do not open the backoff window, or
|
||||
// every caller queued on ConnectGate behind it would be throttled for ~1 s for nothing.
|
||||
if (!(ex is OperationCanceledException && ct.IsCancellationRequested))
|
||||
device.Backoff.RecordFailure(DateTime.UtcNow); // 05/STAB-8: open the backoff window
|
||||
device.Backoff.RecordFailure(DateTime.UtcNow); // open the backoff window
|
||||
throw;
|
||||
}
|
||||
device.Backoff.RecordSuccess(); // 05/STAB-8: recovery resets the window immediately
|
||||
device.Backoff.RecordSuccess(); // recovery resets the window immediately
|
||||
return client;
|
||||
}
|
||||
finally { device.ConnectGate.Release(); }
|
||||
@@ -1895,7 +1889,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// <summary>
|
||||
/// Unique <c>Axes/{segment}</c> path segments, one per axis in slot order — bare
|
||||
/// display names when unique, occurrence-suffixed (<c>AA_1</c>, <c>AA_2</c>) when a
|
||||
/// CNC reports duplicate sibling axis names (#548). The emitter, the poll loop's
|
||||
/// CNC reports duplicate sibling axis names. The emitter, the poll loop's
|
||||
/// snapshot keys and the read path all use THIS, never <c>Display</c> directly, so
|
||||
/// they cannot disagree.
|
||||
/// </summary>
|
||||
@@ -1926,7 +1920,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
bool ServoLoad, // cnc_rdsvmeter bootstrap probe returned data
|
||||
bool ProgramInfo, // cnc_exeprgname2 + cnc_rdblkcount + cnc_rdopmode work
|
||||
bool Timers, // cnc_rdtimer works for at least PowerOn
|
||||
bool Status = false); // cnc_statinfo answered at bootstrap (#257)
|
||||
bool Status = false); // cnc_statinfo answered at bootstrap
|
||||
|
||||
internal sealed class DeviceState(FocasHostAddress parsedAddress, FocasDeviceOptions options)
|
||||
{
|
||||
@@ -1938,7 +1932,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
public IFocasClient? Client { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Per-device connect-attempt throttle (05/STAB-8). A dead CNC fails fast inside the
|
||||
/// Per-device connect-attempt throttle. A dead CNC fails fast inside the
|
||||
/// backoff window instead of paying a full two-socket reconnect on every tick of each of
|
||||
/// the read / write / probe / fixed-tree / recycle loops; the probe loop bypasses it and a
|
||||
/// successful connect resets it. The connect itself is serialized by
|
||||
@@ -1964,11 +1958,11 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
public CancellationTokenSource? RecycleCts { get; set; }
|
||||
/// <summary>Gets or sets the cancellation token source for the fixed-tree loop.</summary>
|
||||
public CancellationTokenSource? FixedTreeCts { get; set; }
|
||||
/// <summary>The probe loop task, retained so shutdown can join it (STAB-23).</summary>
|
||||
/// <summary>The probe loop task, retained so shutdown can join it.</summary>
|
||||
public Task? ProbeTask { get; set; }
|
||||
/// <summary>The recycle loop task, retained so shutdown can join it (STAB-23).</summary>
|
||||
/// <summary>The recycle loop task, retained so shutdown can join it.</summary>
|
||||
public Task? RecycleTask { get; set; }
|
||||
/// <summary>The fixed-tree loop task, retained so shutdown can join it (STAB-23).</summary>
|
||||
/// <summary>The fixed-tree loop task, retained so shutdown can join it.</summary>
|
||||
public Task? FixedTreeTask { get; set; }
|
||||
/// <summary>Gets or sets the fixed-tree cache for this device.</summary>
|
||||
public FocasFixedTreeCache? FixedTreeCache { get; set; }
|
||||
@@ -1982,7 +1976,7 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
/// <b>This is what stops a dead CNC publishing its last values as Good forever.</b> The
|
||||
/// fixed-tree poll loop swallows a failed tick (LogDebug + retry) by design, so a device
|
||||
/// that stops answering leaves the caches populated and unchanging with nothing marking
|
||||
/// them stale. That was harmless while nothing could bind to the fixed tree; Gitea #540
|
||||
/// them stale. That was harmless while nothing could bind to the fixed tree; binding to it
|
||||
/// makes those nodes authorable, so reads are now dated from this stamp and go Bad once
|
||||
/// it falls outside <see cref="FixedTreeStaleAfter"/>.
|
||||
/// </remarks>
|
||||
@@ -1997,10 +1991,10 @@ public sealed class FocasDriver : IDriver, IReadable, IWritable, ITagDiscovery,
|
||||
public ConcurrentDictionary<string, double> LastFixedSnapshots { get; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
/// <summary>
|
||||
/// PMC ranges (<see cref="FocasPmcRangePlan.Key"/>) the CNC rejected as a merged read, so later polls skip
|
||||
/// straight to per-tag reads instead of paying a doomed round-trip every cycle (#266).
|
||||
/// straight to per-tag reads instead of paying a doomed round-trip every cycle.
|
||||
/// </summary>
|
||||
public ConcurrentDictionary<string, byte> CoalesceRejected { get; } = new(StringComparer.Ordinal);
|
||||
/// <summary>Gets or sets the last <c>cnc_statinfo</c> snapshot (#257); null until the first answer.</summary>
|
||||
/// <summary>Gets or sets the last <c>cnc_statinfo</c> snapshot; null until the first answer.</summary>
|
||||
public FocasStatus? LastStatus
|
||||
{
|
||||
get => Volatile.Read(ref _lastStatus);
|
||||
|
||||
Reference in New Issue
Block a user