mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-08 17:13:45 +08:00
Guten Morgen
This commit is contained in:
@@ -117,6 +117,14 @@ def run_navigationd(started: bool, params: Params, CP: car.CarParams, starpilot_
|
||||
return started and params.get("NavDestination") is not None
|
||||
|
||||
|
||||
def run_mapd(started: bool, params: Params, CP: car.CarParams, starpilot_toggles: SimpleNamespace) -> bool:
|
||||
if started:
|
||||
return True
|
||||
|
||||
memory_params = Params(memory=True)
|
||||
return memory_params.get_bool("DownloadMaps") or memory_params.get_bool("CancelDownloadMaps")
|
||||
|
||||
|
||||
def bluetooth_enabled(started: bool, params: Params, CP: car.CarParams, starpilot_toggles: SimpleNamespace) -> bool:
|
||||
return params.get_bool("BluetoothEnabled")
|
||||
|
||||
@@ -216,7 +224,7 @@ else:
|
||||
procs += [
|
||||
PythonProcess("device_syncd", "starpilot.system.device_syncd", always_run),
|
||||
PythonProcess("starpilot_process", "starpilot.starpilot_process", always_run),
|
||||
PythonProcess("mapd", "starpilot.navigation.mapd_wrapper", always_run, nice=19),
|
||||
PythonProcess("mapd", "starpilot.navigation.mapd_wrapper", run_mapd, nice=19),
|
||||
PythonProcess("navigationd", "starpilot.navigation.navigationd", run_navigationd, nice=19),
|
||||
PythonProcess("speed_limit_filler", "starpilot.system.speed_limit_filler", run_speed_limit_filler, nice=19),
|
||||
PythonProcess("speed_limit_vision", "starpilot.system.speed_limit_vision", run_speed_limit_vision, nice=19),
|
||||
|
||||
@@ -4,6 +4,7 @@ import pytest
|
||||
|
||||
from cereal import car
|
||||
from opendbc.car.ford.values import CAR as FORD_CAR
|
||||
import openpilot.system.manager.process_config as process_config
|
||||
from openpilot.system.manager.process_config import (
|
||||
allow_uploads,
|
||||
bluetooth_enabled,
|
||||
@@ -48,6 +49,31 @@ def test_uploader_runs_at_background_priority():
|
||||
assert managed_processes["uploader"].nice == 19
|
||||
|
||||
|
||||
def test_mapd_runs_onroad_or_during_offroad_map_transfer(monkeypatch):
|
||||
class MemoryParams:
|
||||
values = {}
|
||||
|
||||
def __init__(self, *, memory=False):
|
||||
assert memory
|
||||
|
||||
def get_bool(self, key):
|
||||
return self.values.get(key, False)
|
||||
|
||||
monkeypatch.setattr(process_config, "Params", MemoryParams)
|
||||
params = object()
|
||||
CP = car.CarParams.new_message()
|
||||
toggles = SimpleNamespace()
|
||||
|
||||
assert process_config.run_mapd(True, params, CP, toggles)
|
||||
assert not process_config.run_mapd(False, params, CP, toggles)
|
||||
|
||||
MemoryParams.values["DownloadMaps"] = True
|
||||
assert process_config.run_mapd(False, params, CP, toggles)
|
||||
|
||||
MemoryParams.values = {"DownloadMaps": False, "CancelDownloadMaps": True}
|
||||
assert process_config.run_mapd(False, params, CP, toggles)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("enabled", [False, True])
|
||||
def test_bluetooth_process_is_param_gated(enabled):
|
||||
params = SimpleNamespace(get_bool=lambda key: enabled if key == "BluetoothEnabled" else False)
|
||||
|
||||
Reference in New Issue
Block a user