From 6ba1f8ee683ba00ba365d48e3ff459f265cf1406 Mon Sep 17 00:00:00 2001 From: kabdelhak <38032125+kabdelhak@users.noreply.github.com> Date: Wed, 15 May 2024 10:57:11 +0200 Subject: [PATCH] [NB] update event detection (#12427) - fix detecting pre variables as conditions after swapping execution order of Events and DetectStates modules --- OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo index 2ec1d9c586..a99a18b698 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo @@ -1029,6 +1029,13 @@ protected Pointer.update(bucket_ptr, bucket); then exp; + // replace $PRE variables with auxiliaries + // necessary if the $PRE variable is a when condition (cannot check the pre of a pre variable) + case Expression.CREF() guard(BVariable.isPrevious(BVariable.getVarPointer(exp.cref))) algorithm + (exp, bucket) := CompositeEvent.add(Condition.CONDITION(exp, iter), Pointer.access(bucket_ptr), true); + Pointer.update(bucket_ptr, bucket); + then exp; + // ToDo: math events (check the call name in a function and merge with sample case?) else exp;