v3 Batch 2 — /raw project-tree AdminUI + Calculation driver #470
+14
-3
@@ -3,6 +3,7 @@
|
|||||||
ModbusDriverPage and by DriverConfigModal. Exposes GetConfigJson() for the parent to pull at save +
|
ModbusDriverPage and by DriverConfigModal. Exposes GetConfigJson() for the parent to pull at save +
|
||||||
Test-connect time, and fires DriverConfigJsonChanged for @bind support. *@
|
Test-connect time, and fires DriverConfigJsonChanged for @bind support. *@
|
||||||
@using System.Text.Json
|
@using System.Text.Json
|
||||||
|
@using System.Text.Json.Nodes
|
||||||
@using System.Text.Json.Serialization
|
@using System.Text.Json.Serialization
|
||||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
||||||
@using ZB.MOM.WW.OtOpcUa.Driver.Modbus
|
@using ZB.MOM.WW.OtOpcUa.Driver.Modbus
|
||||||
@@ -241,10 +242,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Serializes the current channel/protocol config to camelCase JSON (endpoint excluded from the UI,
|
// v3: the endpoint lives on the Device (DeviceConfig), not the driver. Strip the endpoint keys from
|
||||||
/// carried at harmless defaults; the device's DeviceConfig merges its endpoint up at deploy/probe time).</summary>
|
// the serialized channel config so DeviceConfig is the SOLE endpoint source — otherwise a stale
|
||||||
|
// driver-level default (host=127.0.0.1) is carried in DriverConfig and shadows the device on any
|
||||||
|
// driver that reads a single top-level Host, silently, as soon as a 2nd device exists (reviewer H1).
|
||||||
|
private static readonly string[] EndpointKeys = ["host", "port", "unitId"];
|
||||||
|
|
||||||
|
/// <summary>Serializes the current channel/protocol config to camelCase JSON, with the endpoint keys
|
||||||
|
/// removed (the device's DeviceConfig is the sole endpoint source, merged up at deploy/probe time).</summary>
|
||||||
public string GetConfigJson()
|
public string GetConfigJson()
|
||||||
=> JsonSerializer.Serialize(_form.ToOptions(), _jsonOpts);
|
{
|
||||||
|
var node = JsonSerializer.SerializeToNode(_form.ToOptions(), _jsonOpts)!.AsObject();
|
||||||
|
foreach (var key in EndpointKeys) node.Remove(key);
|
||||||
|
return node.ToJsonString(_jsonOpts);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task EmitAsync()
|
private async Task EmitAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-1
@@ -2,6 +2,7 @@
|
|||||||
OpcUaClientDeviceForm (Device.DeviceConfig) in v3; the EndpointUrls FAILOVER LIST stays here (it is a
|
OpcUaClientDeviceForm (Device.DeviceConfig) in v3; the EndpointUrls FAILOVER LIST stays here (it is a
|
||||||
driver-level policy). Hosted by the routed page + DriverConfigModal. *@
|
driver-level policy). Hosted by the routed page + DriverConfigModal. *@
|
||||||
@using System.Text.Json
|
@using System.Text.Json
|
||||||
|
@using System.Text.Json.Nodes
|
||||||
@using System.Text.Json.Serialization
|
@using System.Text.Json.Serialization
|
||||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
||||||
@using ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient
|
@using ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient
|
||||||
@@ -232,7 +233,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string GetConfigJson()
|
public string GetConfigJson()
|
||||||
=> JsonSerializer.Serialize(_form.OpcUa.ToRecord(_endpoints.Select(r => r.ToUrl()).ToList()), _jsonOpts);
|
{
|
||||||
|
// v3 (reviewer H1): the convenience scalar endpoint lives on the Device (DeviceConfig). Strip the
|
||||||
|
// scalar "endpointUrl" so the device is its sole source; the "endpointUrls" failover list stays
|
||||||
|
// here (it is a driver-level policy and wins over the scalar at runtime when populated).
|
||||||
|
var node = JsonSerializer.SerializeToNode(
|
||||||
|
_form.OpcUa.ToRecord(_endpoints.Select(r => r.ToUrl()).ToList()), _jsonOpts)!.AsObject();
|
||||||
|
node.Remove("endpointUrl");
|
||||||
|
return node.ToJsonString(_jsonOpts);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task EmitAsync()
|
private async Task EmitAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
+13
-3
@@ -3,6 +3,7 @@
|
|||||||
S7DriverPage and by DriverConfigModal. Exposes GetConfigJson() for the parent to pull at save +
|
S7DriverPage and by DriverConfigModal. Exposes GetConfigJson() for the parent to pull at save +
|
||||||
Test-connect time, and fires DriverConfigJsonChanged for @bind support. *@
|
Test-connect time, and fires DriverConfigJsonChanged for @bind support. *@
|
||||||
@using System.Text.Json
|
@using System.Text.Json
|
||||||
|
@using System.Text.Json.Nodes
|
||||||
@using System.Text.Json.Serialization
|
@using System.Text.Json.Serialization
|
||||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
||||||
@using ZB.MOM.WW.OtOpcUa.Driver.S7
|
@using ZB.MOM.WW.OtOpcUa.Driver.S7
|
||||||
@@ -98,10 +99,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Serializes the current protocol config to camelCase JSON (endpoint excluded from the UI,
|
// v3: the endpoint lives on the Device (DeviceConfig). Strip the endpoint keys so DeviceConfig is the
|
||||||
/// carried at harmless defaults; the device's DeviceConfig merges its endpoint up at deploy/probe time).</summary>
|
// sole endpoint source — a stale driver-level default would otherwise shadow the device on the
|
||||||
|
// single-top-level-Host read path as soon as a 2nd device exists (reviewer H1).
|
||||||
|
private static readonly string[] EndpointKeys = ["host", "port", "rack", "slot"];
|
||||||
|
|
||||||
|
/// <summary>Serializes the current protocol config to camelCase JSON, with the endpoint keys removed
|
||||||
|
/// (the device's DeviceConfig is the sole endpoint source, merged up at deploy/probe time).</summary>
|
||||||
public string GetConfigJson()
|
public string GetConfigJson()
|
||||||
=> JsonSerializer.Serialize(_form.ToOptions(), _jsonOpts);
|
{
|
||||||
|
var node = JsonSerializer.SerializeToNode(_form.ToOptions(), _jsonOpts)!.AsObject();
|
||||||
|
foreach (var key in EndpointKeys) node.Remove(key);
|
||||||
|
return node.ToJsonString(_jsonOpts);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task EmitAsync()
|
private async Task EmitAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user