Skip to content
Snippets Groups Projects
Commit b788361c authored by Christoph Schmidt's avatar Christoph Schmidt
Browse files

Streaming can now be stopped.

parent aeea7340
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,6 @@ from rich.logging import RichHandler
from CaptDeviceControl.model.AD2CaptDeviceModel import AD2CaptDeviceModel, AD2CaptDeviceSignals
from CaptDeviceControl.model.AD2Constants import AD2Constants
from CaptDeviceControl.controller.mp_AD2Capture.MPCaptDeviceControl import MPCaptDeviceControl
from CaptDeviceControl.controller.mp_AD2Capture.MPCaptDevice import MPCaptDevice
......@@ -82,7 +81,6 @@ class BaseAD2CaptDevice(cmp.CProcessControl):
self.selected_ain_channel = self.model.analog_in.selected_ain_channel
def connect_signals(self):
self.dwf_version_changed.connect(self._on_dwf_version_changed)
self.discovered_devices_changed.connect(self.on_discovered_devices_changed)
......@@ -114,14 +112,15 @@ class BaseAD2CaptDevice(cmp.CProcessControl):
self.device_state_changed.connect(
lambda x: type(self.model.device_information).device_state.fset(self.model.device_information, x))
self.capture_process_state_changed.connect(
lambda x: type(self.model.capturing_information).device_capturing_state.fset(self.model.capturing_information, x))
lambda x: type(self.model.capturing_information).device_capturing_state.fset(
self.model.capturing_information, x))
self.open_device_finished.connect(self.on_open_device_finished)
def _connect_config_signals(self):
self.model.ad2captdev_config.streaming_history.connect(self._on_streaming_history_changed)
# self.model.ad2captdev_config.selected_device_index.connect(self._on_selected_device_index_changed)
# ==================================================================================================================
# Device control
# ==================================================================================================================
......@@ -154,6 +153,8 @@ class BaseAD2CaptDevice(cmp.CProcessControl):
def on_open_device_finished(self, device_handle: int):
self.logger.info(f"Opening device finished with handle {device_handle}")
self.start_capturing_process(self.model.capturing_information.sample_rate,
self.model.analog_in.selected_ain_channel)
def close_device(self):
pass
......@@ -167,10 +168,14 @@ class BaseAD2CaptDevice(cmp.CProcessControl):
:param ain_channel:
:return:
"""
self.kill_capture_flag.value = int(False)
self.streaming_dqueue = deque(maxlen=self.model.capturing_information.streaming_deque_length)
self.thread_manager.start(self.qt_consume_data)
self.thread_manager.start(self.qt_stream_data)
def stop_capturing_process(self):
self.kill_capture_flag.value = int(True)
def _on_streaming_history_changed(self, history: float):
self.streaming_dqueue = deque(maxlen=self.model.capturing_information.streaming_deque_length)
......@@ -193,8 +198,6 @@ class BaseAD2CaptDevice(cmp.CProcessControl):
def on_discovered_devices_changed(self, devices: list):
self.model.device_information.connected_devices = devices
def _on_selected_device_index_changed(self, index):
self.model.device_information.selected_device_index = index
......@@ -269,8 +272,6 @@ class BaseAD2CaptDevice(cmp.CProcessControl):
self.model.capturing_information.recorded_samples = []
self.model.measurement_time = 0
# ==================================================================================================================
def start_device_process(self):
self.logger.info(f"[{self.pref} Task] Starting capturing process...")
......
......@@ -282,7 +282,7 @@ class MPCaptDevice(cmp.CProcess, ):
self.logger.info(f"[Task] Closing device...")
self.dwf.FDwfDeviceClose(self.hdwf)
self.hdwf.value = 0
self._connected = self.connected()
self.connected = False
self.logger.info(f"[Task] Device closed.")
# ==================================================================================================================
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;stroke:#E6E6E6;stroke-width:0.875;stroke-miterlimit:10;}
</style>
<circle class="st0" cx="8" cy="8" r="7"/>
</svg>
......@@ -119,6 +119,9 @@ class ControlWindow(QMainWindow):
lambda: self.controller.start_capturing_process(self.model.capturing_information.sample_rate,
self.model.analog_in.selected_ain_channel)
)
self._ui.btn_stop.clicked.connect(self.controller.stop_capturing_process)
self._ui.btn_record.clicked.connect(self._ui_on_btn_recording_clicked)
self._ui.btn_reset.clicked.connect(self._ui_on_btn_reset_clicked)
......@@ -205,10 +208,10 @@ class ControlWindow(QMainWindow):
""" Gets called if the ui changes the field (should modify the model) """
self.model.analog_in.selected_ain_channel = channel_index
def _on_ui_btn_connect_clicked(self):
if self.model.device_information.device_connected:
self.controller.close_device()
self._ui.btn_connect.setText("Connect")
else:
#if self.model.device_information.device_connected:
# self.controller.close_device()
# self._ui.btn_connect.setText("Connect")
#else:
try:
self.controller.open_device(self.model.device_information.selected_device_index)
self.controller.start_capturing_process(
......@@ -216,7 +219,7 @@ class ControlWindow(QMainWindow):
)
except Exception as e:
self.logger.error(f"Error: {e}")
self._ui.btn_connect.setText("Disconnect")
#self._ui.btn_connect.setText("Disconnect")
self.capture_update_timer.start()
def _on_ui_sample_rate_changed(self, sample_rate: int):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment