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:
@@ -2,7 +2,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
|
||||
/// <summary>
|
||||
/// Turns a device-reported sibling-name sequence (axes, spindles) into unique fixed-tree
|
||||
/// path segments (Gitea #548).
|
||||
/// path segments.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
@@ -27,7 +27,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
/// <para>
|
||||
/// <b>The whole collision set is suffixed, not just the second occurrence.</b> When two
|
||||
/// axes are both called <c>AA</c>, the bare segment <c>AA</c> ceases to exist — a bare name
|
||||
/// that silently means "one of the two" is the same silent-wrongness class #534 and #540
|
||||
/// that silently means "one of the two" is the same silent-wrongness class the earlier selector fixes
|
||||
/// were about. A tag authored against bare <c>AA</c> on such a machine reads Bad, never one
|
||||
/// arbitrary axis's data.
|
||||
/// </para>
|
||||
|
||||
@@ -3,7 +3,7 @@ using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
|
||||
/// <summary>An authored <c>ALARM:</c> raw tag the driver drives a Part 9 condition for (Gitea #647).</summary>
|
||||
/// <summary>An authored <c>ALARM:</c> raw tag the driver drives a Part 9 condition for.</summary>
|
||||
/// <param name="RawPath">The tag's RawPath — the condition's ConditionId, the only key the host routes on.</param>
|
||||
/// <param name="DeviceHostAddress">The device whose alarm list the tag selects from.</param>
|
||||
/// <param name="Selector">Which alarms on that device drive the condition.</param>
|
||||
@@ -35,7 +35,7 @@ internal sealed record FocasConditionView(IReadOnlyList<FocasMatchedAlarm> Match
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects, per authored <c>ALARM:</c> tag, the matching entries of a device's flat CNC alarm list (Gitea #647).
|
||||
/// Selects, per authored <c>ALARM:</c> tag, the matching entries of a device's flat CNC alarm list.
|
||||
/// Pure — the projection hands it one successful read and gets back what each condition sees.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
@@ -101,7 +101,7 @@ internal static class FocasAlarmMatcher
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the server was last TOLD about one FOCAS condition (Gitea #647) — the diff baseline that keeps a
|
||||
/// What the server was last TOLD about one FOCAS condition — the diff baseline that keeps a
|
||||
/// reconnect, a re-subscribe or a reordered list from re-raising (and so un-acknowledging) an alarm.
|
||||
/// </summary>
|
||||
/// <param name="Active">Whether the condition was last told active.</param>
|
||||
@@ -119,7 +119,7 @@ internal sealed record FocasToldCondition(
|
||||
int? OpcUaSeverity);
|
||||
|
||||
/// <summary>
|
||||
/// The FOCAS alarm list → OPC UA Part 9 transition, as one pure function (Gitea #647): given what the server was
|
||||
/// The FOCAS alarm list → OPC UA Part 9 transition, as one pure function: given what the server was
|
||||
/// last told about a condition and what the CNC says now, the single <see cref="AlarmEventArgs"/> to raise — or
|
||||
/// none — and what the server has been told afterwards.
|
||||
/// </summary>
|
||||
@@ -130,7 +130,7 @@ internal sealed record FocasToldCondition(
|
||||
/// <item><term>active → a key not in the told set appears</term><description><see cref="AlarmTransitionKind.Retrigger"/>
|
||||
/// — a new CNC alarm number is a statement the operator has not seen, so it un-acknowledges</description></item>
|
||||
/// <item><term>active → the displayed alarm left, others remain</term><description><see cref="AlarmTransitionKind.Retrigger"/>
|
||||
/// with the next one down (the MTConnect #626 precedent: a different statement the operator has not seen)</description></item>
|
||||
/// with the next one down (the MTConnect precedent: a different statement the operator has not seen)</description></item>
|
||||
/// <item><term>active → a NON-displayed member left</term><description>nothing (no message-only events)</description></item>
|
||||
/// <item><term>active → nothing matches</term><description><see cref="AlarmTransitionKind.Clear"/></description></item>
|
||||
/// <item><term>unchanged</term><description>nothing</description></item>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
|
||||
/// <summary>
|
||||
/// Polls the CNC active-alarm list (<c>cnc_rdalmmsg2</c>) of every device that owns a subscribed
|
||||
/// <c>ALARM:</c> raw tag and drives ONE Part 9 condition per such tag (Gitea #647).
|
||||
/// <c>ALARM:</c> raw tag and drives ONE Part 9 condition per such tag.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
@@ -15,21 +15,21 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
/// arrive through <see cref="SubscribeAsync"/>. Every event uses the RawPath as
|
||||
/// <see cref="AlarmEventArgs.ConditionId"/> — the exact key the host routes on — and carries a
|
||||
/// <see cref="AlarmEventArgs.Kind"/>, without which the host's projector keeps the prior state. Before
|
||||
/// #647 this class treated the RawPaths as device-host filters (so nothing was ever polled) and raised
|
||||
/// alarm selectors were supported this class treated the RawPaths as device-host filters (so nothing was ever polled) and raised
|
||||
/// <c>"{host}#{Type}:{Number}"</c> with no kind (so nothing would have routed anyway).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>A failed read is not an empty list.</b> <see cref="IFocasClient.ReadAlarmsAsync"/> throws on any
|
||||
/// failure; the device is then skipped for that tick and every condition on it keeps its state. The
|
||||
/// host already annotates the driver's conditions <c>BadNoCommunication</c> on comms loss (#477).
|
||||
/// host already annotates the driver's conditions <c>BadNoCommunication</c> on comms loss.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Delivery is diffed against what the server was TOLD</b> (<see cref="_told"/>, the MTConnect #626
|
||||
/// <b>Delivery is diffed against what the server was TOLD</b> (<see cref="_told"/>, the MTConnect
|
||||
/// pattern), recorded only while an <c>OnAlarmEvent</c> handler is attached. The record lives on this
|
||||
/// object, which lives as long as the driver: it survives a re-subscribe with the same set (a reconnect),
|
||||
/// a re-initialise and a shutdown/re-init cycle — the server's condition nodes outlive all three, and
|
||||
/// re-raising there would un-acknowledge an acknowledged alarm. A changed subscribed set prunes only the
|
||||
/// RawPaths that LEFT it (the server carries every survivor across the rebuild, #641).
|
||||
/// RawPaths that LEFT it (the server carries every survivor across the rebuild).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>One poll loop</b>, owned by the current subscription. Evaluation and delivery run under
|
||||
@@ -77,11 +77,11 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
|
||||
private const uint QualityBadNoCommunication = 0x80310000u;
|
||||
|
||||
/// <summary>
|
||||
/// Whether an alarm-read failure is a CNC REFUSAL (Gitea #647 re-review R2): the CNC answered with a non-OK
|
||||
/// Whether an alarm-read failure is a CNC REFUSAL: the CNC answered with a non-OK
|
||||
/// FOCAS return code, so the transport is fine and the control simply will not serve <c>cnc_rdalmmsg2</c>
|
||||
/// (e.g. <c>EW_FUNC</c>, as <c>cnc_rdparam</c> does on the Makino). That is a capability answer, not comms
|
||||
/// loss: it must NOT degrade driver health, or an alarm-only driver on such a control would be reconnected by
|
||||
/// the #527 watchdog every 90 s forever. Everything else (session down, wire fault, malformed reply, backoff)
|
||||
/// the comms-loss watchdog every 90 s forever. Everything else (session down, wire fault, malformed reply, backoff)
|
||||
/// is a transport failure.
|
||||
/// </summary>
|
||||
/// <param name="error">The alarm-read failure.</param>
|
||||
@@ -125,9 +125,9 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
|
||||
var sub = new Subscription(new FocasAlarmSubscriptionHandle(Interlocked.Increment(ref _nextId)), refs);
|
||||
lock (_alarmLock)
|
||||
{
|
||||
// Forget only the conditions that LEFT the set (#641) — the SAME set (a reconnect) prunes nothing.
|
||||
// Forget only the conditions that LEFT the set — the SAME set (a reconnect) prunes nothing.
|
||||
foreach (var gone in _told.Keys.Where(k => !refs.Contains(k)).ToList()) _told.Remove(gone);
|
||||
// A (re)subscribe follows a reconnect, where the host re-annotates every condition Good (#477); forget
|
||||
// A (re)subscribe follows a reconnect, where the host re-annotates every condition Good; forget
|
||||
// which conditions this projection marked Bad, so a still-failing device re-asserts its Bad.
|
||||
_qualityBadTold.Clear();
|
||||
Volatile.Write(ref _current, sub);
|
||||
@@ -173,7 +173,8 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
public Task ResumeAsync() => Volatile.Read(ref _current) is null ? Task.CompletedTask : RestartLoopAsync();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Stops the poll loop and releases the projection.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async ValueTask DisposeAsync() => await StopLoopAsync().ConfigureAwait(false);
|
||||
|
||||
private async Task RestartLoopAsync()
|
||||
@@ -328,8 +329,8 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A FAILED read of <paramref name="deviceHostAddress"/> (Gitea #647 review): conditions keep their state, but
|
||||
/// each subscribed one is annotated once per outage through the #626 quality-only path (no Active/Acked change,
|
||||
/// A FAILED read of <paramref name="deviceHostAddress"/>: conditions keep their state, but
|
||||
/// each subscribed one is annotated once per outage through the quality-only path (no Active/Acked change,
|
||||
/// no <c>/alerts</c> row) — <c>BadNoCommunication</c> for a transport failure, <c>BadNotSupported</c> for a CNC
|
||||
/// refusal (R2, <see cref="IsCncRefusal"/>) — and the first failure of the episode (per kind) logs one
|
||||
/// Warning. The next successful read lifts the Bad in <see cref="Tick"/>.
|
||||
@@ -379,7 +380,7 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A quality-only annotation (#626): <see cref="AlarmTransitionKind.Unspecified"/> + a status code.</summary>
|
||||
/// <summary>A quality-only annotation: <see cref="AlarmTransitionKind.Unspecified"/> + a status code.</summary>
|
||||
private AlarmEventArgs QualityOnly(FocasAlarmTag tag, IAlarmSubscriptionHandle handle, uint quality, DateTime now)
|
||||
{
|
||||
_told.TryGetValue(tag.RawPath, out var told);
|
||||
|
||||
@@ -40,7 +40,7 @@ public static class FocasCapabilityMatrix
|
||||
// per subtree; a path this machine does not have resolves to BadNodeIdUnknown at read.
|
||||
FocasAreaKind.Fixed => null,
|
||||
// An ALARM: selector reads the device's whole active-alarm list (cnc_rdalmmsg2), which every
|
||||
// series exposes; the selector filters it driver-side, so there is no range to check (#647).
|
||||
// series exposes; the selector filters it driver-side, so there is no range to check.
|
||||
FocasAreaKind.Alarm => null,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -36,7 +36,7 @@ public static class FocasDriverFactoryExtensions
|
||||
/// </summary>
|
||||
/// <param name="registry">The driver factory registry to register with.</param>
|
||||
/// <param name="loggerFactory">Optional logger factory; without it the driver and its wire client run on
|
||||
/// the null logger and none of their diagnostics reach the node log (CONV-3).</param>
|
||||
/// the null logger and none of their diagnostics reach the node log.</param>
|
||||
public static void Register(DriverFactoryRegistry registry, ILoggerFactory? loggerFactory = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(registry);
|
||||
@@ -61,7 +61,7 @@ public static class FocasDriverFactoryExtensions
|
||||
loggerFactory?.CreateLogger<FocasDriver>(),
|
||||
// Hand the driver the SAME parse it was built with, so InitializeAsync can re-derive EVERY
|
||||
// config-derived dependency on a reinitialize — options AND the backend client factory
|
||||
// together (#516). Re-parsing options alone would run a new device/tag set against the old
|
||||
// together. Re-parsing options alone would run a new device/tag set against the old
|
||||
// backend, which is worse than not re-parsing at all.
|
||||
rebind: json => ParseBinding(driverInstanceId, json, loggerFactory));
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public static class FocasDriverFactoryExtensions
|
||||
/// <paramref name="defaultMs"/> for a null / zero / negative value. A non-positive
|
||||
/// <c>Timeout</c> would make <see cref="SynchronizedFocasClient"/> DISABLE its per-call
|
||||
/// wall-clock ceiling (falling back to the caller's long-lived poll token), reintroducing the
|
||||
/// exact unbounded-read-on-a-frozen-peer wedge the S7 R2-01 read-leg fix eliminated. Clamping
|
||||
/// exact unbounded-read-on-a-frozen-peer wedge the S7 read-leg fix eliminated. Clamping
|
||||
/// here at the config boundary guarantees the deadline can never be authored away.
|
||||
/// </summary>
|
||||
/// <param name="ms">The operator-supplied timeout in milliseconds, or null.</param>
|
||||
@@ -365,7 +365,7 @@ public static class FocasDriverFactoryExtensions
|
||||
public TimeSpan? PollInterval { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>Optional <c>PmcCoalesce</c> config section (#266).</summary>
|
||||
/// <summary>Optional <c>PmcCoalesce</c> config section.</summary>
|
||||
internal sealed class FocasPmcCoalesceDto
|
||||
{
|
||||
/// <summary>Gets or sets a value indicating whether coalescing is on.</summary>
|
||||
@@ -392,7 +392,7 @@ public static class FocasDriverFactoryExtensions
|
||||
/// reinitialize adopts all of it atomically.
|
||||
/// <para>This exists because a partial adoption is a real hazard, not a theoretical one: the driver's
|
||||
/// <see cref="IFocasClientFactory"/> is chosen by the config's <c>Backend</c> key, so re-parsing
|
||||
/// <see cref="Options"/> alone would poll a NEW device/tag set through the OLD backend (Gitea #516).</para>
|
||||
/// <see cref="Options"/> alone would poll a NEW device/tag set through the OLD backend.</para>
|
||||
/// </summary>
|
||||
/// <param name="Options">The typed driver options.</param>
|
||||
/// <param name="ClientFactory">The backend client factory the <c>Backend</c> key selects.</param>
|
||||
|
||||
@@ -32,7 +32,7 @@ internal sealed record FocasPmcRangePlan(
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges adjacent / near PMC reads in one poll batch into fewer <c>pmc_rdpmcrng</c> calls (Gitea #266).
|
||||
/// Merges adjacent / near PMC reads in one poll batch into fewer <c>pmc_rdpmcrng</c> calls.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Items are grouped by <c>(letter, slot width class)</c> and merged in address order while (a) the gap to
|
||||
|
||||
@@ -69,7 +69,7 @@ public interface IFocasClient : IDisposable
|
||||
/// active". The alarm projection polls this per device and diffs it into Part 9
|
||||
/// condition transitions on the driver's <c>OnAlarmEvent</c>.
|
||||
/// <para>
|
||||
/// <b>A failed read MUST throw</b>, never answer empty (Gitea #647): the projection treats an
|
||||
/// <b>A failed read MUST throw</b>, never answer empty: the projection treats an
|
||||
/// empty answer as "every alarm cleared", so a failure reported as <c>[]</c> becomes a mass
|
||||
/// clear followed by an un-acknowledged re-raise on recovery. A throw keeps the last state.
|
||||
/// </para>
|
||||
@@ -82,7 +82,7 @@ public interface IFocasClient : IDisposable
|
||||
/// <summary>
|
||||
/// Read one PMC range (<c>pmc_rdpmcrng</c>) as raw slots: <c>(end - start + 1)</c> bytes split into
|
||||
/// slots of <paramref name="slotType"/>'s width, from <paramref name="start"/>. The primitive behind PMC
|
||||
/// range coalescing (Gitea #266) — the driver slices individual tag values out of the returned slots with
|
||||
/// range coalescing — the driver slices individual tag values out of the returned slots with
|
||||
/// the same decode a per-tag read uses.
|
||||
/// </summary>
|
||||
/// <param name="letter">PMC area letter.</param>
|
||||
@@ -149,7 +149,7 @@ public interface IFocasClient : IDisposable
|
||||
/// <returns>The aggregate program + operation-mode snapshot.</returns>
|
||||
Task<FocasProgramInfo> GetProgramInfoAsync(CancellationToken cancellationToken);
|
||||
|
||||
// ---- Fixed-tree T2.5 (CNC status flags, Gitea #257) ----
|
||||
// ---- Fixed-tree T2.5 (CNC status flags) ----
|
||||
|
||||
/// <summary>
|
||||
/// Read the CNC status flags via <c>cnc_statinfo</c> (<c>ODBST</c>). Populates the
|
||||
|
||||
@@ -379,7 +379,7 @@ public sealed class FocasWireClient : IAsyncDisposable, IDisposable
|
||||
/// Validity (vacant <c>0xFFFF</c> exponent, a base other than 2/10, an absurd exponent) is a
|
||||
/// per-node quality decision made by <see cref="FocasPosition.IsValid"/>, not a fault here:
|
||||
/// raising would let one empty slot take out the whole poll. Ported from the sister
|
||||
/// ignitionoee driver v0.17.0 (<c>Dynamic2.scaledPosition</c>, Focas.Wire-014).
|
||||
/// ignitionoee driver v0.17.0 (<c>Dynamic2.scaledPosition</c>).
|
||||
/// </remarks>
|
||||
/// <param name="payload">The 0x0026 response-block payload.</param>
|
||||
/// <returns>The position with whatever scale the block carried.</returns>
|
||||
@@ -602,7 +602,7 @@ public sealed class FocasWireClient : IAsyncDisposable, IDisposable
|
||||
/// so reading the decimal at offset 4 decoded every macro on every control without ever
|
||||
/// failing — just wrongly (the captured <c>#500 = 1.0</c> published <c>0.01</c>). Pinned by
|
||||
/// a live Makino 31i-B capture; found and fixed by the sister ignitionoee driver
|
||||
/// (Focas.Wire-013, 2026-08-05). A payload shorter than 8 bytes carries no
|
||||
/// (2026-08-05). A payload shorter than 8 bytes carries no
|
||||
/// <c>dec_val</c> and is refused rather than guessed at.
|
||||
/// </remarks>
|
||||
/// <param name="number">The macro number the request asked for.</param>
|
||||
@@ -987,7 +987,7 @@ public sealed class FocasWireClient : IAsyncDisposable, IDisposable
|
||||
/// so the load is <c>value / base^exponent</c>, a direct percentage. (A 12-byte stride
|
||||
/// misaligned after the first record; reading offset 4 as a decimal count divided every load
|
||||
/// by 10^10 — both fixed against live 31i-B captures, the latter by the sister ignitionoee
|
||||
/// driver, Focas.Wire-019.) Axis NAMES are not in the svmeter payload; they come from the
|
||||
/// driver.) Axis NAMES are not in the svmeter payload; they come from the
|
||||
/// <c>cnc_rdaxisname</c> (0x0089) block requested alongside it and are correlated by index.
|
||||
/// The payload is a fixed 32-slot buffer: slots past the controlled-axis count are residue
|
||||
/// and decode as <see cref="WireServoMeter.IsValid"/> = false.
|
||||
@@ -1104,7 +1104,7 @@ public sealed class FocasWireClient : IAsyncDisposable, IDisposable
|
||||
/// <summary>
|
||||
/// Decode a <c>cnc_rdalmmsg2</c> payload: the 76-byte vendor stride, else the 80-byte legacy one. An empty
|
||||
/// payload is "no alarms active". A non-empty payload that fits NEITHER stride is malformed and throws
|
||||
/// (Gitea #647 review): it used to fall into the legacy parser, decode zero records, and so read as "no
|
||||
/// It used to fall into the legacy parser, decode zero records, and so read as "no
|
||||
/// alarms" — a mass Clear of every condition on the device, then an un-acknowledged re-raise next poll.
|
||||
/// </summary>
|
||||
/// <param name="payload">The reply payload.</param>
|
||||
|
||||
@@ -101,7 +101,7 @@ internal static class FocasValueEnvelope
|
||||
/// Offset 4 used to be read as a decimal count ("data / 10^dec"). It is the <b>base</b> — a
|
||||
/// steady 10 — so every load was divided by 10^10 and published ~0 (a real Makino cutting at
|
||||
/// 20,000 rpm read servo 0% on every axis). Found by the sister ignitionoee driver,
|
||||
/// Focas.Wire-019 (v0.17.2).
|
||||
/// the Focas wire library (v0.17.2).
|
||||
/// </remarks>
|
||||
/// <param name="Index">1-based axis slot.</param>
|
||||
/// <param name="Name">Axis name from the companion 0x0089 block (empty when none).</param>
|
||||
@@ -141,7 +141,7 @@ public sealed record WireSpindleMetric(
|
||||
/// The meter's full-scale count: <c>16384</c> = 2^14 = 100% of rated load (type 0) or of
|
||||
/// maximum spindle speed (type 1). Settled on the real Z-34184 by regressing the type-1
|
||||
/// meter against <c>cnc_rddynamic2</c> spindle speed over 596–20,000 rpm:
|
||||
/// <c>rpm = 1.220749 × meter</c>, <c>16384 × 1.220749 = 20000.75</c> (Focas.Wire-019).
|
||||
/// <c>rpm = 1.220749 × meter</c>, <c>16384 × 1.220749 = 20000.75</c>.
|
||||
/// </summary>
|
||||
public const int FullScale = 1 << 14;
|
||||
|
||||
|
||||
@@ -246,13 +246,13 @@ internal static class FocasWireProtocol
|
||||
/// <remarks>
|
||||
/// <para><b>All four bytes are name bytes.</b> This used to read only the first two, which
|
||||
/// collapsed the real 31i-B's paired axes <c>"AA6"</c>/<c>"AA7"</c> (live capture
|
||||
/// <c>ref-axisname-0x0089.bin</c>) to two axes both called <c>"AA"</c> — the duplicate Gitea
|
||||
/// #548 then had to disambiguate as <c>AA_1</c>/<c>AA_2</c>.</para>
|
||||
/// <c>ref-axisname-0x0089.bin</c>) to two axes both called <c>"AA"</c> — the duplicate name the
|
||||
/// driver then had to disambiguate as <c>AA_1</c>/<c>AA_2</c>.</para>
|
||||
/// <para><b>The first NUL terminates, not trailing-NUL trimming.</b> A control writes only the
|
||||
/// bytes its name needs and leaves the rest of the buffer as it found it: Makino Z-34184's
|
||||
/// <c>cnc_rdspdlname</c> answered <c>53 31 00 4e</c> — <c>"S1"</c> plus the <c>'N'</c> of an
|
||||
/// earlier <c>"CNC"</c> response. Both rules are ported from the sister ignitionoee FOCAS
|
||||
/// driver (Focas.Wire-001 / Focas.Wire-022).</para>
|
||||
/// driver (see the ignitionoee driver's wire layer).</para>
|
||||
/// </remarks>
|
||||
/// <param name="bytes">The record bytes (4 on the wire; a shorter span is read as far as it goes).</param>
|
||||
/// <returns>The decoded name; empty for a blank record.</returns>
|
||||
|
||||
@@ -73,7 +73,7 @@ public sealed class WireFocasClient : IFocasClient
|
||||
{
|
||||
// Contract: a RETURNED status is always a CNC return code (a refusal); a transport failure THROWS.
|
||||
// The coalescing caller needs that distinction — it falls back per tag on a refusal but must not
|
||||
// re-hit a dead link (#266).
|
||||
// re-hit a dead link.
|
||||
RequireConnected();
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -115,18 +115,16 @@ public sealed class WireFocasClient : IFocasClient
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// Gitea #647: every failure THROWS — a disconnected session, a non-OK return code and a wire fault
|
||||
/// alike. This used to answer <c>[]</c> for all three, which the alarm projection could not tell
|
||||
/// from "no alarms active": every comms blip cleared every active alarm, and recovery re-raised them
|
||||
/// un-acknowledged. <see cref="FocasWireException"/> propagates as-is; a refusal (non-OK rc) is thrown carrying its <c>Rc</c>.
|
||||
/// </remarks>
|
||||
public async Task<IReadOnlyList<FocasActiveAlarm>> ReadAlarmsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// Every failure THROWS — a disconnected session, a non-OK return code and a wire fault
|
||||
// alike. This used to answer [] for all three, which the alarm projection could not tell
|
||||
// from "no alarms active": every comms blip cleared every active alarm, and recovery re-raised them
|
||||
// un-acknowledged. FocasWireException propagates as-is; a refusal (non-OK rc) is thrown carrying its Rc.
|
||||
RequireConnected();
|
||||
var result = await _wire.ReadAlarmsAsync(FocasAlarmType.All, MaxAlarmsPerRead, cancellationToken).ConfigureAwait(false);
|
||||
// A non-OK return code is the CNC REFUSING the call over a healthy transport — thrown carrying the rc, so
|
||||
// the alarm projection can tell it from comms loss and keep it out of driver health (#647 re-review R2).
|
||||
// the alarm projection can tell it from comms loss and keep it out of driver health.
|
||||
if (!result.IsOk)
|
||||
throw new FocasWireException($"cnc_rdalmmsg2 refused by the CNC (EW_{result.Rc}).", result.Rc);
|
||||
return (result.Value ?? []).Select(Map).ToList();
|
||||
@@ -167,6 +165,9 @@ public sealed class WireFocasClient : IFocasClient
|
||||
return MapStatus(result.Value!);
|
||||
}
|
||||
|
||||
/// <summary>Maps the wire-level status snapshot to the driver's status record.</summary>
|
||||
/// <param name="s">The wire status.</param>
|
||||
/// <returns>The mapped status.</returns>
|
||||
internal static FocasStatus MapStatus(WireStatus s) =>
|
||||
new(s.Auto, s.Run, s.Motion, s.Mstb, s.Emergency, s.Alarm, s.Edit, s.TmMode);
|
||||
|
||||
@@ -426,7 +427,7 @@ public sealed class WireFocasClient : IFocasClient
|
||||
/// integer tag is <see cref="FocasStatusMapper.BadTypeMismatch"/> — truncating or rounding
|
||||
/// would publish a plausible wrong count at Good quality — and a whole value that does not
|
||||
/// fit the type is <see cref="FocasStatusMapper.BadOutOfRange"/>. Ported from the sister
|
||||
/// ignitionoee driver's <c>macroInteger</c>/<c>macroReal</c> (Focas-017/018).</para>
|
||||
/// ignitionoee driver's <c>macroInteger</c>/<c>macroReal</c>.</para>
|
||||
/// </remarks>
|
||||
/// <param name="m">The decoded macro.</param>
|
||||
/// <param name="type">The tag's declared data type.</param>
|
||||
@@ -472,7 +473,7 @@ public sealed class WireFocasClient : IFocasClient
|
||||
|
||||
/// <summary>
|
||||
/// Records requested per <c>cnc_rdalmmsg2</c> call. A reply carrying exactly this many may have been
|
||||
/// truncated by the CNC; the alarm projection warns about it (Gitea #647).
|
||||
/// truncated by the CNC; the alarm projection warns about it.
|
||||
/// </summary>
|
||||
internal const short MaxAlarmsPerRead = 32;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user