Plugins were not meant to run standalone
This commit is contained in:
@@ -421,10 +421,19 @@ samzoom:
|
||||
readoutPriority: monitored
|
||||
readOnly: 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:
|
||||
description: Sample camera device
|
||||
deviceClass: ophyd_devices.devices.areadetector.cam.GenICam
|
||||
deviceConfig: {prefix: 'X06DA-SAMCAM:cam1:'}
|
||||
description: Sample camera aggregate device
|
||||
deviceClass: pxiii_bec.devices.SamCamDetector
|
||||
deviceConfig: {prefix: 'X06DA-SAMCAM:'}
|
||||
onFailure: buffer
|
||||
enabled: true
|
||||
readoutPriority: monitored
|
||||
@@ -452,15 +461,15 @@ samimg:
|
||||
readoutPriority: async
|
||||
readOnly: false
|
||||
softwareTrigger: false
|
||||
samimg_ad:
|
||||
description: Sample camera image via AD plugin
|
||||
deviceClass: ophyd_devices.devices.areadetector.plugins.ImagePlugin_V35
|
||||
deviceConfig: {prefix: 'X06DA-SAMCAM:image1:'}
|
||||
onFailure: buffer
|
||||
enabled: true
|
||||
readoutPriority: monitored
|
||||
readOnly: true
|
||||
softwareTrigger: false
|
||||
# samimg_ad:
|
||||
# description: Sample camera image via AD plugin
|
||||
# deviceClass: ophyd_devices.devices.areadetector.plugins.ImagePlugin_V35
|
||||
# deviceConfig: {prefix: 'X06DA-SAMCAM:image1:'}
|
||||
# onFailure: buffer
|
||||
# enabled: true
|
||||
# readoutPriority: monitored
|
||||
# readOnly: true
|
||||
# softwareTrigger: false
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
# -*- 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
|
||||
"""
|
||||
import numpy as np
|
||||
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
|
||||
|
||||
logger = bec_logger.logger
|
||||
|
||||
|
||||
class NDArrayPreview(Device):
|
||||
"""Wrapper class around AreaDetector's NDStdArray plugins
|
||||
|
||||
This is a monolithic class to display images from AreaDetector's
|
||||
ImagePlugin without the use of DynamicDeviceComponent or multiple
|
||||
interitance (that doesn't work with BEC).
|
||||
This is a standalone class to display images from AreaDetector's
|
||||
ImagePlugin without using a parent device. It also offers BEC exposed
|
||||
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
|
||||
USER_ACCESS = ["image", "savemode"]
|
||||
SUB_MONITOR = "device_monitor_2d"
|
||||
@@ -43,22 +50,22 @@ class NDArrayPreview(Device):
|
||||
)
|
||||
|
||||
def read(self):
|
||||
""" Stream out data on every read()"""
|
||||
if self._staged==Staged.yes:
|
||||
"""Stream out data on every read()"""
|
||||
if self._staged == Staged.yes:
|
||||
image = self.shaped_image.get()
|
||||
self._run_subs(sub_type=self.SUB_MONITOR, value=image)
|
||||
return super().read()
|
||||
|
||||
def savemode(self, save=False):
|
||||
""" Toggle save mode for the shaped image"""
|
||||
#pylint: disable=protected-access
|
||||
"""Toggle save mode for the shaped image"""
|
||||
# pylint: disable=protected-access
|
||||
if save:
|
||||
self.shaped_image._kind = Kind.normal
|
||||
else:
|
||||
self.shaped_image._kind = Kind.omitted
|
||||
|
||||
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())
|
||||
if array_size == (0, 0, 0):
|
||||
raise RuntimeError("Invalid image; ensure array_callbacks are on")
|
||||
@@ -70,7 +77,6 @@ class NDArrayPreview(Device):
|
||||
return np.array(image).reshape(array_size)
|
||||
|
||||
|
||||
|
||||
# Automatically connect to SAMCAM at PXIII if directly invoked
|
||||
if __name__ == "__main__":
|
||||
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 .StdDaqPreview import StdDaqPreviewDetector
|
||||
from .NDArrayPreview import NDArrayPreview
|
||||
from .SamCamDetector import SamCamDetector
|
||||
|
||||
Reference in New Issue
Block a user