Browse Source

Update self.last_pos_datetime handling

Updated all `self.last_pos_datetime` caculations to not exit the program if `ac_dict.time_position` is NoneType.
pull/53/head
NomsterDude 3 years ago committed by GitHub
parent
commit
f2e5314578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      planeClass.py

11
planeClass.py

@ -88,7 +88,8 @@ class Plane:
from mictronics_parse import get_aircraft_reg_by_icao, get_type_code_by_icao
self.reg = get_aircraft_reg_by_icao(self.icao)
self.type = get_type_code_by_icao(self.icao)
self.last_pos_datetime = datetime.fromtimestamp(ac_dict.time_position)
if ac_dict.time_position is not None:
self.last_pos_datetime = datetime.fromtimestamp(ac_dict.time_position)
except ValueError as e:
print("Got data but some data is invalid!")
print(e)
@ -544,7 +545,8 @@ class Plane:
if self.feeding:
#Squawks
emergency_squawks ={"7500" : "Hijacking", "7600" :"Radio Failure", "7700" : "General Emergency"}
seen = datetime.now() - self.last_pos_datetime
if self.last_pos_datetime is not None:
seen = datetime.now() - self.last_pos_datetime
#Only run check if emergency data previously set
if self.last_emergency is not None and not self.emergency_already_triggered:
time_since_org_emer = datetime.now() - self.last_emergency[0]
@ -567,7 +569,8 @@ class Plane:
#Realizes first time seeing emergency, stores time and type
elif self.squawk in emergency_squawks.keys() and not self.emergency_already_triggered and not self.on_ground:
print("Emergency", self.squawk, "detected storing code and time and waiting to trigger")
self.last_emergency = (self.last_pos_datetime, self.squawk)
if self.last_pos_datetime is not None:
self.last_emergency = (self.last_pos_datetime, self.squawk)
elif self.squawk not in emergency_squawks.keys() and self.emergency_already_triggered:
self.emergency_already_triggered = None
@ -876,4 +879,4 @@ class Plane:
print(time_since_ra)
if time_since_ra.seconds >= 600:
print(ra_type)
self.recent_ra_types.pop(ra_type)
self.recent_ra_types.pop(ra_type)

Loading…
Cancel
Save