Associate AB and Focas tag editor fields

This commit is contained in:
Joseph Doherty
2026-11-13 20:53:58 -05:00
parent 7e57074653
commit 2415db8ca4
8 changed files with 173 additions and 24 deletions
@@ -4,25 +4,25 @@
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers
<div class="row g-2">
<div class="col-md-4"><label class="form-label">Device host</label>
<input class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="ab://gateway[:port]/cip-path" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-4"><label for="@FieldId("field-01")" class="form-label">Device host</label>
<input id="@FieldId("field-01")" class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="ab://gateway[:port]/cip-path" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-5">
<label class="form-label">Tag path</label>
<label for="@FieldId("field-02")" class="form-label">Tag path</label>
<div class="input-group input-group-sm">
<input class="form-control form-control-sm mono" value="@_m.TagPath" placeholder="e.g. Motor1.Speed" @onchange="@(e => Update(() => _m.TagPath = e.Value?.ToString() ?? string.Empty))" />
<input id="@FieldId("field-02")" class="form-control form-control-sm mono" value="@_m.TagPath" placeholder="e.g. Motor1.Speed" @onchange="@(e => Update(() => _m.TagPath = e.Value?.ToString() ?? string.Empty))" />
<button type="button" class="btn btn-outline-secondary" @onclick="@(() => _showPicker = true)">Build</button>
</div>
</div>
<div class="col-md-3"><label class="form-label">Data type</label>
<select class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, AbCipDataType.DInt)))">
<div class="col-md-3"><label for="@FieldId("field-03")" class="form-label">Data type</label>
<select id="@FieldId("field-03")" class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, AbCipDataType.DInt)))">
@foreach (var v in Enum.GetValues<AbCipDataType>()) { <option value="@v">@v</option> }
</select></div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="abcip-writable"
<input type="checkbox" class="form-check-input" id="@FieldId("abcip-writable")"
checked="@(_m.Writable ?? true)"
@onchange="@(e => Update(() => _m.Writable = e.Value is bool b && b))" />
<label class="form-check-label small" for="abcip-writable">Writable (uncheck for a read-only tag)</label>
<label class="form-check-label small" for="@FieldId("abcip-writable")">Writable (uncheck for a read-only tag)</label>
</div>
</div>
</div>
@@ -41,6 +41,9 @@
}
@code {
private readonly string _fieldScope = "ab-cip-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ConfigJson { get; set; }
[Parameter] public EventCallback<string> ConfigJsonChanged { get; set; }
/// <summary>DriverType of the selected driver — lets browse-capable pickers open a universal session.</summary>
@@ -4,25 +4,25 @@
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers
<div class="row g-2">
<div class="col-md-4"><label class="form-label">Device host</label>
<input class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="ab://host" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-4"><label for="@FieldId("field-01")" class="form-label">Device host</label>
<input id="@FieldId("field-01")" class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="ab://host" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-5">
<label class="form-label">Address</label>
<label for="@FieldId("field-02")" class="form-label">Address</label>
<div class="input-group input-group-sm">
<input class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. N7:0, B3:0/0" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<input id="@FieldId("field-02")" class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. N7:0, B3:0/0" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<button type="button" class="btn btn-outline-secondary" @onclick="@(() => _showPicker = true)">Build</button>
</div>
</div>
<div class="col-md-3"><label class="form-label">Data type</label>
<select class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, AbLegacyDataType.Int)))">
<div class="col-md-3"><label for="@FieldId("field-03")" class="form-label">Data type</label>
<select id="@FieldId("field-03")" class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, AbLegacyDataType.Int)))">
@foreach (var v in Enum.GetValues<AbLegacyDataType>()) { <option value="@v">@v</option> }
</select></div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="ablegacy-writable"
<input type="checkbox" class="form-check-input" id="@FieldId("ablegacy-writable")"
checked="@(_m.Writable ?? true)"
@onchange="@(e => Update(() => _m.Writable = e.Value is bool b && b))" />
<label class="form-check-label small" for="ablegacy-writable">Writable (uncheck for a read-only tag)</label>
<label class="form-check-label small" for="@FieldId("ablegacy-writable")">Writable (uncheck for a read-only tag)</label>
</div>
</div>
</div>
@@ -39,6 +39,9 @@
}
@code {
private readonly string _fieldScope = "ab-legacy-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ConfigJson { get; set; }
[Parameter] public EventCallback<string> ConfigJsonChanged { get; set; }
/// <summary>DriverType of the selected driver — lets browse-capable pickers open a universal session.</summary>
@@ -4,17 +4,17 @@
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers
<div class="row g-2">
<div class="col-md-4"><label class="form-label">Device host</label>
<input class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="host[:port]" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-4"><label for="@FieldId("field-01")" class="form-label">Device host</label>
<input id="@FieldId("field-01")" class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="host[:port]" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-5">
<label class="form-label">Address</label>
<label for="@FieldId("field-02")" class="form-label">Address</label>
<div class="input-group input-group-sm">
<input class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. X0.0, R100, PARAM:1815/0, MACRO:500" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<input aria-describedby="@FieldId("type-mismatch")" aria-invalid="@(FocasTagDefinitionFactory.DescribeDataTypeMismatch(_m.DataType, _m.Address) is not null ? "true" : null)" id="@FieldId("field-02")" class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. X0.0, R100, PARAM:1815/0, MACRO:500" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<button type="button" class="btn btn-outline-secondary" @onclick="@(() => _showPicker = true)">Build</button>
</div>
</div>
<div class="col-md-3"><label class="form-label">Data type</label>
<select class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, FocasDataType.Int32)))">
<div class="col-md-3"><label for="@FieldId("field-03")" class="form-label">Data type</label>
<select aria-describedby="@FieldId("type-mismatch")" aria-invalid="@(FocasTagDefinitionFactory.DescribeDataTypeMismatch(_m.DataType, _m.Address) is not null ? "true" : null)" id="@FieldId("field-03")" class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, FocasDataType.Int32)))">
@foreach (var v in Enum.GetValues<FocasDataType>())
{
@* String is only readable from the fixed tree (FocasTagDefinitionFactory.DescribeDataTypeMismatch):
@@ -26,15 +26,17 @@
}
}
</select>
<div id="@FieldId("type-mismatch")" class="field-error" role="alert">
@if (FocasTagDefinitionFactory.DescribeDataTypeMismatch(_m.DataType, _m.Address) is { } typeError)
{
<div class="form-text text-danger small">@typeError</div>
}
</div>
</div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="focas-writable" disabled checked="false" />
<label class="form-check-label small text-muted" for="focas-writable">Writable — FOCAS writes are unsupported; tags are read-only.</label>
<input type="checkbox" class="form-check-input" id="@FieldId("focas-writable")" disabled checked="false" />
<label class="form-check-label small text-muted" for="@FieldId("focas-writable")">Writable — FOCAS writes are unsupported; tags are read-only.</label>
</div>
</div>
</div>
@@ -53,6 +55,9 @@
}
@code {
private readonly string _fieldScope = "focas-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ConfigJson { get; set; }
[Parameter] public EventCallback<string> ConfigJsonChanged { get; set; }
/// <summary>DriverType of the selected driver — lets browse-capable pickers open a universal session.</summary>