feat(vtags): carry VirtualTag.Historize onto EquipmentVirtualTagPlan (H5a, stillpending §1)

This commit is contained in:
Joseph Doherty
2026-06-15 10:17:05 -04:00
parent ebf2f1dd7a
commit fc8121cbf3
2 changed files with 83 additions and 3 deletions
@@ -113,6 +113,11 @@ public sealed record EquipmentTagAlarmInfo(string AlarmType, int Severity);
/// that NodeId. <see cref="DependencyRefs"/> = the distinct <c>ctx.GetTag("…")</c> literals in
/// the script source.
/// </summary>
/// <param name="Historize">When true, this VirtualTag's values are historized (carried from the
/// <c>VirtualTag.Historize</c> entity column). Threaded through the deploy-diff equality below so a
/// Historize-only toggle is detected as a change. Defaults to <c>false</c> — matching both the entity
/// default for an unset column and the artifact-decode default when the flag is absent/non-bool —
/// which keeps existing positional+named ctor call sites compiling and preserves byte-parity.</param>
public sealed record EquipmentVirtualTagPlan(
string VirtualTagId,
string EquipmentId,
@@ -120,12 +125,14 @@ public sealed record EquipmentVirtualTagPlan(
string Name,
string DataType,
string Expression,
IReadOnlyList<string> DependencyRefs)
IReadOnlyList<string> DependencyRefs,
bool Historize = false)
{
/// <summary>Structural equality: the auto-generated record equality would compare
/// <see cref="DependencyRefs"/> (an interface-typed list) BY REFERENCE, flagging every
/// VirtualTag as "changed" on every parse (fresh list instances). Compare it element-wise
/// so a no-op redeploy diffs empty.</summary>
/// so a no-op redeploy diffs empty. <see cref="Historize"/> is included so a Historize-only
/// toggle is detected as a change.</summary>
public bool Equals(EquipmentVirtualTagPlan? other) =>
other is not null &&
VirtualTagId == other.VirtualTagId &&
@@ -134,6 +141,7 @@ public sealed record EquipmentVirtualTagPlan(
Name == other.Name &&
DataType == other.DataType &&
Expression == other.Expression &&
Historize == other.Historize &&
DependencyRefs.SequenceEqual(other.DependencyRefs, StringComparer.Ordinal);
public override int GetHashCode()
@@ -141,6 +149,7 @@ public sealed record EquipmentVirtualTagPlan(
var hash = new HashCode();
hash.Add(VirtualTagId); hash.Add(EquipmentId); hash.Add(FolderPath);
hash.Add(Name); hash.Add(DataType); hash.Add(Expression);
hash.Add(Historize);
foreach (var r in DependencyRefs) hash.Add(r, StringComparer.Ordinal);
return hash.ToHashCode();
}
@@ -385,7 +394,8 @@ public static class Phase7Composer
Name: v.Name,
DataType: v.DataType,
Expression: expanded,
DependencyRefs: EquipmentScriptPaths.ExtractDependencyRefs(expanded));
DependencyRefs: EquipmentScriptPaths.ExtractDependencyRefs(expanded),
Historize: v.Historize);
})
.ToList();