diff --git a/devices_general/motors.py b/devices_general/motors.py index 3c51286..75e80b0 100644 --- a/devices_general/motors.py +++ b/devices_general/motors.py @@ -1,4 +1,6 @@ -from ...eco_epics.motor import Motor as _Motor +from ..eco_epics.motor import Motor as _Motor +import subprocess +from threading import Thread _MotorRocordStandardProperties = \ {} @@ -6,7 +8,7 @@ _posTypes = ['user','dial','raw'] _guiTypes = ['xdm'] def _keywordChecker(kw_key_list_tups): - for tkw,tkey,tlist in keyw_list_pairs: + for tkw,tkey,tlist in kw_key_list_tups: assert tkey in tlist, "Keyword %s should be one of %s"%(tkw,tlist) class MotorRecord: @@ -19,15 +21,16 @@ class MotorRecord: """ Adjustable convention""" mover = lambda value: self._motor.move(\ - value, ignore_limits=(not check)) + value, ignore_limits=(not check), + wait=True) return Changer( target=value, parent=self, mover=mover, - stopper=self._motor.stop, - blocker) + hold=hold, + stopper=self._motor.stop) - def get_position(self,posType='user'): + def get_current_value(self,posType='user'): """ Adjustable convention""" _keywordChecker([('posType',posType,_posTypes)]) if posType == 'user': @@ -37,7 +40,7 @@ class MotorRecord: if posType == 'raw': return self._motor.get_position(raw=True) - def set_position(self,value,posType='user'): + def set_current_value(self,value,posType='user'): """ Adjustable convention""" _keywordChecker([('posType',posType,_posTypes)]) if posType == 'user': @@ -74,7 +77,12 @@ class MotorRecord: def gui(self, guiType='xdm'): """ Adjustable convention""" - pass + cmd = ['caqtdm','-macro'] + + cmd.append('\"P=%s:,M=%s\"'%tuple(self.Id.split(':'))) + cmd.append('/sf/common/config/qt/motorx_all.ui') + print(cmd) + return subprocess.run(cmd) # epics motor record specific methods @@ -82,13 +90,14 @@ class MotorRecord: # spec-inspired convenience methods def mv(self,value): - pass - def wm(self): - pass - def mvr(self,value): - pass + self._currentChange = self.changeTo(value) + def wm(self,*args,**kwargs): + self.get_current_value(*args,**kwargs) + def mvr(self,value,*args,**kwargs): + startvalue = self.get_current_value(*args,**kwargs) + self._currentChange = self.changeTo(value+startvalue,*args,**kwargs) def wait(self): - pass + self._currentChange.wait() @@ -102,17 +111,30 @@ class MotorRecord: class Changer: - def __init__(self, parent=None, mover=None, hold=True, ): - - pass + def __init__(self, target=None, parent=None, mover=None, hold=True, stopper=None): + self.target = target + self._mover = mover + self._stopper = stopper + self._thread = Thread(target=self._mover,args=(target,)) + if not hold: + self._thread.start() + def wait(self): - pass + self._thread.join() + def start(self): - pass + self._thread.start() + def status(self): - pass - - + if self._thread.ident is None: + return 'waiting' + else: + if self._isAlive: + return 'changing' + else: + return 'done' + def stop(self): + self._stopper() diff --git a/eco_epics/__pycache__/__init__.cpython-35.pyc b/eco_epics/__pycache__/__init__.cpython-35.pyc index 9fb2f4b..5e8f89a 100644 Binary files a/eco_epics/__pycache__/__init__.cpython-35.pyc and b/eco_epics/__pycache__/__init__.cpython-35.pyc differ diff --git a/eco_epics/__pycache__/device.cpython-35.pyc b/eco_epics/__pycache__/device.cpython-35.pyc index 5c91ff9..3011fdf 100644 Binary files a/eco_epics/__pycache__/device.cpython-35.pyc and b/eco_epics/__pycache__/device.cpython-35.pyc differ diff --git a/eco_epics/__pycache__/motor.cpython-35.pyc b/eco_epics/__pycache__/motor.cpython-35.pyc index f5f0361..dc98da5 100644 Binary files a/eco_epics/__pycache__/motor.cpython-35.pyc and b/eco_epics/__pycache__/motor.cpython-35.pyc differ