diff --git a/output_view_ui.py b/output_view_ui.py index 3c86310..906125c 100644 --- a/output_view_ui.py +++ b/output_view_ui.py @@ -158,11 +158,16 @@ def close(self): if self.e4_view: self.e4_view.stop_plot() self.e4_view.disconnect_e4() - if self.video_view.player: - self.video_view.player.loading = False - if self.video_view.recorder: - self.video_view.recorder.stop_recording() - self.video_view.recorder.stop_playback() + if self.video_view: + if self.video_view.player: + self.video_view.player.loading = False + if self.video_view.recorder: + self.video_view.recorder.stop_recording() + self.video_view.recorder.stop_playback() + if self.ble_view: + self.ble_view.disconnect_ble() + if self.woodway_view: + self.woodway_view.disconnect_woodway() def start_session(self, recording_path=None): if self.e4_view: @@ -405,6 +410,9 @@ def disable_ui_elements(self): self.prot_load_button.config(state='disabled') self.calibrate_button.config(state='disabled') + def __enable_connect_button(self): + self.woodway_connect_button.config(state='active') + def __disable_ui_elements(self): self.belt_incline_l.config(state='disabled') self.belt_speed_l.config(state='disabled') @@ -432,10 +440,12 @@ def start_session(self): self.__save_protocol_to_file() def stop_session(self): - self.session_started = False - self.woodway.belt_a.set_speed(0.0) - self.woodway.belt_b.set_speed(0.0) - self.woodway.set_elevations(0.0) + if self.woodway: + self.session_started = False + self.woodway.belt_a.set_speed(0.0) + self.woodway.belt_b.set_speed(0.0) + self.woodway.set_elevations(0.0) + self.woodway.close() def next_protocol_step(self, current_time): if current_time == 1: @@ -591,12 +601,11 @@ def __connect_to_woodway(self): def disconnect_woodway(self): if self.woodway: self.woodway.stop_belts() - self.woodway.set_elevations(0) + self.woodway.set_elevations(float(0.0)) self.woodway.close() self.woodway = None self.__disable_ui_elements() - else: - messagebox.showwarning("Warning", "Connect to Woodway first!") + self.__enable_connect_button() def __write_speed(self): if self.session_started: @@ -818,6 +827,7 @@ def stop_session(self): self.session_started = False self.right_vta.stop_imu() self.left_vta.stop_imu() + self.disconnect_ble() def is_calibrated(self): return self.calibrated diff --git a/ui_params.py b/ui_params.py index db8eea5..d5f91ac 100644 --- a/ui_params.py +++ b/ui_params.py @@ -1,4 +1,4 @@ -cometrics_version = "1.1.1" +cometrics_version = "1.1.3" ui_title = f"cometrics v{cometrics_version}" cometrics_data_root = fr'C:\cometrics'