print globals to quickly test access to all devices, fixed devices built from SmarActRecord, cleaned str of laser object, fixed __str__ cannot return None, fake epics device get method returns number to satisfy some string formatting

This commit is contained in:
2020-02-26 14:53:11 +00:00
parent b8e59c737b
commit 4d2b7bd7f6
4 changed files with 27 additions and 20 deletions
+8 -5
View File
@@ -1,6 +1,7 @@
import sys
sys.path.append("..")
from ..general.motors import MotorRecord
from ..general.smaract import SmarActRecord
from epics import PV
class Huber:
@@ -63,15 +64,17 @@ class Table:
% (self.x,self.y,self.z,self.pitch,self.yaw,self.modeSP.get(as_string=True),self.status.get())
class Microscope:
def __init__(self, Id, alias_namespace=None, z_undulator=None, description=None):
def __init__(self, Id, gonio=None, rotat=None, alias_namespace=None, z_undulator=None, description=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
# self._smaractaxes = {
# 'gonio': '_xmic_gon', # will become self.gonio
# 'rot': '_xmic_rot'} # """ self.rot
self.gonio = SmarActRecord(gonio) #TODO: can this be None?
self.rot = SmarActRecord(rotat) #TODO: can this be None?
def __str__(self):
return "Microscope positions\nfocus: %s\nzoom: %s\ngonio: %s\nrot: %s"\
+5 -1
View File
@@ -182,6 +182,8 @@ class SmarActRecord:
def get_current_value(self):
return self._rbv.get()
wm = get_current_value
# def set_current_value(self,value):
# return self._drive.put(value)
@@ -278,7 +280,9 @@ class SmarActStage:
def __init__(self, axes, name=None, z_undulator=None, description=None):
self._keys = axes.keys()
for axis in self._keys:
self.__dict__[axis] = axes[axis]
ax = axes[axis]
ax = SmarActRecord(ax)
self.__dict__[axis] = ax
self.name = name
def __str__(self):
+12 -6
View File
@@ -122,17 +122,23 @@ class Laser_Exp:
def get_adjustable_positions_str(self):
ostr = '*****Laser motor positions*****\n'
ostr = 'Laser motor positions\n'
for tkey,item in self.__dict__.items():
res = {}
for key, item in self.__dict__.items():
if hasattr(item,'get_current_value'):
pos = item.get_current_value()
ostr += ' ' + tkey.ljust(10) + ' : % 14g\n'%pos
elif hasattr(item,'get'):
pos = item.get()
ostr += ' ' + tkey.ljust(10) + ' : % 14g\n'%pos
pos = item.get()
else:
continue
res[key] = pos
length = max(len(k) for k in res) + 1
lines = sorted("{}:{}{}".format(k, " "*(length-len(k)), v) for k, v in res.items())
ostr += "\n".join(lines)
return ostr
#def pos(self):
+2 -8
View File
@@ -8,13 +8,6 @@ class AttenuatorAramis:
self._pv_status_int = PV(self.Id+':IDX_RB')
pass
def __call__(self):
pass
def __str__(self):
pass
def __status__(self):
pass
def updateE(self,energy = None):
if energy == None:
energy = PV("SARUN03-UIND030:FELPHOTENE").value
@@ -57,9 +50,10 @@ class AttenuatorAramis:
s += '%s'%self.get_status()[0]
return s
__str__ = __repr__
def __call__(self,*args,**kwargs):
self.set_transmission(*args,**kwargs)