Merge branch 'master' into TellSampleHandling
This commit is contained in:
@@ -127,7 +127,8 @@ class MainWindow(QMainWindow):
|
||||
self.beamline_view_layout.addWidget(self.beamline_view)
|
||||
|
||||
self.gonio_view = VideoGraphicsView()
|
||||
self.gonio_camera_thread = VideoThread(ip="axis-accc8ed2972e.psi.ch")
|
||||
#TODO add option to change cameras for gonio_camera_thread
|
||||
self.gonio_camera_thread = VideoThread(ip="axis-accc8ed2972e.psi.ch", camera=3)
|
||||
self.gonio_camera_thread.frame_ready.connect(self.gonio_view.update_frame)
|
||||
self.gonio_camera_thread.frame_ready.connect(self.beamline_view_1_combined.update_frame)
|
||||
self.gonio_camera_thread.start()
|
||||
@@ -455,6 +456,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
@Slot(DAQStatusModel)
|
||||
def update_daq_status(self, s: DAQStatusModel):
|
||||
self.beamline_camera_thread.set_busy(s.busy)
|
||||
self.gonio_camera_thread.set_busy(s.busy)
|
||||
if not self.__mounting and s.state == BeamlineStateEnum.RobotSampleExchange:
|
||||
self.__mounting = True
|
||||
self.video_tab.setCurrentIndex(3)
|
||||
|
||||
@@ -177,7 +177,7 @@ class ScanSettingsPanel(QWidget):
|
||||
# Handle target resolution (common to all panels)
|
||||
if (target_res := getattr(self._params, 'targetresolution', None)) is not None:
|
||||
self._high_res = target_res
|
||||
self.high_res_enter.force_update_value(self._high_res)
|
||||
self.high_res_enter.update_value(self._high_res)
|
||||
self.set_high_res(self._high_res)
|
||||
|
||||
# Store metadata (common to all panels)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import cv2
|
||||
import requests
|
||||
import numpy as np
|
||||
from PySide6.QtCore import QThread, Signal
|
||||
from PySide6.QtGui import QImage
|
||||
from PySide6.QtCore import QThread, Signal, QRect, QPoint
|
||||
from PySide6.QtGui import QImage, QPainter, QPen, QColor, Qt, QFontMetrics, QFont
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
@@ -10,19 +10,24 @@ class VideoThread(QThread):
|
||||
frame_ready = Signal(QImage)
|
||||
error_occurred = Signal(str)
|
||||
|
||||
def __init__(self, ip: str):
|
||||
def __init__(self, ip: str, camera = 1):
|
||||
super().__init__()
|
||||
self.camera_ip = ip
|
||||
self.running = False
|
||||
self.session = None
|
||||
self.last_good_frame = None
|
||||
self.camera: int = camera
|
||||
self.is_busy = False
|
||||
|
||||
def set_camera_ip(self, ip: str):
|
||||
self.camera_ip = ip
|
||||
|
||||
def set_busy(self, busy: bool):
|
||||
self.is_busy = busy
|
||||
|
||||
def run(self):
|
||||
# MJPEG URL
|
||||
mjpeg_url = f"http://{self.camera_ip}/axis-cgi/mjpg/video.cgi?resolution=1280x720&fps=10"
|
||||
mjpeg_url = f"http://{self.camera_ip}/axis-cgi/mjpg/video.cgi?resolution=1280x720&fps=20&compression=30&camera={self.camera}"
|
||||
|
||||
# Create a session for connection reuse
|
||||
self.session = requests.Session()
|
||||
@@ -122,6 +127,7 @@ class VideoThread(QThread):
|
||||
if self.last_good_frame is not None:
|
||||
self.frame_ready.emit(self.last_good_frame)
|
||||
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
if self.session:
|
||||
|
||||
@@ -157,14 +157,22 @@ class CheckedLineEdit(QWidget):
|
||||
def set_busy(self, busy: bool):
|
||||
# if an external wants to change the busy state.
|
||||
#update self._busy and change editor read only state. After enable/disable check_box and set colour
|
||||
self.blockSignals(True)
|
||||
self._busy = busy
|
||||
self.setReadOnly()
|
||||
self.check_box.blockSignals(True)
|
||||
|
||||
if self._busy:
|
||||
self.check_box.setEnabled(False)
|
||||
self.check_box.setStyleSheet("background-color: rgb(240, 240, 240);")
|
||||
if self._checked:
|
||||
self.editor.force_update_value(self._internal_value)
|
||||
|
||||
else:
|
||||
self.check_box.setEnabled(True)
|
||||
self.check_box.setStyleSheet("background-color: rgb(240, 240, 240);")
|
||||
self.check_box.setStyleSheet("background-color: rgb(255, 255, 255);")
|
||||
self.check_box.blockSignals(False)
|
||||
self.blockSignals(False)
|
||||
|
||||
def update_value(self, value):
|
||||
#wrapper for NumberLineEdit.update_value
|
||||
@@ -175,9 +183,10 @@ class CheckedLineEdit(QWidget):
|
||||
|
||||
def force_update_value(self, value):
|
||||
#wrapper for NumberLineEdit.force_update_value
|
||||
#self._external_value = value
|
||||
self.editor.force_update_value(value)
|
||||
self._on_editor_value_changed(value)
|
||||
self._external_value = value
|
||||
if not self._checked:
|
||||
self.editor.force_update_value(value)
|
||||
self._on_editor_value_changed(value)
|
||||
|
||||
@property
|
||||
def value(self) -> float:
|
||||
@@ -205,6 +214,7 @@ class CheckedLineEdit(QWidget):
|
||||
if not self._busy and self._checked: # Only set editor to writeable if busy is False and the checkbox is checked,
|
||||
should_be_ro = False
|
||||
self.editor.setReadOnly(False)
|
||||
|
||||
#state_changed = self.editor.isReadOnly() != should_be_ro
|
||||
self.editor.setReadOnly(should_be_ro)
|
||||
self.readOnlyChanged.emit(should_be_ro)
|
||||
|
||||
Reference in New Issue
Block a user