STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
solenoid_characterization_gui Namespace Reference

Classes

class  PacketType
class  ConfigManager
class  UDPReceiver
class  FullPlotWindow
class  SolenoidCharacterizationWindow

Functions

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)
Dict extract_solenoid_timing_live (np.ndarray t, np.ndarray P, float t_open_cmd, float t_close_cmd, *, float smooth_window_sec=0.020, float derivative_threshold_psi_s=50.0, float settle_threshold_psi_s=20.0, float pre_window_sec=0.5, float guard_sec=0.005, float min_step_psi=5.0, int sustain_samples=10, float search_max_sec=5.0, bool open_is_drop=True)
Dict extract_solenoid_timing_from_commands (pd.DataFrame df, *, str time_col="time_sec", str pressure_col="pressure_psi", str actuation_col="ACTUATION", str open_token="OPEN", str close_token="CLOSED", float smooth_window_sec=0.020, float derivative_threshold_psi_s=50.0, float settle_threshold_psi_s=20.0, float pre_window_sec=0.5, float guard_sec=0.005, float min_step_psi=5.0, int sustain_samples=10, float search_max_sec=5.0, bool open_is_drop=True)
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 ()

Variables

 PT_CALIBRATION_CSV
 _qt_plugins = os.environ.get("QT_QPA_PLATFORM_PLUGIN_PATH")
list _candidates
 reverse
 _p
int DIABLO_COMMS_VERSION = 0
int MAX_PACKET_SIZE = 512
str DEFAULT_SENSOR_IP = "192.168.2.21"
str DEFAULT_ACTUATOR_IP = "192.168.2.12"
int DEFAULT_DEVICE_PORT = 5005
int DEFAULT_RECEIVE_PORT = 5006
str PACKET_HEADER_FORMAT = "<BBI"
int PACKET_HEADER_SIZE = 6
str ACTUATOR_COMMAND_PACKET_FORMAT = "<B"
int ACTUATOR_COMMAND_PACKET_SIZE = 1
str ACTUATOR_COMMAND_FORMAT = "<BB"
int ACTUATOR_COMMAND_SIZE = 2
str PWM_ACTUATOR_COMMAND_PACKET_FORMAT = "<B"
int PWM_ACTUATOR_COMMAND_PACKET_SIZE = 1
str PWM_ACTUATOR_COMMAND_FORMAT = "<BIff"
int PWM_ACTUATOR_COMMAND_SIZE = 13
str SENSOR_DATA_PACKET_FORMAT = "<BB"
int SENSOR_DATA_PACKET_SIZE = 2
str SENSOR_DATA_CHUNK_FORMAT = "<I"
int SENSOR_DATA_CHUNK_SIZE = 4
str SENSOR_DATAPOINT_FORMAT = "<BI"
int SENSOR_DATAPOINT_SIZE = 5
float DEFAULT_WINDOW_SECONDS = 10.0
int MAX_POINTS = 150000
int UPDATE_INTERVAL_MS = 50
int SAMPLE_RATE_HZ = 7200
list DEFAULT_ACTUATOR_ROLE_NAMES
list DEFAULT_SENSOR_ROLE_NAMES
str CONFIG_FILE = Path(__file__).parent / "config.json"
 CONFIG = ConfigManager()
 NUM_CONNECTORS = CONFIG.get_num_connectors()
 NUM_ACTUATORS = CONFIG.get_num_actuators()
 antialias

Function Documentation

◆ calculate_pressure()

float solenoid_characterization_gui.calculate_pressure ( float adc_code,
float PT_A,
float PT_B,
float PT_C,
float PT_D )

◆ create_actuator_command_packet()

bytes solenoid_characterization_gui.create_actuator_command_packet ( List[Tuple[int, int]] commands)

◆ create_pwm_actuator_command_packet()

bytes solenoid_characterization_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 756 of file solenoid_characterization_gui.py.

References time.time().

Referenced by solenoid_characterization_gui.SolenoidCharacterizationWindow.on_pwm_go_clicked().

◆ extract_solenoid_timing_from_commands()

