From ee5191e448952a8e63cb6a1219b5023559e9b285 Mon Sep 17 00:00:00 2001 From: minsoo Date: Mon, 21 Sep 2026 16:27:32 -0500 Subject: [PATCH 1/3] Add updated events manager model from ramtares_main --- .../include/watch_values_base.hh | 29 ++++++++++++++++++- .../include/watch_values_base_core.hh | 12 +++++--- .../events_manager/src/watch_values_set.cc | 7 +++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/models/vehicle_management/events_manager/include/watch_values_base.hh b/models/vehicle_management/events_manager/include/watch_values_base.hh index 7df24027..5f12c7f1 100644 --- a/models/vehicle_management/events_manager/include/watch_values_base.hh +++ b/models/vehicle_management/events_manager/include/watch_values_base.hh @@ -57,10 +57,29 @@ class WatchValuesBase : public WatchValuesBaseCore { /***************************************************************************** set_watch Purpose:(Sets the variable and the reference against which it will be compared) +Notes: +- If the variable passed in is not of type watchType, the compiler would + implicitly cast that variable to a temporary storage space of the expected + type, and the watch value would monitor that temporary storage space, not + the intended variable, for changes. This is a big problem if a user gets the + type wrong in setting up their WatchValue, or setse it up correctly and the + variable type later changes. +- To rule that out and explicitly require a type match, we delete set_watch + for all types of "var", then implement only the one in which "var" is of + type "watchType". Now if the types do not match, the project will not build. +- When setting the reference by pointer: set_watch( T1&, T2*) + T2 must be of type watchType already; everything else is blocked. + So we only need to check on the type of var. *****************************************************************************/ + template + void set_watch (const T& var, watchType ref) = delete; + template + void set_watch (const T1& var, const watchType * ref) = delete; + + // ************************************************************************ // ** reference is fixed-value ** // ************************************************************************ - void set_watch( const watchType & var, watchType ref) { + void set_watch( const watchType & var, watchType ref) { variable = &var; reference = ref; reference_is_variable = false; @@ -391,4 +410,12 @@ Purpose:(Generates the new reference value.) reference += variable_at_activation; } }; + +template <> inline void WatchValuesBase::set_dbl_reference(double ref) +{ + // Semantically equivalent to static_cast(ref) (i.e., ref != 0.0), + // but avoids '=='/'!=' comparisons that trigger -Wfloat-equal. + reference = (ref > 0.0) || (ref < 0.0) || std::isnan(ref); +} + #endif \ No newline at end of file diff --git a/models/vehicle_management/events_manager/include/watch_values_base_core.hh b/models/vehicle_management/events_manager/include/watch_values_base_core.hh index d8885b8b..430f4614 100644 --- a/models/vehicle_management/events_manager/include/watch_values_base_core.hh +++ b/models/vehicle_management/events_manager/include/watch_values_base_core.hh @@ -64,14 +64,18 @@ class WatchValuesBaseCore : public SubscriptionBase { std::string name; /* (--) Name, primarily for debugging purposes. May be left blank.*/ bool locked{false}; /* (--) - Boolean used to lock at each cycle, so each WatchValuesBase cannot be - tested more than once per cycle, leading to unintended behavior.*/ + Boolean used to lock at each cycle, so each WatchValuesBase cannot be + tested more than once per cycle. Elaborate extension of WatchValuesBaseCore + -- such as EventTrigger -- caan create false negatives if evaluated + multiple times with the same value of the watch-variable. */ bool externally_managed{false}; /* (--) Boolean setting that bool "locked" is set to once trigger is evaluated true: lock after evaluation - (commonly set in CompoundEventsManager::create_trigger()) + (commonly set when an WatchValue is added to the CompoundEventsManager's + managed_triggers listi, such as when using create)trigger(...)) false: do not lock after evaluation, can be evaluated multiple times per - logging cycle (default, but overriden by create_trigger()) */ + logging cycle (default, but overriden by + CompoundEventssManager::add_trigger(...)) */ protected: diff --git a/models/vehicle_management/events_manager/src/watch_values_set.cc b/models/vehicle_management/events_manager/src/watch_values_set.cc index 24f1818b..c35c3716 100644 --- a/models/vehicle_management/events_manager/src/watch_values_set.cc +++ b/models/vehicle_management/events_manager/src/watch_values_set.cc @@ -47,6 +47,13 @@ WatchValuesSet::initialize( std::list * active_watch_in) return; } for (WatchValuesBaseCore * trigger : triggers) { + // if (require_all) { + // // force multi_shot for all triggers when the set requires all triggers + // // to be fulfilled for the set to be fulfilled. This fixes a discrepancy + // // with DataCollect's behavior without requiring the logging user to be + // // careful with the multi_shot optimization. + // trigger->multi_shot = true; + // } trigger->add_self_to_manager_active_list = false; trigger->SubscriptionBase::initialize(); } From 3be67021944d4639f493a65a98c76adcc56efb63 Mon Sep 17 00:00:00 2001 From: Minsoo Kang Date: Wed, 30 Sep 2026 17:09:03 -0500 Subject: [PATCH 2/3] Fix deprecated comments and update to coding standards --- .../events_manager/include/watch_values_base.hh | 4 +--- .../include/watch_values_base_core.hh | 6 +++--- .../events_manager/src/watch_values_set.cc | 17 ----------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/models/vehicle_management/events_manager/include/watch_values_base.hh b/models/vehicle_management/events_manager/include/watch_values_base.hh index 5f12c7f1..6f297742 100644 --- a/models/vehicle_management/events_manager/include/watch_values_base.hh +++ b/models/vehicle_management/events_manager/include/watch_values_base.hh @@ -413,9 +413,7 @@ Purpose:(Generates the new reference value.) template <> inline void WatchValuesBase::set_dbl_reference(double ref) { - // Semantically equivalent to static_cast(ref) (i.e., ref != 0.0), - // but avoids '=='/'!=' comparisons that trigger -Wfloat-equal. - reference = (ref > 0.0) || (ref < 0.0) || std::isnan(ref); + reference = std::fpclassify(ref) != FP_ZERO; } #endif \ No newline at end of file diff --git a/models/vehicle_management/events_manager/include/watch_values_base_core.hh b/models/vehicle_management/events_manager/include/watch_values_base_core.hh index 430f4614..7dc12c55 100644 --- a/models/vehicle_management/events_manager/include/watch_values_base_core.hh +++ b/models/vehicle_management/events_manager/include/watch_values_base_core.hh @@ -66,13 +66,13 @@ class WatchValuesBaseCore : public SubscriptionBase { bool locked{false}; /* (--) Boolean used to lock at each cycle, so each WatchValuesBase cannot be tested more than once per cycle. Elaborate extension of WatchValuesBaseCore - -- such as EventTrigger -- caan create false negatives if evaluated + -- such as EventTrigger -- can create false negatives if evaluated multiple times with the same value of the watch-variable. */ bool externally_managed{false}; /* (--) Boolean setting that bool "locked" is set to once trigger is evaluated true: lock after evaluation - (commonly set when an WatchValue is added to the CompoundEventsManager's - managed_triggers listi, such as when using create)trigger(...)) + (commonly set when a WatchValue is added to the CompoundEventsManager's + managed_triggers list, such as when using create_trigger(...)) false: do not lock after evaluation, can be evaluated multiple times per logging cycle (default, but overriden by CompoundEventssManager::add_trigger(...)) */ diff --git a/models/vehicle_management/events_manager/src/watch_values_set.cc b/models/vehicle_management/events_manager/src/watch_values_set.cc index c35c3716..0fd5f28f 100644 --- a/models/vehicle_management/events_manager/src/watch_values_set.cc +++ b/models/vehicle_management/events_manager/src/watch_values_set.cc @@ -47,13 +47,6 @@ WatchValuesSet::initialize( std::list * active_watch_in) return; } for (WatchValuesBaseCore * trigger : triggers) { - // if (require_all) { - // // force multi_shot for all triggers when the set requires all triggers - // // to be fulfilled for the set to be fulfilled. This fixes a discrepancy - // // with DataCollect's behavior without requiring the logging user to be - // // careful with the multi_shot optimization. - // trigger->multi_shot = true; - // } trigger->add_self_to_manager_active_list = false; trigger->SubscriptionBase::initialize(); } @@ -79,16 +72,6 @@ WatchValuesSet::test_crossing() } } - /* If the set triggers with ANY trigger, and any trigger satisfies its - condition, the set is Triggered. - If the set only triggers with ALL triggers, and any trigger does not - satisfy its condition, the set is NotTriggered. - So we can compare the require_all boolean against the event_triggered - value of each trigger-event to identify any significant single results. - - If any trigger has a status that does not match with "require_all", then - the overall status is "not require_all" - - Conversely, if all triggers have status matching "require_all", then the - overall status is going to be "require_all"*/ event_triggered = std::any_of( triggers.begin(), triggers.end(), [this](WatchValuesBaseCore * trigger_) { return (require_all != trigger_->event_triggered);} )? From d7caa7322f3f60020b4b753172a7d7177a732a9a Mon Sep 17 00:00:00 2001 From: Minsoo Kang Date: Thu, 1 Oct 2026 13:54:03 -0500 Subject: [PATCH 3/3] Fix typo in the comment --- .../events_manager/include/watch_values_base.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/vehicle_management/events_manager/include/watch_values_base.hh b/models/vehicle_management/events_manager/include/watch_values_base.hh index 6f297742..174501d1 100644 --- a/models/vehicle_management/events_manager/include/watch_values_base.hh +++ b/models/vehicle_management/events_manager/include/watch_values_base.hh @@ -62,7 +62,7 @@ Notes: implicitly cast that variable to a temporary storage space of the expected type, and the watch value would monitor that temporary storage space, not the intended variable, for changes. This is a big problem if a user gets the - type wrong in setting up their WatchValue, or setse it up correctly and the + type wrong in setting up their WatchValue, or sets it up correctly and the variable type later changes. - To rule that out and explicitly require a type match, we delete set_watch for all types of "var", then implement only the one in which "var" is of