mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix: q selection for gui_event signal
This commit is contained in:
@ -15,6 +15,7 @@ from pyqtgraph.Qt import QtCore, QtWidgets, uic
|
|||||||
from pyqtgraph.Qt.QtCore import pyqtSignal
|
from pyqtgraph.Qt.QtCore import pyqtSignal
|
||||||
|
|
||||||
from bec_widgets.bec_dispatcher import bec_dispatcher
|
from bec_widgets.bec_dispatcher import bec_dispatcher
|
||||||
|
from bec_lib.core.redis_connector import MessageObject, RedisConnector
|
||||||
|
|
||||||
client = bec_dispatcher.client
|
client = bec_dispatcher.client
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ class BasicPlot(QtWidgets.QWidget):
|
|||||||
self.title = ""
|
self.title = ""
|
||||||
self.label_bottom = ""
|
self.label_bottom = ""
|
||||||
self.label_left = ""
|
self.label_left = ""
|
||||||
|
self.producer = RedisConnector(["localhost:6379"]).producer()
|
||||||
|
|
||||||
self.scan_motors = []
|
self.scan_motors = []
|
||||||
self.y_value_list = y_value_list
|
self.y_value_list = y_value_list
|
||||||
@ -160,6 +162,14 @@ class BasicPlot(QtWidgets.QWidget):
|
|||||||
"""For testing purpose now, get roi region and print it to self.label as tuple"""
|
"""For testing purpose now, get roi region and print it to self.label as tuple"""
|
||||||
region = self.roi_selector.getRegion()
|
region = self.roi_selector.getRegion()
|
||||||
self.label.setText(f"x = {(10**region[0]):.4f}, y ={(10**region[1]):.4f}")
|
self.label.setText(f"x = {(10**region[0]):.4f}, y ={(10**region[1]):.4f}")
|
||||||
|
return_dict = {
|
||||||
|
"qranges": [
|
||||||
|
np.where(self.plotter_data_x[0] > 10 ** region[0])[0][0],
|
||||||
|
np.where(self.plotter_data_x[0] < 10 ** region[1])[0][-1],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
msg = BECMessage.DeviceMessage(signals=return_dict).dumps()
|
||||||
|
self.producer.set_and_publish("px_stream/gui_event", msg=msg)
|
||||||
self.roi_signal.emit(region)
|
self.roi_signal.emit(region)
|
||||||
|
|
||||||
def add_text_items(self): # TODO probably can be removed
|
def add_text_items(self): # TODO probably can be removed
|
||||||
@ -388,14 +398,14 @@ class BasicPlot(QtWidgets.QWidget):
|
|||||||
data = [BECMessage.DeviceMessage.loads(msg) for msg in msgs]
|
data = [BECMessage.DeviceMessage.loads(msg) for msg in msgs]
|
||||||
if not data:
|
if not data:
|
||||||
continue
|
continue
|
||||||
|
with np.errstate(divide="ignore", invalid="ignore"):
|
||||||
self.plotter_data_y = [
|
self.plotter_data_y = [
|
||||||
np.sum(
|
np.sum(
|
||||||
np.sum(data[-1].content["signals"]["data"] * self._current_norm, axis=1)
|
np.sum(data[-1].content["signals"]["data"] * self._current_norm, axis=1)
|
||||||
/ np.sum(self._current_norm, axis=0),
|
/ np.sum(self._current_norm, axis=0),
|
||||||
axis=0,
|
axis=0,
|
||||||
).squeeze()
|
).squeeze()
|
||||||
]
|
]
|
||||||
|
|
||||||
self.update_signal.emit()
|
self.update_signal.emit()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user