Dict solenoid_characterization_gui.extract_solenoid_timing_from_commands ( pd.DataFrame df,
* ,
str time_col = "time_sec",
str pressure_col = "pressure_psi",
str actuation_col = "ACTUATION",
str open_token = "OPEN",
str close_token = "CLOSED",
float smooth_window_sec = 0.020,
float derivative_threshold_psi_s = 50.0,
float settle_threshold_psi_s = 20.0,
float pre_window_sec = 0.5,
float guard_sec = 0.005,
float min_step_psi = 5.0,
int sustain_samples = 10,
float search_max_sec = 5.0,
bool open_is_drop = True )
Pressure-based timing from a DataFrame with ACTUATION column.
Parses df to (t, P, t_open_cmd, t_close_cmd) then calls extract_solenoid_timing_live.
Use this for CSV/offline; use extract_solenoid_timing_live for live GUI.

Definition at line 602 of file solenoid_characterization_gui.py.

References extract_solenoid_timing_live().

◆ extract_solenoid_timing_live()

Dict solenoid_characterization_gui.extract_solenoid_timing_live ( np.ndarray t,
np.ndarray P,
float t_open_cmd,
float t_close_cmd,
* ,
float smooth_window_sec = 0.020,
float derivative_threshold_psi_s = 50.0,
float settle_threshold_psi_s = 20.0,
float pre_window_sec = 0.5,
float guard_sec = 0.005,
float min_step_psi = 5.0,
int sustain_samples = 10,
float search_max_sec = 5.0,
bool open_is_drop = True )
Extract solenoid valve timing from pressure data using derivative-based edge detection.

Detects 4 events:
  - t_open_start: When valve starts opening (pressure begins changing after OPEN cmd)
  - t_open_end: When valve is fully open (pressure stabilizes at low point)
  - t_close_start: When valve starts closing (pressure begins recovering)
  - t_close_end: When valve is fully closed (pressure returns to baseline)

This algorithm handles overlapping command/response timing where the physical valve
response lags behind electrical commands by hundreds of milliseconds.

Args:
    t: Time array in seconds
    P: Pressure array in psi
    t_open_cmd: Time of OPEN command
    t_close_cmd: Time of CLOSE command
    smooth_window_sec: Window for smoothing pressure (default: 20ms)
    derivative_threshold_psi_s: Rate of change to detect transition start (default: 50 psi/s)
    settle_threshold_psi_s: Rate of change threshold for "settled" state (default: 20 psi/s)
    pre_window_sec: Time before command to calculate baseline (default: 0.5s)
    guard_sec: Minimum time after command before looking for response (default: 5ms)
    min_step_psi: Minimum pressure change to consider valid (default: 5 psi)
    sustain_samples: Number of consecutive samples to confirm a state (default: 10)
    search_max_sec: Maximum time after command to search for events (default: 5s)
    open_is_drop: If True, opening causes pressure drop; if False, opening causes pressure rise

Returns:
    Dictionary with timing results including t_open_start, t_open_end, t_close_start, t_close_end

Definition at line 339 of file solenoid_characterization_gui.py.

References max, and min.

Referenced by solenoid_characterization_gui.FullPlotWindow._run_analysis(), extract_solenoid_timing_from_commands(), and solenoid_characterization_gui.SolenoidCharacterizationWindow.save_characterization_csv().

◆ load_pt_calibration()

Tuple[Dict[int, Tuple[float, float, float, float]], Optional[str]] solenoid_characterization_gui.load_pt_calibration ( csv_paths)

Definition at line 282 of file solenoid_characterization_gui.py.

◆ main()

solenoid_characterization_gui.main ( void )

Definition at line 1939 of file solenoid_characterization_gui.py.

References main().

◆ parse_packet_header()

Optional[Tuple[int, int, int]] solenoid_characterization_gui.parse_packet_header ( bytes data)

◆ parse_sensor_data_packet()

Optional[Tuple[dict, List[dict]]] solenoid_characterization_gui.parse_sensor_data_packet ( bytes data)

Variable Documentation

◆ _candidates

list solenoid_characterization_gui._candidates
protected
Initial value:
1= [
2 "/opt/homebrew/share/qt/plugins/platforms",
3 "/opt/homebrew/Cellar/qtbase/6.10.1/share/qt/plugins/platforms",
4 ]

