diff --git a/connections/serial/serial_connection.py b/connections/serial/serial_connection.py index 6ffdc15d..9826e9bb 100644 --- a/connections/serial/serial_connection.py +++ b/connections/serial/serial_connection.py @@ -39,7 +39,7 @@ def shutdown(self): self.device.close() def isIntBigEndian(self): - return True + return False def isFloatBigEndian(self): return False diff --git a/connections/sim/hw/hw_sim.py b/connections/sim/hw/hw_sim.py index c55efa8e..55cb5bea 100644 --- a/connections/sim/hw/hw_sim.py +++ b/connections/sim/hw/hw_sim.py @@ -85,10 +85,10 @@ def analog_read(self, pin): val = self._ignitor_reads[pin].read() LOGGER.debug(f"Analog read from pin={pin} returned value={val}") - else: - voltage_sensor = self._sensors[SensorType.VOLTAGE] - if voltage_sensor is not None and pin == voltage_sensor.pin: - val = self._sensors[SensorType.VOLTAGE].read() + # else: + # voltage_sensor = self._sensors[SensorType.VOLTAGE] + # if voltage_sensor is not None and pin == voltage_sensor.pin: + # val = self._sensors[SensorType.VOLTAGE].read() return val diff --git a/connections/sim/hw/sensors/sensor.py b/connections/sim/hw/sensors/sensor.py index 2de85379..e7b20eb0 100644 --- a/connections/sim/hw/sensors/sensor.py +++ b/connections/sim/hw/sensors/sensor.py @@ -14,7 +14,7 @@ class SensorType(Enum): REQUIRED_SENSOR_FLOATS = { SensorType.GPS: 3, - SensorType.IMU: 4, + SensorType.IMU: 7, SensorType.ACCELEROMETER: 3, SensorType.BAROMETER: 2, SensorType.TEMPERATURE: 1, diff --git a/main_window/competition/comp_app.py b/main_window/competition/comp_app.py index fca01b2e..318aecf9 100644 --- a/main_window/competition/comp_app.py +++ b/main_window/competition/comp_app.py @@ -182,7 +182,7 @@ def mousePressEvent(QMouseEvent): if label.map_fn is not None: qt_text.mousePressEvent = gen_clicked_callback(label) - if label.name == "GPS": + if "GPS" in label.name: self.selected_label = label if self.selected_label is None: @@ -259,7 +259,7 @@ def setup_view_menu(self) -> None: dataplot_view_menu = view_menu.addMenu("Data Plot") for label in self.label_windows: - if label.name != "GPS": + if "GPS" not in label.name: data_label = QAction(f'{label.name}', self) data_label.triggered.connect( lambda i, label_name=label: self.open_plot_window(label_name)) diff --git a/main_window/device_manager.py b/main_window/device_manager.py index 6ea4c209..971cbd27 100644 --- a/main_window/device_manager.py +++ b/main_window/device_manager.py @@ -12,8 +12,8 @@ class DeviceType(Enum): - TANTALUS_STAGE_1_FLARE = auto() - TANTALUS_STAGE_2_FLARE = auto() + BNB_STAGE_1_FLARE = auto() + BNB_STAGE_2_FLARE = auto() CO_PILOT_FLARE = auto() HOLLYBURN_BODY_FLARE = auto() HOLLYBURN_NOSE_FLARE = auto() @@ -21,8 +21,8 @@ class DeviceType(Enum): _FLARE_DEVICE_TYPES = [ - DeviceType.TANTALUS_STAGE_1_FLARE, - DeviceType.TANTALUS_STAGE_2_FLARE, + DeviceType.BNB_STAGE_1_FLARE, + DeviceType.BNB_STAGE_2_FLARE, DeviceType.CO_PILOT_FLARE, DeviceType.HOLLYBURN_BODY_FLARE, DeviceType.HOLLYBURN_NOSE_FLARE, diff --git a/main_window/packet_parser.py b/main_window/packet_parser.py index 29e23dc4..82263a6c 100644 --- a/main_window/packet_parser.py +++ b/main_window/packet_parser.py @@ -52,8 +52,8 @@ class SubpacketIds(Enum): ID_TO_DEVICE_TYPE = { - 0x00: DeviceType.TANTALUS_STAGE_1_FLARE, - 0x01: DeviceType.TANTALUS_STAGE_2_FLARE, + 0x00: DeviceType.BNB_STAGE_1_FLARE, + 0x01: DeviceType.BNB_STAGE_2_FLARE, 0x02: DeviceType.CO_PILOT_FLARE, 0x03: DeviceType.HOLLYBURN_BODY_FLARE, 0x04: DeviceType.HOLLYBURN_NOSE_FLARE, diff --git a/profiles/mpl_funcs.py b/profiles/mpl_funcs.py index 40cc90be..180d51d3 100644 --- a/profiles/mpl_funcs.py +++ b/profiles/mpl_funcs.py @@ -65,7 +65,8 @@ def receive_time_series(self, plot_widget: MplWidget, label: Label) -> None: self.im = None - if label.name == "Acceleration" and not plot_widget.showing_checkboxes: + is_acceleration = "Acceleration" in label.name + if is_acceleration and not plot_widget.showing_checkboxes: plot_widget.show_checkboxes() # Plot data on graph @@ -75,7 +76,7 @@ def receive_time_series(self, plot_widget: MplWidget, label: Label) -> None: plot_widget.canvas.ax.cla() data_entry_id = self.rocket_profile.label_to_data_id[label.name] - if label.name == "Acceleration": + if is_acceleration: labels = ["X", "Y", "Z"] colors = ["Red", "Blue", "Green"] plot_data = False diff --git a/profiles/rocket_profile_list.py b/profiles/rocket_profile_list.py index 0d3f9a84..8fd40cb7 100644 --- a/profiles/rocket_profile_list.py +++ b/profiles/rocket_profile_list.py @@ -3,14 +3,14 @@ from .rocket_profile import RocketProfile from .rockets.silvertip import SilvertipProfile -from .rockets.tantalus import TantalusProfile +from .rockets.bnb import BNBProfile from .rockets.co_pilot import CoPilotProfile from .rockets.hollyburn import HollyburnProfile from .rockets.whistler_blackcomb import WbProfile ROCKET_PROFILES: List[RocketProfile] = [ + BNBProfile(), SilvertipProfile(), - TantalusProfile(), CoPilotProfile(), HollyburnProfile(), WbProfile(), diff --git a/profiles/rockets/bnb.py b/profiles/rockets/bnb.py new file mode 100644 index 00000000..18e9c2e8 --- /dev/null +++ b/profiles/rockets/bnb.py @@ -0,0 +1,282 @@ +"""Profile for Beauty & the Beast""" + +from connections.debug.debug_connection import DebugConnection +from connections.serial.serial_connection import SerialConnection +from connections.sim.hw.hw_sim import HWSim +from connections.sim.hw.ignitor_sim import Ignitor, IgnitorType +from connections.sim.hw.rocket_sim import RocketSim +from connections.sim.hw.sensors.dummy_sensor import DummySensor +from connections.sim.hw.sensors.sensor import SensorType +from connections.sim.hw.sensors.voltage_sensor_sim import VoltageSensor +from connections.sim.sim_connection import SimConnection +from main_window.competition.comp_app import CompApp +from main_window.competition.comp_packet_parser import CompPacketParser +from main_window.data_entry_id import DataEntryIds +from main_window.device_manager import DeviceType +from main_window.packet_parser import DEVICE_TYPE_TO_ID +from util.detail import REQUIRED_FLARE +from ..label import ( + Label, + update_acceleration, + update_altitude, + update_gps, + update_max_altitude, + update_pressure, + update_state, +) +from ..mpl_funcs import receive_map, receive_time_series +from ..rocket_profile import RocketProfile + + +class BNBProfile(RocketProfile): + """BNB""" + @property + def rocket_name(self): + return "BNB" + + @property + def buttons(self): + return { + "Arm Stage 1": "BNB_STAGE_1_FLARE.ARM", + "Ping Stage 1": "BNB_STAGE_1_FLARE.PING", + "Arm Stage 2": "BNB_STAGE_2_FLARE.ARM", + "Ping Stage 2": "BNB_STAGE_2_FLARE.PING", + } + + @property + def label_to_data_id(self): + # labels unique to BNB + other_labels = { + "Stage1Altitude": DataEntryIds.CALCULATED_ALTITUDE, + "Stage1MaxAltitude": None, + "Stage1State": DataEntryIds.STATE, + "Stage1Pressure": DataEntryIds.PRESSURE, + "Stage1Acceleration": [ + DataEntryIds.ACCELERATION_X, + DataEntryIds.ACCELERATION_Y, + DataEntryIds.ACCELERATION_Z + ], + "Stage2Altitude": DataEntryIds.CALCULATED_ALTITUDE, + "Stage2MaxAltitude": None, + "Stage2State": DataEntryIds.STATE, + "Stage2Pressure": DataEntryIds.PRESSURE, + "Stage2Acceleration": [ + DataEntryIds.ACCELERATION_X, + DataEntryIds.ACCELERATION_Y, + DataEntryIds.ACCELERATION_Z + ] + } + return {**super().label_to_data_id, **other_labels} + + @property + def label_unit(self): + other_units = { + "Stage1Altitude": "m", + "Stage1MaxAltitude": "m", + "Stage1State": "", + "Stage1Pressure": "", + "Stage1Acceleration": "g", + "Stage2Altitude": "m", + "Stage2MaxAltitude": "m", + "Stage2State": "", + "Stage2Pressure": "", + "Stage2Acceleration": "g", + } + return {**super().label_unit, **other_units} + + @property + def labels(self): + return [ + # Labels for data that are displayed + Label( + DeviceType.BNB_STAGE_1_FLARE, + "Stage1Altitude", + update_altitude, + "Stage 1 Altitude", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_1_FLARE, + "Stage1MaxAltitude", + update_max_altitude, + "Stage 1 Max Altitude", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_1_FLARE, + "Stage1GPS", + update_gps, + "Stage 1 GPS", + map_fn=receive_map + ), + Label( + DeviceType.BNB_STAGE_1_FLARE, + "Stage1State", + update_state, + "Stage 1 State", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_1_FLARE, + "Stage1Pressure", + update_pressure, + "Stage 1 Pressure", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_1_FLARE, + "Stage1Acceleration", + update_acceleration, + "Stage 1 Acceleration", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_2_FLARE, + "Stage2Altitude", + update_altitude, + "Stage 2 Altitude", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_2_FLARE, + "Stage2MaxAltitude", + update_max_altitude, + "Stage 2 Max Altitude", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_2_FLARE, + "Stage2GPS", + update_gps, + "Stage 2 GPS", + map_fn=receive_map + ), + Label( + DeviceType.BNB_STAGE_2_FLARE, + "Stage2State", + update_state, + "Stage 2 State", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_2_FLARE, + "Stage2Pressure", + update_pressure, + "Stage 2 Pressure", + map_fn=receive_time_series + ), + Label( + DeviceType.BNB_STAGE_2_FLARE, + "Stage2Acceleration", + update_acceleration, + "Stage 2 Acceleration", + map_fn=receive_time_series + ), + ] + + @property + def expected_devices(self): + return [ + DeviceType.BNB_STAGE_1_FLARE, + DeviceType.BNB_STAGE_2_FLARE, + ] + + @property + def mapping_devices(self): + return [ + DeviceType.BNB_STAGE_1_FLARE, + DeviceType.BNB_STAGE_2_FLARE, + ] + + @property + def required_device_versions(self): + return { + DeviceType.BNB_STAGE_1_FLARE: REQUIRED_FLARE, + DeviceType.BNB_STAGE_2_FLARE: REQUIRED_FLARE, + } + + @property + def expected_apogee_point(self): + return None + + @property + def expected_main_deploy_point(self): + return None + + def construct_serial_connection(self, com_port, baud_rate): + return { + "XBEE_RADIO": SerialConnection(com_port, baud_rate), + } + + def construct_debug_connection(self): + return { + "BNB_STAGE_1_CONNECTION": DebugConnection( + "BNB_STAGE_1_RADIO_ADDRESS", + DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_1_FLARE], + generate_radio_packets=True + ), + "BNB_STAGE_2_CONNECTION": DebugConnection( + "BNB_STAGE_2_RADIO_ADDRESS", + DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_2_FLARE], + generate_radio_packets=True + ), + } + + def construct_sim_connection(self): + # Assemble HW here + """ + Stage 1 + """ + rocket_sim_stage_1 = RocketSim('simple.ork') # TODO: Update ORK file once possible + + hw_sim_sensors_stage_1 = [ + DummySensor(SensorType.BAROMETER, (1000, 25)), + DummySensor(SensorType.GPS, (12.6, 13.2, 175)), + DummySensor(SensorType.ACCELEROMETER, (1, 0, 0)), + DummySensor(SensorType.IMU, (1, 0, 0, 0, 0, 0, 0)), + DummySensor(SensorType.TEMPERATURE, (20,)), + # VoltageSensor() + ] + + hw_sim_ignitors_stage_1 = [ + Ignitor(IgnitorType.MAIN, 33, 33, 20), + Ignitor(IgnitorType.DROGUE, 33, 33, 15), + ] + + hwsim_stage_1 = HWSim(rocket_sim_stage_1, + hw_sim_sensors_stage_1, hw_sim_ignitors_stage_1) + + """ + Stage 2 + """ + rocket_sim_stage_2 = RocketSim('simple.ork') + # TODO: Update ORK file once possible + + hw_sim_sensors_stage_2 = [ + DummySensor(SensorType.BAROMETER, (100000, 25)), + DummySensor(SensorType.GPS, (12.6, 13.2, 175)), + DummySensor(SensorType.ACCELEROMETER, (1, 0, 0)), + DummySensor(SensorType.IMU, (1, 0, 0, 0, 0, 0, 0)), + DummySensor(SensorType.TEMPERATURE, (20,)), + # VoltageSensor() + ] + + hw_sim_ignitors_stage_2 = [ + Ignitor(IgnitorType.MAIN, 33, 33, 20), + Ignitor(IgnitorType.DROGUE, 33, 33, 15), + ] + + hwsim_stage_2 = HWSim(rocket_sim_stage_2, + hw_sim_sensors_stage_2, + hw_sim_ignitors_stage_2) + + return { + 'BNB_STAGE_1_CONNECTION': SimConnection("BNBStage1", "0013A20041678FC0", hwsim_stage_1), + 'BNB_STAGE_2_CONNECTION': SimConnection("BNBStage2", "0013A20041678FC0", hwsim_stage_2), + } + + def construct_app(self, connections): + return CompApp(connections, self) + + def construct_packet_parser(self): + return CompPacketParser() diff --git a/profiles/rockets/silvertip.py b/profiles/rockets/silvertip.py index 520518a7..3b3329e4 100644 --- a/profiles/rockets/silvertip.py +++ b/profiles/rockets/silvertip.py @@ -111,14 +111,14 @@ def construct_sim_connection(self): SensorSim(SensorType.BAROMETER, rocket_sim, error_stdev=(50, 0.005)), DummySensor(SensorType.GPS, (12.6, 13.2, 175)), SensorSim(SensorType.ACCELEROMETER, rocket_sim), - DummySensor(SensorType.IMU, (1, 0, 0, 0)), + DummySensor(SensorType.IMU, (1, 0, 0, 0, 0, 0, 0)), DummySensor(SensorType.TEMPERATURE, (20,)), - VoltageSensor() + # VoltageSensor() ] hw_sim_ignitors = [ - Ignitor(IgnitorType.MAIN, 4, 14, 16, action_fn=rocket_sim.deploy_main), - Ignitor(IgnitorType.DROGUE, 17, 34, 35, action_fn=rocket_sim.deploy_drogue), + Ignitor(IgnitorType.MAIN, 33, 33, 20, action_fn=rocket_sim.deploy_main), + Ignitor(IgnitorType.DROGUE, 33, 33, 15, action_fn=rocket_sim.deploy_drogue), ] hwsim = HWSim(rocket_sim, hw_sim_sensors, hw_sim_ignitors) diff --git a/profiles/rockets/tantalus.py b/profiles/rockets/tantalus.py deleted file mode 100644 index 41297205..00000000 --- a/profiles/rockets/tantalus.py +++ /dev/null @@ -1,234 +0,0 @@ -"""Profile for Tantalus""" - -from connections.debug.debug_connection import DebugConnection -from connections.serial.serial_connection import SerialConnection -from connections.sim.hw.hw_sim import HWSim -from connections.sim.hw.ignitor_sim import Ignitor, IgnitorType -from connections.sim.hw.rocket_sim import RocketSim -from connections.sim.hw.sensors.dummy_sensor import DummySensor -from connections.sim.hw.sensors.sensor import SensorType -from connections.sim.hw.sensors.voltage_sensor_sim import VoltageSensor -from connections.sim.sim_connection import SimConnection -from main_window.competition.comp_app import CompApp -from main_window.competition.comp_packet_parser import CompPacketParser -from main_window.data_entry_id import DataEntryIds -from main_window.device_manager import DeviceType -from main_window.packet_parser import DEVICE_TYPE_TO_ID -from util.detail import REQUIRED_FLARE -from ..label import ( - Label, - update_acceleration, - update_altitude, - update_gps, - update_max_altitude, - update_pressure, - update_state, -) -from ..mpl_funcs import receive_map, receive_time_series -from ..rocket_profile import RocketProfile - - -class TantalusProfile(RocketProfile): - """Tantalus""" - @property - def rocket_name(self): - return "Tantalus" - - @property - def buttons(self): - return { - "Arm Stage 1": "TANTALUS_STAGE_1_FLARE.ARM", - "Ping Stage 1": "TANTALUS_STAGE_1_FLARE.PING", - "Arm Stage 2": "TANTALUS_STAGE_2_FLARE.ARM", - "Ping Stage 2": "TANTALUS_STAGE_2_FLARE.PING", - } - - @property - def label_to_data_id(self): - # labels unique to Tantalus - other_labels = {"Stage2State": DataEntryIds.STATE} - return {**super().label_to_data_id, **other_labels} - - @property - def label_unit(self): - other_units = {"Stage2State": ""} - return {**super().label_unit, **other_units} - - @property - def labels(self): - return [ - # Labels for data that are displayed - Label(DeviceType.TANTALUS_STAGE_1_FLARE, - "Altitude", - update_altitude, - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_1_FLARE, - "MaxAltitude", - update_max_altitude, - "Max Altitude", - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_1_FLARE, - "GPS", - update_gps, - map_fn=receive_map), - Label( - DeviceType.TANTALUS_STAGE_1_FLARE, - "Pressure", - update_pressure, - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_1_FLARE, - "Acceleration", - update_acceleration, - map_fn=receive_time_series, ), - Label(DeviceType.TANTALUS_STAGE_1_FLARE, - "State", - update_state, - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_2_FLARE, - "Stage2State", - update_state, - "Stage 2 State", - map_fn=receive_time_series, ), - ] - - @property - def all_labels(self): - return self.labels + [ - Label(DeviceType.TANTALUS_STAGE_2_FLARE, - "Altitude", - update_altitude, - "Stage 2 Altitude", - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_2_FLARE, - "MaxAltitude", - update_max_altitude, - "Stage 2 Max Altitude", - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_2_FLARE, - "Pressure", - update_pressure, - "Stage 2 Pressure", - map_fn=receive_time_series), - Label( - DeviceType.TANTALUS_STAGE_2_FLARE, - "Acceleration", - update_acceleration, - "Stage 2 Acceleration", - map_fn=receive_time_series, ), - ] - - @property - def expected_devices(self): - return [ - DeviceType.TANTALUS_STAGE_1_FLARE, - DeviceType.TANTALUS_STAGE_2_FLARE, - ] - - @property - def mapping_devices(self): - return [ - DeviceType.TANTALUS_STAGE_1_FLARE, - DeviceType.TANTALUS_STAGE_2_FLARE, - ] - - @property - def required_device_versions(self): - return { - DeviceType.TANTALUS_STAGE_1_FLARE: REQUIRED_FLARE, - DeviceType.TANTALUS_STAGE_2_FLARE: REQUIRED_FLARE, - } - - @property - def expected_apogee_point(self): - return None - - @property - def expected_main_deploy_point(self): - return None - - def construct_serial_connection(self, com_port, baud_rate): - return { - "XBEE_RADIO": SerialConnection(com_port, baud_rate), - } - - def construct_debug_connection(self): - return { - "TANTALUS_STAGE_1_CONNECTION": DebugConnection( - "TANTALUS_STAGE_1_RADIO_ADDRESS", - DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE], - generate_radio_packets=True, - ), - "TANTALUS_STAGE_2_CONNECTION": DebugConnection( - "TANTALUS_STAGE_2_RADIO_ADDRESS", - DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE], - generate_radio_packets=True, - ), - } - - def construct_sim_connection(self): - # Assemble HW here - """ - Stage 1 - """ - rocket_sim_stage_1 = RocketSim( - 'simple.ork') # TODO: Update ORK file once possible - - hw_sim_sensors_stage_1 = [ - DummySensor(SensorType.BAROMETER, (1000, 25)), - DummySensor(SensorType.GPS, (12.6, 13.2, 175)), - DummySensor(SensorType.ACCELEROMETER, (1, 0, 0)), - DummySensor(SensorType.IMU, (1, 0, 0, 0)), - DummySensor(SensorType.TEMPERATURE, (20,)), - VoltageSensor() - ] - - hw_sim_ignitors_stage_1 = [ - Ignitor(IgnitorType.MAIN, 4, 14, 16), - Ignitor(IgnitorType.DROGUE, 17, 34, 35), - ] - - hwsim_stage_1 = HWSim(rocket_sim_stage_1, - hw_sim_sensors_stage_1, hw_sim_ignitors_stage_1) - - """ - Stage 2 - """ - rocket_sim_stage_2 = RocketSim('simple.ork') - # TODO: Update ORK file once possible - - hw_sim_sensors_stage_2 = [ - DummySensor(SensorType.BAROMETER, (100000, 25)), - DummySensor(SensorType.GPS, (12.6, 13.2, 175)), - DummySensor(SensorType.ACCELEROMETER, (1, 0, 0)), - DummySensor(SensorType.IMU, (1, 0, 0, 0)), - DummySensor(SensorType.TEMPERATURE, (20,)), - VoltageSensor() - ] - - hw_sim_ignitors_stage_2 = [ - Ignitor(IgnitorType.MAIN, 4, 14, 16), - Ignitor(IgnitorType.DROGUE, 17, 34, 35), - ] - - hwsim_stage_2 = HWSim(rocket_sim_stage_2, - hw_sim_sensors_stage_2, - hw_sim_ignitors_stage_2) - - return { - "TANTALUS_STAGE_1_CONNECTION": SimConnection( - "TantalusStage1", "0013A20041678FC0", hwsim_stage_1), - "TANTALUS_STAGE_2_CONNECTION": SimConnection( - "TantalusStage2", "0013A20041678FC0", hwsim_stage_2), - } - - def construct_app(self, connections): - return CompApp(connections, self) - - def construct_packet_parser(self): - return CompPacketParser() diff --git a/profiles/rockets/whistler_blackcomb.py b/profiles/rockets/whistler_blackcomb.py index f8d12bab..ea2d8b03 100644 --- a/profiles/rockets/whistler_blackcomb.py +++ b/profiles/rockets/whistler_blackcomb.py @@ -47,9 +47,9 @@ def construct_serial_connection(self, com_port, baud_rate): def construct_debug_connection(self): return { - "TANTALUS_STAGE_1_CONNECTION": DebugConnection( - "TANTALUS_STAGE_1_RADIO_ADDRESS", - DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE], + "BNB_STAGE_1_CONNECTION": DebugConnection( + "BNB_STAGE_1_RADIO_ADDRESS", + DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_1_FLARE], generate_radio_packets=False, ) } diff --git a/required_flare.txt b/required_flare.txt index 61da52bf..f1bb867d 100644 --- a/required_flare.txt +++ b/required_flare.txt @@ -1 +1 @@ -1a7991e7dd0802a6bf8a751725269ec0775bb9f9 \ No newline at end of file +82d21d94abffb64dee84c5bbe8dfda3d898aabf2 \ No newline at end of file diff --git a/start.py b/start.py index 5dae57fc..91f38d8a 100644 --- a/start.py +++ b/start.py @@ -6,7 +6,7 @@ matplotlib.use('QT5Agg') # Ensures that the Qt5 backend is used, otherwise there might be some issues on some OSs (Mac) from com_window.main import ComWindow from PyQt5 import QtWidgets, QtCore -from profiles.rockets.tantalus import TantalusProfile +from profiles.rockets.bnb import BNBProfile from util.self_test import SelfTest from util.detail import IS_PYINSTALLER, LOGGER @@ -57,7 +57,7 @@ main_window = rocket.construct_app(connection) else: - rocket = TantalusProfile() + rocket = BNBProfile() connection = rocket.construct_debug_connection() main_window = rocket.construct_app(connection) test = SelfTest(main_window) diff --git a/tests/integration_tests/test_debug.py b/tests/integration_tests/test_debug.py index c628bca7..700be106 100644 --- a/tests/integration_tests/test_debug.py +++ b/tests/integration_tests/test_debug.py @@ -1,10 +1,9 @@ import pytest from unittest.mock import MagicMock, ANY - -from main_window.competition.comp_app import LABELS_UPDATED_EVENT from .integration_utils import test_app, valid_paramitrization, all_profiles from connections.debug.debug_connection import DebugConnection, ARMED_EVENT, DISARMED_EVENT -from profiles.rockets.tantalus import TantalusProfile +from main_window.competition.comp_app import LABELS_UPDATED_EVENT +from profiles.rockets.bnb import BNBProfile from connections.debug import radio_packets from main_window.rocket_data import BUNDLE_ADDED_EVENT from main_window.data_entry_id import DataEntryIds, DataEntryValues @@ -29,27 +28,27 @@ @pytest.fixture(scope="function") -def single_connection_tantalus(test_app): - yield test_app(TantalusProfile(), { - 'DEBUG_CONNECTION': DebugConnection('TANTALUS_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE], generate_radio_packets=False) +def single_connection_bnb(test_app): + yield test_app(BNBProfile(), { + 'DEBUG_CONNECTION': DebugConnection('BNB_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_1_FLARE], generate_radio_packets=False) }, num_devices=1) -def test_arm_signal(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_arm_signal(qtbot, single_connection_bnb): + app = single_connection_bnb snapshot = get_event_stats_snapshot() - app.send_command("tantalus_stage_1_flare.arm") + app.send_command("bnb_stage_1_flare.arm") assert ARMED_EVENT.wait(snapshot) == 1 - app.send_command("tantalus_stage_1_flare.disarm") + app.send_command("bnb_stage_1_flare.disarm") assert DISARMED_EVENT.wait(snapshot) == 1 -def test_bulk_sensor_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_bulk_sensor_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] state_input = 0x09 @@ -70,7 +69,7 @@ def test_bulk_sensor_packet(qtbot, single_connection_tantalus): assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 def get_val(val): - return app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, val) + return app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, val) vals_to_get = ( DataEntryIds.CALCULATED_ALTITUDE, @@ -94,13 +93,13 @@ def get_val(val): assert LABELS_UPDATED_EVENT.wait(snapshot) >= 1 - assert app.AltitudeLabel.text() == '2.00 m' - assert app.GPSLabel.text() == '9.00000\xb0, 10.00000\xb0' - assert app.StateLabel.text() == STATE_IDS[state_input].name + assert app.Stage1AltitudeLabel.text() == '2.00 m' + assert app.Stage1GPSLabel.text() == '9.00000\xb0, 10.00000\xb0' + assert app.Stage1StateLabel.text() == STATE_IDS[state_input].name -def test_single_sensor_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_single_sensor_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] vals = [ @@ -138,13 +137,13 @@ def test_single_sensor_packet(qtbot, single_connection_tantalus): connection.receive(packet) assert SINGLE_SENSOR_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, data_entry_id) == val + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, data_entry_id) == val -def test_event_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_event_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] event_to_test = 0x00 packet = radio_packets.event(0xFFFFFFFF, event_to_test) @@ -152,13 +151,13 @@ def test_event_packet(qtbot, single_connection_tantalus): connection.receive(packet) assert EVENT_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.EVENT) == EVENT_IDS[event_to_test] -def test_state_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_state_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] state_to_test = 0x00 packet = radio_packets.state(0xFFFFFFFF, state_to_test) @@ -166,14 +165,14 @@ def test_state_packet(qtbot, single_connection_tantalus): connection.receive(packet) assert STATE_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.STATE) == STATE_IDS[state_to_test] -def test_message_packet(qtbot, single_connection_tantalus, caplog): - app = single_connection_tantalus +def test_message_packet(qtbot, single_connection_bnb, caplog): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] packet = radio_packets.message(0xFFFFFFFF, "test_message") @@ -184,15 +183,15 @@ def test_message_packet(qtbot, single_connection_tantalus, caplog): assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.MESSAGE) == "test_message" assert "test_message" in caplog.text -def test_config_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_config_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] version_id = REQUIRED_FLARE @@ -207,16 +206,16 @@ def test_config_packet(qtbot, single_connection_tantalus): assert CONFIG_EVENT.wait(snapshot) == 1 assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.IS_SIM) == True - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, - DataEntryIds.DEVICE_TYPE) == DeviceType.TANTALUS_STAGE_1_FLARE - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.VERSION_ID) == version_id + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.IS_SIM) == True + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, + DataEntryIds.DEVICE_TYPE) == DeviceType.BNB_STAGE_1_FLARE + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.VERSION_ID) == version_id -def test_status_ping_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_status_ping_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] packet = radio_packets.status_ping( @@ -229,20 +228,20 @@ def test_status_ping_packet(qtbot, single_connection_tantalus): assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF assert ( - app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.OVERALL_STATUS) + app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.OVERALL_STATUS) == DataEntryValues.STATUS_CRITICAL_FAILURE ) for sensor in SENSOR_TYPES: - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, sensor) == 1 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, sensor) == 1 for other in OTHER_STATUS_TYPES: - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, other) == 1 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, other) == 1 -def test_gps_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_gps_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] gps_inputs = (0xFFFFFFFF, 1, 2, 3) @@ -255,15 +254,15 @@ def test_gps_packet(qtbot, single_connection_tantalus): assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.LATITUDE) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.LONGITUDE) == 2 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.GPS_ALTITUDE) == 3 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.LATITUDE) == 1 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.LONGITUDE) == 2 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.GPS_ALTITUDE) == 3 -def test_orientation_packet(qtbot, single_connection_tantalus): - app = single_connection_tantalus +def test_orientation_packet(qtbot, single_connection_bnb): + app = single_connection_bnb connection = app.connections['DEBUG_CONNECTION'] orientation_inputs = (0xFFFFFFFF, 1, 2, 3, 4) @@ -276,25 +275,25 @@ def test_orientation_packet(qtbot, single_connection_tantalus): assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.TIME) == 0xFFFFFFFF - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.ORIENTATION_1) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.ORIENTATION_2) == 2 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.ORIENTATION_3) == 3 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.ORIENTATION_4) == 4 def test_multi_connection_receive(qtbot, test_app): - con_a = DebugConnection('TANTALUS_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE], + con_a = DebugConnection('BNB_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_1_FLARE], generate_radio_packets=False) - con_b = DebugConnection('TANTALUS_STAGE_2_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE], + con_b = DebugConnection('BNB_STAGE_2_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_2_FLARE], generate_radio_packets=False) snapshot = get_event_stats_snapshot() - app = test_app(TantalusProfile(), {'DEBUG_CONNECTION_1': con_a, 'DEBUG_CONNECTION_2': con_b}, num_devices=2) + app = test_app(BNBProfile(), {'DEBUG_CONNECTION_1': con_a, 'DEBUG_CONNECTION_2': con_b}, num_devices=2) con_a.receive(radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 1)) con_b.receive(radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 2)) @@ -308,22 +307,22 @@ def test_multi_connection_receive(qtbot, test_app): assert DEVICE_REGISTERED_EVENT.wait(snapshot, num_expected=3) == 3 assert BUNDLE_ADDED_EVENT.wait(snapshot, num_expected=6) == 6 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, DataEntryIds.PRESSURE) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_2_FLARE, DataEntryIds.PRESSURE) == 2 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, DataEntryIds.PRESSURE) == 1 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_2_FLARE, DataEntryIds.PRESSURE) == 2 assert app.rocket_data.last_value_by_device(DeviceType.CO_PILOT_FLARE, DataEntryIds.PRESSURE) == 3 def test_multi_connection_commands(qtbot, test_app): - con_a = DebugConnection('TANTALUS_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE], + con_a = DebugConnection('BNB_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_1_FLARE], generate_radio_packets=False) - con_b = DebugConnection('TANTALUS_STAGE_2_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE], + con_b = DebugConnection('BNB_STAGE_2_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_2_FLARE], generate_radio_packets=False) con_a.send = MagicMock() con_b.send = MagicMock() snapshot = get_event_stats_snapshot() - app = test_app(TantalusProfile(), {'DEBUG_CONNECTION_1': con_a, 'DEBUG_CONNECTION_2': con_b}, num_devices=2) + app = test_app(BNBProfile(), {'DEBUG_CONNECTION_1': con_a, 'DEBUG_CONNECTION_2': con_b}, num_devices=2) # Fake some other device on same connection con_a.device_address = 'OTHER_ADDRESS' @@ -335,14 +334,14 @@ def test_multi_connection_commands(qtbot, test_app): # Send commands to each and assert called snapshot = get_event_stats_snapshot() - app.send_command("tantalus_stage_1_flare.arm") + app.send_command("bnb_stage_1_flare.arm") COMMAND_SENT_EVENT.wait(snapshot) - con_a.send.assert_called_with('TANTALUS_STAGE_1_ADDRESS', ANY) + con_a.send.assert_called_with('BNB_STAGE_1_ADDRESS', ANY) snapshot = get_event_stats_snapshot() - app.send_command("tantalus_stage_2_flare.arm") + app.send_command("bnb_stage_2_flare.arm") COMMAND_SENT_EVENT.wait(snapshot) - con_b.send.assert_called_with('TANTALUS_STAGE_2_ADDRESS', ANY) + con_b.send.assert_called_with('BNB_STAGE_2_ADDRESS', ANY) snapshot = get_event_stats_snapshot() app.send_command("co_pilot_flare.arm") @@ -351,21 +350,21 @@ def test_multi_connection_commands(qtbot, test_app): def test_register_after_data(qtbot, test_app): - con = DebugConnection('TANTALUS_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_1_FLARE], + con = DebugConnection('BNB_STAGE_1_ADDRESS', DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_1_FLARE], generate_radio_packets=False) - app = test_app(TantalusProfile(), {'DEBUG_CONNECTION': con}, num_devices=1) + app = test_app(BNBProfile(), {'DEBUG_CONNECTION': con}, num_devices=1) snapshot = get_event_stats_snapshot() # Fake stage 2 on same connection - con.device_address = 'TANTALUS_STAGE_2_ADDRESS' + con.device_address = 'BNB_STAGE_2_ADDRESS' con.receive(radio_packets.single_sensor(0xFFFFFFFF, SubpacketIds.PRESSURE, 1)) assert BUNDLE_ADDED_EVENT.wait(snapshot) == 1 # Cause device to register - con.receive(radio_packets.config(0xFFFFFFFF, True, DEVICE_TYPE_TO_ID[DeviceType.TANTALUS_STAGE_2_FLARE], REQUIRED_FLARE)) + con.receive(radio_packets.config(0xFFFFFFFF, True, DEVICE_TYPE_TO_ID[DeviceType.BNB_STAGE_2_FLARE], REQUIRED_FLARE)) assert DEVICE_REGISTERED_EVENT.wait(snapshot) == 1 - assert app.rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_2_FLARE, DataEntryIds.PRESSURE) == 1 + assert app.rocket_data.last_value_by_device(DeviceType.BNB_STAGE_2_FLARE, DataEntryIds.PRESSURE) == 1 @pytest.mark.parametrize("profile", valid_paramitrization(all_profiles(excluding='WbProfile'))) diff --git a/tests/integration_tests/test_sim.py b/tests/integration_tests/test_sim.py index 20dc964c..96a85a5c 100644 --- a/tests/integration_tests/test_sim.py +++ b/tests/integration_tests/test_sim.py @@ -128,43 +128,40 @@ def test_gps_read(self, qtbot, sim_app, device_type): def test_pin_mode(self, qtbot, sim_app, device_type): hw = get_hw_sim(sim_app, device_type) + # Pin modes get flipped in _handleDigitalPinWrite & _handleAnalogRead? + assert hw.get_pin_mode(31) == PinModes.INPUT + assert hw.get_pin_mode(15) == PinModes.INPUT assert hw.get_pin_mode(20) == PinModes.INPUT - assert hw.get_pin_mode(21) == PinModes.INPUT - assert hw.get_pin_mode(13) == PinModes.INPUT - assert hw.get_pin_mode(13) == PinModes.INPUT - assert hw.get_pin_mode(16) == PinModes.INPUT - assert hw.get_pin_mode(4) == PinModes.INPUT - assert hw.get_pin_mode(14) == PinModes.OUTPUT - assert hw.get_pin_mode(35) == PinModes.INPUT - assert hw.get_pin_mode(17) == PinModes.INPUT - assert hw.get_pin_mode(34) == PinModes.OUTPUT - - def test_voltage_reading(self, qtbot, sim_app, device_type): - flush_packets(sim_app, device_type) - - snapshot = get_event_stats_snapshot() - sim_app.send_command(device_type.name + ".VOLT") - assert SINGLE_SENSOR_EVENT.wait(snapshot) == 1 - - last_battery_voltage = sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.VOLTAGE) - assert(round(last_battery_voltage, 1) == VoltageSensor.NOMINAL_BATTERY_VOLTAGE) - assert sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.EVENT) is None - - # The ADC level of 863 gets converted to 10.9V in battery.cpp in FLARE 21899292dc39015570f795ef9e607081aab57e3e - updated_voltage_sensor = VoltageSensor(dummy_adc_level=863) - hw = get_hw_sim(sim_app, device_type) - hw.replace_sensor(updated_voltage_sensor) - - flush_packets(sim_app, device_type) - - snapshot = get_event_stats_snapshot() - sim_app.send_command(device_type.name + ".VOLT") - assert SINGLE_SENSOR_EVENT.wait(snapshot) == 1 - - last_battery_voltage = sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.VOLTAGE) - assert(round(last_battery_voltage, 1) == 10.9) - assert sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.EVENT) \ - == DataEntryValues.EVENT_LOW_VOLTAGE + assert hw.get_pin_mode(193) == PinModes.OUTPUT + assert hw.get_pin_mode(200) == PinModes.OUTPUT + + # No voltage sensor in 2022/23 + # def test_voltage_reading(self, qtbot, sim_app, device_type): + # flush_packets(sim_app, device_type) + # + # snapshot = get_event_stats_snapshot() + # sim_app.send_command(device_type.name + ".VOLT") + # assert SINGLE_SENSOR_EVENT.wait(snapshot) == 1 + # + # last_battery_voltage = sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.VOLTAGE) + # assert(round(last_battery_voltage, 1) == VoltageSensor.NOMINAL_BATTERY_VOLTAGE) + # assert sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.EVENT) is None + # + # # The ADC level of 863 gets converted to 10.9V in battery.cpp in FLARE 21899292dc39015570f795ef9e607081aab57e3e + # updated_voltage_sensor = VoltageSensor(dummy_adc_level=863) + # hw = get_hw_sim(sim_app, device_type) + # hw.replace_sensor(updated_voltage_sensor) + # + # flush_packets(sim_app, device_type) + # + # snapshot = get_event_stats_snapshot() + # sim_app.send_command(device_type.name + ".VOLT") + # assert SINGLE_SENSOR_EVENT.wait(snapshot) == 1 + # + # last_battery_voltage = sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.VOLTAGE) + # assert(round(last_battery_voltage, 1) == 10.9) + # assert sim_app.rocket_data.last_value_by_device(device_type, DataEntryIds.EVENT) \ + # == DataEntryValues.EVENT_LOW_VOLTAGE def test_baro_altitude(self, qtbot, sim_app, device_type): Pb = 101325 @@ -233,10 +230,10 @@ def test_accelerometer_read(self, qtbot, sim_app, device_type): def test_imu_read(self, qtbot, sim_app, device_type): test_vals = [ - (1, 0, 0, 0), - (0, 1, 0, 0), - (0, 0, 1, 0), - (0, 0, 0, 1), + (1, 0, 0, 0, 0, 0, 0), + (0, 1, 0, 0, 0, 0, 0), + (0, 0, 1, 0, 0, 0, 0), + (0, 0, 0, 1, 0, 0, 0), ] for vals in test_vals: @@ -387,7 +384,7 @@ def assert_flight_point(name, flight_point, deployment_time, sim_event, initial_ DataEntryValues.STATE_MAIN_DESCENT) -@pytest.mark.parametrize("sim_app", valid_paramitrization(all_profiles(excluding=['WbProfile', 'CoPilotProfile'])), +@pytest.mark.parametrize("sim_app", valid_paramitrization(all_profiles(excluding=['WbProfile', 'CoPilotProfile', 'HollyburnProfile'])), indirect=True) def test_clean_shutdown(qtbot, sim_app): assert sim_app.ReadThread.isRunning() diff --git a/tests/test_command_parser.py b/tests/test_command_parser.py index 5e340455..dd2dfbd7 100644 --- a/tests/test_command_parser.py +++ b/tests/test_command_parser.py @@ -42,8 +42,8 @@ def test_broadcast_format(full_device_manager): def test_bad_commannds(full_device_manager): bad_commands = [ "NOT.A.COMMAND", - f"{DeviceType.TANTALUS_STAGE_1_FLARE.name}.NOT_A_COMMAND", - f"{DeviceType.TANTALUS_STAGE_1_FLARE.name}", + f"{DeviceType.BNB_STAGE_1_FLARE.name}.NOT_A_COMMAND", + f"{DeviceType.BNB_STAGE_1_FLARE.name}", f"NOT_A_DEVICE.{CommandType.ARM.name}", CommandType.ARM.name, ] @@ -59,12 +59,12 @@ def test_unregistered_device(full_device_manager): all_commands = full_command_parser.available_commands() device_manager = DeviceManager(None, None) - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, None, ('CONNECTION', DeviceType.TANTALUS_STAGE_1_FLARE.name)) + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, None, ('CONNECTION', DeviceType.BNB_STAGE_1_FLARE.name)) command_parser = CommandParser(device_manager) for command in all_commands: (device, _, _) = full_command_parser.pase_command(command) - if device == DeviceType.TANTALUS_STAGE_1_FLARE: + if device == DeviceType.BNB_STAGE_1_FLARE: assert command_parser.pase_command(command) is not None else: with pytest.raises(CommandParsingError): diff --git a/tests/test_device_manager.py b/tests/test_device_manager.py index a60b9a09..231f1a4e 100644 --- a/tests/test_device_manager.py +++ b/tests/test_device_manager.py @@ -6,57 +6,57 @@ def test_normal_registration(): device_manager = DeviceManager(None, None) - full_address_1 = FullAddress(connection_name='TantalusStage1Connection', device_address='TantalusStage1Address') - full_address_2 = FullAddress(connection_name='TantalusStage2Connection', device_address='TantalusStage2Address') + full_address_1 = FullAddress(connection_name='BNBStage1Connection', device_address='BNBStage1Address') + full_address_2 = FullAddress(connection_name='BNBStage2Connection', device_address='BNBStage2Address') snapshot = get_event_stats_snapshot() - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, None, full_address_1) - device_manager.register_device(DeviceType.TANTALUS_STAGE_2_FLARE, None, full_address_2) + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, None, full_address_1) + device_manager.register_device(DeviceType.BNB_STAGE_2_FLARE, None, full_address_2) assert DEVICE_REGISTERED_EVENT.wait(snapshot, num_expected=2, timeout=0) == 2 - assert device_manager.get_full_address(DeviceType.TANTALUS_STAGE_1_FLARE) == full_address_1 - assert device_manager.get_full_address(DeviceType.TANTALUS_STAGE_2_FLARE) == full_address_2 + assert device_manager.get_full_address(DeviceType.BNB_STAGE_1_FLARE) == full_address_1 + assert device_manager.get_full_address(DeviceType.BNB_STAGE_2_FLARE) == full_address_2 def test_existing_device(): device_manager = DeviceManager(None, None) - full_address_1 = FullAddress(connection_name='TantalusStage1Connection', device_address='TantalusStage1Address') - full_address_2 = FullAddress(connection_name='TantalusStage2Connection', device_address='TantalusStage2Address') - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, None, full_address_1) + full_address_1 = FullAddress(connection_name='BNBStage1Connection', device_address='BNBStage1Address') + full_address_2 = FullAddress(connection_name='BNBStage2Connection', device_address='BNBStage2Address') + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, None, full_address_1) with pytest.raises(InvalidRegistration): - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, None, full_address_2) + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, None, full_address_2) - assert device_manager.get_full_address(DeviceType.TANTALUS_STAGE_1_FLARE) == full_address_1 + assert device_manager.get_full_address(DeviceType.BNB_STAGE_1_FLARE) == full_address_1 def test_existing_full_address(): device_manager = DeviceManager(None, None) - full_address_1 = FullAddress(connection_name='TantalusStage1Connection', device_address='TantalusStage1Address') - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, None, full_address_1) + full_address_1 = FullAddress(connection_name='BNBStage1Connection', device_address='BNBStage1Address') + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, None, full_address_1) with pytest.raises(InvalidRegistration): - device_manager.register_device(DeviceType.TANTALUS_STAGE_2_FLARE, None, full_address_1) + device_manager.register_device(DeviceType.BNB_STAGE_2_FLARE, None, full_address_1) - assert device_manager.get_full_address(DeviceType.TANTALUS_STAGE_1_FLARE) == full_address_1 + assert device_manager.get_full_address(DeviceType.BNB_STAGE_1_FLARE) == full_address_1 def test_wrong_version(): - device_manager = DeviceManager(None, {DeviceType.TANTALUS_STAGE_1_FLARE: 'RequiredVersion'}) - full_address_1 = FullAddress(connection_name='TantalusStage1Connection', device_address='TantalusStage1Address') + device_manager = DeviceManager(None, {DeviceType.BNB_STAGE_1_FLARE: 'RequiredVersion'}) + full_address_1 = FullAddress(connection_name='BNBStage1Connection', device_address='BNBStage1Address') with pytest.raises(InvalidDeviceVersion): - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, 'OtherVersion', full_address_1) + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, 'OtherVersion', full_address_1) - assert device_manager.get_full_address(DeviceType.TANTALUS_STAGE_1_FLARE) is None + assert device_manager.get_full_address(DeviceType.BNB_STAGE_1_FLARE) is None def test_num_expected(): - device_manager = DeviceManager([DeviceType.TANTALUS_STAGE_1_FLARE], None) - full_address_1 = FullAddress(connection_name='TantalusStage1Connection', device_address='TantalusStage1Address') - full_address_2 = FullAddress(connection_name='TantalusStage2Connection', device_address='TantalusStage2Address') + device_manager = DeviceManager([DeviceType.BNB_STAGE_1_FLARE], None) + full_address_1 = FullAddress(connection_name='BNBStage1Connection', device_address='BNBStage1Address') + full_address_2 = FullAddress(connection_name='BNBStage2Connection', device_address='BNBStage2Address') - device_manager.register_device(DeviceType.TANTALUS_STAGE_2_FLARE, None, full_address_2) + device_manager.register_device(DeviceType.BNB_STAGE_2_FLARE, None, full_address_2) assert device_manager.num_expected_registered() == 0 - device_manager.register_device(DeviceType.TANTALUS_STAGE_1_FLARE, None, full_address_1) + device_manager.register_device(DeviceType.BNB_STAGE_1_FLARE, None, full_address_1) assert device_manager.num_expected_registered() == 1 diff --git a/tests/test_rocket_data.py b/tests/test_rocket_data.py index fe1f6c82..5abee732 100644 --- a/tests/test_rocket_data.py +++ b/tests/test_rocket_data.py @@ -27,7 +27,7 @@ def bulk_sensor_bundle(): DataEntryIds.LATITUDE: 8, DataEntryIds.LONGITUDE: 9, DataEntryIds.STATE: 10, - DataEntryIds.DEVICE_TYPE: DeviceType.TANTALUS_STAGE_1_FLARE, + DataEntryIds.DEVICE_TYPE: DeviceType.BNB_STAGE_1_FLARE, # DataEntryIds.VERSION_ID: REQUIRED_FLARE, } @@ -73,7 +73,7 @@ def test_last_value_by_device(full_device_manager, rocket_data_with_bulk_added, rocket_data, full_address = rocket_data_with_bulk_added for key, val in bulk_sensor_bundle.items(): - assert rocket_data.last_value_by_device(DeviceType.TANTALUS_STAGE_1_FLARE, key) == val + assert rocket_data.last_value_by_device(DeviceType.BNB_STAGE_1_FLARE, key) == val return @@ -82,7 +82,7 @@ def test_highest_altitude_by_device_single(full_device_manager, rocket_data_with altitude_bundle = { DataEntryIds.TIME: 5, DataEntryIds.CALCULATED_ALTITUDE: 1234, - DataEntryIds.DEVICE_TYPE: DeviceType.TANTALUS_STAGE_2_FLARE, + DataEntryIds.DEVICE_TYPE: DeviceType.BNB_STAGE_2_FLARE, # DataEntryIds.VERSION_ID: REQUIRED_FLARE, } full_address_stage_2 = full_device_manager.get_full_address(altitude_bundle[DataEntryIds.DEVICE_TYPE]) @@ -100,7 +100,7 @@ def test_highest_altitude_by_device_multiple(full_device_manager, rocket_data_wi altitude_bundle = { DataEntryIds.TIME: 5, DataEntryIds.CALCULATED_ALTITUDE: 1234, - DataEntryIds.DEVICE_TYPE: DeviceType.TANTALUS_STAGE_2_FLARE, + DataEntryIds.DEVICE_TYPE: DeviceType.BNB_STAGE_2_FLARE, # DataEntryIds.VERSION_ID: REQUIRED_FLARE, } full_address_stage_2 = full_device_manager.get_full_address(altitude_bundle[DataEntryIds.DEVICE_TYPE])