|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Classes | |
| class | PacketType |
| class | ConfigManager |
| class | UDPReceiver |
| class | SensorDebugDialog |
| class | SensorPlotWidget |
| class | SensorPlotWindow |
| class | ActuatorControlWidget |
| class | PWMControlWindow |
| class | PressureBarWidget |
| class | TopBarWidget |
| class | SettingsWidget |
| class | ActuatorControlWindow |
| class | CalibrationWindow |
| class | CombinedMainWindow |
Functions | |
| float | actuator_counts_to_volts (int data_u32) |
| get_num_actuators () | |
| tuple[Dict[str, Dict[str, str]], int] | load_state_machine_csv (Path csv_path) |
| Dict[str, Dict[str, bool]] | load_state_transitions_csv (Path csv_path) |
| int | get_actuator_id_from_role (str role_name) |
| apply_state_from_csv (actuator_widget, str state_name, Dict[str, Dict[str, str]] state_machine) | |
| float | calculate_pressure (float adc_code, float PT_A, float PT_B, float PT_C, float PT_D) |
| Tuple[Dict[int, Tuple[float, float, float, float]], Optional[str]] | load_pt_calibration (csv_paths) |
| Optional[Tuple[int, int, int]] | parse_packet_header (bytes data) |
| Optional[Tuple[dict, List[dict]]] | parse_sensor_data_packet (bytes data) |
| bytes | create_actuator_command_packet (List[Tuple[int, int]] commands) |
| bytes | create_pwm_actuator_command_packet (List[Tuple[int, int, float, float]] commands) |
| main () | |
Combined Sensor & Actuator Control GUI Opens one full-screen window with: - Left (66%): Sensor/PT data receiver and real-time plotting - Right (33%): Actuator control and voltage monitoring Requirements: pip install pyqt6 pyqtgraph numpy
| float combined_gui.actuator_counts_to_volts | ( | int | data_u32 | ) |
Actuator current-sense datapoint -> volts. Boards send raw 12-bit counts (<= 4095). Firmware from before that sent float volts as bits; any nonzero voltage float encodes far above 4095, so those are still read as floats until every board is reflashed.
Definition at line 160 of file combined_gui.py.
Referenced by combined_gui.ActuatorControlWidget.on_sensor_data().
| combined_gui.apply_state_from_csv | ( | actuator_widget, | |
| str | state_name, | ||
| Dict[str, Dict[str, str]] | state_machine ) |
Apply actuator states from CSV for the given state name. Mapping: - FV = Fuel Vent - OV = LOX Vent - FP = Fuel Press - OP = LOX Press - FM = Fuel Main - OM = LOX Main
Definition at line 648 of file combined_gui.py.
References get_actuator_id_from_role(), and get_num_actuators().
| float combined_gui.calculate_pressure | ( | float | adc_code, |
| float | PT_A, | ||
| float | PT_B, | ||
| float | PT_C, | ||
| float | PT_D ) |
Compute pressure (psi) from ADC code using cubic polynomial.
Definition at line 713 of file combined_gui.py.
Referenced by combined_gui.SensorPlotWidget.on_sensor_data(), and combined_gui.SensorPlotWidget.zero_pts().
| bytes combined_gui.create_actuator_command_packet | ( | List[Tuple[int, int]] | commands | ) |
Create an actuator command packet. commands: List of (actuator_id, actuator_state) tuples actuator_id: 1-10 (1-indexed) actuator_state: 0 = OFF, non-zero = ON
Definition at line 927 of file combined_gui.py.
References time.time().
Referenced by combined_gui.ActuatorControlWidget.send_actuator_command().
| bytes combined_gui.create_pwm_actuator_command_packet | ( | List[Tuple[int, int, float, float]] | commands | ) |
Creates a PWM Actuator Command packet.
Packet layout: PacketHeader + PWMActuatorCommandPacket + N PWMActuatorCommand.
commands: List of tuples (actuator_id, duration_ms, duty_cycle, frequency)
Note: duration is in ms (uint32), duty_cycle is float (0.0-1.0), frequency is float (Hz)
Definition at line 975 of file combined_gui.py.
References time.time().
Referenced by combined_gui.PWMControlWindow.execute_now().
| int combined_gui.get_actuator_id_from_role | ( | str | role_name | ) |
Get actuator ID from role name. Returns 0 if not found.
Definition at line 643 of file combined_gui.py.
Referenced by apply_state_from_csv().
| combined_gui.get_num_actuators | ( | ) |
Get number of actuators dynamically from CSV/config.
Definition at line 521 of file combined_gui.py.
Referenced by apply_state_from_csv(), combined_gui.SettingsWidget.on_actuator_role_changed(), combined_gui.ActuatorControlWidget.on_sensor_data(), combined_gui.ActuatorControlWidget.update_actuator_visibility(), and combined_gui.ActuatorControlWidget.update_current_display().
| Tuple[Dict[int, Tuple[float, float, float, float]], Optional[str]] combined_gui.load_pt_calibration | ( | csv_paths | ) |
Load PT calibration coefficients from one or more CSV files.
Args:
csv_paths: Single CSV path (str) or list of CSV paths. Empty string/list uses default.
Returns:
Tuple of (result_dict, error_message):
- result_dict: connector_id -> (PT_A, PT_B, PT_C, PT_D) for each PT present in CSVs
- error_message: None if successful, error string if duplicates or other errors found
The number in the CSV (PT1, PT2, ...) is the board connector number; this same ID is used
everywhere: config.json sensor_roles, mappings, and packet sensor_id.
CSV columns per PT: ADC Code, Pressure, Coefficient 0 (A), 1 (B), 2 (C), 3 (D).
Uses the last data row as the calibration coefficients.
Works with any number of PTs; PT numbers are discovered from column names "PT{N} Coefficient 0".
If multiple CSVs contain the same PT number, returns error message listing duplicates.
Definition at line 720 of file combined_gui.py.
Referenced by combined_gui.SensorPlotWidget.reload_pt_calibration().
| tuple[Dict[str, Dict[str, str]], int] combined_gui.load_state_machine_csv | ( | Path | csv_path | ) |
Load state machine CSV file.
Returns tuple: (state_machine_dict, num_actuators)
state_machine_dict: state_name -> {actuator_abbrev -> OPEN/CLOSE}
num_actuators: number of actuators found in CSV
CSV format: first row is header with state names (first column empty), first column of data rows is actuator abbreviations
Definition at line 530 of file combined_gui.py.
Referenced by combined_gui.ConfigManager.get_num_actuators().
| Dict[str, Dict[str, bool]] combined_gui.load_state_transitions_csv | ( | Path | csv_path | ) |
Load state transitions CSV file.
Returns dict: current_state -> {next_state -> allowed (True/False)}
CSV format: first row is header with next states, first column is current states
Definition at line 593 of file combined_gui.py.
| combined_gui.main | ( | void | ) |
Main entry point
Definition at line 5995 of file combined_gui.py.
| Optional[Tuple[int, int, int]] combined_gui.parse_packet_header | ( | bytes | data | ) |
Parse the packet header. Returns: (packet_type, version, timestamp) or None
Definition at line 851 of file combined_gui.py.
Referenced by parse_sensor_data_packet(), and combined_gui.UDPReceiver.run().
| Optional[Tuple[dict, List[dict]]] combined_gui.parse_sensor_data_packet | ( | bytes | data | ) |
Parse a sensor data packet. Returns: (header_dict, chunks_list) or None
Definition at line 864 of file combined_gui.py.
References parse_packet_header().
Referenced by combined_gui.UDPReceiver.run().
|
protected |
Definition at line 83 of file combined_gui.py.
|
protected |
Definition at line 38 of file combined_gui.py.
|
protected |
Definition at line 230 of file combined_gui.py.
|
protected |
Definition at line 231 of file combined_gui.py.
|
protected |
Definition at line 77 of file combined_gui.py.
|
protected |
Definition at line 80 of file combined_gui.py.
|
protected |
Definition at line 81 of file combined_gui.py.
|
protected |
Definition at line 46 of file combined_gui.py.
|
protected |
Definition at line 82 of file combined_gui.py.
|
protected |
Definition at line 36 of file combined_gui.py.
|
protected |
Definition at line 24 of file combined_gui.py.
| int combined_gui.ACT_ADC_MAX = 4095 |
Definition at line 156 of file combined_gui.py.
| float combined_gui.ACT_ADC_VREF = 3.3 |
Definition at line 157 of file combined_gui.py.
| str combined_gui.ACTUATOR_COMMAND_FORMAT = "<BB" |
Definition at line 137 of file combined_gui.py.
| str combined_gui.ACTUATOR_COMMAND_PACKET_FORMAT = "<B" |
Definition at line 134 of file combined_gui.py.
| int combined_gui.ACTUATOR_COMMAND_PACKET_SIZE = 1 |
Definition at line 135 of file combined_gui.py.
| int combined_gui.ACTUATOR_COMMAND_SIZE = 2 |
Definition at line 138 of file combined_gui.py.
| list combined_gui.ACTUATOR_DISPLAY_ORDER_WHEN_ROLES |
Definition at line 202 of file combined_gui.py.
| str combined_gui.ACTUATOR_LABELS_FILE = _SCRIPT_DIR / "actuator_labels.json" |
Definition at line 211 of file combined_gui.py.
| combined_gui.antialias |
Definition at line 68 of file combined_gui.py.
| combined_gui.CONFIG = ConfigManager() |
Definition at line 515 of file combined_gui.py.
| str combined_gui.CONFIG_FILE = _SCRIPT_DIR / "config.json" |
Definition at line 229 of file combined_gui.py.
| dict combined_gui.DEFAULT_ACTUATOR_ABBREV_TO_ROLE |
Definition at line 193 of file combined_gui.py.
| str combined_gui.DEFAULT_ACTUATOR_IP = "192.168.2.201" |
Definition at line 126 of file combined_gui.py.
| list combined_gui.DEFAULT_ACTUATOR_ROLE_NAMES |
Definition at line 179 of file combined_gui.py.
| int combined_gui.DEFAULT_DEVICE_PORT = 5005 |
Definition at line 127 of file combined_gui.py.
| int combined_gui.DEFAULT_RECEIVE_PORT = 5006 |
Definition at line 128 of file combined_gui.py.
| str combined_gui.DEFAULT_SENSOR_IP = "192.168.2.101" |
Definition at line 125 of file combined_gui.py.
| list combined_gui.DEFAULT_SENSOR_ROLE_NAMES |
Definition at line 187 of file combined_gui.py.
| float combined_gui.DEFAULT_WINDOW_SECONDS = 10.0 |
Definition at line 173 of file combined_gui.py.
| int combined_gui.DIABLO_COMMS_VERSION = 0 |
Definition at line 105 of file combined_gui.py.
| int combined_gui.MAX_PACKET_SIZE = 512 |
Definition at line 106 of file combined_gui.py.
| int combined_gui.MAX_POINTS = 200000 |
Definition at line 174 of file combined_gui.py.
| combined_gui.NUM_CONNECTORS = 10 |
Definition at line 176 of file combined_gui.py.
| str combined_gui.PACKET_HEADER_FORMAT = "<BBI" |
Definition at line 131 of file combined_gui.py.
| int combined_gui.PACKET_HEADER_SIZE = 6 |
Definition at line 132 of file combined_gui.py.
| combined_gui.PT_CALIBRATION_CSV |
Definition at line 27 of file combined_gui.py.
| str combined_gui.PWM_ACTUATOR_COMMAND_FORMAT = "<BIff" |
Definition at line 143 of file combined_gui.py.
| str combined_gui.PWM_ACTUATOR_COMMAND_PACKET_FORMAT = "<B" |
Definition at line 140 of file combined_gui.py.
| int combined_gui.PWM_ACTUATOR_COMMAND_PACKET_SIZE = 1 |
Definition at line 141 of file combined_gui.py.
| int combined_gui.PWM_ACTUATOR_COMMAND_SIZE = 13 |
Definition at line 144 of file combined_gui.py.
| combined_gui.reverse |
Definition at line 44 of file combined_gui.py.
| bool combined_gui.ROBUST_CALIBRATION_AVAILABLE = True |
Definition at line 93 of file combined_gui.py.
| list combined_gui.SENSOR_COLORS |
Definition at line 215 of file combined_gui.py.
| str combined_gui.SENSOR_DATA_CHUNK_FORMAT = "<I" |
Definition at line 149 of file combined_gui.py.
| int combined_gui.SENSOR_DATA_CHUNK_SIZE = 4 |
Definition at line 150 of file combined_gui.py.
| str combined_gui.SENSOR_DATA_PACKET_FORMAT = "<BB" |
Definition at line 146 of file combined_gui.py.
| int combined_gui.SENSOR_DATA_PACKET_SIZE = 2 |
Definition at line 147 of file combined_gui.py.
| str combined_gui.SENSOR_DATAPOINT_FORMAT = "<BI" |
Definition at line 152 of file combined_gui.py.
| int combined_gui.SENSOR_DATAPOINT_SIZE = 5 |
Definition at line 153 of file combined_gui.py.
| str combined_gui.SENSOR_LABELS_FILE = _SCRIPT_DIR / "sensor_labels.json" |
Definition at line 212 of file combined_gui.py.
| combined_gui.True |
Definition at line 68 of file combined_gui.py.
| int combined_gui.UPDATE_INTERVAL_MS = 100 |
Definition at line 175 of file combined_gui.py.
| combined_gui.useOpenGL |
Definition at line 68 of file combined_gui.py.