refactor(historian-gateway): retire Wonderware historian projects (gateway is sole backend)
The HistorianGateway driver is now the sole historian read/write+alarm backend, so the Wonderware sidecar projects are dead code. Removes the 5 Wonderware projects (driver, .Client, .Client.Contracts, + their 2 test projects) from the solution and tree, and fully retires the vestigial 'Historian.Wonderware' driver type (UI/probe-only; it had no driver factory): the Host probe registration, the AdminUI driver-config surface (driver page, tag-config editor/model/validator entry, address picker/builder, driver-type catalog + dropdown + edit-router entries), and their tests. Prunes the now-unused Wonderware connection fields (Host/Port/UseTls/ServerCertThumbprint/SharedSecret) from AlarmHistorianOptions (keeping Enabled + the SQLite store-and-forward knobs) and refreshes the stale XML docs that named Wonderware as the production backend. Claude-Session: https://claude.ai/code/session_012SDSQ3AcaXqPcBtDESBRii
This commit is contained in:
-1
@@ -60,7 +60,6 @@ else
|
||||
["Focas"] = typeof(FocasDriverPage),
|
||||
["OpcUaClient"] = typeof(OpcUaClientDriverPage),
|
||||
["GalaxyMxGateway"] = typeof(GalaxyDriverPage),
|
||||
["Historian.Wonderware"] = typeof(HistorianWonderwareDriverPage),
|
||||
};
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
||||
-1
@@ -45,6 +45,5 @@
|
||||
new DriverTypeEntry("Focas", "focas", "[FOC]", "Fanuc CNC via FOCAS library."),
|
||||
new DriverTypeEntry("OpcUaClient", "opcuaclient", "[OPC]", "Upstream OPC UA server pull."),
|
||||
new DriverTypeEntry("Galaxy", "galaxy", "[Gx]", "AVEVA System Platform (Wonderware) via mxaccessgw."),
|
||||
new DriverTypeEntry("Historian.Wonderware", "historianwonderware","[Hx]", "Wonderware Historian replay/cyclic reads."),
|
||||
};
|
||||
}
|
||||
|
||||
-367
@@ -1,367 +0,0 @@
|
||||
@page "/clusters/{ClusterId}/drivers/new/historianwonderware"
|
||||
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
|
||||
@rendermode RenderMode.InteractiveServer
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Clients
|
||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
|
||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers
|
||||
@using ZB.MOM.WW.OtOpcUa.Configuration
|
||||
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
|
||||
@using ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Client
|
||||
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h4 class="mb-0">@(IsNew ? "New Wonderware Historian driver" : "Edit Wonderware Historian driver") · <span class="mono">@ClusterId</span></h4>
|
||||
<a href="/clusters/@ClusterId/drivers" class="btn btn-outline-secondary btn-sm">Cancel</a>
|
||||
</div>
|
||||
<ClusterNav ClusterId="@ClusterId" ActiveTab="drivers" />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p>Loading…</p>
|
||||
}
|
||||
else if (!IsNew && _existing is null)
|
||||
{
|
||||
<section class="panel notice rise" style="animation-delay:.02s">
|
||||
Driver instance <span class="mono">@DriverInstanceId</span> was not found in cluster <span class="mono">@ClusterId</span>.
|
||||
</section>
|
||||
}
|
||||
else
|
||||
{
|
||||
<EditForm Model="_form" OnValidSubmit="SubmitAsync" FormName="historianwonderwareDriverEdit">
|
||||
<DataAnnotationsValidator />
|
||||
<DriverFormShell IsNew="IsNew" Busy="_busy" Error="@_error"
|
||||
CancelHref="@($"/clusters/{ClusterId}/drivers")"
|
||||
OnDelete="@(IsNew ? null : (EventCallback?)EventCallback.Factory.Create(this, DeleteAsync))">
|
||||
|
||||
<DriverIdentitySection Model="_identityModel" Namespaces="_namespaces" IsNew="IsNew" ShowDriverType="false" />
|
||||
|
||||
@if (!IsNew && !string.IsNullOrEmpty(DriverInstanceId))
|
||||
{
|
||||
<DriverStatusPanel DriverInstanceId="@DriverInstanceId" Enabled="@_identityModel.Enabled" />
|
||||
}
|
||||
|
||||
<div class="mt-2 mb-3">
|
||||
<DriverTestConnectButton DriverType="@DriverTypeKey"
|
||||
GetConfigJson="@SerializeCurrentConfig"
|
||||
TimeoutSeconds="@_form.Historian.ProbeTimeoutSeconds" />
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-2"
|
||||
@onclick="@(() => _showPicker = true)">
|
||||
Pick address
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<DriverTagPicker @bind-Visible="_showPicker"
|
||||
Title="Historian Wonderware address"
|
||||
CurrentAddress="@_pickedAddress"
|
||||
OnPickAddress="@OnAddressPicked">
|
||||
<HistorianWonderwareAddressPickerBody CurrentAddress="@_pickedAddress"
|
||||
CurrentAddressChanged="@((s) => _pickedAddress = s)" />
|
||||
</DriverTagPicker>
|
||||
|
||||
@* Connection *@
|
||||
<section class="panel rise mt-3" style="animation-delay:.06s">
|
||||
<div class="panel-head">Connection</div>
|
||||
<div style="padding:1rem">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Sidecar host</label>
|
||||
<InputText @bind-Value="_form.Historian.Host" class="form-control form-control-sm mono"
|
||||
placeholder="localhost" />
|
||||
<div class="form-text">DNS name or IP the historian sidecar's TCP listener is reachable at.</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Sidecar port</label>
|
||||
<InputNumber @bind-Value="_form.Historian.Port" class="form-control form-control-sm mono" />
|
||||
<div class="form-text">Must match the sidecar's <code>OTOPCUA_HISTORIAN_TCP_PORT</code>.</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Shared secret</label>
|
||||
<InputText @bind-Value="_form.Historian.SharedSecret" type="password" class="form-control form-control-sm" autocomplete="new-password" />
|
||||
<div class="form-text">Per-process secret verified in the Hello frame — must match the sidecar's configured secret.</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Peer name (diagnostic)</label>
|
||||
<InputText @bind-Value="_form.Historian.PeerName" class="form-control form-control-sm"
|
||||
placeholder="OtOpcUa" />
|
||||
<div class="form-text">Sent in Hello for sidecar logging. Default: OtOpcUa.</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TLS</label>
|
||||
<div class="form-check mt-1">
|
||||
<InputCheckbox @bind-Value="_form.Historian.UseTls" class="form-check-input" id="historianUseTls" />
|
||||
<label class="form-check-label" for="historianUseTls">Use TLS</label>
|
||||
</div>
|
||||
<div class="form-text">Wrap the sidecar TCP stream in TLS before the Hello handshake.</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label class="form-label">Server cert thumbprint (TLS pin)</label>
|
||||
<InputText @bind-Value="_form.Historian.ServerCertThumbprint" class="form-control form-control-sm mono" />
|
||||
<div class="form-text">SHA-1 thumbprint to pin; blank = validate CA chain.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@* Timing *@
|
||||
<section class="panel rise mt-3" style="animation-delay:.08s">
|
||||
<div class="panel-head">Timing</div>
|
||||
<div style="padding:1rem">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Connect timeout (s, blank = default 10 s)</label>
|
||||
<InputNumber @bind-Value="_form.Historian.ConnectTimeoutSeconds" class="form-control form-control-sm" />
|
||||
<div class="form-text">Cap on TCP connect + Hello round-trip. Null = 10 s.</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Call timeout (s, blank = default 30 s)</label>
|
||||
<InputNumber @bind-Value="_form.Historian.CallTimeoutSeconds" class="form-control form-control-sm" />
|
||||
<div class="form-text">Cap on a single read/write once connected. Null = 30 s.</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Effective connect timeout (s)</label>
|
||||
<input class="form-control form-control-sm" readonly
|
||||
value="@(_form.Historian.ConnectTimeoutSeconds?.ToString() ?? "10 (default)")" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Effective call timeout (s)</label>
|
||||
<input class="form-control form-control-sm" readonly
|
||||
value="@(_form.Historian.CallTimeoutSeconds?.ToString() ?? "30 (default)")" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@* Diagnostics *@
|
||||
<section class="panel rise mt-3" style="animation-delay:.10s">
|
||||
<div class="panel-head">Diagnostics</div>
|
||||
<div style="padding:1rem">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Admin UI probe timeout (seconds)</label>
|
||||
<InputNumber @bind-Value="_form.Historian.ProbeTimeoutSeconds" class="form-control form-control-sm" />
|
||||
<div class="form-text">Max 60. Used by Test Connect. Default 15.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<DriverResilienceSection @bind-ResilienceConfig="_form.ResilienceConfig" />
|
||||
</DriverFormShell>
|
||||
</EditForm>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public string ClusterId { get; set; } = "";
|
||||
[Parameter] public string? DriverInstanceId { get; set; }
|
||||
|
||||
private const string DriverTypeKey = "Historian.Wonderware";
|
||||
|
||||
private bool IsNew => string.IsNullOrEmpty(DriverInstanceId);
|
||||
|
||||
private static readonly System.Text.Json.JsonSerializerOptions _jsonOpts = new()
|
||||
{
|
||||
PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase,
|
||||
UnmappedMemberHandling = System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip,
|
||||
WriteIndented = false,
|
||||
Converters = { new System.Text.Json.Serialization.JsonStringEnumConverter() },
|
||||
};
|
||||
|
||||
private FormModel _form = new();
|
||||
private DriverIdentitySection.DriverIdentityModel _identityModel = new() { DriverType = DriverTypeKey };
|
||||
private DriverInstance? _existing;
|
||||
private List<Namespace> _namespaces = new();
|
||||
private bool _loaded;
|
||||
private bool _busy;
|
||||
private string? _error;
|
||||
|
||||
// Address picker state
|
||||
private bool _showPicker;
|
||||
private string _pickedAddress = "";
|
||||
|
||||
private void OnAddressPicked(string address) => _pickedAddress = address;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await using var db = await DbFactory.CreateDbContextAsync();
|
||||
_namespaces = await db.Namespaces.AsNoTracking()
|
||||
.Where(n => n.ClusterId == ClusterId)
|
||||
.OrderBy(n => n.NamespaceId)
|
||||
.ToListAsync();
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
_identityModel = new()
|
||||
{
|
||||
DriverInstanceId = "",
|
||||
Name = "",
|
||||
DriverType = DriverTypeKey,
|
||||
NamespaceId = _namespaces.FirstOrDefault()?.NamespaceId ?? "",
|
||||
Enabled = true,
|
||||
};
|
||||
_form = new FormModel();
|
||||
}
|
||||
else
|
||||
{
|
||||
_existing = await db.DriverInstances.AsNoTracking()
|
||||
.FirstOrDefaultAsync(d => d.ClusterId == ClusterId && d.DriverInstanceId == DriverInstanceId);
|
||||
if (_existing is not null)
|
||||
{
|
||||
_identityModel = new()
|
||||
{
|
||||
DriverInstanceId = _existing.DriverInstanceId,
|
||||
Name = _existing.Name,
|
||||
DriverType = _existing.DriverType,
|
||||
NamespaceId = _existing.NamespaceId,
|
||||
Enabled = _existing.Enabled,
|
||||
};
|
||||
var opts = TryDeserialize(_existing.DriverConfig) ?? CreateDefaultOptions();
|
||||
_form = new FormModel();
|
||||
_form.Historian = WonderwareHistorianClientFormModel.FromRecord(opts);
|
||||
_form.ResilienceConfig = _existing.ResilienceConfig;
|
||||
_form.RowVersion = _existing.RowVersion;
|
||||
}
|
||||
}
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
private static WonderwareHistorianClientOptions CreateDefaultOptions() =>
|
||||
new(Host: "localhost", Port: 32569, SharedSecret: "") { UseTls = false, ServerCertThumbprint = null };
|
||||
|
||||
private async Task SubmitAsync()
|
||||
{
|
||||
_busy = true; _error = null;
|
||||
try
|
||||
{
|
||||
var opts = _form.Historian.ToRecord();
|
||||
var configJson = System.Text.Json.JsonSerializer.Serialize(opts, _jsonOpts);
|
||||
await using var db = await DbFactory.CreateDbContextAsync();
|
||||
if (IsNew)
|
||||
{
|
||||
if (await db.DriverInstances.AnyAsync(d => d.DriverInstanceId == _identityModel.DriverInstanceId))
|
||||
{
|
||||
_error = $"Driver instance '{_identityModel.DriverInstanceId}' already exists."; return;
|
||||
}
|
||||
db.DriverInstances.Add(new DriverInstance
|
||||
{
|
||||
DriverInstanceId = _identityModel.DriverInstanceId,
|
||||
ClusterId = ClusterId,
|
||||
NamespaceId = _identityModel.NamespaceId,
|
||||
Name = _identityModel.Name,
|
||||
DriverType = DriverTypeKey,
|
||||
Enabled = _identityModel.Enabled,
|
||||
DriverConfig = configJson,
|
||||
ResilienceConfig = string.IsNullOrWhiteSpace(_form.ResilienceConfig) ? null : _form.ResilienceConfig,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await db.DriverInstances.FirstOrDefaultAsync(
|
||||
d => d.ClusterId == ClusterId && d.DriverInstanceId == DriverInstanceId);
|
||||
if (entity is null) { _error = "Row no longer exists."; return; }
|
||||
db.Entry(entity).Property(e => e.RowVersion).OriginalValue = _form.RowVersion;
|
||||
entity.NamespaceId = _identityModel.NamespaceId;
|
||||
entity.Name = _identityModel.Name;
|
||||
entity.Enabled = _identityModel.Enabled;
|
||||
entity.DriverConfig = configJson;
|
||||
entity.ResilienceConfig = string.IsNullOrWhiteSpace(_form.ResilienceConfig) ? null : _form.ResilienceConfig;
|
||||
}
|
||||
await db.SaveChangesAsync();
|
||||
Nav.NavigateTo($"/clusters/{ClusterId}/drivers");
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
_error = "Another user changed this driver instance while you were editing. Reload to see the latest values, then re-apply your changes.";
|
||||
}
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _busy = false; }
|
||||
}
|
||||
|
||||
private async Task DeleteAsync()
|
||||
{
|
||||
if (IsNew) return;
|
||||
_busy = true; _error = null;
|
||||
try
|
||||
{
|
||||
await using var db = await DbFactory.CreateDbContextAsync();
|
||||
var entity = await db.DriverInstances.FirstOrDefaultAsync(
|
||||
d => d.ClusterId == ClusterId && d.DriverInstanceId == DriverInstanceId);
|
||||
if (entity is null) { Nav.NavigateTo($"/clusters/{ClusterId}/drivers"); return; }
|
||||
db.Entry(entity).Property(e => e.RowVersion).OriginalValue = _form.RowVersion;
|
||||
db.DriverInstances.Remove(entity);
|
||||
await db.SaveChangesAsync();
|
||||
Nav.NavigateTo($"/clusters/{ClusterId}/drivers");
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
_error = "Another user changed this driver instance while you were viewing it. Reload before deleting.";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_error = $"Delete failed: {ex.Message}. (Likely because equipment/tags still reference this driver — remove them first.)";
|
||||
}
|
||||
finally { _busy = false; }
|
||||
}
|
||||
|
||||
private string SerializeCurrentConfig()
|
||||
=> System.Text.Json.JsonSerializer.Serialize(_form.Historian.ToRecord(), _jsonOpts);
|
||||
|
||||
private static WonderwareHistorianClientOptions? TryDeserialize(string json)
|
||||
{
|
||||
try { return System.Text.Json.JsonSerializer.Deserialize<WonderwareHistorianClientOptions>(json, _jsonOpts); }
|
||||
catch { return null; }
|
||||
}
|
||||
|
||||
public sealed class FormModel
|
||||
{
|
||||
public WonderwareHistorianClientFormModel Historian { get; set; } = new();
|
||||
public string? ResilienceConfig { get; set; }
|
||||
public byte[] RowVersion { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mutable mirror of <see cref="WonderwareHistorianClientOptions"/> (positional record).
|
||||
/// <c>ConnectTimeoutSeconds</c> and <c>CallTimeoutSeconds</c> are nullable int — null
|
||||
/// round-trips to a null TimeSpan?, which the record resolves to its compiled default.
|
||||
/// </summary>
|
||||
public sealed class WonderwareHistorianClientFormModel
|
||||
{
|
||||
public string Host { get; set; } = "localhost";
|
||||
public int Port { get; set; } = 32569;
|
||||
public string SharedSecret { get; set; } = "";
|
||||
public string PeerName { get; set; } = "OtOpcUa";
|
||||
public int? ConnectTimeoutSeconds { get; set; }
|
||||
public int? CallTimeoutSeconds { get; set; }
|
||||
public int ProbeTimeoutSeconds { get; set; } = 15;
|
||||
public bool UseTls { get; set; }
|
||||
public string? ServerCertThumbprint { get; set; }
|
||||
|
||||
public static WonderwareHistorianClientFormModel FromRecord(WonderwareHistorianClientOptions r) => new()
|
||||
{
|
||||
Host = r.Host,
|
||||
Port = r.Port,
|
||||
SharedSecret = r.SharedSecret,
|
||||
PeerName = r.PeerName,
|
||||
ConnectTimeoutSeconds = r.ConnectTimeout.HasValue ? (int)r.ConnectTimeout.Value.TotalSeconds : null,
|
||||
CallTimeoutSeconds = r.CallTimeout.HasValue ? (int)r.CallTimeout.Value.TotalSeconds : null,
|
||||
ProbeTimeoutSeconds = r.ProbeTimeoutSeconds,
|
||||
UseTls = r.UseTls,
|
||||
ServerCertThumbprint = r.ServerCertThumbprint,
|
||||
};
|
||||
|
||||
public WonderwareHistorianClientOptions ToRecord() => new(
|
||||
Host: Host,
|
||||
Port: Port,
|
||||
SharedSecret: SharedSecret,
|
||||
PeerName: PeerName,
|
||||
ConnectTimeout: ConnectTimeoutSeconds.HasValue ? TimeSpan.FromSeconds(ConnectTimeoutSeconds.Value) : null,
|
||||
CallTimeout: CallTimeoutSeconds.HasValue ? TimeSpan.FromSeconds(CallTimeoutSeconds.Value) : null)
|
||||
{
|
||||
ProbeTimeoutSeconds = ProbeTimeoutSeconds,
|
||||
UseTls = UseTls,
|
||||
ServerCertThumbprint = ServerCertThumbprint,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user