Skip to content

Commit

Permalink
optional skipping of Bpod initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Nov 1, 2023
1 parent b2347ca commit c301402
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions iblrig/gui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def flush(self):
self.enable_UI_elements()

try:
bpod = Bpod(self.model.hardware_settings['device_bpod']['COM_BPOD']) # bpod is a singleton
bpod = Bpod(self.model.hardware_settings['device_bpod']['COM_BPOD'], skip_initialization=True)
bpod.manual_override(bpod.ChannelTypes.OUTPUT, bpod.ChannelNames.VALVE, 1, self.uiPushFlush.isChecked())
except (OSError, exceptions.bpod_error.BpodErrorException):
print(traceback.format_exc())
Expand All @@ -668,7 +668,7 @@ def toggle_status_led(self, is_toggled: bool):
self.enable_UI_elements()

try:
bpod = Bpod(self.model.hardware_settings['device_bpod']['COM_BPOD'])
bpod = Bpod(self.model.hardware_settings['device_bpod']['COM_BPOD'], skip_initialization=True)
bpod.set_status_led(is_toggled)
except (OSError, exceptions.bpod_error.BpodErrorException, AttributeError):
self.uiPushStatusLED.setChecked(False)
Expand Down
9 changes: 5 additions & 4 deletions iblrig/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def __new__(cls, *args, **kwargs):
Bpod._instances[serial_port] = instance
return instance

def __init__(self, *args, **kwargs):
# # skip initialization if it has already been performed before
# if self._is_initialized:
# return
def __init__(self, *args, skip_initialization: bool = False, **kwargs):
# skip initialization if it has already been performed before
# IMPORTANT: only use this for non-critical tasks (e.g., flushing valve from GUI)
if skip_initialization and self._is_initialized:
return

# try to instantiate once for nothing
try:
Expand Down

0 comments on commit c301402

Please sign in to comment.