fix(virtualtags): consume VirtualTag.TimerIntervalMs; add VirtualTagNoEffectiveTrigger gate (lmxopcua#783)
v2-ci / unit-tests (push) Waiting to run
v2-ci / unit-tests (push) Waiting to run
Choice: implement the timer (option a). The field was designed and promised as a working trigger: the entity doc says ChangeTriggered and TimerIntervalMs together realize the trigger model, the DB check constraint requires ChangeTriggered OR a timer >= 50, the AdminUI virtual-tag modal exposes "TimerIntervalMs (optional)" and UnsTreeService rejects a tag with neither, and the 2026-06-08 design specified "ChangeTriggered OR TimerIntervalMs>=50". Only the runtime never honoured it (the standalone TimerTriggerScheduler was deleted in #603), so a timer-only tag sat at BadWaitingForInitialData forever. - EquipmentVirtualTagPlan carries ChangeTriggered/TimerIntervalMs (in equality, so an edit respawns the child); both the composer and the artifact decode fill them. - VirtualTagActor schedules a repeating tick (PreStart, cancelled in PostStop, clamped to the 50 ms floor). ChangeTriggered=false makes the timer the only trigger. A tick during an in-flight async run (#779) is dropped, not stashed, so slow scripts never build a backlog of runs. - DraftValidator VirtualTagNoEffectiveTrigger (hard error, same severity as CalculationNoEffectiveTrigger): no timer and no change trigger with a literal ctx.GetTag read. Tests: VirtualTagActorTimerTests, DraftValidatorVirtualTagTriggerTests, artifact decode test. Mutation-checked: no scheduling, stashing ticks, no cancel in PostStop, and removing the validator call each fail a test. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -376,6 +376,8 @@ public sealed record EquipmentTagAlarmInfo(string AlarmType, int Severity, bool?
|
||||
/// Historize-only toggle is detected as a change. Defaults to <c>false</c> — matching both the CLR
|
||||
/// default of the <c>bool VirtualTag.Historize</c> 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>
|
||||
/// <param name="ChangeTriggered">Evaluate on a dependency change (entity default <c>true</c>).</param>
|
||||
/// <param name="TimerIntervalMs">Periodic re-evaluation cadence in ms, or null for none (lmxopcua#783).</param>
|
||||
public sealed record EquipmentVirtualTagPlan(
|
||||
string VirtualTagId,
|
||||
string EquipmentId,
|
||||
@@ -384,7 +386,9 @@ public sealed record EquipmentVirtualTagPlan(
|
||||
string DataType,
|
||||
string Expression,
|
||||
IReadOnlyList<string> DependencyRefs,
|
||||
bool Historize = false)
|
||||
bool Historize = false,
|
||||
bool ChangeTriggered = true,
|
||||
int? TimerIntervalMs = null)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
// Structural equality: the auto-generated record equality would compare DependencyRefs (an
|
||||
@@ -400,6 +404,8 @@ public sealed record EquipmentVirtualTagPlan(
|
||||
DataType == other.DataType &&
|
||||
Expression == other.Expression &&
|
||||
Historize == other.Historize &&
|
||||
ChangeTriggered == other.ChangeTriggered &&
|
||||
TimerIntervalMs == other.TimerIntervalMs &&
|
||||
DependencyRefs.SequenceEqual(other.DependencyRefs, StringComparer.Ordinal);
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -408,7 +414,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);
|
||||
hash.Add(Historize); hash.Add(ChangeTriggered); hash.Add(TimerIntervalMs);
|
||||
foreach (var r in DependencyRefs) hash.Add(r, StringComparer.Ordinal);
|
||||
return hash.ToHashCode();
|
||||
}
|
||||
@@ -625,7 +631,9 @@ public static class AddressSpaceComposer
|
||||
DataType: v.DataType,
|
||||
Expression: expanded,
|
||||
DependencyRefs: EquipmentScriptPaths.ExtractDependencyRefs(expanded),
|
||||
Historize: v.Historize);
|
||||
Historize: v.Historize,
|
||||
ChangeTriggered: v.ChangeTriggered,
|
||||
TimerIntervalMs: v.TimerIntervalMs);
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user