Skip to content

Commit 07b63c1

Browse files
Update to Ledger to accomodate Balloons and Mutliple Concurrent Feeds
1 parent 843d5da commit 07b63c1

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

object-ledger/object_ledger_pub_sub.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ def _state_callback(
232232
state["object_type"] = "ship"
233233
state["track"] = state["course"]
234234

235+
elif "Radiosonde" in data:
236+
logging.debug(f"Processing AIS state message data: {data}")
237+
state = json.loads(data["Radiosonde"])
238+
state["object_id"] = state["sonde_serial"]
239+
state["object_type"] = "balloon"
240+
235241
else:
236242
logging.debug(f"Skipping state message data: {data}")
237243
return
@@ -255,11 +261,13 @@ def _state_callback(
255261
)
256262

257263
else:
258-
logging.debug(
259-
f"Updating entry state data for object id: {entry.index}"
260-
)
261-
self.ledger.update(entry)
262-
264+
if (entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0] > 0:
265+
self.ledger.update(entry)
266+
logging.debug(f"Updating entry state data for object id: {entry.index[0]} | {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} newer than ledger")
267+
#logging.info(
268+
# f"Index: {entry.index[0]} | Time Delta (seconds): {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} | "
269+
# f"New Time: {entry['timestamp'].iloc[0]} | Ledger Time: {self.ledger.loc[entry.index, 'timestamp'].iloc[0]}"
270+
#)
263271
else:
264272
logging.debug(f"Invalid entry: {entry}")
265273

0 commit comments

Comments
 (0)