Plugins were not meant to run standalone
This commit is contained in:
@@ -421,10 +421,19 @@ samzoom:
|
|||||||
readoutPriority: monitored
|
readoutPriority: monitored
|
||||||
readOnly: false
|
readOnly: false
|
||||||
softwareTrigger: false
|
softwareTrigger: false
|
||||||
|
# samcam:
|
||||||
|
# description: Sample camera device
|
||||||
|
# deviceClass: ophyd_devices.devices.areadetector.cam.GenICam
|
||||||
|
# deviceConfig: {prefix: 'X06DA-SAMCAM:cam1:'}
|
||||||
|
# onFailure: buffer
|
||||||
|
# enabled: true
|
||||||
|
# readoutPriority: monitored
|
||||||
|
# readOnly: false
|
||||||
|
# softwareTrigger: false
|
||||||
samcam:
|
samcam:
|
||||||
description: Sample camera device
|
description: Sample camera aggregate device
|
||||||
deviceClass: ophyd_devices.devices.areadetector.cam.GenICam
|
deviceClass: pxiii_bec.devices.SamCamDetector
|
||||||
deviceConfig: {prefix: 'X06DA-SAMCAM:cam1:'}
|
deviceConfig: {prefix: 'X06DA-SAMCAM:'}
|
||||||
onFailure: buffer
|
onFailure: buffer
|
||||||
enabled: true
|
enabled: true
|
||||||
readoutPriority: monitored
|
readoutPriority: monitored
|
||||||
@@ -452,15 +461,15 @@ samimg:
|
|||||||
readoutPriority: async
|
readoutPriority: async
|
||||||
readOnly: false
|
readOnly: false
|
||||||
softwareTrigger: false
|
softwareTrigger: false
|
||||||
samimg_ad:
|
# samimg_ad:
|
||||||
description: Sample camera image via AD plugin
|
# description: Sample camera image via AD plugin
|
||||||
deviceClass: ophyd_devices.devices.areadetector.plugins.ImagePlugin_V35
|
# deviceClass: ophyd_devices.devices.areadetector.plugins.ImagePlugin_V35
|
||||||
deviceConfig: {prefix: 'X06DA-SAMCAM:image1:'}
|
# deviceConfig: {prefix: 'X06DA-SAMCAM:image1:'}
|
||||||
onFailure: buffer
|
# onFailure: buffer
|
||||||
enabled: true
|
# enabled: true
|
||||||
readoutPriority: monitored
|
# readoutPriority: monitored
|
||||||
readOnly: true
|
# readOnly: true
|
||||||
softwareTrigger: false
|
# softwareTrigger: false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,35 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Standard DAQ preview image stream module
|
``NDArrayPreview`` --- Standalone Preview for ImagePlugin
|
||||||
|
*********************************************************
|
||||||
|
|
||||||
Created on Thu Jun 27 17:28:43 2024
|
This module provides a standalone object to receive images to ophyd from the
|
||||||
|
AreaDetector's ImagePlugin.
|
||||||
|
|
||||||
|
Created on Wed Jan 29 2025
|
||||||
|
|
||||||
@author: mohacsi_i
|
@author: mohacsi_i
|
||||||
"""
|
"""
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from ophyd import Device, Component, EpicsSignal, Kind, Staged
|
from ophyd import Device, Component, EpicsSignal, Kind, Staged
|
||||||
from ophyd.areadetector.base import NDDerivedSignal
|
from ophyd.areadetector import NDDerivedSignal
|
||||||
|
|
||||||
|
|
||||||
from bec_lib import bec_logger
|
from bec_lib import bec_logger
|
||||||
|
|
||||||
logger = bec_logger.logger
|
logger = bec_logger.logger
|
||||||
|
|
||||||
|
|
||||||
class NDArrayPreview(Device):
|
class NDArrayPreview(Device):
|
||||||
"""Wrapper class around AreaDetector's NDStdArray plugins
|
"""Wrapper class around AreaDetector's NDStdArray plugins
|
||||||
|
|
||||||
This is a monolithic class to display images from AreaDetector's
|
This is a standalone class to display images from AreaDetector's
|
||||||
ImagePlugin without the use of DynamicDeviceComponent or multiple
|
ImagePlugin without using a parent device. It also offers BEC exposed
|
||||||
interitance (that doesn't work with BEC).
|
methods to transfer image and change image array Kind-ness.
|
||||||
|
|
||||||
NOTE: As an explicit request, it doesnt record the data, unless
|
NOTE: As an explicit request, it can toggle data recording
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Subscriptions for plotting image
|
# Subscriptions for plotting image
|
||||||
USER_ACCESS = ["image", "savemode"]
|
USER_ACCESS = ["image", "savemode"]
|
||||||
SUB_MONITOR = "device_monitor_2d"
|
SUB_MONITOR = "device_monitor_2d"
|
||||||
@@ -43,22 +50,22 @@ class NDArrayPreview(Device):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
""" Stream out data on every read()"""
|
"""Stream out data on every read()"""
|
||||||
if self._staged==Staged.yes:
|
if self._staged == Staged.yes:
|
||||||
image = self.shaped_image.get()
|
image = self.shaped_image.get()
|
||||||
self._run_subs(sub_type=self.SUB_MONITOR, value=image)
|
self._run_subs(sub_type=self.SUB_MONITOR, value=image)
|
||||||
return super().read()
|
return super().read()
|
||||||
|
|
||||||
def savemode(self, save=False):
|
def savemode(self, save=False):
|
||||||
""" Toggle save mode for the shaped image"""
|
"""Toggle save mode for the shaped image"""
|
||||||
#pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
if save:
|
if save:
|
||||||
self.shaped_image._kind = Kind.normal
|
self.shaped_image._kind = Kind.normal
|
||||||
else:
|
else:
|
||||||
self.shaped_image._kind = Kind.omitted
|
self.shaped_image._kind = Kind.omitted
|
||||||
|
|
||||||
def image(self):
|
def image(self):
|
||||||
""" Fallback method in case image streaming fills up the BEC"""
|
"""Fallback method in case image streaming fills up the BEC"""
|
||||||
array_size = (self.array_size_z.get(), self.array_size_y.get(), self.array_size_x.get())
|
array_size = (self.array_size_z.get(), self.array_size_y.get(), self.array_size_x.get())
|
||||||
if array_size == (0, 0, 0):
|
if array_size == (0, 0, 0):
|
||||||
raise RuntimeError("Invalid image; ensure array_callbacks are on")
|
raise RuntimeError("Invalid image; ensure array_callbacks are on")
|
||||||
@@ -70,7 +77,6 @@ class NDArrayPreview(Device):
|
|||||||
return np.array(image).reshape(array_size)
|
return np.array(image).reshape(array_size)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Automatically connect to SAMCAM at PXIII if directly invoked
|
# Automatically connect to SAMCAM at PXIII if directly invoked
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
img = NDArrayPreview("X06DA-SAMCAM:image1:", name="samimg")
|
img = NDArrayPreview("X06DA-SAMCAM:image1:", name="samimg")
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
``SamCam`` --- Sample Camera control software
|
||||||
|
*********************************************
|
||||||
|
|
||||||
|
This module provides an object to control the sample camera at the PX III
|
||||||
|
beamline. The camera should run continously and stream data via ZMQ for
|
||||||
|
the GUI and alignment scripts.
|
||||||
|
|
||||||
|
Created on Thu Jan 30 2025
|
||||||
|
|
||||||
|
@author: mohacsi_i
|
||||||
|
"""
|
||||||
|
from ophyd import ADComponent
|
||||||
|
from ophyd_devices.devices.areadetector.cam import GenICam
|
||||||
|
from ophyd_devices.devices.areadetector.plugins import ImagePlugin_V35
|
||||||
|
from ophyd_devices.interfaces.base_classes.psi_detector_base import (
|
||||||
|
PSIDetectorBase,
|
||||||
|
CustomDetectorMixin,
|
||||||
|
)
|
||||||
|
|
||||||
|
from bec_lib import bec_logger
|
||||||
|
|
||||||
|
logger = bec_logger.logger
|
||||||
|
|
||||||
|
|
||||||
|
class SamCamSetup(CustomDetectorMixin):
|
||||||
|
def on_stage(self):
|
||||||
|
"""Just make sure it's running continously"""
|
||||||
|
self.parent.cam.acquire.put(1, wait=True)
|
||||||
|
|
||||||
|
def on_unstage(self):
|
||||||
|
"""Should run continously"""
|
||||||
|
|
||||||
|
def on_stop(self):
|
||||||
|
"""Should run continously"""
|
||||||
|
|
||||||
|
|
||||||
|
class SamCamDetector(PSIDetectorBase):
|
||||||
|
"""Sample camera device
|
||||||
|
|
||||||
|
The SAMCAM continously streams images to the GUI and sample alignment
|
||||||
|
scripts via ZMQ.
|
||||||
|
"""
|
||||||
|
|
||||||
|
custom_prepare_cls = SamCamSetup
|
||||||
|
|
||||||
|
cam = ADComponent(GenICam, "cam1:")
|
||||||
|
image = ADComponent(ImagePlugin_V35, "image1:")
|
||||||
@@ -9,3 +9,4 @@ from .A3200utils import A3200Axis
|
|||||||
from .SmarGon import SmarGonAxis
|
from .SmarGon import SmarGonAxis
|
||||||
from .StdDaqPreview import StdDaqPreviewDetector
|
from .StdDaqPreview import StdDaqPreviewDetector
|
||||||
from .NDArrayPreview import NDArrayPreview
|
from .NDArrayPreview import NDArrayPreview
|
||||||
|
from .SamCamDetector import SamCamDetector
|
||||||
|
|||||||
Reference in New Issue
Block a user