Fleet Manager

Added functionality to view screen recordings, error logs, routes, and control Navigation settings via the "Fleet Manager" process.

Credit goes to mike8643!

https: //github.com/mike8643
Co-Authored-By: mike8643 <98910897+mike8643@users.noreply.github.com>
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent b4f7c38bcc
commit 081646bd0a
31 changed files with 1876 additions and 0 deletions

View File

@@ -172,6 +172,37 @@ class RouteEngine:
resp.raise_for_status()
r = resp.json()
r1 = resp.json()
# Function to remove specified keys recursively unnessary for display
def remove_keys(obj, keys_to_remove):
if isinstance(obj, list):
return [remove_keys(item, keys_to_remove) for item in obj]
elif isinstance(obj, dict):
return {key: remove_keys(value, keys_to_remove) for key, value in obj.items() if key not in keys_to_remove}
else:
return obj
keys_to_remove = ['geometry', 'annotation', 'incidents', 'intersections', 'components', 'sub', 'waypoints']
self.r2 = remove_keys(r1, keys_to_remove)
self.r3 = {}
# Add items for display under "routes"
if 'routes' in self.r2 and len(self.r2['routes']) > 0:
first_route = self.r2['routes'][0]
nav_destination_json = self.params.get('NavDestination')
try:
nav_destination_data = json.loads(nav_destination_json)
place_name = nav_destination_data.get('place_name', 'Default Place Name')
first_route['Destination'] = place_name
first_route['Metric'] = self.params.get_bool("IsMetric")
self.r3['CurrentStep'] = 0
self.r3['uuid'] = self.r2['uuid']
except json.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
# Save slim json as file
with open('navdirections.json', 'w') as json_file:
json.dump(self.r2, json_file, indent=4)
with open('CurrentStep.json', 'w') as json_file:
json.dump(self.r3, json_file, indent=4)
if len(r['routes']):
self.route = r['routes'][0]['legs'][0]['steps']
self.route_geometry = []
@@ -317,6 +348,12 @@ class RouteEngine:
if self.step_idx + 1 < len(self.route):
self.step_idx += 1
self.reset_recompute_limits()
# Update the 'CurrentStep' value in the JSON
if 'routes' in self.r2 and len(self.r2['routes']) > 0:
self.r3['CurrentStep'] = self.step_idx
# Write the modified JSON data back to the file
with open('CurrentStep.json', 'w') as json_file:
json.dump(self.r3, json_file, indent=4)
else:
cloudlog.warning("Destination reached")