Skip to content

Commit

Permalink
fixed LT before start
Browse files Browse the repository at this point in the history
  • Loading branch information
biuti committed Aug 23, 2024
1 parent aecd59a commit ec1a797
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
65 changes: 43 additions & 22 deletions airscore/core/livetracking.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""
Code to get live tracking tracks chunks and calculate live results
Web interrogation:
https://lt.flymaster.net/wlb/getLiveData.php?trackers={“176399":1559779200,”177485":1557549310}
https://lt.flymaster.net/wlb/getLiveData.php?grp=123456&token=a1b2c3d4c5&trackers={“176399":1559779200,”177485":1557549310}
where 176399 is the tracker serial number, and 1559779200 is unixtime stamp of the fixes, 100 fixes will be sent.
where:
123456 is the group number on flymaster server, a1b2c3d4c5 is the API token of the group,
176399 is the tracker serial number, and 1559779200 is unixtime stamp of the fixes, 100 fixes will be sent.
result will be a json array:
Expand Down Expand Up @@ -52,8 +54,16 @@ def __init__(self, rawtime, lat, lon, press_alt, gnss_alt, alt=None, height=None
self.height = height
self.speed = speed

super().__init__(rawtime=rawtime, lat=lat, lon=lon, validity='A',
press_alt=press_alt, gnss_alt=gnss_alt, index=index, extras='')
super().__init__(
rawtime=rawtime,
lat=lat,
lon=lon,
validity='A',
press_alt=press_alt,
gnss_alt=gnss_alt,
index=index,
extras=''
)


class LiveResult(FlightResult):
Expand Down Expand Up @@ -95,8 +105,13 @@ def create_result_dict(self):
result['suspect_landing_fix'] = None
if self.suspect_landing_fix:
f = self.suspect_landing_fix
result['suspect_landing_fix'] = dict(rawtime=f.rawtime, lat=f.lat, lon=f.lon, press_alt=f.press_alt,
gnss_alt=f.gnss_alt, alt=f.alt, speed=f.speed, index=f.index)
result['suspect_landing_fix'] = dict(
rawtime=f.rawtime,
lat=f.lat, lon=f.lon,
press_alt=f.press_alt,
gnss_alt=f.gnss_alt, alt=f.alt, speed=f.speed,
index=f.index
)

return result

Expand Down Expand Up @@ -375,9 +390,12 @@ def create_result(self):

if p.suspect_landing_fix:
f = p.suspect_landing_fix
result['suspect_landing_fix'] = dict(rawtime=f.rawtime, lat=f.lat, lon=f.lon,
press_alt=f.press_alt, gnss_alt=f.gnss_alt,
index=f.index)
result['suspect_landing_fix'] = dict(
rawtime=f.rawtime,
lat=f.lat, lon=f.lon,
press_alt=f.press_alt, gnss_alt=f.gnss_alt,
index=f.index
)
data.append(result)
self.result.update(dict(file_stats=file_stats, headers=headers, info=info, route=route, data=data))
self.create_json_file()
Expand All @@ -390,8 +408,8 @@ def update_result_status(self, finalise: bool = False):
status = self.result['file_stats']['status']
if finalise or not status == self.status:
if finalise:
self.result['file_stats']['status'] = f'Livetracking is terminated. ' \
f'Provisional Results will be available shortly.'
self.result['file_stats']['status'] = 'Livetracking is terminated. ' \
'Provisional Results will be available shortly.'
else:
self.result['file_stats']['status'] = self.status
self.result['headers'] = self.headers
Expand All @@ -412,9 +430,12 @@ def update_pilot_result(self, p: LiveResult):
result['suspect_landing_fix'] = None
if p.suspect_landing_fix and not p.landing_time:
f = p.suspect_landing_fix
result['suspect_landing_fix'] = dict(rawtime=f.rawtime, lat=f.lat, lon=f.lon,
press_alt=f.press_alt, gnss_alt=f.gnss_alt,
index=f.index)
result['suspect_landing_fix'] = dict(
rawtime=f.rawtime,
lat=f.lat, lon=f.lon,
press_alt=f.press_alt, gnss_alt=f.gnss_alt,
index=f.index
)
print(f"{result}")

def create_json_file(self):
Expand Down Expand Up @@ -689,11 +710,11 @@ def associate_livetracks(task: LiveTask, pilots: list, response, timestamp):
continue
if not pil.first_time and not pilot_is_airborne(fixes):
'''did not take off yet'''
print(f"*** Pilot {pil.ID} did not took off yet")
# pil.last_time = int(fixes[-1]['d']) - midnight
# pil.live_comment = 'not flying'
# pil.livetrack = []
# continue
print(f"*** Pilot {pil.ID} did not take off yet")
pil.last_time = int(fixes[-1]['d']) - midnight
pil.live_comment = 'not flying'
pil.livetrack = []
continue
flight = []
# print(f"{pil.name}: first_time {pil.first_time} - adding fixes to pilot object")
# print(f"Fixes to add: {len(fixes)}")
Expand Down Expand Up @@ -724,9 +745,9 @@ def associate_livetracks(task: LiveTask, pilots: list, response, timestamp):
def check_livetrack(result: LiveResult, task: LiveTask, airspace: AirspaceCheck = None):
"""Checks a list of LiveFix objects against the task, having previous result.
Args:
result: a LiveResult object
task: a LiveTask object
airspace: a AirspaceCheck object
result: a LiveResult object
task: a LiveTask object
airspace: a AirspaceCheck object
"""
from flightcheck import flightcheck
from flightcheck.flightpointer import FlightPointer
Expand Down
2 changes: 1 addition & 1 deletion defines.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ igc_sources:
flymaster: on

g_record_validation_server: http://vali.fai-civl.org/api/vali/json
flymaster_live_server: https://lt.flymaster.net/wlb/getLiveData.php?trackers=
flymaster_live_server: https://wlb.flymaster.net/getLiveData.php?

# Telegram Bot Service.
# switch telegram bot update feature on or off
Expand Down

0 comments on commit ec1a797

Please sign in to comment.