Definition at line 37 of file solenoid_characterization_gui.py.

◆ _p

solenoid_characterization_gui._p
protected
Initial value:
1= os.path.join(
2 "/opt/homebrew/Cellar/qtbase",
3 _name,
4 "share",
5 "qt",
6 "plugins",
7 "platforms",
8 )

Definition at line 45 of file solenoid_characterization_gui.py.

◆ _qt_plugins

solenoid_characterization_gui._qt_plugins = os.environ.get("QT_QPA_PLATFORM_PLUGIN_PATH")
protected

Definition at line 35 of file solenoid_characterization_gui.py.

◆ ACTUATOR_COMMAND_FORMAT

str solenoid_characterization_gui.ACTUATOR_COMMAND_FORMAT = "<BB"

Definition at line 96 of file solenoid_characterization_gui.py.

◆ ACTUATOR_COMMAND_PACKET_FORMAT

str solenoid_characterization_gui.ACTUATOR_COMMAND_PACKET_FORMAT = "<B"

Definition at line 94 of file solenoid_characterization_gui.py.

◆ ACTUATOR_COMMAND_PACKET_SIZE

int solenoid_characterization_gui.ACTUATOR_COMMAND_PACKET_SIZE = 1

Definition at line 95 of file solenoid_characterization_gui.py.

◆ ACTUATOR_COMMAND_SIZE

int solenoid_characterization_gui.ACTUATOR_COMMAND_SIZE = 2

Definition at line 97 of file solenoid_characterization_gui.py.

◆ antialias

solenoid_characterization_gui.antialias

Definition at line 272 of file solenoid_characterization_gui.py.

◆ CONFIG

solenoid_characterization_gui.CONFIG = ConfigManager()

Definition at line 268 of file solenoid_characterization_gui.py.

◆ CONFIG_FILE

str solenoid_characterization_gui.CONFIG_FILE = Path(__file__).parent / "config.json"

Definition at line 131 of file solenoid_characterization_gui.py.

◆ DEFAULT_ACTUATOR_IP

str solenoid_characterization_gui.DEFAULT_ACTUATOR_IP = "192.168.2.12"

Definition at line 88 of file solenoid_characterization_gui.py.

◆ DEFAULT_ACTUATOR_ROLE_NAMES

list solenoid_characterization_gui.DEFAULT_ACTUATOR_ROLE_NAMES
Initial value:
1= [
2 "LOX Main",
3 "Fuel Main",
4 "Fuel Vent",
5 "Fuel Press",
6 "LOX Vent",
7 "LOX Press",
8]

Definition at line 116 of file solenoid_characterization_gui.py.

◆ DEFAULT_DEVICE_PORT

int solenoid_characterization_gui.DEFAULT_DEVICE_PORT = 5005

Definition at line 89 of file solenoid_characterization_gui.py.

◆ DEFAULT_RECEIVE_PORT

int solenoid_characterization_gui.DEFAULT_RECEIVE_PORT = 5006

Definition at line 90 of file solenoid_characterization_gui.py.

◆ DEFAULT_SENSOR_IP

str solenoid_characterization_gui.DEFAULT_SENSOR_IP = "192.168.2.21"

Definition at line 87 of file solenoid_characterization_gui.py.

◆ DEFAULT_SENSOR_ROLE_NAMES

list solenoid_characterization_gui.DEFAULT_SENSOR_ROLE_NAMES
Initial value:
1= [
2 "LOX Upstream",
3 "LOX Downstream",
4 "Low Press PT",
5 "Fuel Downstream",
6]

Definition at line 124 of file solenoid_characterization_gui.py.

◆ DEFAULT_WINDOW_SECONDS

float solenoid_characterization_gui.DEFAULT_WINDOW_SECONDS = 10.0

Definition at line 110 of file solenoid_characterization_gui.py.

◆ DIABLO_COMMS_VERSION

int solenoid_characterization_gui.DIABLO_COMMS_VERSION = 0

Definition at line 69 of file solenoid_characterization_gui.py.

◆ MAX_PACKET_SIZE

int solenoid_characterization_gui.MAX_PACKET_SIZE = 512

