From 4502eeca2f03503c8464eeca54b0487cb1f7c95b Mon Sep 17 00:00:00 2001 From: Antoine Gautier Date: Fri, 25 Oct 2024 20:58:55 +0200 Subject: [PATCH] Refactor to ensure passed=u if t=0 (#4022) * Refactor to ensure passed=u if t=0 * Update checksum --- .../templates/Plants.HeatPumps.checksum | 2 +- .../Controls/Utilities/TimerWithReset.mo | 36 +++++++++---------- .../UsersGuide/ReleaseNotes/Version_12_0_0.mo | 10 ++++++ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Buildings/Resources/Scripts/travis/templates/Plants.HeatPumps.checksum b/Buildings/Resources/Scripts/travis/templates/Plants.HeatPumps.checksum index 9f7de139ffa..eb8da03ea4f 100644 --- a/Buildings/Resources/Scripts/travis/templates/Plants.HeatPumps.checksum +++ b/Buildings/Resources/Scripts/travis/templates/Plants.HeatPumps.checksum @@ -1 +1 @@ -9f5001757d1555f1948b175403b37304 +66fd47582d1789884f4a44648f72548a diff --git a/Buildings/Templates/Plants/Controls/Utilities/TimerWithReset.mo b/Buildings/Templates/Plants/Controls/Utilities/TimerWithReset.mo index cf530459b2f..4fb60c2412b 100644 --- a/Buildings/Templates/Plants/Controls/Utilities/TimerWithReset.mo +++ b/Buildings/Templates/Plants/Controls/Utilities/TimerWithReset.mo @@ -28,28 +28,20 @@ protected final unit="s") "Time instant when u became true"; initial equation - pre(entryTime)=time; - pre(passed)=t <= 0; + entryTime = time; + passed = t <= 0; equation - when u and not reset then - entryTime=time; - // When u becomes true, and t=0, we want passed to be true - // at the first step (in superdense time). - passed=t <= 0; - elsewhen reset then - entryTime=time; - passed=false; - elsewhen - (u and time >= t + pre(entryTime)) then - passed=true; - entryTime=pre(entryTime); + when {u, reset} then + entryTime = time; + passed = u and t <= 0; + elsewhen u and time >= pre(entryTime) + t then + entryTime = pre(entryTime); + passed = true; elsewhen not u then - // Set passed to false. - // This is the behavior a timer would have if the threshold test is done with a greater block connected to the output of the timer - passed=false; - entryTime=pre(entryTime); + entryTime = pre(entryTime); + passed = false; end when; - y=if u then time - entryTime else 0.0; + y = if u then time - entryTime else 0.0; annotation ( __cdl( extensionBlock=true), @@ -125,6 +117,12 @@ equation Documentation(revisions="