From fd7208ed3e7742b8617a88b6eb4470911019cfa8 Mon Sep 17 00:00:00 2001 From: Mohacsi Istvan Date: Tue, 22 Nov 2022 13:44:28 +0100 Subject: [PATCH] All devices instantiate --- ophyd_devices/epics/DeviceFactory.py | 4 +++ ophyd_devices/epics/db/x12sa_database.yml | 6 ++-- .../epics/devices/cSaxsVirtualMotors.py | 28 +++++++++++++++++++ ophyd_devices/epics/devices/specMotors.py | 4 +-- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 ophyd_devices/epics/devices/cSaxsVirtualMotors.py diff --git a/ophyd_devices/epics/DeviceFactory.py b/ophyd_devices/epics/DeviceFactory.py index 70676e6..7eafe8a 100644 --- a/ophyd_devices/epics/DeviceFactory.py +++ b/ophyd_devices/epics/DeviceFactory.py @@ -53,10 +53,14 @@ def createProxy(name: str, connect=True) -> OphydObject: if __name__ == "__main__": + num_errors = 0 for key in lut_db: try: dut = createProxy(str(key)) # print(f"{key}\t: {type(dut)}\t{dut.read()}") print(f"{key}\t: {type(dut)}") except Exception as ex: + num_errors += 1 + print(key) print(ex) + print(f"\nTotal number of errors: {num_errors}") diff --git a/ophyd_devices/epics/db/x12sa_database.yml b/ophyd_devices/epics/db/x12sa_database.yml index 874dd47..8bdae37 100644 --- a/ophyd_devices/epics/db/x12sa_database.yml +++ b/ophyd_devices/epics/db/x12sa_database.yml @@ -162,7 +162,7 @@ motrz1: motrz1e: desc: 'Monochromator crystal 1 axial movement encoder' acquisition: {schedule: sync} - config: {name: motrz1e, prefix: 'X12SA-OP-MO:ECZ1'} + config: {name: motrz1e, read_pv: 'X12SA-OP-MO:ECZ1'} deviceGroup: monitor status: {enabled: true} type: EpicsSignalRO @@ -176,7 +176,7 @@ motrz1e: moth1e: desc: 'Monochromator crystal 1 theta encoder' acquisition: {schedule: sync} - config: {name: moth1e, prefix: 'X12SA-OP-MO:ECX1'} + config: {name: moth1e, read_pv: 'X12SA-OP-MO:ECX1'} deviceGroup: monitor status: {enabled: true} type: EpicsSignalRO @@ -211,7 +211,7 @@ motry2: moth2e: desc: 'Monochromator crystal 2 theta encoder' acquisition: {schedule: sync} - config: {name: moth2e, prefix: 'X12SA-OP-MO:ECX2'} + config: {name: moth2e, read_pv: 'X12SA-OP-MO:ECX2'} deviceGroup: monitor status: {enabled: true} type: EpicsSignalRO diff --git a/ophyd_devices/epics/devices/cSaxsVirtualMotors.py b/ophyd_devices/epics/devices/cSaxsVirtualMotors.py new file mode 100644 index 0000000..b87825b --- /dev/null +++ b/ophyd_devices/epics/devices/cSaxsVirtualMotors.py @@ -0,0 +1,28 @@ + + +TABLES_DT_PUSH_DIST_MM = 890 + + +class DetectorTableTheta(PseudoPositioner): + """Detector table tilt motor + + Small wrapper to adjust the detector table tilt as angle. + The table is pushed from one side by a single vertical motor. + + Note: Rarely used! + """ + + # Real axis (in degrees) + pusher = Component(EpicsMotor, "", name="pusher") + # Virtual axis + theta = Component(PseudoSingle, name="theta") + + _real = ["pusher"] + + @pseudo_position_argument + def forward(self, pseudo_pos): + return self.RealPosition(pusher = tan(pseudo_pos.theta * 3.141592 / 180.0) * TABLES_DT_PUSH_DIST_MM) + + @real_position_argument + def inverse(self, real_pos): + return self.PseudoPosition(theta = -180 * atan(real_pos.pusher / TABLES_DT_PUSH_DIST_MM) / 3.141592) diff --git a/ophyd_devices/epics/devices/specMotors.py b/ophyd_devices/epics/devices/specMotors.py index f5d4e71..7afb824 100644 --- a/ophyd_devices/epics/devices/specMotors.py +++ b/ophyd_devices/epics/devices/specMotors.py @@ -8,7 +8,7 @@ IMPORTANT: Virtual monochromator axes should be implemented already in EPICS!!! """ import numpy as np -from math import isclose +from math import isclose, tan, atan from ophyd import ( EpicsSignal, EpicsSignalRO, @@ -20,7 +20,7 @@ from ophyd import ( Kind, ) from ophyd.pseudopos import pseudo_position_argument, real_position_argument -from ophyd.sim import SynAxis, Syn2DGauss + class PmMonoBender(PseudoPositioner):