Definition at line 70 of file solenoid_characterization_gui.py.

◆ MAX_POINTS

int solenoid_characterization_gui.MAX_POINTS = 150000

Definition at line 112 of file solenoid_characterization_gui.py.

◆ NUM_ACTUATORS

solenoid_characterization_gui.NUM_ACTUATORS = CONFIG.get_num_actuators()

Definition at line 270 of file solenoid_characterization_gui.py.

◆ NUM_CONNECTORS

solenoid_characterization_gui.NUM_CONNECTORS = CONFIG.get_num_connectors()

Definition at line 269 of file solenoid_characterization_gui.py.

◆ PACKET_HEADER_FORMAT

str solenoid_characterization_gui.PACKET_HEADER_FORMAT = "<BBI"

Definition at line 92 of file solenoid_characterization_gui.py.

◆ PACKET_HEADER_SIZE

int solenoid_characterization_gui.PACKET_HEADER_SIZE = 6

Definition at line 93 of file solenoid_characterization_gui.py.

◆ PT_CALIBRATION_CSV

solenoid_characterization_gui.PT_CALIBRATION_CSV
Initial value:
1= str(
2 Path(__file__).parent.parent
3 / "PT_Board"
4 / "Calibration"
5 / "PT Calibration Attempt 2026-02-04_test2.csv"
6)

Definition at line 26 of file solenoid_characterization_gui.py.

◆ PWM_ACTUATOR_COMMAND_FORMAT

str solenoid_characterization_gui.PWM_ACTUATOR_COMMAND_FORMAT = "<BIff"

Definition at line 101 of file solenoid_characterization_gui.py.

◆ PWM_ACTUATOR_COMMAND_PACKET_FORMAT

str solenoid_characterization_gui.PWM_ACTUATOR_COMMAND_PACKET_FORMAT = "<B"

Definition at line 98 of file solenoid_characterization_gui.py.

◆ PWM_ACTUATOR_COMMAND_PACKET_SIZE

int solenoid_characterization_gui.PWM_ACTUATOR_COMMAND_PACKET_SIZE = 1

Definition at line 99 of file solenoid_characterization_gui.py.

◆ PWM_ACTUATOR_COMMAND_SIZE

int solenoid_characterization_gui.PWM_ACTUATOR_COMMAND_SIZE = 13

Definition at line 102 of file solenoid_characterization_gui.py.

◆ reverse

solenoid_characterization_gui.reverse

Definition at line 43 of file solenoid_characterization_gui.py.

◆ SAMPLE_RATE_HZ

int solenoid_characterization_gui.SAMPLE_RATE_HZ = 7200

Definition at line 115 of file solenoid_characterization_gui.py.

◆ SENSOR_DATA_CHUNK_FORMAT

str solenoid_characterization_gui.SENSOR_DATA_CHUNK_FORMAT = "<I"

Definition at line 105 of file solenoid_characterization_gui.py.

◆ SENSOR_DATA_CHUNK_SIZE

int solenoid_characterization_gui.SENSOR_DATA_CHUNK_SIZE = 4

Definition at line 106 of file solenoid_characterization_gui.py.

◆ SENSOR_DATA_PACKET_FORMAT

str solenoid_characterization_gui.SENSOR_DATA_PACKET_FORMAT = "<BB"

Definition at line 103 of file solenoid_characterization_gui.py.

◆ SENSOR_DATA_PACKET_SIZE

int solenoid_characterization_gui.SENSOR_DATA_PACKET_SIZE = 2

Definition at line 104 of file solenoid_characterization_gui.py.

◆ SENSOR_DATAPOINT_FORMAT

str solenoid_characterization_gui.SENSOR_DATAPOINT_FORMAT = "<BI"

Definition at line 107 of file solenoid_characterization_gui.py.

◆ SENSOR_DATAPOINT_SIZE

int solenoid_characterization_gui.SENSOR_DATAPOINT_SIZE = 5

Definition at line 108 of file solenoid_characterization_gui.py.

◆ UPDATE_INTERVAL_MS

int solenoid_characterization_gui.UPDATE_INTERVAL_MS = 50

Definition at line 113 of file solenoid_characterization_gui.py.