STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
combined_gui.SensorPlotWidget Class Reference
Inheritance diagram for combined_gui.SensorPlotWidget:
[legend]
Collaboration diagram for combined_gui.SensorPlotWidget:
[legend]

Public Member Functions

 __init__ (self, receiver, str bind_address="0.0.0.0", parent=None)
str format_label_two_rows (self, str text)
 on_sensor_label_changed (self, int connector_id, str text)
 update_plot_legend (self, int connector_id)
 init_ui (self)
 init_connector_plots (self)
 reload_pt_calibration (self)
 zero_pts (self)
 clear_pt_zeros (self)
 open_debug_menu (self)
 on_auto_scale_toggled (self, state)
 on_demo_mode_toggled (self, state)
 update_buffer_size (self)
 on_graph_moving_avg_changed (self, value)
 on_display_moving_avg_changed (self, value)
float code_to_voltage (self, int code_uint32)
 on_navigation_requested (self, str target)
 on_status_update (self, str message)
 on_packet_received (self, int packet_size, int packet_type)
 on_sensor_data (self, dict header, List[dict] chunks, str source_ip)
 add_sensor_plot (self, int sensor_id)
 update_plots (self)
 update_statistics (self)
 save_pressures_csv (self)
 save_events_csv (self)

Public Attributes

 receiver = receiver
 bind_address = bind_address
 window_seconds = DEFAULT_WINDOW_SECONDS
int display_moving_avg_samples = 10
tuple graph_moving_avg_samples
int adc_bits = 32
float reference_voltage = 2.5
 filter_source_ip = DEFAULT_SENSOR_IP
bool y_axis_auto_scale = True
float y_axis_min = 0.0
float y_axis_max = 700.0
dict sensor_data = {}
tuple sensor_adc_codes
dict sensor_psi_plot_t = {}
dict sensor_psi_plot_v = {}
tuple sensor_psi_history
dict sensor_plots = {}
dict plot_enabled
 stats_start_time = time.time()
 pt_calibration
 pt_calibration_error
dict pt_offsets = {}
 main_window_ref = None
dict sensor_labels
dict debug_values = {}
dict network_stats
int total_samples_received = 0
int last_sps_sample_count = 0
 last_sps_time = time.time()
int plot_buffer_size = int(self.window_seconds * 1200) + 1000
 only_show_pt_with_roles = disp.get("only_show_pt_with_roles", False)
bool demo_mode = False
Optional[float] demo_start_time = None
Optional[socket.socket] demo_send_socket = None
Optional[QtCore.QTimer] demo_send_timer = None
 on_sensor_data
 on_status_update
 on_packet_received
 update_timer = QtCore.QTimer(self)
 update_plots
 stats_timer = QtCore.QTimer(self)
 update_statistics
tuple under_graph_name_labels
 legend
 status_label = QtWidgets.QLabel("Starting...")
 auto_scale_checkbox = QtWidgets.QCheckBox("Auto-scale Y-axis")
 on_auto_scale_toggled
 save_pressures_csv
 save_events_csv
 plot_widget = pg.GraphicsLayoutWidget()
dict under_graph_labels = {}
tuple under_graph_containers
 plot_item
 sps_text_item
 settings_widget_ref
 current_sps_display = sps

Protected Member Functions

 _on_plot_toggle (self, int connector_id, state)
 _clear_all_sensor_deques (self)
 _apply_demo_mode (self, bool enabled)
 _send_demo_packet (self)

Protected Attributes

 _send_demo_packet

Detailed Description

Reusable sensor/PT plotting panel. Used in SensorPlotWindow and CombinedMainWindow.

Definition at line 1207 of file combined_gui.py.

Constructor & Destructor Documentation

◆ __init__()

combined_gui.SensorPlotWidget.__init__ ( self,
receiver,
str bind_address = "0.0.0.0",
parent = None )

Definition at line 1210 of file combined_gui.py.

References __init__().

Referenced by __init__().

Member Function Documentation

◆ _apply_demo_mode()

combined_gui.SensorPlotWidget._apply_demo_mode ( self,
bool enabled )
protected

◆ _clear_all_sensor_deques()

combined_gui.SensorPlotWidget._clear_all_sensor_deques ( self)
protected
Clear all sensor data deques so plot/stats show only new data.

Definition at line 1633 of file combined_gui.py.

References plot_buffer_size, sensor_adc_codes, sensor_data, pt_multi_gui.PTPlotWindow.sensor_data, sensor_psi_history, sensor_psi_plot_t, and sensor_psi_plot_v.

