Skip to content

Commit 913c55a

Browse files
Updates to Handling
1 parent 6e38866 commit 913c55a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

object-ledger/object_ledger_pub_sub.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(
3333
ledger_topic: str,
3434
max_aircraft_entry_age: float = 60.0,
3535
max_ship_entry_age: float = 180.0,
36+
max_balloon_entry_age: float = 120.0,
3637
publish_interval: float = 1.0,
3738
heartbeat_interval: int = 10,
3839
loop_interval: float = 0.001,
@@ -58,6 +59,9 @@ def __init__(
5859
max_ship_entry_age: float
5960
Maximum age of a ship entry in the ledger, after which it
6061
is dropped [s]
62+
max_balloon_entry_age: float
63+
Maximum age of aballoon entry in the ledger, after which it
64+
is dropped [s]
6165
publish_interval: float
6266
Interval at which the ledger message is published [s]
6367
heartbeat_interval: int
@@ -82,6 +86,7 @@ def __init__(
8286
self.ledger_topic = ledger_topic
8387
self.max_aircraft_entry_age = max_aircraft_entry_age
8488
self.max_ship_entry_age = max_ship_entry_age
89+
self.max_balloon_entry_age = max_balloon_entry_age
8590
self.publish_interval = publish_interval
8691
self.heartbeat_interval = heartbeat_interval
8792
self.loop_interval = loop_interval
@@ -175,6 +180,7 @@ def _set_max_entry_age(self) -> None:
175180
self.max_entry_age = {
176181
"aircraft": self.max_aircraft_entry_age,
177182
"ship": self.max_ship_entry_age,
183+
"balloon": self.max_balloon_entry_age,
178184
}
179185

180186
def _get_max_entry_age(self, object_type: str) -> float:
@@ -233,7 +239,7 @@ def _state_callback(
233239
state["track"] = state["course"]
234240

235241
elif "Radiosonde" in data:
236-
logging.debug(f"Processing AIS state message data: {data}")
242+
logging.debug(f"Processing Radiosonde state message data: {data}")
237243
state = json.loads(data["Radiosonde"])
238244
state["object_id"] = state["sonde_serial"]
239245
state["object_type"] = "balloon"
@@ -263,7 +269,7 @@ def _state_callback(
263269
else:
264270
if (entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0] > 0:
265271
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")
272+
logging.debug(f"Updating entry for {entry.index[0]} is {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} newer than ledger!")
267273
#logging.info(
268274
# f"Index: {entry.index[0]} | Time Delta (seconds): {(entry['timestamp'] - self.ledger.loc[entry.index, 'timestamp']).iloc[0]} | "
269275
# f"New Time: {entry['timestamp'].iloc[0]} | Ledger Time: {self.ledger.loc[entry.index, 'timestamp'].iloc[0]}"
@@ -413,6 +419,7 @@ def main(self) -> None:
413419
ledger_topic=os.getenv("LEDGER_TOPIC", ""),
414420
max_aircraft_entry_age=float(os.getenv("MAX_AIRCRAFT_ENTRY_AGE", 60.0)),
415421
max_ship_entry_age=float(os.getenv("MAX_SHIP_ENTRY_AGE", 180.0)),
422+
max_balloon_entry_age=float(os.getenv("MAX_BALLOON_ENTRY_AGE", 120.0)),
416423
publish_interval=float(os.getenv("PUBLISH_INTERVAL", 1.0)),
417424
heartbeat_interval=int(os.getenv("HEARTBEAT_INTERVAL", 10)),
418425
loop_interval=float(os.getenv("LOOP_INTERVAL", 0.001)),

0 commit comments

Comments
 (0)