From cb4bfd84387b98f20d00420790fc38beb85bf56e Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Thu, 19 Dec 2024 13:20:33 -0800 Subject: [PATCH 1/2] Fixes nasa/fprime#3086. Default to insertion order for chrono hist Chronological history needs to default to insertion order when the timestamps of the items are identical. This is fixed by changing the < to <= when comparing timestamps for "older" items. --- src/fprime_gds/common/history/chrono.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fprime_gds/common/history/chrono.py b/src/fprime_gds/common/history/chrono.py index 75b15456..52ce06dd 100644 --- a/src/fprime_gds/common/history/chrono.py +++ b/src/fprime_gds/common/history/chrono.py @@ -160,7 +160,9 @@ def __insert_chrono(data_object, ordered): the index that the item was inserted at (int) """ for i, item in reversed(list(enumerate(ordered))): - if item.get_time() < data_object.get_time(): + # Note: for events with the exact same time, this should default to the order received from downlink + # and as such the data item should be treated as older. + if item.get_time() <= data_object.get_time(): ordered.insert(i + 1, data_object) return i # If the data object is the earliest in the list or the list was empty From a867f577f4f10bfc99f162716e4c4ba762e5a4b5 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 19 Dec 2024 13:24:22 -0800 Subject: [PATCH 2/2] Fix comment --- src/fprime_gds/common/history/chrono.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fprime_gds/common/history/chrono.py b/src/fprime_gds/common/history/chrono.py index 52ce06dd..d3c523af 100644 --- a/src/fprime_gds/common/history/chrono.py +++ b/src/fprime_gds/common/history/chrono.py @@ -161,7 +161,7 @@ def __insert_chrono(data_object, ordered): """ for i, item in reversed(list(enumerate(ordered))): # Note: for events with the exact same time, this should default to the order received from downlink - # and as such the data item should be treated as older. + # and as such the data item should be treated as newer because it was received later. if item.get_time() <= data_object.get_time(): ordered.insert(i + 1, data_object) return i