feat: add JoeAppEngine OPC UA nodes, fix DCL auto-reconnect and quality push

- Add JoeAppEngine folder to OPC UA nodes.json (BTCS, AlarmCntsBySeverity, Scheduler/ScanTime)
- Fix DataConnectionActor: capture Self in PreStart for use from non-actor threads,
  preventing Self.Tell failure in Disconnected event handler
- Implement InstanceActor.HandleConnectionQualityChanged to mark attributes Bad on disconnect
- Fix LmxFakeProxy TagMapper to serialize arrays as JSON instead of "System.Int32[]"
- Allow DataType and DataSourceReference updates in TemplateService.UpdateAttributeAsync
- Update test_infra_opcua.md with JoeAppEngine documentation
This commit is contained in:
Joseph Doherty
2026-03-19 13:27:54 -04:00
parent ffdda51990
commit 7740a3bcf9
70 changed files with 2684 additions and 541 deletions

View File

@@ -65,6 +65,16 @@
}
</select>
</div>
<div class="col-md-2">
<label class="form-label small">Area</label>
<select class="form-select form-select-sm" @bind="_createAreaId">
<option value="0">No area</option>
@foreach (var a in _allAreas.Where(a => a.SiteId == _createSiteId))
{
<option value="@a.Id">@a.Name</option>
}
</select>
</div>
<div class="col-md-2">
<button class="btn btn-success btn-sm me-1" @onclick="CreateInstance">Create</button>
<button class="btn btn-outline-secondary btn-sm" @onclick="() => _showCreateForm = false">Cancel</button>
@@ -181,10 +191,62 @@
}
<button class="btn btn-outline-info btn-sm py-0 px-1 me-1"
@onclick="() => ToggleBindings(inst)">Bindings</button>
<button class="btn btn-outline-secondary btn-sm py-0 px-1 me-1"
@onclick="() => ToggleOverrides(inst)">Overrides</button>
<button class="btn btn-outline-info btn-sm py-0 px-1 me-1"
@onclick="() => ShowDiff(inst)" disabled="@(_actionInProgress || inst.State == InstanceState.NotDeployed)">Diff</button>
<button class="btn btn-outline-danger btn-sm py-0 px-1"
@onclick="() => DeleteInstance(inst)" disabled="@_actionInProgress">Delete</button>
</td>
</tr>
@if (_overrideInstanceId == inst.Id)
{
<tr>
<td colspan="7" class="bg-light p-3">
<div class="d-flex justify-content-between align-items-center mb-2">
<strong>Attribute Overrides for @inst.UniqueName</strong>
<div>
<label class="form-label small d-inline me-1">Reassign Area:</label>
<select class="form-select form-select-sm d-inline-block me-1" style="width:auto;" @bind="_reassignAreaId">
<option value="0">No area</option>
@foreach (var a in _allAreas.Where(a => a.SiteId == inst.SiteId))
{
<option value="@a.Id">@a.Name</option>
}
</select>
<button class="btn btn-sm btn-outline-primary" @onclick="() => ReassignArea(inst)" disabled="@_actionInProgress">Set Area</button>
</div>
</div>
@if (_overrideAttrs.Count == 0)
{
<p class="text-muted small mb-0">No overridable (non-locked) attributes in this template.</p>
}
else
{
<table class="table table-sm table-bordered mb-2">
<thead class="table-light">
<tr><th>Attribute</th><th>Template Value</th><th>Override Value</th></tr>
</thead>
<tbody>
@foreach (var attr in _overrideAttrs)
{
<tr>
<td class="small">@attr.Name <span class="badge bg-light text-dark">@attr.DataType</span></td>
<td class="small text-muted">@(attr.Value ?? "—")</td>
<td>
<input type="text" class="form-control form-control-sm"
value="@GetOverrideValue(attr.Name)"
@onchange="(e) => OnOverrideChanged(attr.Name, e)" />
</td>
</tr>
}
</tbody>
</table>
<button class="btn btn-success btn-sm" @onclick="SaveOverrides" disabled="@_actionInProgress">Save Overrides</button>
}
</td>
</tr>
}
@if (_bindingInstanceId == inst.Id)
{
<tr>
@@ -268,6 +330,55 @@
<div class="text-muted small">
@_filteredInstances.Count instance(s) total
</div>
@* Diff Modal *@
@if (_showDiffModal)
{
<div class="modal d-block" tabindex="-1" style="background-color: rgba(0,0,0,0.5);">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Deployment Diff — @_diffInstanceName</h5>
<button type="button" class="btn-close" @onclick="() => _showDiffModal = false"></button>
</div>
<div class="modal-body">
@if (_diffLoading)
{
<LoadingSpinner IsLoading="true" />
}
else if (_diffError != null)
{
<div class="alert alert-danger">@_diffError</div>
}
else if (_diffResult != null)
{
<div class="mb-2">
<span class="badge @(_diffResult.IsStale ? "bg-warning text-dark" : "bg-success")">
@(_diffResult.IsStale ? "Stale — changes pending" : "Current")
</span>
<span class="text-muted small ms-2">
Deployed: @_diffResult.DeployedRevisionHash[..8]
| Current: @_diffResult.CurrentRevisionHash[..8]
| Deployed at: @_diffResult.DeployedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm")
</span>
</div>
@if (!_diffResult.IsStale)
{
<p class="text-muted">No differences between deployed and current configuration.</p>
}
else
{
<p class="text-muted small">The deployed revision hash differs from the current template-derived hash. Redeploy to apply changes.</p>
}
}
</div>
<div class="modal-footer">
<button class="btn btn-secondary btn-sm" @onclick="() => _showDiffModal = false">Close</button>
</div>
</div>
</div>
</div>
}
}
</div>
@@ -508,6 +619,7 @@
private string _createName = string.Empty;
private int _createTemplateId;
private int _createSiteId;
private int _createAreaId;
private string? _createError;
private void ShowCreateForm()
@@ -515,6 +627,7 @@
_createName = string.Empty;
_createTemplateId = 0;
_createSiteId = 0;
_createAreaId = 0;
_createError = null;
_showCreateForm = true;
}
@@ -530,7 +643,7 @@
{
var user = await GetCurrentUserAsync();
var result = await InstanceService.CreateInstanceAsync(
_createName.Trim(), _createTemplateId, _createSiteId, null, user);
_createName.Trim(), _createTemplateId, _createSiteId, _createAreaId == 0 ? null : _createAreaId, user);
if (result.IsSuccess)
{
_showCreateForm = false;
@@ -548,6 +661,118 @@
}
}
// Override state
private int _overrideInstanceId;
private List<TemplateAttribute> _overrideAttrs = new();
private Dictionary<string, string?> _overrideValues = new();
private int _reassignAreaId;
private async Task ToggleOverrides(Instance inst)
{
if (_overrideInstanceId == inst.Id) { _overrideInstanceId = 0; return; }
_overrideInstanceId = inst.Id;
_overrideValues.Clear();
_reassignAreaId = inst.AreaId ?? 0;
var attrs = await TemplateEngineRepository.GetAttributesByTemplateIdAsync(inst.TemplateId);
_overrideAttrs = attrs.Where(a => !a.IsLocked).ToList();
var overrides = await TemplateEngineRepository.GetOverridesByInstanceIdAsync(inst.Id);
foreach (var o in overrides)
{
_overrideValues[o.AttributeName] = o.OverrideValue;
}
}
private string? GetOverrideValue(string attrName) =>
_overrideValues.GetValueOrDefault(attrName);
private void OnOverrideChanged(string attrName, ChangeEventArgs e)
{
var val = e.Value?.ToString();
if (string.IsNullOrEmpty(val))
_overrideValues.Remove(attrName);
else
_overrideValues[attrName] = val;
}
private async Task SaveOverrides()
{
_actionInProgress = true;
try
{
var user = await GetCurrentUserAsync();
foreach (var (attrName, value) in _overrideValues)
{
await InstanceService.SetAttributeOverrideAsync(_overrideInstanceId, attrName, value, user);
}
_toast.ShowSuccess($"Saved {_overrideValues.Count} override(s).");
_overrideInstanceId = 0;
}
catch (Exception ex)
{
_toast.ShowError($"Save overrides failed: {ex.Message}");
}
_actionInProgress = false;
}
private async Task ReassignArea(Instance inst)
{
_actionInProgress = true;
try
{
var user = await GetCurrentUserAsync();
var result = await InstanceService.AssignToAreaAsync(inst.Id, _reassignAreaId == 0 ? null : _reassignAreaId, user);
if (result.IsSuccess)
{
_toast.ShowSuccess($"Area reassigned for '{inst.UniqueName}'.");
await LoadDataAsync();
}
else
{
_toast.ShowError($"Reassign failed: {result.Error}");
}
}
catch (Exception ex)
{
_toast.ShowError($"Reassign failed: {ex.Message}");
}
_actionInProgress = false;
}
// Diff state
private bool _showDiffModal;
private bool _diffLoading;
private string? _diffError;
private string _diffInstanceName = string.Empty;
private DeploymentComparisonResult? _diffResult;
private async Task ShowDiff(Instance inst)
{
_showDiffModal = true;
_diffLoading = true;
_diffError = null;
_diffResult = null;
_diffInstanceName = inst.UniqueName;
try
{
var result = await DeploymentService.GetDeploymentComparisonAsync(inst.Id);
if (result.IsSuccess)
{
_diffResult = result.Value;
}
else
{
_diffError = result.Error;
}
}
catch (Exception ex)
{
_diffError = $"Failed to load diff: {ex.Message}";
}
_diffLoading = false;
}
// Connection binding state
private int _bindingInstanceId;
private List<TemplateAttribute> _bindingDataSourceAttrs = new();