Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
void set_watch (const T& var, watchType ref) = delete;
template <typename T1>
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;
Expand Down Expand Up @@ -391,4 +410,12 @@ Purpose:(Generates the new reference value.)
reference += variable_at_activation;
}
};

template <> inline void WatchValuesBase<bool>::set_dbl_reference(double ref)
{
// Semantically equivalent to static_cast<bool>(ref) (i.e., ref != 0.0),
// but avoids '=='/'!=' comparisons that trigger -Wfloat-equal.
reference = (ref > 0.0) || (ref < 0.0) || std::isnan(ref);
Comment on lines +416 to +418

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the standard library.

Suggested change
// Semantically equivalent to static_cast<bool>(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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling.

Suggested change
-- 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 in CompoundEventsManager::create_trigger())
(commonly set when an WatchValue is added to the CompoundEventsManager's
managed_triggers listi, such as when using create)trigger(...))
Comment on lines +74 to +75

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar.

Suggested change
(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 create_trigger()) */
logging cycle (default, but overriden by
CompoundEventssManager::add_trigger(...)) */


protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ WatchValuesSet::initialize( std::list<WatchValuesBaseCore *> * 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;
// }
Comment on lines +50 to +56

@ninotarantino ninotarantino Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code isn't allowed unless there's some additional metadata included: https://nasa.github.io/cml/contributing/coding-standards.html#cml-mcs-general-5-commented-out-code-shall-only-be-allowed-when-accompanied-by-an-associated-project-issue-point-of-contact-email-address-and-current-date.

Why is this commented out? What additional changes are necessary before uncommenting it? If this comment remains in, it needs to be specific about what "DataCollect" refers to. No such type or function exists in CML, Trick, or JEOD.

trigger->add_self_to_manager_active_list = false;
trigger->SubscriptionBase::initialize();
}
Expand Down
Loading