mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2026-01-22 17:32:21 +01:00
refactor: fixed black formatting
This commit is contained in:
@@ -54,6 +54,7 @@ class SpmSim(SpmBase):
|
|||||||
|
|
||||||
def _simFrame(self):
|
def _simFrame(self):
|
||||||
"""Generator to simulate a jumping gaussian"""
|
"""Generator to simulate a jumping gaussian"""
|
||||||
|
|
||||||
# Define normalized 2D gaussian
|
# Define normalized 2D gaussian
|
||||||
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
||||||
return np.exp(
|
return np.exp(
|
||||||
|
|||||||
@@ -6,26 +6,30 @@ from typing import Any
|
|||||||
from ophyd import Component as Cpt
|
from ophyd import Component as Cpt
|
||||||
from ophyd import FormattedComponent as FCpt
|
from ophyd import FormattedComponent as FCpt
|
||||||
|
|
||||||
from ophyd import (
|
from ophyd import Device, EpicsSignal, EpicsSignalRO, Kind, PVPositioner, EpicsMotor
|
||||||
Device,
|
|
||||||
EpicsSignal,
|
|
||||||
EpicsSignalRO,
|
|
||||||
Kind,
|
|
||||||
PVPositioner,
|
|
||||||
EpicsMotor
|
|
||||||
)
|
|
||||||
from ophyd.pv_positioner import PVPositionerComparator
|
from ophyd.pv_positioner import PVPositionerComparator
|
||||||
|
|
||||||
__all__ = ["X07MAUndulator", "PGMMonochromator", "PGMOtFScan", "VacuumValve", "X07MAExitSlit",
|
__all__ = [
|
||||||
"X07MAMagnet", "X07MAAnalogSignals", "X07MASampleManipulator",
|
"X07MAUndulator",
|
||||||
"X07MATemperatureController", "X07MAAutoTemperatureControl"]
|
"PGMMonochromator",
|
||||||
|
"PGMOtFScan",
|
||||||
|
"VacuumValve",
|
||||||
|
"X07MAExitSlit",
|
||||||
|
"X07MAMagnet",
|
||||||
|
"X07MAAnalogSignals",
|
||||||
|
"X07MASampleManipulator",
|
||||||
|
"X07MATemperatureController",
|
||||||
|
"X07MAAutoTemperatureControl",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class X07MAUndulator(PVPositioner):
|
class X07MAUndulator(PVPositioner):
|
||||||
"""
|
"""
|
||||||
X07MA undulator
|
X07MA undulator
|
||||||
"""
|
"""
|
||||||
|
|
||||||
setpoint = Cpt(EpicsSignal, "ENERGY", auto_monitor=True)
|
setpoint = Cpt(EpicsSignal, "ENERGY", auto_monitor=True)
|
||||||
readback = Cpt(EpicsSignalRO, "ENERGY-READ", kind=Kind.hinted, auto_monitor=True)
|
readback = Cpt(EpicsSignalRO, "ENERGY-READ", kind=Kind.hinted, auto_monitor=True)
|
||||||
done = Cpt(EpicsSignalRO, "DONE", kind=Kind.omitted, auto_monitor=True)
|
done = Cpt(EpicsSignalRO, "DONE", kind=Kind.omitted, auto_monitor=True)
|
||||||
stop_signal = Cpt(EpicsSignal, "STOP", kind=Kind.omitted)
|
stop_signal = Cpt(EpicsSignal, "STOP", kind=Kind.omitted)
|
||||||
|
|
||||||
@@ -34,28 +38,33 @@ class X07MAUndulator(PVPositioner):
|
|||||||
pol_angle = Cpt(EpicsSignal, "ALPHA")
|
pol_angle = Cpt(EpicsSignal, "ALPHA")
|
||||||
harmonic = Cpt(EpicsSignal, "HARMONIC")
|
harmonic = Cpt(EpicsSignal, "HARMONIC")
|
||||||
|
|
||||||
|
|
||||||
class PGMMonochromator(PVPositioner):
|
class PGMMonochromator(PVPositioner):
|
||||||
"""
|
"""
|
||||||
PGM monochromator
|
PGM monochromator
|
||||||
"""
|
"""
|
||||||
|
|
||||||
setpoint = Cpt(EpicsSignal, "PHS-E:GO.A", auto_monitor=True)
|
setpoint = Cpt(EpicsSignal, "PHS-E:GO.A", auto_monitor=True)
|
||||||
readback = Cpt(EpicsSignalRO, "PGM:CERBK", kind=Kind.hinted, auto_monitor=True)
|
readback = Cpt(EpicsSignalRO, "PGM:CERBK", kind=Kind.hinted, auto_monitor=True)
|
||||||
done = Cpt(EpicsSignalRO, "PHS:alldone", kind=Kind.omitted, auto_monitor=True)
|
done = Cpt(EpicsSignalRO, "PHS:alldone", kind=Kind.omitted, auto_monitor=True)
|
||||||
stop_signal = Cpt(EpicsSignal, "PGM:stop", kind=Kind.omitted)
|
stop_signal = Cpt(EpicsSignal, "PGM:stop", kind=Kind.omitted)
|
||||||
|
|
||||||
cff = Cpt(EpicsSignal, "PGM:rbkcff", write_pv="PGM:cff.A", kind=Kind.config)
|
cff = Cpt(EpicsSignal, "PGM:rbkcff", write_pv="PGM:cff.A", kind=Kind.config)
|
||||||
with_undulator = Cpt(EpicsSignal, "PHS-E:OPT", kind=Kind.config)
|
with_undulator = Cpt(EpicsSignal, "PHS-E:OPT", kind=Kind.config)
|
||||||
|
|
||||||
|
|
||||||
class PGMOtFScan(Device):
|
class PGMOtFScan(Device):
|
||||||
"""
|
"""
|
||||||
PGM on-the-fly scan
|
PGM on-the-fly scan
|
||||||
"""
|
"""
|
||||||
|
|
||||||
e1 = Cpt(EpicsSignal, "E1")
|
e1 = Cpt(EpicsSignal, "E1")
|
||||||
e2 = Cpt(EpicsSignal, "E2")
|
e2 = Cpt(EpicsSignal, "E2")
|
||||||
time = Cpt(EpicsSignal, 'TIME')
|
time = Cpt(EpicsSignal, "TIME")
|
||||||
folder = Cpt(EpicsSignal, 'FOLDER')
|
folder = Cpt(EpicsSignal, "FOLDER")
|
||||||
file = Cpt(EpicsSignal, 'FILE')
|
file = Cpt(EpicsSignal, "FILE")
|
||||||
start = Cpt(EpicsSignal, 'START')
|
start = Cpt(EpicsSignal, "START")
|
||||||
|
|
||||||
|
|
||||||
class VacuumValve(PVPositionerComparator):
|
class VacuumValve(PVPositionerComparator):
|
||||||
"""
|
"""
|
||||||
@@ -67,14 +76,15 @@ class VacuumValve(PVPositionerComparator):
|
|||||||
|
|
||||||
The readback is of 8 choices
|
The readback is of 8 choices
|
||||||
0 - TO CONNECT
|
0 - TO CONNECT
|
||||||
1 - MAN OPEN
|
1 - MAN OPEN
|
||||||
2 - CLOSED
|
2 - CLOSED
|
||||||
3 - ERROR
|
3 - ERROR
|
||||||
4 - MOVING
|
4 - MOVING
|
||||||
5 - OPEN
|
5 - OPEN
|
||||||
6 - ERROR
|
6 - ERROR
|
||||||
7 - ERROR
|
7 - ERROR
|
||||||
"""
|
"""
|
||||||
|
|
||||||
setpoint = Cpt(EpicsSignal, "WT_SET")
|
setpoint = Cpt(EpicsSignal, "WT_SET")
|
||||||
readback = Cpt(EpicsSignalRO, "POSITION")
|
readback = Cpt(EpicsSignalRO, "POSITION")
|
||||||
|
|
||||||
@@ -82,44 +92,58 @@ class VacuumValve(PVPositionerComparator):
|
|||||||
kwargs.update({"limits": (0, 1)})
|
kwargs.update({"limits": (0, 1)})
|
||||||
super().__init__(prefix, name=name, **kwargs)
|
super().__init__(prefix, name=name, **kwargs)
|
||||||
|
|
||||||
def done_comparator(self, readback:Any, setpoint:Any) -> bool:
|
def done_comparator(self, readback: Any, setpoint: Any) -> bool:
|
||||||
return readback != 4
|
return readback != 4
|
||||||
|
|
||||||
|
|
||||||
class X07MAExitSlit(PVPositioner):
|
class X07MAExitSlit(PVPositioner):
|
||||||
"""
|
"""
|
||||||
Exit slit
|
Exit slit
|
||||||
"""
|
"""
|
||||||
|
|
||||||
setpoint = Cpt(EpicsSignal, "TR_AP")
|
setpoint = Cpt(EpicsSignal, "TR_AP")
|
||||||
readback = Cpt(EpicsSignalRO, "TR_ISAP", kind=Kind.hinted, auto_monitor=True)
|
readback = Cpt(EpicsSignalRO, "TR_ISAP", kind=Kind.hinted, auto_monitor=True)
|
||||||
done = Cpt(EpicsSignalRO, "TR.DMOV", kind=Kind.omitted, auto_monitor=True)
|
done = Cpt(EpicsSignalRO, "TR.DMOV", kind=Kind.omitted, auto_monitor=True)
|
||||||
|
|
||||||
|
|
||||||
class X07MAMagnet(Device):
|
class X07MAMagnet(Device):
|
||||||
"""
|
"""
|
||||||
Magnet fields.
|
Magnet fields.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class MagnetAxis(PVPositioner):
|
class MagnetAxis(PVPositioner):
|
||||||
"""
|
"""
|
||||||
A single magnet field axis.
|
A single magnet field axis.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
done_value = 2
|
done_value = 2
|
||||||
actuate_value = 1
|
actuate_value = 1
|
||||||
setpoint = FCpt(EpicsSignal, "{prefix}{_axis_id}:DMD")
|
setpoint = FCpt(EpicsSignal, "{prefix}{_axis_id}:DMD")
|
||||||
readback = FCpt(EpicsSignalRO, "{prefix}{_axis_id}:RBV", kind=Kind.hinted, auto_monitor=True)
|
readback = FCpt(
|
||||||
|
EpicsSignalRO, "{prefix}{_axis_id}:RBV", kind=Kind.hinted, auto_monitor=True
|
||||||
|
)
|
||||||
actuate = Cpt(EpicsSignal, "STARTRAMP.PROC", kind=Kind.omitted)
|
actuate = Cpt(EpicsSignal, "STARTRAMP.PROC", kind=Kind.omitted)
|
||||||
done = FCpt(EpicsSignalRO, '{_ps_prefix}STS:RAMP:MADE', kind=Kind.omitted, auto_monitor=True)
|
done = FCpt(
|
||||||
ramprate = FCpt(EpicsSignal, "{_ps_prefix}STS:RAMPRATE:TPM", write_pv="{_ps_prefix}SET:DMD:RAMPRATE:TPM")
|
EpicsSignalRO, "{_ps_prefix}STS:RAMP:MADE", kind=Kind.omitted, auto_monitor=True
|
||||||
|
)
|
||||||
|
ramprate = FCpt(
|
||||||
|
EpicsSignal, "{_ps_prefix}STS:RAMPRATE:TPM", write_pv="{_ps_prefix}SET:DMD:RAMPRATE:TPM"
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, prefix="", axis_id="", ps_prefix="", *, name=None, **kwargs):
|
def __init__(self, prefix="", axis_id="", ps_prefix="", *, name=None, **kwargs):
|
||||||
self._axis_id = axis_id
|
self._axis_id = axis_id
|
||||||
self._ps_prefix = ps_prefix
|
self._ps_prefix = ps_prefix
|
||||||
super().__init__(prefix, name=name, **kwargs)
|
super().__init__(prefix, name=name, **kwargs)
|
||||||
|
|
||||||
x = Cpt(MagnetAxis, '', axis_id='X', ps_prefix='X07MA-PC-PS2:', name='x')
|
x = Cpt(MagnetAxis, "", axis_id="X", ps_prefix="X07MA-PC-PS2:", name="x")
|
||||||
z = Cpt(MagnetAxis, '', axis_id='Z', ps_prefix='X07MA-PC-PS1:', name='z')
|
z = Cpt(MagnetAxis, "", axis_id="Z", ps_prefix="X07MA-PC-PS1:", name="z")
|
||||||
|
|
||||||
|
|
||||||
class X07MAAnalogSignals(Device):
|
class X07MAAnalogSignals(Device):
|
||||||
"""
|
"""
|
||||||
ADC inputs
|
ADC inputs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
s1 = Cpt(EpicsSignalRO, "SIGNAL0")
|
s1 = Cpt(EpicsSignalRO, "SIGNAL0")
|
||||||
s2 = Cpt(EpicsSignalRO, "SIGNAL1")
|
s2 = Cpt(EpicsSignalRO, "SIGNAL1")
|
||||||
s3 = Cpt(EpicsSignalRO, "SIGNAL2")
|
s3 = Cpt(EpicsSignalRO, "SIGNAL2")
|
||||||
@@ -135,25 +159,31 @@ class X07MAAnalogSignals(Device):
|
|||||||
field_z = s4
|
field_z = s4
|
||||||
field_x = s5
|
field_x = s5
|
||||||
|
|
||||||
|
|
||||||
class X07MASampleManipulator(Device):
|
class X07MASampleManipulator(Device):
|
||||||
"""
|
"""
|
||||||
Sample manipulator
|
Sample manipulator
|
||||||
"""
|
"""
|
||||||
|
|
||||||
hor = Cpt(EpicsMotor, "TRZS")
|
hor = Cpt(EpicsMotor, "TRZS")
|
||||||
vert = Cpt(EpicsMotor, "TRY1")
|
vert = Cpt(EpicsMotor, "TRY1")
|
||||||
rot = Cpt(EpicsMotor, "ROY1")
|
rot = Cpt(EpicsMotor, "ROY1")
|
||||||
|
|
||||||
|
|
||||||
class X07MATemperatureController(Device):
|
class X07MATemperatureController(Device):
|
||||||
"""
|
"""
|
||||||
Temperature controller
|
Temperature controller
|
||||||
"""
|
"""
|
||||||
needle_valve = Cpt(EpicsSignal, 'STS:LOOP2:MANUAL', write_pv='DMD:LOOP2:MANUAL')
|
|
||||||
setpoint = Cpt(EpicsSignal, 'STS:LOOP1:SETPOINT', write_pv='DMD:LOOP1:SETPOINT')
|
needle_valve = Cpt(EpicsSignal, "STS:LOOP2:MANUAL", write_pv="DMD:LOOP2:MANUAL")
|
||||||
readback = Cpt(EpicsSignalRO, 'STS:T1', kind=Kind.hinted, auto_monitor=True)
|
setpoint = Cpt(EpicsSignal, "STS:LOOP1:SETPOINT", write_pv="DMD:LOOP1:SETPOINT")
|
||||||
|
readback = Cpt(EpicsSignalRO, "STS:T1", kind=Kind.hinted, auto_monitor=True)
|
||||||
|
|
||||||
|
|
||||||
class X07MAAutoTemperatureControl(Device):
|
class X07MAAutoTemperatureControl(Device):
|
||||||
"""
|
"""
|
||||||
Automatic temperature control.
|
Automatic temperature control.
|
||||||
"""
|
"""
|
||||||
control = Cpt(EpicsSignal, 'CONTROL')
|
|
||||||
status = Cpt(EpicsSignalRO, 'STATUS', kind=Kind.hinted, string=True, auto_monitor=True)
|
control = Cpt(EpicsSignal, "CONTROL")
|
||||||
|
status = Cpt(EpicsSignalRO, "STATUS", kind=Kind.hinted, string=True, auto_monitor=True)
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class XbpmSim(XbpmBase):
|
|||||||
|
|
||||||
def _simFrame(self):
|
def _simFrame(self):
|
||||||
"""Generator to simulate a jumping gaussian"""
|
"""Generator to simulate a jumping gaussian"""
|
||||||
|
|
||||||
# define normalized 2D gaussian
|
# define normalized 2D gaussian
|
||||||
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, sy=1):
|
||||||
return np.exp(
|
return np.exp(
|
||||||
|
|||||||
@@ -559,7 +559,6 @@ class GalilMotor(Device, PositionerBase):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
mock = False
|
mock = False
|
||||||
if not mock:
|
if not mock:
|
||||||
leyey = GalilMotor("H", name="leyey", host="mpc2680.psi.ch", port=8081, sign=-1)
|
leyey = GalilMotor("H", name="leyey", host="mpc2680.psi.ch", port=8081, sign=-1)
|
||||||
|
|||||||
@@ -174,7 +174,6 @@ class NPointController(SingletonController):
|
|||||||
|
|
||||||
@channel_checked
|
@channel_checked
|
||||||
def _get_current_pos(self, channel: int) -> float:
|
def _get_current_pos(self, channel: int) -> float:
|
||||||
|
|
||||||
# for first channel: 0x11 83 13 34
|
# for first channel: 0x11 83 13 34
|
||||||
addr = self._channel_base.copy()
|
addr = self._channel_base.copy()
|
||||||
addr.extend([f"{19 + 16 * channel:x}", "34"])
|
addr.extend([f"{19 + 16 * channel:x}", "34"])
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ class NPointController(SingletonController):
|
|||||||
|
|
||||||
@channel_checked
|
@channel_checked
|
||||||
def _get_current_pos(self, channel: int) -> float:
|
def _get_current_pos(self, channel: int) -> float:
|
||||||
|
|
||||||
# for first channel: 0x11 83 13 34
|
# for first channel: 0x11 83 13 34
|
||||||
addr = self._channel_base.copy()
|
addr = self._channel_base.copy()
|
||||||
addr.extend([f"{19 + 16 * channel:x}", "34"])
|
addr.extend([f"{19 + 16 * channel:x}", "34"])
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ def is_serializable(f) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def get_user_interface(obj, obj_interface):
|
def get_user_interface(obj, obj_interface):
|
||||||
|
|
||||||
# user_funcs = get_user_functions(obj)
|
# user_funcs = get_user_functions(obj)
|
||||||
for f in [f for f in dir(obj) if f in obj.USER_ACCESS]:
|
for f in [f for f in dir(obj) if f in obj.USER_ACCESS]:
|
||||||
if f == "controller" or f == "on":
|
if f == "controller" or f == "on":
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ class Controller(OphydObject):
|
|||||||
labels=None,
|
labels=None,
|
||||||
kind=None,
|
kind=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
if not hasattr(self, "_initialized"):
|
if not hasattr(self, "_initialized"):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=name, attr_name=attr_name, parent=parent, labels=labels, kind=kind
|
name=name, attr_name=attr_name, parent=parent, labels=labels, kind=kind
|
||||||
|
|||||||
Reference in New Issue
Block a user