Skip to content

hardware_sets_view

frog.gui.hardware_set.hardware_sets_view ¤

Provides a panel for choosing between hardware sets and (dis)connecting.

Attributes¤

Classes¤

ActiveDeviceProperties(args, state) dataclass ¤

The properties of a device that is connecting or connected.

Attributes¤
args instance-attribute ¤

Arguments used to open the device.

state instance-attribute ¤

Whether the device is connecting or connected.

Functions¤
__post_init__() ¤

Check whether user attempted to create for a disconnected device.

Source code in frog/gui/hardware_set/hardware_sets_view.py
41
42
43
44
45
46
def __post_init__(self) -> None:
    """Check whether user attempted to create for a disconnected device."""
    if self.state == ConnectionStatus.DISCONNECTED:
        raise ValueError(
            "Cannot create ActiveDeviceProperties for disconnected device"
        )

HardwareSetsControl() ¤

Bases: QGroupBox

A panel for choosing between hardware sets and (dis)connecting.

Create a new HardwareSetsControl.

Source code in frog/gui/hardware_set/hardware_sets_view.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
def __init__(self) -> None:
    """Create a new HardwareSetsControl."""
    super().__init__("Hardware set")

    self._active_devices: dict[DeviceInstanceRef, ActiveDeviceProperties] = {}
    pub.subscribe(self._on_device_open_start, "device.before_opening")
    pub.subscribe(self._on_device_open_end, "device.after_opening")
    pub.subscribe(self._on_device_closed, "device.closed")
    pub.subscribe(self._on_device_error, "device.error")

    self._combo = HardwareSetsComboBox()
    """A combo box for the different hardware sets."""
    self._combo.setSizePolicy(
        QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum
    )
    if last_selected := _get_last_selected_hardware_set():
        self._combo.current_hardware_set = last_selected

    self._connect_btn = QPushButton("Connect")
    self._connect_btn.setSizePolicy(
        QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum
    )
    self._connect_btn.pressed.connect(self._on_connect_btn_pressed)
    self._disconnect_btn = QPushButton("Disconnect all")
    self._disconnect_btn.setSizePolicy(
        QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum
    )
    self._disconnect_btn.pressed.connect(self._on_disconnect_btn_pressed)

    import_hw_set_btn = QPushButton("Import config")
    import_hw_set_btn.pressed.connect(self._import_hardware_set)

    self._remove_hw_set_btn = QPushButton("Remove")
    self._remove_hw_set_btn.pressed.connect(self._remove_current_hardware_set)

    manage_devices_btn = QPushButton("Manage devices")
    manage_devices_btn.pressed.connect(self._show_manage_devices_dialog)
    self._manage_devices_dialog: ManageDevicesDialog

    row1 = QHBoxLayout()
    row1.addWidget(self._combo)
    row1.addWidget(self._connect_btn)
    row1.addWidget(self._disconnect_btn)
    row2 = QHBoxLayout()
    row2.addWidget(import_hw_set_btn)
    row2.addWidget(self._remove_hw_set_btn)
    row2.addWidget(manage_devices_btn)

    layout = QVBoxLayout()
    layout.addLayout(row1)
    layout.addLayout(row2)
    self.setLayout(layout)

    self._update_control_state()

    self._combo.currentIndexChanged.connect(self._update_control_state)
Functions¤

ManageDevicesDialog(connected_devices) ¤

Bases: QDialog

A dialog for manually opening, closing and configuring devices.

Create a new ManageDevicesDialog.

Parameters:

Name Type Description Default
connected_devices Set[OpenDeviceArgs]

Which devices are already connected

required
Source code in frog/gui/hardware_set/hardware_sets_view.py
68
69
70
71
72
73
74
75
76
77
78
79
80
def __init__(self, connected_devices: Set[OpenDeviceArgs]) -> None:
    """Create a new ManageDevicesDialog.

    Args:
        connected_devices: Which devices are already connected
    """
    super().__init__()
    self.setWindowTitle("Manage devices")
    self.setModal(True)

    layout = QVBoxLayout()
    layout.addWidget(DeviceControl(connected_devices))
    self.setLayout(layout)
Functions¤

Functions¤