Merge remote-tracking branch 'origin/master'

This commit is contained in:
Chris Milne
2018-01-26 09:03:26 +01:00
4 changed files with 116 additions and 70 deletions
+6 -8
View File
@@ -245,22 +245,20 @@ aliases = {
'z_und' : 0,
'desc' : 'PRISM rotation',
'eco_type' : 'devices_general.smaract.SmarActRecord',
'device' : 'prism',
'axis' : 'rot'},
'device' : 'prism', # a virtual stage for eco namespace
'axis' : 'rot'}, # a axis of this virtual stage
'SARES11-CMOV-SMA691113' : {
'alias' : '_xmic_gon',
'z_und' : 0,
'desc' : 'Mirror of the microscope, gonio',
'eco_type' : 'devices_general.smaract.SmarActRecord',
'device' : 'microscope',
'axis' : 'gonio'},
'eco_type' : 'devices_general.smaract.SmarActRecord'},
# no 'device' becauses its appended to other stage in
# ..endstations/alvra_prime.py
'SARES11-CMOV-SMA691114' : {
'alias' : '_xmic_rot',
'z_und' : 0,
'desc' : 'Mirror of the microscope, rot',
'eco_type' : 'devices_general.smaract.SmarActRecord',
'device' : 'microscope',
'axis' : 'rot'}
'eco_type' : 'devices_general.smaract.SmarActRecord'}
}
+13 -12
View File
@@ -7,8 +7,6 @@ from ..eco_epics.device import Device
_guiTypes = ['xdm']
fpath = '/gpfs/sf-data/home/gac-alvra/eco_debug_2' # DEBUG
def _keywordChecker(kw_key_list_tups):
for tkw,tkey,tlist in kw_key_list_tups:
assert tkey in tlist, "Keyword %s should be one of %s"%(tkw,tlist)
@@ -19,17 +17,13 @@ class SmarActException(Exception):
Exception.__init__(self, *args)
self.msg = msg
def __str__(self):
return str(self.msg)
return str(self.msg)
class SmarAct(Device):
_extras = {'disabled':'_able.VAL', }
_init_list = ('VAL', 'DESC', 'RTYP')
_nonpvs = ('_prefix', '_pvs', '_delim', '_init', '_init_list', '_alias', '_extras')
def __init__(self, name=None, timeout=3.0, record=None):
f=open(fpath,'a') # DEBUG
f.write('Processing '+self.__class__.__name__ +': '+ name +" : init \n")
f.flush
if name is None:
raise SmarActException("must supply SmarAct name")
@@ -52,8 +46,6 @@ class SmarAct(Device):
# self.add_pv(pvname, attr=key)
# self.put('disabled', 0)
f.write('Processing '+self.__class__.__name__ +': '+ name +" : done \n")
f.flush
class SmarActRecord:
def __init__(self,Id, name=None, elog=None):
@@ -261,7 +253,8 @@ class SmarActRecord:
# return string with motor value as variable representation
def __str__(self):
return "SmarAct is at %s %s"%(self.wm(),self.units)
return "SmarAct is at %s"%(self.wm())
#return "SmarAct is at %s %s"%(self.wm(),self.units)
def __repr__(self):
return self.__str__()
@@ -278,9 +271,17 @@ class SmarActDevice(SmarActRecord):
# self.x = SmarActRecord(Id+':DRIVE')
class SmarActStage:
def __init__(self, axes):
for axis in axes.keys():
def __init__(self, axes, name):
self._keys = axes.keys()
for axis in self._keys:
self.__dict__[axis] = axes[axis]
self.name = name
def __str__(self):
return "SmarAct positions\n%s" % "\n".join(["%s: %s"%(key,self.__dict__[key].wm()) for key in self._keys])
def __repr__(self):
return str({key:self.__dict__[key].wm() for key in self._keys})
class Changer:
def __init__(self, target=None, parent=None, mover=None, hold=True, stopper=None):
+64 -29
View File
@@ -4,39 +4,74 @@ from ..devices_general.motors import MotorRecord
from epics import PV
class huber:
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### Huber sample stages ###
self.x = MotorRecord(Id+':MOTOR_X1')
self.y = MotorRecord(Id+':MOTOR_Y1')
self.z = MotorRecord(Id+':MOTOR_Z1')
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### Huber sample stages ###
self.x = MotorRecord(Id+':MOTOR_X1')
self.y = MotorRecord(Id+':MOTOR_Y1')
self.z = MotorRecord(Id+':MOTOR_Z1')
def __str__(self):
return "Huber Stage %s\nx: %s mm\ny: %s mm\nz: %s mm" \
%(self.Id, self.x.wm(),self.y.wm(),self.z.wm())
def __repr__(self):
return "{'x': %s, 'y': %s, 'z': %s}"%(self.x.wm(),self.y.wm(),self.z.wm())
class vonHamosBragg:
def __init__(self,Id,alias_namespace=None):
self.Id = Id
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### Owis linear stages ###
self.cry1 = MotorRecord(Id+':CRY_1')
self.cry2 = MotorRecord(Id+':CRY_2')
### Owis linear stages ###
self.cry1 = MotorRecord(Id+':CRY_1')
self.cry2 = MotorRecord(Id+':CRY_2')
def __str__(self):
return "von Hamos positions\nCrystal 1: %s mm\nCrystal 2: %s mm" \
% (self.cry1.wm(),self.cry2.wm())
def __repr__(self):
return "{'cry 1': %s, 'cry 2': %s}" % (self.cry1.wm(),self.cry2.wm())
class table:
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### ADC optical table ###
self.x1 = MotorRecord(Id+':MOTOR_X1')
self.y1 = MotorRecord(Id+':MOTOR_Y1')
self.y2 = MotorRecord(Id+':MOTOR_Y2')
self.y3 = MotorRecord(Id+':MOTOR_Y3')
self.z1 = MotorRecord(Id+':MOTOR_Z1')
self.z2 = MotorRecord(Id+':MOTOR_Z2')
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### ADC optical table ###
self.x1 = MotorRecord(Id+':MOTOR_X1')
self.y1 = MotorRecord(Id+':MOTOR_Y1')
self.y2 = MotorRecord(Id+':MOTOR_Y2')
self.y3 = MotorRecord(Id+':MOTOR_Y3')
self.z1 = MotorRecord(Id+':MOTOR_Z1')
self.z2 = MotorRecord(Id+':MOTOR_Z2')
def __str__(self):
return "Table positions\nx1: %s mm\ny1: %s mm\ny2: %s\ny3: %s mm\nz1: %s mm\nz2: %s mm" \
% (self.x1.wm(),self.y1.wm(),self.y2.wm(),self.y3.wm(),self.z1.wm(),self.z2.wm())
def __repr__(self):
return "{'x1': %s, 'y1': %s,'y2': %s,'y3': %s, 'z1': %s, 'z2': %s}" \
% (self.x1,self.y1,self.y2,self.y3,self.z1,self.z2)
class microscope:
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### Microscope focus and zoom motors ###
self.focus = MotorRecord(Id+':FOCUS')
self.zoom = MotorRecord(Id+':ZOOM')
def __init__(self,Id,alias_namespace=None):
self.Id = Id
### Microscope motors ###
self.focus = MotorRecord(Id+':FOCUS')
self.zoom = MotorRecord(Id+':ZOOM')
self._smaractaxes = {
'gonio': '_xmic_gon', # will become self.gonio
'rot': '_xmic_rot'} # """ self.rot
def __str__(self):
return "Microscope positions\nfocus: %s\nzoom: %s\ngonio: %s\nrot: %s"\
% (self.focus.wm(),self.zoom.wm(),self.gonio.wm(),self.rot.wm())
def __repr__(self):
return "{'focus': %s, 'zoom': %s, 'gonio': %s, 'rot': %s}"\
% (self.focus.wm(),self.zoom.wm(),self.gonio.wm(),self.rot.wm())
# prism (as a SmarAct-only stage) is defined purely in ../aliases/alvra.py
+33 -21
View File
@@ -11,7 +11,7 @@ import traceback
elog = _Elog(_elog_info['url'],user='gac-alvra',screenshot_directory=_elog_info['screenshot_directory'])
screenshot = _Screenshot(screenshot_directory=_elog_info['screenshot_directory'])
_smaractappends = []
from ..aliases.alvra import aliases as _aliases
def _attach_device(devDict,devId,args,kwargs):
@@ -38,37 +38,49 @@ def _attach_device(devDict,devId,args,kwargs):
return error
errors = []
composed = {}
_composed = {}
for device_Id in _aliases.keys():
if 'eco_type' in _aliases[device_Id].keys() \
and _aliases[device_Id]['eco_type']:
if 'args' in _aliases[device_Id].keys() \
and _aliases[device_Id]['args']:
args = _aliases[device_Id]['args']
alias = _aliases[device_Id]
if 'eco_type' in alias.keys() \
and alias['eco_type']:
if 'args' in alias.keys() \
and alias['args']:
args = alias['args']
else:
args = tuple()
if 'kwargs' in _aliases[device_Id].keys() \
and _aliases[device_Id]['kwargs']:
kwargs = _aliases[device_Id]['kwargs']
if 'kwargs' in alias.keys() \
and alias['kwargs']:
kwargs = alias['kwargs']
else:
kwargs = dict()
e = _attach_device(_aliases[device_Id],device_Id,args,kwargs)
e = _attach_device(alias,device_Id,args,kwargs)
if e:
errors.append((_aliases[device_Id]['alias'],e))
errors.append((alias['alias'],e))
else:
device = _aliases[device_Id]
if device['eco_type'].endswith('SmarActRecord') \
and device['device'] and device['axis']:
if device['device'] not in composed:
composed[device['device']] = {}
composed[device['device']][device['axis']] = globals()[device['alias']]
_device = globals()[alias['alias'][0].lower()+alias['alias'][1:]]
if hasattr(_device, '_smaractaxes'):
_smaractappends.append(_device)
else:
if alias['eco_type'].endswith('SmarActRecord') \
and 'device' in alias and 'axis' in alias:
if alias['device'] not in _composed:
_composed[alias['device']] = {}
_composed[alias['device']][alias['axis']] = globals()[alias['alias']]
print('Integrating SmarAct devices:')
for _device in _smaractappends:
print(" Appending %s: %s" \
%(_device.name,', '.join(map(str, list(_device._smaractaxes.keys())))))
for _axis in _device._smaractaxes.keys():
setattr(_device, _axis, globals()[_device._smaractaxes[_axis]])
from ..devices_general.smaract import SmarActStage as _SmarActStage
for key in composed.keys():
print('Composing %s(%s)'%(key,', '.join(map(str, list(composed[key].keys())))))
globals()[key] = _SmarActStage(composed[key])
for _key in _composed.keys():
print(' Composing %s: %s'%(_key,', '.join(map(str, list(_composed[_key].keys())))))
globals()[_key] = _SmarActStage(_composed[_key], _key)
if len(errors)>0:
print('Found errors when configuring %s'%[te[0] for te in errors])