Skip to content

Commit

Permalink
Issue #198 - Address stagnant DN to EU value issue
Browse files Browse the repository at this point in the history
Update the packet diffing code so a fields raw / DNtoEU value is
always included in the diff if a DNtoEU is defined for that field.
This ensures that fields with "complex" DNtoEU functions which take
multiple input values or rely on other means to determine a value will
always be updated. This does mean that we're performing some
"unnecessary" DNtoEU conversions but in practice I expect this to have
no noticeable impact on performance.

Resolve #198
  • Loading branch information
MJJoyce committed Mar 10, 2021
1 parent 6b8449a commit 7aea97a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ait/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,17 @@ def get_packet_delta(pkt_defn, packet):
delta, dntoeus = {}, {}

for field in pkt_defn.fields:
new_value = getattr(ait_pkt.raw, field.name)
last_value = packet_states[pkt_defn.name]['raw'][field.name]

if new_value != last_value:
delta[field.name] = new_value
packet_states[pkt_defn.name]['raw'][field.name] = new_value
new_raw = getattr(ait_pkt.raw, field.name)
last_raw = packet_states[pkt_defn.name]['raw'][field.name]

# A field update needs sent when the raw value has changed or if a
# DN to EU is defined on the field. DN to EUs can take multiple
# telemetry points as input or may rely on other means to determine
# a value. We can't be sure that they won't change so we should
# always calculate them.
if new_raw != last_raw or field.dntoeu is not None:
delta[field.name] = new_raw
packet_states[pkt_defn.name]['raw'][field.name] = new_raw

if field.dntoeu is not None or field.enum is not None or field.type.name in dtype.ComplexTypeMap.keys():
try:
Expand Down

0 comments on commit 7aea97a

Please sign in to comment.