Skip to content

Commit

Permalink
Fixes nasa/fprime#3086. Default to insertion order for chrono hist (#184
Browse files Browse the repository at this point in the history
)

* 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.

* Fix comment
  • Loading branch information
LeStarch authored Dec 19, 2024
1 parent 600999c commit e6522f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fprime_gds/common/history/chrono.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 newer because it was received later.
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
Expand Down

0 comments on commit e6522f2

Please sign in to comment.