Auto: focas-f4a — write infrastructure + per-tag opt-in

Closes #268
This commit is contained in:
Joseph Doherty
2026-04-26 04:32:43 -04:00
parent 6f1657b1c0
commit 1bfe8fba0e
13 changed files with 521 additions and 11 deletions

View File

@@ -38,7 +38,11 @@ public sealed class WriteCommand : FocasCommandBase
Address: Address,
DataType: DataType,
Writable: true);
var options = BuildOptions([tag]);
// The CLI is a per-invocation operator tool; it bypasses the server-side
// FocasDriverOptions.Writes.Enabled gate by enabling writes locally for this single
// process. Configure-the-server code paths still respect the safer-by-default flag —
// see docs/Driver.FOCAS.Cli.md "Writes" subsection (issue #268, plan PR F4-a).
var options = BuildOptions([tag], writesEnabled: true);
var parsed = ParseValue(Value, DataType);

View File

@@ -41,9 +41,12 @@ public abstract class FocasCommandBase : DriverCommandBase
/// + the tag list a subclass supplies. Probe disabled; the default
/// <see cref="FwlibFocasClientFactory"/> attempts <c>Fwlib32.dll</c> P/Invoke, which
/// throws <see cref="DllNotFoundException"/> at first call when the DLL is absent —
/// surfaced through the driver as <c>BadCommunicationError</c>.
/// surfaced through the driver as <c>BadCommunicationError</c>. Pass
/// <paramref name="writesEnabled"/> = <c>true</c> to bypass the F4-a driver-level
/// write gate for the lifetime of this CLI invocation (issue #268).
/// </summary>
protected FocasDriverOptions BuildOptions(IReadOnlyList<FocasTagDefinition> tags) => new()
protected FocasDriverOptions BuildOptions(
IReadOnlyList<FocasTagDefinition> tags, bool writesEnabled = false) => new()
{
Devices = [new FocasDeviceOptions(
HostAddress: HostAddress,
@@ -52,6 +55,7 @@ public abstract class FocasCommandBase : DriverCommandBase
Tags = tags,
Timeout = Timeout,
Probe = new FocasProbeOptions { Enabled = false },
Writes = new FocasWritesOptions { Enabled = writesEnabled },
};
protected string DriverInstanceId => $"focas-cli-{CncHost}:{CncPort}";