|
|
@@ -1,30 +1,84 @@
|
|
|
class Vehicle:
|
|
|
def __init__(self,
|
|
|
+ id: str,
|
|
|
name: str,
|
|
|
+ ap_source_subdir: str,
|
|
|
+ fw_server_vehicle_sdir: str,
|
|
|
waf_build_command: str,
|
|
|
) -> None:
|
|
|
+ self.id = id
|
|
|
self.name = name
|
|
|
+ self.ap_source_subdir = ap_source_subdir
|
|
|
+ self.fw_server_vehicle_sdir = fw_server_vehicle_sdir
|
|
|
self.waf_build_command = waf_build_command
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
if isinstance(other, Vehicle):
|
|
|
- return self.name == other.name
|
|
|
+ return self.id == other.id
|
|
|
return False
|
|
|
|
|
|
def __hash__(self):
|
|
|
- return hash(self.name)
|
|
|
+ return hash(self.id)
|
|
|
|
|
|
|
|
|
# Default vehicles configuration
|
|
|
DEFAULT_VEHICLES = [
|
|
|
- Vehicle(name="Copter", waf_build_command="copter"),
|
|
|
- Vehicle(name="Plane", waf_build_command="plane"),
|
|
|
- Vehicle(name="Rover", waf_build_command="rover"),
|
|
|
- Vehicle(name="Sub", waf_build_command="sub"),
|
|
|
- Vehicle(name="Heli", waf_build_command="heli"),
|
|
|
- Vehicle(name="Blimp", waf_build_command="blimp"),
|
|
|
- Vehicle(name="Tracker", waf_build_command="antennatracker"),
|
|
|
- Vehicle(name="AP_Periph", waf_build_command="AP_Periph"),
|
|
|
+ Vehicle(
|
|
|
+ id="copter",
|
|
|
+ name="Copter",
|
|
|
+ ap_source_subdir="ArduCopter",
|
|
|
+ fw_server_vehicle_sdir="Copter",
|
|
|
+ waf_build_command="copter"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="plane",
|
|
|
+ name="Plane",
|
|
|
+ ap_source_subdir="ArduPlane",
|
|
|
+ fw_server_vehicle_sdir="Plane",
|
|
|
+ waf_build_command="plane"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="rover",
|
|
|
+ name="Rover",
|
|
|
+ ap_source_subdir="Rover",
|
|
|
+ fw_server_vehicle_sdir="Rover",
|
|
|
+ waf_build_command="rover"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="sub",
|
|
|
+ name="Sub",
|
|
|
+ ap_source_subdir="ArduSub",
|
|
|
+ fw_server_vehicle_sdir="Sub",
|
|
|
+ waf_build_command="sub"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="heli",
|
|
|
+ name="Heli",
|
|
|
+ ap_source_subdir="ArduCopter",
|
|
|
+ fw_server_vehicle_sdir="Copter",
|
|
|
+ waf_build_command="heli"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="blimp",
|
|
|
+ name="Blimp",
|
|
|
+ ap_source_subdir="Blimp",
|
|
|
+ fw_server_vehicle_sdir="Blimp",
|
|
|
+ waf_build_command="blimp"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="tracker",
|
|
|
+ name="Tracker",
|
|
|
+ ap_source_subdir="AntennaTracker",
|
|
|
+ fw_server_vehicle_sdir="AntennaTracker",
|
|
|
+ waf_build_command="antennatracker"
|
|
|
+ ),
|
|
|
+ Vehicle(
|
|
|
+ id="ap-periph",
|
|
|
+ name="AP_Periph",
|
|
|
+ ap_source_subdir="Tools/AP_Periph",
|
|
|
+ fw_server_vehicle_sdir="AP_Periph",
|
|
|
+ waf_build_command="AP_Periph"
|
|
|
+ ),
|
|
|
]
|
|
|
|
|
|
|
|
|
@@ -47,23 +101,20 @@ class VehiclesManager:
|
|
|
|
|
|
VehiclesManager.__singleton = self
|
|
|
|
|
|
- def get_all_vehicle_names_sorted(self) -> list:
|
|
|
- return sorted([v.name for v in self.vehicles])
|
|
|
-
|
|
|
def get_all_vehicles(self) -> frozenset:
|
|
|
return frozenset(self.vehicles)
|
|
|
|
|
|
def add_vehicle(self, vehicle: Vehicle) -> None:
|
|
|
return self.vehicles.add(vehicle)
|
|
|
|
|
|
- def get_vehicle_from_name(self, vehicle_name: str) -> Vehicle:
|
|
|
- if vehicle_name is None:
|
|
|
- raise ValueError("vehicle_name is a required parameter.")
|
|
|
+ def get_vehicle_by_id(self, vehicle_id: str) -> Vehicle:
|
|
|
+ if vehicle_id is None:
|
|
|
+ raise ValueError("vehicle_id is a required parameter.")
|
|
|
|
|
|
return next(
|
|
|
(
|
|
|
vehicle for vehicle in self.get_all_vehicles()
|
|
|
- if vehicle.name == vehicle_name
|
|
|
+ if vehicle.id == vehicle_id
|
|
|
),
|
|
|
None
|
|
|
)
|