Complete protocol field associations and verify rendered inventory

This commit is contained in:
Joseph Doherty
2026-11-13 21:29:03 -05:00
parent ee8ac73e8c
commit 27bca683c1
23 changed files with 11500 additions and 32 deletions
@@ -11,8 +11,8 @@
<div class="row g-2">
<div class="col-md-6">
<label class="form-label">Script</label>
<select class="form-select form-select-sm" value="@_m.ScriptId" @onchange="OnScriptChangedAsync">
<label for="@FieldId("field-01")" class="form-label">Script</label>
<select id="@FieldId("field-01")" class="form-select form-select-sm" value="@_m.ScriptId" @onchange="OnScriptChangedAsync">
<option value="">— pick script —</option>
@foreach (var (id, display) in _scripts)
{
@@ -21,7 +21,7 @@
</select>
</div>
<div class="col-md-3">
<label class="form-label">Change-triggered</label>
<label for="calc-change-@_uid" class="form-label">Change-triggered</label>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="calc-change-@_uid"
checked="@_m.ChangeTriggered"
@@ -30,11 +30,11 @@
</div>
</div>
<div class="col-md-3">
<label class="form-label">Timer (ms)</label>
<input type="number" min="50" step="1" class="form-control form-control-sm"
<label for="@FieldId("field-03")" class="form-label">Timer (ms)</label>
<input aria-describedby="@FieldIds("field-03-hint")" id="@FieldId("field-03")" type="number" min="50" step="1" class="form-control form-control-sm"
value="@_m.TimerIntervalMs"
@onchange="@(e => Update(() => _m.TimerIntervalMs = ParseTimer(e.Value)))" />
<div class="form-text">Blank = change-trigger only. Min 50 ms.</div>
<div id="@FieldId("field-03-hint")" class="form-text">Blank = change-trigger only. Min 50 ms.</div>
</div>
</div>
@@ -75,7 +75,7 @@
Editing shared script "<span class="mono">@_scriptName</span>" — used by
@_scriptUsageCount virtual tag(s). Changes affect every tag using it.
</div>
<MonacoEditor @bind-Value="_scriptSource" Height="300px" />
<MonacoEditor AriaLabel="Calculation script source" @bind-Value="_scriptSource" Height="300px" />
@if (!string.IsNullOrWhiteSpace(_scriptError))
{
<div class="text-danger small mt-2">@_scriptError</div>
@@ -97,6 +97,10 @@
}
@code {
private readonly string _fieldScope = "calculation-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldIds(params string[] names) => string.Join(" ", names.Select(FieldId));
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 — accepted for dispatch uniformity; unused here.</summary>
@@ -19,23 +19,23 @@
This tag carries an <span class="mono">alarm</span> object, but driver type
<span class="mono">@DriverType</span> does not raise native alarms, so it has no effect.
</div>
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" id="native-alarm-remove"
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" id="@FieldId("native-alarm-remove")"
@onclick="@(() => Update(m => m.IsAlarm = false))">Remove alarm object</button>
}
else
{
<div class="form-check form-switch">
<input id="native-alarm-enabled" type="checkbox" class="form-check-input"
<input id="@FieldId("native-alarm-enabled")" type="checkbox" class="form-check-input"
checked="@_m.IsAlarm"
@onchange="@(e => Update(m => m.IsAlarm = e.Value is true))" />
<label class="form-check-label" for="native-alarm-enabled">Native alarm (Part 9 condition)</label>
<label class="form-check-label" for="@FieldId("native-alarm-enabled")">Native alarm (Part 9 condition)</label>
</div>
@if (_m.IsAlarm)
{
<div class="row g-2 mt-1">
<div class="col-md-4">
<label class="form-label" for="native-alarm-type">Alarm type</label>
<select id="native-alarm-type" class="form-select form-select-sm" value="@_m.AlarmType"
<label class="form-label" for="@FieldId("native-alarm-type")">Alarm type</label>
<select id="@FieldId("native-alarm-type")" class="form-select form-select-sm" value="@_m.AlarmType"
@onchange="@(e => Update(m => m.AlarmType = e.Value?.ToString() ?? "AlarmCondition"))">
@foreach (var t in NativeAlarmModel.KnownAlarmTypes) { <option value="@t">@t</option> }
@if (!NativeAlarmModel.KnownAlarmTypes.Contains(_m.AlarmType))
@@ -45,14 +45,14 @@
</select>
</div>
<div class="col-md-4">
<label class="form-label" for="native-alarm-severity">Severity (1..1000)</label>
<input id="native-alarm-severity" type="number" min="1" max="1000" class="form-control form-control-sm"
<label class="form-label" for="@FieldId("native-alarm-severity")">Severity (1..1000)</label>
<input id="@FieldId("native-alarm-severity")" type="number" min="1" max="1000" class="form-control form-control-sm"
value="@_m.Severity"
@onchange="@(e => Update(m => m.Severity = int.TryParse(e.Value?.ToString(), out var s) ? s : 500))" />
</div>
<div class="col-md-4">
<label class="form-label" for="native-alarm-historize">Historize to AVEVA</label>
<select id="native-alarm-historize" class="form-select form-select-sm"
<label class="form-label" for="@FieldId("native-alarm-historize")">Historize to AVEVA</label>
<select id="@FieldId("native-alarm-historize")" class="form-select form-select-sm"
value="@HistorizeValue(_m.HistorizeToAveva)"
@onchange="@(e => Update(m => m.HistorizeToAveva = ParseHistorize(e.Value?.ToString())))">
<option value="default">Default (yes)</option>
@@ -71,6 +71,9 @@
}
@code {
private readonly string _fieldScope = "native-alarm-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The tag's raw TagConfig JSON (supports <c>@bind-ConfigJson</c>).</summary>
[Parameter] public string? ConfigJson { get; set; }
/// <summary>Two-way config callback.</summary>
@@ -5,24 +5,24 @@
<div class="row g-2">
<div class="col-md-5">
<label class="form-label">Address</label>
<label for="@FieldId("field-01")" 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. DB1.DBW0, M0.0, I0.0, QD4" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<input id="@FieldId("field-01")" class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. DB1.DBW0, M0.0, I0.0, QD4" @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-4"><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, S7DataType.Int16)))">
<div class="col-md-4"><label for="@FieldId("field-02")" class="form-label">Data type</label>
<select id="@FieldId("field-02")" class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, S7DataType.Int16)))">
@foreach (var v in Enum.GetValues<S7DataType>()) { <option value="@v">@v</option> }
</select></div>
<div class="col-md-3"><label class="form-label">String len</label>
<input type="number" class="form-control form-control-sm" value="@_m.StringLength" @onchange="@(e => Update(() => _m.StringLength = ParseInt(e.Value)))" /></div>
<div class="col-md-3"><label for="@FieldId("field-03")" class="form-label">String len</label>
<input id="@FieldId("field-03")" type="number" class="form-control form-control-sm" value="@_m.StringLength" @onchange="@(e => Update(() => _m.StringLength = ParseInt(e.Value)))" /></div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="s7-writable"
<input type="checkbox" class="form-check-input" id="@FieldId("s7-writable")"
checked="@(_m.Writable ?? true)"
@onchange="@(e => Update(() => _m.Writable = e.Value is bool b && b))" />
<label class="form-check-label small" for="s7-writable">Writable (uncheck for a read-only tag)</label>
<label class="form-check-label small" for="@FieldId("s7-writable")">Writable (uncheck for a read-only tag)</label>
</div>
</div>
</div>
@@ -39,6 +39,9 @@
}
@code {
private readonly string _fieldScope = "s7-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="AmsNetId[: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="AmsNetId[:port]" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-5">
<label class="form-label">Symbol path</label>
<label for="@FieldId("field-02")" class="form-label">Symbol path</label>
<div class="input-group input-group-sm">
<input class="form-control form-control-sm mono" value="@_m.SymbolPath" placeholder="e.g. MAIN.bStart, GVL.Counter" @onchange="@(e => Update(() => _m.SymbolPath = e.Value?.ToString() ?? string.Empty))" />
<input id="@FieldId("field-02")" class="form-control form-control-sm mono" value="@_m.SymbolPath" placeholder="e.g. MAIN.bStart, GVL.Counter" @onchange="@(e => Update(() => _m.SymbolPath = 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, TwinCATDataType.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, TwinCATDataType.DInt)))">
@foreach (var v in Enum.GetValues<TwinCATDataType>()) { <option value="@v">@v</option> }
</select></div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="twincat-writable"
<input type="checkbox" class="form-check-input" id="@FieldId("twincat-writable")"
checked="@(_m.Writable ?? true)"
@onchange="@(e => Update(() => _m.Writable = e.Value is bool b && b))" />
<label class="form-check-label small" for="twincat-writable">Writable (uncheck for a read-only tag)</label>
<label class="form-check-label small" for="@FieldId("twincat-writable")">Writable (uncheck for a read-only tag)</label>
</div>
</div>
</div>
@@ -41,6 +41,9 @@
}
@code {
private readonly string _fieldScope = "twin-c-a-t-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>