feat(opcua): remove SystemPlatform mirror producer + Galaxy exception from Phase7Composer

This commit is contained in:
Joseph Doherty
2026-06-12 21:17:39 -04:00
parent 47cb5725a9
commit e2c6c15ae0
2 changed files with 37 additions and 76 deletions
@@ -335,43 +335,18 @@ public static class Phase7Composer
.Select(a => new ScriptedAlarmPlan(a.ScriptedAlarmId, a.EquipmentId, a.PredicateScriptId, a.MessageTemplate))
.ToList();
// SystemPlatform tags = Galaxy tags. Match each tag to its DriverInstance and that
// driver's Namespace; emit only when the namespace kind is SystemPlatform AND the tag
// has no EquipmentId (per the entity invariant for SystemPlatform).
var driversById = driverInstances.ToDictionary(d => d.DriverInstanceId, StringComparer.Ordinal);
var namespacesById = namespaces.ToDictionary(n => n.NamespaceId, StringComparer.Ordinal);
var galaxyTags = tags
.Where(t => t.EquipmentId is null)
.Where(t => driversById.TryGetValue(t.DriverInstanceId, out var di)
&& namespacesById.TryGetValue(di.NamespaceId, out var ns)
&& ns.Kind == NamespaceKind.SystemPlatform)
.OrderBy(t => t.DriverInstanceId, StringComparer.Ordinal)
.ThenBy(t => t.FolderPath, StringComparer.Ordinal)
.ThenBy(t => t.Name, StringComparer.Ordinal)
.Select(t => new GalaxyTagPlan(
TagId: t.TagId,
DriverInstanceId: t.DriverInstanceId,
FolderPath: t.FolderPath ?? string.Empty,
DisplayName: t.Name,
DataType: t.DataType,
// MXAccess reference: "FolderPath.Name" when FolderPath is set, else just "Name".
MxAccessRef: string.IsNullOrWhiteSpace(t.FolderPath) ? t.Name : $"{t.FolderPath}.{t.Name}"))
.ToList();
// Equipment tags = the inverse filter: a Tag bound to an Equipment (non-null EquipmentId)
// whose driver's namespace is Equipment-kind. FullName is the driver-side wire reference
// pulled from TagConfig — it becomes the variable's NodeId + read/write routing key.
// A Galaxy alias is the one exception to the Equipment-kind namespace rule: a GalaxyMxGateway
// driver lives in a SystemPlatform-kind namespace, yet an equipment-scoped alias Tag bound to
// it must still surface as an equipment tag — so admit those by DriverType. The galaxyTags
// producer keeps its `t.EquipmentId is null` guard, so an alias (EquipmentId set) never
// double-counts there.
// Equipment tags = a Tag bound to an Equipment (non-null EquipmentId) whose driver's namespace
// is Equipment-kind. FullName is the driver-side wire reference pulled from TagConfig — it
// becomes the variable's NodeId + read/write routing key. Galaxy points are ordinary equipment
// tags now (GalaxyMxGateway is a standard Equipment-kind driver), so no driver-type exception.
var equipmentTags = tags
.Where(t => t.EquipmentId is not null)
.Where(t => driversById.TryGetValue(t.DriverInstanceId, out var di)
&& namespacesById.TryGetValue(di.NamespaceId, out var ns)
&& (ns.Kind == NamespaceKind.Equipment || di.DriverType == "GalaxyMxGateway"))
&& ns.Kind == NamespaceKind.Equipment)
.OrderBy(t => t.EquipmentId, StringComparer.Ordinal)
.ThenBy(t => t.FolderPath ?? string.Empty, StringComparer.Ordinal) // coalesce so the sort matches the artifact-decode side exactly
.ThenBy(t => t.Name, StringComparer.Ordinal)
@@ -465,7 +440,7 @@ public static class Phase7Composer
Enabled: a.Enabled));
}
return new Phase7CompositionResult(areas, lines, nodes, plans, alarms, galaxyTags)
return new Phase7CompositionResult(areas, lines, nodes, plans, alarms, Array.Empty<GalaxyTagPlan>())
{
EquipmentTags = equipmentTags,
EquipmentVirtualTags = equipmentVirtualTags,