From f1d0702ad87c4b17470cd0173195ced394f48e46 Mon Sep 17 00:00:00 2001 From: Chris Karageorgiou Kaneen Date: Thu, 24 Dec 2020 22:52:35 +0200 Subject: [PATCH] Simplify `if emulator` branching in base --- pybpodapi/bpod/bpod_base.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pybpodapi/bpod/bpod_base.py b/pybpodapi/bpod/bpod_base.py index 880e5f6..60b8b03 100644 --- a/pybpodapi/bpod/bpod_base.py +++ b/pybpodapi/bpod/bpod_base.py @@ -272,23 +272,18 @@ def run_state_machine(self, sma): self.trial_timestamps = [] # Store the trial timestamps in case bpod is using live_timestamps - if self._emulator is None: - self._bpodcom_run_state_machine() - - if self._new_sma_sent and self._emulator is None: - if self._bpodcom_state_machine_installation_status(): - self._new_sma_sent = False - else: - raise BpodErrorException('Error: The last state machine sent was not acknowledged by the Bpod device.', self) - elif self._emulator: - self._emulator.set_state_machine(sma) - if self._emulator: + self._emulator.set_state_machine(sma) self._emulator.initialize() self._emulator.mirror_state(sma.current_state) # TODO: Do the BpodSystem.RefreshGUI equivalent self.trial_start_timestamp = self._emulator.matrix_start_time else: + self._bpodcom_run_state_machine() + if self._bpodcom_state_machine_installation_status(): + self._new_sma_sent = False + else: + raise BpodErrorException('Error: The last state machine sent was not acknowledged by the Bpod device.', self) self.trial_start_timestamp = self._bpodcom_get_trial_timestamp_start() if self.bpod_start_timestamp is None: