Files
alvra/adhoc.py
2021-12-06 13:03:08 +01:00

85 lines
2.6 KiB
Python

from types import SimpleNamespace
from time import sleep
from epics import PV
from slic.core.adjustable import PVAdjustable
from slic.devices.device import Device
from slic.devices.simpledevice import SimpleDevice
from slic.devices.general.motor import Motor
from slic.devices.general.delay_stage import DelayStage
from slic.devices.general.smaract import SmarActAxis
from slic.devices.xoptics.dcm import CoupledDoubleCrystalMonoEnergyWithTimeCorrection
laser_pitch = SmarActAxis("SARES11-XICM125:ROX1")
laser_trans = SmarActAxis("SARES11-XICM125:TRX1")
laser_yaw = SmarActAxis("SARES11-XICM125:ROY1")
microscope_pitch = SmarActAxis("SARES11-XMI125:ROY1")
microscope_yaw = SmarActAxis("SARES11-XMI125:ROZ1")
CDCMEWTC = CoupledDoubleCrystalMonoEnergyWithTimeCorrection(limit_low=2450, limit_high=2520)
PSSS = Motor("SARFE10-PSSS059:MOTOR_Y3", name="PSSS XTAL y")
opo_delay = PVAdjustable("SLAAR03-LTIM-PDLY:DELAY", name="OPO Delay")
class TXS(Device):
def __init__(self, ID="SAROP11-PTXS128", name="TXS"):
super().__init__(ID, name=name)
self.x = Motor(ID + ":TRX1")
self.y = Motor(ID + ":TRY1")
self.z = Motor(ID + ":TRZ1")
self.crystals = SimpleDevice("TXS Crystals",
left = SimpleDevice("Left Crystals",
linear = SmarActAxis(ID + ":TRX11"),
rotary = SmarActAxis(ID + ":ROTY11"),
gonio1 = SmarActAxis(ID + ":ROTX11"),
gonio2 = SmarActAxis(ID + ":ROTX12"),
gonio3 = SmarActAxis(ID + ":ROTX13")
),
right = SimpleDevice("Right Crystals",
linear = SmarActAxis(ID + ":TRX21"),
rotary = SmarActAxis(ID + ":ROTY21"),
gonio1 = SmarActAxis(ID + ":ROTX21"),
gonio2 = SmarActAxis(ID + ":ROTX22"),
gonio3 = SmarActAxis(ID + ":ROTX23")
)
)
from colorama import Fore, Style
class Deprecator:
def __init__(self, old_name, new_name):
self._old_name = old_name
self._new_name = new_name
def __repr__(self):
return ""
def __getattr__(self, name):
print(
Fore.RED +
f"\"{self._old_name}\" has been renamed \"{self._new_name}\""
+ Style.RESET_ALL
)
return lambda *args, **kwargs: self._method(self._new_name, name, *args, **kwargs)
def _method(self, new_name, meth_name, *args, **kwargs):
args = [repr(v) for v in args]
args += [f"{k}={repr(v)}" for k, v in kwargs.items()]
args = ", ".join(args)
print(f"please use the following command instead:\n {new_name}.{meth_name}({args})")