Skip to content

Commit 3fa813b

Browse files
committed
more debug
1 parent 87e894a commit 3fa813b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

object-ledger/object_ledger_pub_sub.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def _get_max_entry_age(self, object_type: str) -> float:
209209
"""
210210
return self.max_entry_age[object_type]
211211

212-
def _update_state(self, state: Dict[Any, Any]) -> None:
212+
def _update_ledger(self, state: Dict[Any, Any]) -> None:
213213
"""Update the ledger with a state message.
214214
215215
Parameters
@@ -241,11 +241,12 @@ def _update_state(self, state: Dict[Any, Any]) -> None:
241241
)
242242

243243
else:
244+
# Check if the update (entry) is newer than the ledger
244245
if (entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0] > 0:
245246
self.ledger.update(entry)
246247
logging.debug(f"Updating entry for {entry.index[0]} is {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} newer than ledger!")
247248
elif (entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0] < 0:
248-
logging.info(f"Skipping entry for {entry.index[0]} is {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} older than ledger!")
249+
logging.info(f"Skipping entry for {entry.index[0]} is {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} older than ledger! Update: {entry['timestamp'].iloc[0]} | Ledger: {self.ledger.loc[entry.index, 'timestamp'].iloc[0]}")
249250
#logging.info(
250251
# f"Index: {entry.index[0]} | Time Delta (seconds): {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} | "
251252
# f"New Time: {entry['timestamp'].iloc[0]} | Ledger Time: {self.ledger.loc[entry.index, 'timestamp'].iloc[0]}"
@@ -294,29 +295,29 @@ def _state_callback(
294295
for state in aircrafts:
295296
state["object_id"] = state["icao_hex"]
296297
state["object_type"] = "aircraft"
297-
self._update_state(state)
298+
self._update_ledger(state)
298299

299300
if "ADS-B" in data:
300301
logging.debug(f"Processing ADS-B state message data: {data}")
301302
state = json.loads(data["ADS-B"])
302303
state["object_id"] = state["icao_hex"]
303304
state["object_type"] = "aircraft"
304-
self._update_state(state)
305+
self._update_ledger(state)
305306

306307
elif "Decoded AIS" in data:
307308
logging.debug(f"Processing AIS state message data: {data}")
308309
state = json.loads(data["Decoded AIS"])
309310
state["object_id"] = state["mmsi"]
310311
state["object_type"] = "ship"
311312
state["track"] = state["course"]
312-
self._update_state(state)
313+
self._update_ledger(state)
313314

314315
elif "Radiosonde" in data:
315316
logging.debug(f"Processing Radiosonde state message data: {data}")
316317
state = json.loads(data["Radiosonde"])
317318
state["object_id"] = state["sonde_serial"]
318319
state["object_type"] = "balloon"
319-
self._update_state(state)
320+
self._update_ledger(state)
320321

321322
else:
322323
logging.debug(f"Skipping state message data: {data}")

0 commit comments

Comments
 (0)