Referenced by _apply_demo_mode().

◆ _on_plot_toggle()

combined_gui.SensorPlotWidget._on_plot_toggle ( self,
int connector_id,
state )
protected

◆ _send_demo_packet()

◆ add_sensor_plot()

◆ clear_pt_zeros()

combined_gui.SensorPlotWidget.clear_pt_zeros ( self)
Clear all PT zero offsets (restore raw calibration output).

Definition at line 1608 of file combined_gui.py.

References pt_offsets.

◆ code_to_voltage()

float combined_gui.SensorPlotWidget.code_to_voltage ( self,
int code_uint32 )
Convert raw ADC code to voltage.
code_uint32: uint32_t representation of the ADC code
Returns: voltage in Volts

Definition at line 1708 of file combined_gui.py.

References adc_bits, reference_voltage, SensorHotfire::StoredSensorConfig.reference_voltage, and SensorSM::StoredConfig.reference_voltage.

Referenced by on_sensor_data(), and solenoid_characterization_gui.SolenoidCharacterizationWindow.on_sensor_data().

◆ format_label_two_rows()

str combined_gui.SensorPlotWidget.format_label_two_rows ( self,
str text )
Format label text to always be two words, one per row.
Splits text into words and ensures exactly two words on separate lines.

Definition at line 1326 of file combined_gui.py.

References split().

◆ init_connector_plots()

combined_gui.SensorPlotWidget.init_connector_plots ( self)

◆ init_ui()

combined_gui.SensorPlotWidget.init_ui ( self)
Initialize the user interface

Definition at line 1389 of file combined_gui.py.

◆ on_auto_scale_toggled()

combined_gui.SensorPlotWidget.on_auto_scale_toggled ( self,
state )
Handle auto-scale Y-axis toggle

Definition at line 1622 of file combined_gui.py.

References y_axis_auto_scale.

◆ on_demo_mode_toggled()

combined_gui.SensorPlotWidget.on_demo_mode_toggled ( self,
state )
Handle Demo mode checkbox: toggle demo_mode, start/stop UDP sender, clear deques.

Uses QTimer.singleShot to defer state changes to avoid Wayland buffer size mismatch
crashes when the window is maximized (xdg_surface buffer error).

Definition at line 1644 of file combined_gui.py.

References _apply_demo_mode().

◆ on_display_moving_avg_changed()

combined_gui.SensorPlotWidget.on_display_moving_avg_changed ( self,
value )
Handle display moving average window size change

Definition at line 1704 of file combined_gui.py.

References display_moving_avg_samples.

◆ on_graph_moving_avg_changed()

combined_gui.SensorPlotWidget.on_graph_moving_avg_changed ( self,
value )
Handle graph moving average window size change

Definition at line 1700 of file combined_gui.py.

References graph_moving_avg_samples.

◆ on_navigation_requested()

combined_gui.SensorPlotWidget.on_navigation_requested ( self,
str target )

◆ on_packet_received()

combined_gui.SensorPlotWidget.on_packet_received ( self,
int packet_size,
int packet_type )
Handle packet received notification

Definition at line 1740 of file combined_gui.py.

◆ on_sensor_data()

◆ on_sensor_label_changed()

combined_gui.SensorPlotWidget.on_sensor_label_changed ( self,
int connector_id,
str text )
Update local sensor label and plot legend (config is written via set_sensor_role in settings).

Definition at line 1350 of file combined_gui.py.

References sensor_labels.

◆ on_status_update()

combined_gui.SensorPlotWidget.on_status_update ( self,
str message )

◆ open_debug_menu()

combined_gui.SensorPlotWidget.open_debug_menu ( self)
Open the debug popup showing C1, MA, psi per connector.

Definition at line 1617 of file combined_gui.py.

◆ reload_pt_calibration()

◆ save_events_csv()

combined_gui.SensorPlotWidget.save_events_csv ( self)
Save events (mode button clicks and actuator state changes) to CSV file.

Definition at line 2216 of file combined_gui.py.

References main_window_ref.

◆ save_pressures_csv()

combined_gui.SensorPlotWidget.save_pressures_csv ( self)
Save pressure data to CSV file, respecting only_show_pt_with_roles setting.

Definition at line 2080 of file combined_gui.py.

References only_show_pt_with_roles, pt_offsets, sensor_labels, and sensor_psi_history.

◆ update_buffer_size()

combined_gui.SensorPlotWidget.update_buffer_size ( self)

◆ update_plot_legend()

