make use of new features in mx_bec #31
No files matched your search
@@ -14,6 +14,8 @@ logger = bec_logger.logger
|
||||
|
||||
_Widgets = {
|
||||
"PxIIActorConfigWiget": "PxIIActorConfigWiget",
|
||||
"PxIIAutomationPermissionWidget": "PxIIAutomationPermissionWidget",
|
||||
"PxIICurrentSampleWidget": "PxIICurrentSampleWidget",
|
||||
"PxIISampleQueueWidget": "PxIISampleQueueWidget",
|
||||
"PxIISpreadsheetDisplay": "PxIISpreadsheetDisplay",
|
||||
"PxIITaskPanel": "PxIITaskPanel",
|
||||
@@ -32,6 +34,40 @@ class PxIIActorConfigWiget(RPCBase):
|
||||
"""
|
||||
|
||||
|
||||
class PxIIAutomationPermissionWidget(RPCBase):
|
||||
_IMPORT_MODULE = "pxii_bec.bec_widgets.widgets.imported"
|
||||
|
||||
@rpc_call
|
||||
def grant_permission(self):
|
||||
"""
|
||||
Get a token for the current user from AareDAQ and forward it to the AareBec service.
|
||||
Returns at once; the outcome is shown in the widget.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def refresh(self):
|
||||
"""
|
||||
Reload the permission status from Redis.
|
||||
"""
|
||||
|
||||
|
||||
class PxIICurrentSampleWidget(RPCBase):
|
||||
_IMPORT_MODULE = "pxii_bec.bec_widgets.widgets.imported"
|
||||
|
||||
@rpc_call
|
||||
def refresh(self):
|
||||
"""
|
||||
Show the sample which was mounted last, as announced by the AareBec service.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def show_sample(self, sample_id: "int"):
|
||||
"""
|
||||
Fetch the record of the sample with this database id from AareDAQ and show it.
|
||||
Returns at once; the record, or why it could not be fetched, appears in the widget.
|
||||
"""
|
||||
|
||||
|
||||
class PxIISampleQueueWidget(RPCBase):
|
||||
_IMPORT_MODULE = "pxii_bec.bec_widgets.widgets.imported"
|
||||
|
||||
@@ -95,6 +131,12 @@ class PxIITaskQueueWidget(RPCBase):
|
||||
Delete the queue contents
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def start_queue(self):
|
||||
"""
|
||||
Try to start the queue
|
||||
"""
|
||||
|
||||
|
||||
class ScanHistory(RPCBase):
|
||||
_IMPORT_MODULE = "pxii_bec.bec_widgets.widgets.scan_history.scan_history"
|
||||
|
||||
@@ -6,6 +6,11 @@ from __future__ import annotations
|
||||
|
||||
designer_plugins = {
|
||||
"PxIIActorConfigWiget": ("pxii_bec.bec_widgets.widgets.imported", "PxIIActorConfigWiget"),
|
||||
"PxIIAutomationPermissionWidget": (
|
||||
"pxii_bec.bec_widgets.widgets.imported",
|
||||
"PxIIAutomationPermissionWidget",
|
||||
),
|
||||
"PxIICurrentSampleWidget": ("pxii_bec.bec_widgets.widgets.imported", "PxIICurrentSampleWidget"),
|
||||
"PxIISampleQueueWidget": ("pxii_bec.bec_widgets.widgets.imported", "PxIISampleQueueWidget"),
|
||||
"PxIISpreadsheetDisplay": ("pxii_bec.bec_widgets.widgets.imported", "PxIISpreadsheetDisplay"),
|
||||
"PxIITaskPanel": ("pxii_bec.bec_widgets.widgets.imported", "PxIITaskPanel"),
|
||||
@@ -15,6 +20,8 @@ designer_plugins = {
|
||||
|
||||
widget_icons = {
|
||||
"PxIIActorConfigWiget": "format_list_bulleted",
|
||||
"PxIIAutomationPermissionWidget": "key",
|
||||
"PxIICurrentSampleWidget": "science",
|
||||
"PxIISampleQueueWidget": "pending_actions",
|
||||
"PxIISpreadsheetDisplay": "format_list_bulleted",
|
||||
"PxIITaskPanel": "play_arrow",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from mx_bec.bec_widgets.widgets.aare_bec import (
|
||||
MxActorConfigWidget,
|
||||
MxAutomationPermissionWidget,
|
||||
MxCurrentSampleWidget,
|
||||
MxTaskPanel,
|
||||
MxTaskQueueWidget,
|
||||
SampleQueueWidget,
|
||||
@@ -20,3 +22,9 @@ class PxIITaskPanel(MxTaskPanel): ...
|
||||
|
||||
|
||||
class PxIISpreadsheetDisplay(SampleSpreadsheetDisplay): ...
|
||||
|
||||
|
||||
class PxIIAutomationPermissionWidget(MxAutomationPermissionWidget): ...
|
||||
|
||||
|
||||
class PxIICurrentSampleWidget(MxCurrentSampleWidget): ...
|
||||
@@ -0,0 +1 @@
|
||||
{'files': ['imported.py']}
|
||||
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
|
||||
from qtpy.QtWidgets import QWidget
|
||||
|
||||
from bec_widgets.utils.bec_designer import designer_material_icon
|
||||
from pxii_bec.bec_widgets.widgets.imported import PxIIAutomationPermissionWidget
|
||||
|
||||
DOM_XML = """
|
||||
<ui language='c++'>
|
||||
<widget class='PxIIAutomationPermissionWidget' name='px_ii_automation_permission_widget'>
|
||||
</widget>
|
||||
</ui>
|
||||
"""
|
||||
|
||||
|
||||
class PxIIAutomationPermissionWidgetPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._form_editor = None
|
||||
|
||||
def createWidget(self, parent):
|
||||
if parent is None:
|
||||
return QWidget()
|
||||
t = PxIIAutomationPermissionWidget(parent)
|
||||
return t
|
||||
|
||||
def domXml(self):
|
||||
return DOM_XML
|
||||
|
||||
def group(self):
|
||||
return ""
|
||||
|
||||
def icon(self):
|
||||
return designer_material_icon(PxIIAutomationPermissionWidget.ICON_NAME)
|
||||
|
||||
def includeFile(self):
|
||||
return "px_ii_automation_permission_widget"
|
||||
|
||||
def initialize(self, form_editor):
|
||||
self._form_editor = form_editor
|
||||
|
||||
def isContainer(self):
|
||||
return False
|
||||
|
||||
def isInitialized(self):
|
||||
return self._form_editor is not None
|
||||
|
||||
def name(self):
|
||||
return "PxIIAutomationPermissionWidget"
|
||||
|
||||
def toolTip(self):
|
||||
return "PxIIAutomationPermissionWidget"
|
||||
|
||||
def whatsThis(self):
|
||||
return self.toolTip()
|
||||
@@ -0,0 +1 @@
|
||||
{'files': ['imported.py']}
|
||||
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
|
||||
from qtpy.QtWidgets import QWidget
|
||||
|
||||
from bec_widgets.utils.bec_designer import designer_material_icon
|
||||
from pxii_bec.bec_widgets.widgets.imported import PxIICurrentSampleWidget
|
||||
|
||||
DOM_XML = """
|
||||
<ui language='c++'>
|
||||
<widget class='PxIICurrentSampleWidget' name='px_ii_current_sample_widget'>
|
||||
</widget>
|
||||
</ui>
|
||||
"""
|
||||
|
||||
|
||||
class PxIICurrentSampleWidgetPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._form_editor = None
|
||||
|
||||
def createWidget(self, parent):
|
||||
if parent is None:
|
||||
return QWidget()
|
||||
t = PxIICurrentSampleWidget(parent)
|
||||
return t
|
||||
|
||||
def domXml(self):
|
||||
return DOM_XML
|
||||
|
||||
def group(self):
|
||||
return ""
|
||||
|
||||
def icon(self):
|
||||
return designer_material_icon(PxIICurrentSampleWidget.ICON_NAME)
|
||||
|
||||
def includeFile(self):
|
||||
return "px_ii_current_sample_widget"
|
||||
|
||||
def initialize(self, form_editor):
|
||||
self._form_editor = form_editor
|
||||
|
||||
def isContainer(self):
|
||||
return False
|
||||
|
||||
def isInitialized(self):
|
||||
return self._form_editor is not None
|
||||
|
||||
def name(self):
|
||||
return "PxIICurrentSampleWidget"
|
||||
|
||||
def toolTip(self):
|
||||
return "PxIICurrentSampleWidget"
|
||||
|
||||
def whatsThis(self):
|
||||
return self.toolTip()
|
||||
@@ -0,0 +1,15 @@
|
||||
def main(): # pragma: no cover
|
||||
from qtpy import PYSIDE6
|
||||
|
||||
if not PYSIDE6:
|
||||
print("PYSIDE6 is not available in the environment. Cannot patch designer.")
|
||||
return
|
||||
from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
|
||||
|
||||
from pxii_bec.bec_widgets.widgets.px_ii_automation_permission_widget_plugin import PxIIAutomationPermissionWidgetPlugin
|
||||
|
||||
QPyDesignerCustomWidgetCollection.addCustomWidget(PxIIAutomationPermissionWidgetPlugin())
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
main()
|
||||
@@ -0,0 +1,15 @@
|
||||
def main(): # pragma: no cover
|
||||
from qtpy import PYSIDE6
|
||||
|
||||
if not PYSIDE6:
|
||||
print("PYSIDE6 is not available in the environment. Cannot patch designer.")
|
||||
return
|
||||
from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
|
||||
|
||||
from pxii_bec.bec_widgets.widgets.px_ii_current_sample_widget_plugin import PxIICurrentSampleWidgetPlugin
|
||||
|
||||
QPyDesignerCustomWidgetCollection.addCustomWidget(PxIICurrentSampleWidgetPlugin())
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
main()
|
||||
@@ -2,6 +2,9 @@
|
||||
find them through the `bec.messages` entry point registered by this package."""
|
||||
|
||||
from mx_bec.messages import (
|
||||
MXAutomationPermissionMessage,
|
||||
MXAutomationPermissionStatusMessage,
|
||||
MXForwardedAuthPublicKeyMessage,
|
||||
MXMeasurementSequenceMessage,
|
||||
MXQueueChangedMessage,
|
||||
MXSampleExecutionMessage,
|
||||
@@ -10,6 +13,9 @@ from mx_bec.messages import (
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"MXAutomationPermissionMessage",
|
||||
"MXAutomationPermissionStatusMessage",
|
||||
"MXForwardedAuthPublicKeyMessage",
|
||||
"MXMeasurementSequenceMessage",
|
||||
"MXTaskExecutionMessage",
|
||||
"MXSampleExecutionMessage",
|
||||
|
||||
Reference in new issue
Block a user