diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5942bbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.pyc +*.swp diff --git a/__pycache__/eco.cpython-35.pyc b/__pycache__/eco.cpython-35.pyc deleted file mode 100755 index e798083..0000000 Binary files a/__pycache__/eco.cpython-35.pyc and /dev/null differ diff --git a/acquisition/scan.py b/acquisition/scan.py new file mode 100644 index 0000000..33dc359 --- /dev/null +++ b/acquisition/scan.py @@ -0,0 +1,3 @@ +import pyscan + + diff --git a/aliases/bernina.py b/aliases/bernina.py index 8053b23..0e86b2d 100755 --- a/aliases/bernina.py +++ b/aliases/bernina.py @@ -104,6 +104,11 @@ aliases = { 'alias' : 'MonAtt', 'z_und' : 138, 'desc' : 'Intensity/Position monitor after Attenuator'}, + 'SAROP21-PPRM138' : { + 'alias' : 'ProfAtt', + 'z_und' : 138, + 'desc' : 'Profile monitor after Attenuator', + 'eco_type' : 'xdiagnostics.profile_monitors.Pprm'}, 'SAROP21-OKBV139' : { 'alias' : 'KbVer', 'z_und' : 139, @@ -122,7 +127,7 @@ aliases = { 'SARES20-PROF142-M1' : { 'alias' : 'Xeye', 'z_und' : 142, - 'desc' : 'General purpose station', + 'desc' : 'Mobile X-ray eye in Bernina hutch', 'eco_type' : 'xdiagnostics.profile_monitors.Bernina_XEYE'}, 'SLAAR21-LMOT' : { 'alias' : 'LasExp', diff --git a/devices_general/__pycache__/motors.cpython-35.pyc b/devices_general/__pycache__/motors.cpython-35.pyc deleted file mode 100755 index 6772636..0000000 Binary files a/devices_general/__pycache__/motors.cpython-35.pyc and /dev/null differ diff --git a/devices_general/detectors.py b/devices_general/detectors.py index d720b10..780a62f 100755 --- a/devices_general/detectors.py +++ b/devices_general/detectors.py @@ -1,14 +1,22 @@ import numpy as np from epics import caget +from epics import PV + +from cam_server import PipelineClient +from cam_server.utils import get_host_port_from_stream_address +from bsread import source, SUB +import subprocess + _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: @@ -26,8 +34,50 @@ class CameraCA: numpix = int(caget(self.Id+':FPICTURE.NORD')) i = caget(self.Id+':FPICTURE', count=numpix) return i.reshape(h,w) - - + + + def gui(self, guiType='xdm'): + """ Adjustable convention""" + cmd = ['caqtdm','-macro'] + + cmd.append('\"NAME=%s,CAMNAME=%s\"'%(self.Id, self.Id)) + cmd.append('/sf/controls/config/qt/Camera/CameraMiniView.ui') + return subprocess.Popen(' '.join(cmd),shell=True) + +#/sf/controls/config/qt/Camera/CameraMiniView.ui" with macro "NAME=SAROP21-PPRM138,CAMNAME=SAROP21-PPRM138 + +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..0b28125 100755 --- a/devices_general/motors.py +++ b/devices_general/motors.py @@ -1,6 +1,7 @@ from ..eco_epics.motor import Motor as _Motor import subprocess from threading import Thread +from epics import PV _MotorRocordStandardProperties = \ {} @@ -12,9 +13,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 @@ -39,15 +41,15 @@ class MotorRecord: pass - def get_current_value(self,posType='user'): + def get_current_value(self,posType='user',readback=True): """ Adjustable convention""" _keywordChecker([('posType',posType,_posTypes)]) if posType == 'user': - return self._motor.get_position() + return self._motor.get_position( readback=readback) if posType == 'dial': - return self._motor.get_position(dial=True) + return self._motor.get_position( readback=readback, dial=True) if posType == 'raw': - return self._motor.get_position(raw=True) + return self._motor.get_position( readback=readback, raw=True) def set_current_value(self,value,posType='user'): """ Adjustable convention""" @@ -79,6 +81,12 @@ class MotorRecord: """ Adjustable convention""" pass + def get_moveDone(self): + """ Adjustable convention""" + """ 0: moving 1: move done""" + return PV(str(self.Id+".DMOV")).value + + def set_limits(self, values, posType='user', relative_to_present=False): """ Adjustable convention""" _keywordChecker([('posType',posType,_posTypes)]) @@ -121,7 +129,11 @@ class MotorRecord: def wm(self,*args,**kwargs): return self.get_current_value(*args,**kwargs) def mvr(self,value,*args,**kwargs): - startvalue = self.get_current_value(*args,**kwargs) + + if(self.get_moveDone == 1): + startvalue = self.get_current_value(readback=True,*args,**kwargs) + else: + startvalue = self.get_current_value(readback=False,*args,**kwargs) self._currentChange = self.changeTo(value+startvalue,*args,**kwargs) def wait(self): self._currentChange.wait() @@ -134,6 +146,10 @@ class MotorRecord: def __repr__(self): return self.__str__() + def __call__(self,value,*args,**kwargs): + self.changeTo(value,*args,**kqwargs) + + diff --git a/eco_epics/__pycache__/__init__.cpython-35.pyc b/eco_epics/__pycache__/__init__.cpython-35.pyc deleted file mode 100755 index 51cda3b..0000000 Binary files a/eco_epics/__pycache__/__init__.cpython-35.pyc and /dev/null differ diff --git a/eco_epics/__pycache__/device.cpython-35.pyc b/eco_epics/__pycache__/device.cpython-35.pyc deleted file mode 100755 index f3f3e08..0000000 Binary files a/eco_epics/__pycache__/device.cpython-35.pyc and /dev/null differ diff --git a/eco_epics/__pycache__/motor.cpython-35.pyc b/eco_epics/__pycache__/motor.cpython-35.pyc deleted file mode 100755 index 469de92..0000000 Binary files a/eco_epics/__pycache__/motor.cpython-35.pyc and /dev/null differ diff --git a/instruments/__pycache__/bernina.cpython-35.pyc b/instruments/__pycache__/bernina.cpython-35.pyc deleted file mode 100755 index d5320d3..0000000 Binary files a/instruments/__pycache__/bernina.cpython-35.pyc and /dev/null differ 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/loptics/bernina_smaract_tower.py b/loptics/bernina_smaract_tower.py new file mode 100755 index 0000000..7e12ed1 --- /dev/null +++ b/loptics/bernina_smaract_tower.py @@ -0,0 +1,18 @@ +from ..devices_general.motors import MotorRecord +from epics import PV + +class Laser_Exp: + def __init__(self,Id): + self.Id = Id + + ### Mirrors used in the expeirment ### + try: + self.phi = MotorRecord(Id+'-M517:MOT') + except: + print('No Standa steering phi mirror') + pass + try: + self.th = MotorRecord(Id+'-M518:MOT') + except: + print('No Standa steering theta mirror') + pass diff --git a/loptics/standa_mirror.py b/loptics/standa_mirror.py new file mode 100755 index 0000000..7e12ed1 --- /dev/null +++ b/loptics/standa_mirror.py @@ -0,0 +1,18 @@ +from ..devices_general.motors import MotorRecord +from epics import PV + +class Laser_Exp: + def __init__(self,Id): + self.Id = Id + + ### Mirrors used in the expeirment ### + try: + self.phi = MotorRecord(Id+'-M517:MOT') + except: + print('No Standa steering phi mirror') + pass + try: + self.th = MotorRecord(Id+'-M518:MOT') + except: + print('No Standa steering theta mirror') + pass diff --git a/startup_scripts/__pycache__/eco.cpython-35.pyc b/startup_scripts/__pycache__/eco.cpython-35.pyc deleted file mode 100755 index da85629..0000000 Binary files a/startup_scripts/__pycache__/eco.cpython-35.pyc and /dev/null differ diff --git a/utilities/__pycache__/elog.cpython-35.pyc b/utilities/__pycache__/elog.cpython-35.pyc deleted file mode 100755 index 53579b6..0000000 Binary files a/utilities/__pycache__/elog.cpython-35.pyc and /dev/null differ diff --git a/xdiagnostics/__pycache__/__init__.cpython-35.pyc b/xdiagnostics/__pycache__/__init__.cpython-35.pyc deleted file mode 100755 index a303844..0000000 Binary files a/xdiagnostics/__pycache__/__init__.cpython-35.pyc and /dev/null differ diff --git a/xdiagnostics/__pycache__/profile_monitors.cpython-35.pyc b/xdiagnostics/__pycache__/profile_monitors.cpython-35.pyc deleted file mode 100755 index dce85b2..0000000 Binary files a/xdiagnostics/__pycache__/profile_monitors.cpython-35.pyc and /dev/null differ 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/__pycache__/attenuator_aramis.cpython-35.pyc b/xoptics/__pycache__/attenuator_aramis.cpython-35.pyc deleted file mode 100755 index f792874..0000000 Binary files a/xoptics/__pycache__/attenuator_aramis.cpython-35.pyc and /dev/null differ 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) + + +