combined_gui.SensorPlotWidget.update_plot_legend ( self,
int connector_id )
Update the legend for a specific sensor plot

Definition at line 1369 of file combined_gui.py.

References sensor_labels, sensor_plots, and pt_multi_gui.PTPlotWindow.sensor_plots.

◆ update_plots()

◆ update_statistics()

◆ zero_pts()

combined_gui.SensorPlotWidget.zero_pts ( self)
Zero all PTs: capture current PSI reading for each calibrated sensor and store as offset.

Definition at line 1595 of file combined_gui.py.

References combined_gui.calculate_pressure(), display_moving_avg_samples, min, pt_calibration, pt_offsets, and sensor_adc_codes.

Member Data Documentation

◆ _send_demo_packet

combined_gui.SensorPlotWidget._send_demo_packet
protected

Definition at line 1663 of file combined_gui.py.

◆ adc_bits

int combined_gui.SensorPlotWidget.adc_bits = 32

◆ auto_scale_checkbox

combined_gui.SensorPlotWidget.auto_scale_checkbox = QtWidgets.QCheckBox("Auto-scale Y-axis")

Definition at line 1408 of file combined_gui.py.

◆ bind_address

combined_gui.SensorPlotWidget.bind_address = bind_address

◆ current_sps_display

combined_gui.SensorPlotWidget.current_sps_display = sps

Definition at line 2029 of file combined_gui.py.

◆ debug_values

dict combined_gui.SensorPlotWidget.debug_values = {}

Definition at line 1267 of file combined_gui.py.

◆ demo_mode

bool combined_gui.SensorPlotWidget.demo_mode = False

◆ demo_send_socket

Optional[socket.socket] combined_gui.SensorPlotWidget.demo_send_socket = None

Definition at line 1306 of file combined_gui.py.

Referenced by _apply_demo_mode(), and _send_demo_packet().

◆ demo_send_timer

Optional[QtCore.QTimer] combined_gui.SensorPlotWidget.demo_send_timer = None

Definition at line 1307 of file combined_gui.py.

Referenced by _apply_demo_mode().

◆ demo_start_time

Optional[float] combined_gui.SensorPlotWidget.demo_start_time = None

Definition at line 1305 of file combined_gui.py.

Referenced by _apply_demo_mode(), and _send_demo_packet().

◆ display_moving_avg_samples

int combined_gui.SensorPlotWidget.display_moving_avg_samples = 10

Definition at line 1215 of file combined_gui.py.

Referenced by on_display_moving_avg_changed(), and zero_pts().

◆ filter_source_ip

◆ graph_moving_avg_samples

tuple combined_gui.SensorPlotWidget.graph_moving_avg_samples
Initial value:
= (
1 # Moving average for graphed lines (1 = no smoothing)
)

Definition at line 1216 of file combined_gui.py.

Referenced by on_graph_moving_avg_changed(), and update_plots().

◆ last_sps_sample_count

int combined_gui.SensorPlotWidget.last_sps_sample_count = 0

Definition at line 1278 of file combined_gui.py.

Referenced by update_statistics().

◆ last_sps_time

combined_gui.SensorPlotWidget.last_sps_time = time.time()

Definition at line 1279 of file combined_gui.py.

Referenced by update_statistics().

◆ legend

combined_gui.SensorPlotWidget.legend

Definition at line 1382 of file combined_gui.py.

Referenced by add_sensor_plot().

◆ main_window_ref

◆ network_stats

dict combined_gui.SensorPlotWidget.network_stats
Initial value:
= {
"packets": "0",
"pps": "0.0",
"bytes": "0 B",
"bps": "0.0 B/s",
}

Definition at line 1269 of file combined_gui.py.

Referenced by sense_testing_gui.SenseTestingGUIWindow._update_plots(), and update_statistics().

◆ on_auto_scale_toggled

combined_gui.SensorPlotWidget.on_auto_scale_toggled

Definition at line 1410 of file combined_gui.py.

◆ on_packet_received

combined_gui.SensorPlotWidget.on_packet_received

Definition at line 1314 of file combined_gui.py.

◆ on_sensor_data

combined_gui.SensorPlotWidget.on_sensor_data

Definition at line 1312 of file combined_gui.py.

◆ on_status_update

combined_gui.SensorPlotWidget.on_status_update

Definition at line 1313 of file combined_gui.py.

◆ only_show_pt_with_roles

combined_gui.SensorPlotWidget.only_show_pt_with_roles = disp.get("only_show_pt_with_roles", False)

Definition at line 1300 of file combined_gui.py.

