From 0d3f2b62ffcb102dadfb22619eba892d657650b2 Mon Sep 17 00:00:00 2001 From: Henrik Lemke Date: Sun, 12 Nov 2017 16:50:56 +0100 Subject: [PATCH] added more components --- devices_general/detectors.py | 40 +++++++++++++++++++++++++++++- devices_general/motors.py | 7 +++++- instruments/bernina.py | 1 + xdiagnostics/intensity_monitors.py | 9 +++++++ xoptics/attenuator_aramis.py | 22 +++++++++++++++- xoptics/offsetMirrors.py | 14 +++++++++++ xoptics/reflaser.py | 0 xoptics/slits.py | 29 ++++++++++++++++++++++ 8 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 xdiagnostics/intensity_monitors.py create mode 100644 xoptics/offsetMirrors.py create mode 100644 xoptics/reflaser.py create mode 100644 xoptics/slits.py diff --git a/devices_general/detectors.py b/devices_general/detectors.py index d720b10..1497e9d 100755 --- a/devices_general/detectors.py +++ b/devices_general/detectors.py @@ -1,14 +1,20 @@ import numpy as np from epics import caget +from cam_server import PipelineClient +from cam_server.utils import get_host_port_from_stream_address +from bsread import source, SUB + + _cameraArrayTypes = ['monochrome','rgb'] class CameraCA: - def __init__(self, pvname, cameraArrayType='monochrome'): + def __init__(self, pvname, cameraArrayType='monochrome',elog=None): self.Id = pvname self.isBS = False self.px_height = None self.px_width = None + self.elog = elog def get_px_height(self): if not self.px_height: @@ -28,6 +34,38 @@ class CameraCA: return i.reshape(h,w) +class CameraBS: + def __init__(self,Id,elog): + # First create the pipeline for the selected camera. + client = PipelineClient() + + self._instance_id, self._stream_address = \ + client.create_instance_from_config(\ + {"camera_name": Id}) + + # Extract the stream host and port from the stream_address. + self._stream_host, self._stream_port = \ + get_host_port_from_stream_address(stream_address) + self.checkServer() + + def checkServer(self): + # Check if your instance is running on the server. + if self._instance_id not in client.get_server_info()["active_instances"]: + raise ValueError("Requested pipeline is not running.") + def get_message(self): + # Open connection to the stream. When exiting the 'with' section, the source disconnects by itself. + with source(host=self._stream_host, port=self._stream_port, mode=SUB) as input_stream: + input_stream.connect() + + # Read one message. + message = input_stream.receive() + + # Print out the received stream data - dictionary. + # print("Dictionary with data:\n", message.data.data) + + # Print out the X center of mass. + # print("X center of mass: ", message.data.data["x_center_of_mass"].value) + return message.data diff --git a/devices_general/motors.py b/devices_general/motors.py index eeb0b91..2a7f7bb 100755 --- a/devices_general/motors.py +++ b/devices_general/motors.py @@ -12,9 +12,10 @@ def _keywordChecker(kw_key_list_tups): assert tkey in tlist, "Keyword %s should be one of %s"%(tkw,tlist) class MotorRecord: - def __init__(self,pvname): + def __init__(self,pvname, elog=None): self.Id = pvname self._motor = _Motor(pvname) + self._elog = elog # Conventional methods and properties for all Adjustable objects @@ -134,6 +135,10 @@ class MotorRecord: def __repr__(self): return self.__str__() + def __call__(self,value,*args,**kwargs): + self.changeTo(value,*args,**kqwargs) + + diff --git a/instruments/bernina.py b/instruments/bernina.py index db928e6..4d50d76 100755 --- a/instruments/bernina.py +++ b/instruments/bernina.py @@ -18,6 +18,7 @@ def _attach_device(devDict,devId): print(istr) exec(istr) tdev = eval('_%s(Id=\'%s\')'%(eco_type_name,devId)) + tdev.name = dev_alias globals().update([(dev_alias,tdev)]) diff --git a/xdiagnostics/intensity_monitors.py b/xdiagnostics/intensity_monitors.py new file mode 100644 index 0000000..75cb247 --- /dev/null +++ b/xdiagnostics/intensity_monitors.py @@ -0,0 +1,9 @@ + +class GasDetector: + def __init__(self): + pass + +class SolidTargetDetector: + def __init__(self): + pass + diff --git a/xoptics/attenuator_aramis.py b/xoptics/attenuator_aramis.py index 7fb27d8..c33f827 100755 --- a/xoptics/attenuator_aramis.py +++ b/xoptics/attenuator_aramis.py @@ -1,7 +1,27 @@ from ..devices_general.motors import MotorRecord class AttenuatorAramis: - def __init__(idpv='SAROP-OATT135'): + def __init__(Id,elog=None): + self.Id = Id + pass + def __call__(): + pass + def __str__(): + pass + def __status__(): + + def updateE(): + pass + def set_transmission(self,value): + pass + def setE(): + pass + + def get_transmission(self,E=current): + pass + + + diff --git a/xoptics/offsetMirrors.py b/xoptics/offsetMirrors.py new file mode 100644 index 0000000..19bdb12 --- /dev/null +++ b/xoptics/offsetMirrors.py @@ -0,0 +1,14 @@ +class OffsetMirror: + def __init__(self,Id,deflection='up',elog=None): + self.elog = elog + self.deflection = deflection + if deflection is 'up': + self.x + + def out(self): + pass + + def in(self): + pass + + diff --git a/xoptics/reflaser.py b/xoptics/reflaser.py new file mode 100644 index 0000000..e69de29 diff --git a/xoptics/slits.py b/xoptics/slits.py new file mode 100644 index 0000000..99fdd31 --- /dev/null +++ b/xoptics/slits.py @@ -0,0 +1,29 @@ +from ..devices_general.motors import MotorRecord + +class SlitJJ(Id,elog=None): + def __init__(): + pass + + def set_hg(self,value): + pass + + def set_vg(self,value): + pass + + def set_ho(self,value): + pass + + def set_vo(self,value): + pass + + def set_gap(self,hor,ver): + pass + + def set_offs(self,hor,ver): + pass + + def __call__(self,*args): + self.set_gap(*args) + + +