Referenced by save_pressures_csv(), and update_plots().

◆ plot_buffer_size

int combined_gui.SensorPlotWidget.plot_buffer_size = int(self.window_seconds * 1200) + 1000

◆ plot_enabled

◆ plot_item

combined_gui.SensorPlotWidget.plot_item
Initial value:
= self.plot_widget.addPlot(
title="Pressure Data Over Time (Calibrated Sensors)"
)

Definition at line 1490 of file combined_gui.py.

Referenced by solenoid_characterization_gui.SolenoidCharacterizationWindow._add_event_line(), add_sensor_plot(), solenoid_characterization_gui.SolenoidCharacterizationWindow.update_plot(), and update_plots().

◆ plot_widget

◆ pt_calibration

◆ pt_calibration_error

combined_gui.SensorPlotWidget.pt_calibration_error
Initial value:
= load_pt_calibration(
CONFIG.get_pt_calibration_csv_paths()
)

Definition at line 1251 of file combined_gui.py.

Referenced by reload_pt_calibration().

◆ pt_offsets

dict combined_gui.SensorPlotWidget.pt_offsets = {}

Definition at line 1257 of file combined_gui.py.

Referenced by clear_pt_zeros(), on_sensor_data(), save_pressures_csv(), and zero_pts().

◆ receiver

◆ reference_voltage

float combined_gui.SensorPlotWidget.reference_voltage = 2.5

◆ save_events_csv

combined_gui.SensorPlotWidget.save_events_csv

Definition at line 1421 of file combined_gui.py.

◆ save_pressures_csv

combined_gui.SensorPlotWidget.save_pressures_csv

Definition at line 1416 of file combined_gui.py.

◆ sensor_adc_codes

tuple combined_gui.SensorPlotWidget.sensor_adc_codes

◆ sensor_data

◆ sensor_labels

dict combined_gui.SensorPlotWidget.sensor_labels
Initial value:
= {
i: CONFIG.get_sensor_label(i) for i in range(1, NUM_CONNECTORS + 1)
}

Definition at line 1263 of file combined_gui.py.

Referenced by add_sensor_plot(), on_sensor_label_changed(), save_pressures_csv(), update_plot_legend(), and update_plots().

◆ sensor_plots

◆ sensor_psi_history

tuple combined_gui.SensorPlotWidget.sensor_psi_history

◆ sensor_psi_plot_t

dict combined_gui.SensorPlotWidget.sensor_psi_plot_t = {}

◆ sensor_psi_plot_v

dict combined_gui.SensorPlotWidget.sensor_psi_plot_v = {}

◆ settings_widget_ref

combined_gui.SensorPlotWidget.settings_widget_ref

Definition at line 1628 of file combined_gui.py.

◆ sps_text_item

combined_gui.SensorPlotWidget.sps_text_item
Initial value:
= pg.TextItem(
text="SPS: 0", color=(200, 200, 200), anchor=(0, 1)
)

Definition at line 1541 of file combined_gui.py.

Referenced by update_plots().

◆ stats_start_time

◆ stats_timer

combined_gui.SensorPlotWidget.stats_timer = QtCore.QTimer(self)

Definition at line 1322 of file combined_gui.py.

◆ status_label

◆ total_samples_received

int combined_gui.SensorPlotWidget.total_samples_received = 0

Definition at line 1277 of file combined_gui.py.

Referenced by on_sensor_data(), and update_statistics().

◆ under_graph_containers

tuple combined_gui.SensorPlotWidget.under_graph_containers
Initial value:
= (
{}
)

Definition at line 1453 of file combined_gui.py.

Referenced by _on_plot_toggle().

◆ under_graph_labels

dict combined_gui.SensorPlotWidget.under_graph_labels = {}

Definition at line 1449 of file combined_gui.py.

◆ under_graph_name_labels

tuple combined_gui.SensorPlotWidget.under_graph_name_labels

Definition at line 1355 of file combined_gui.py.

◆ update_plots

combined_gui.SensorPlotWidget.update_plots

◆ update_statistics

combined_gui.SensorPlotWidget.update_statistics

◆ update_timer

combined_gui.SensorPlotWidget.update_timer = QtCore.QTimer(self)

◆ window_seconds

◆ y_axis_auto_scale

combined_gui.SensorPlotWidget.y_axis_auto_scale = True

◆ y_axis_max

combined_gui.SensorPlotWidget.y_axis_max = 700.0

◆ y_axis_min

combined_gui.SensorPlotWidget.y_axis_min = 0.0

The documentation for this class was generated from the following file: