From 5d379045407900e54026c4d840f5bc274f990d17 Mon Sep 17 00:00:00 2001 From: Henrik Lemke Date: Fri, 27 Oct 2017 19:55:00 +0200 Subject: [PATCH] first motorrecord class working with basic functionality --- devices_general/motors.py | 66 ++++++++++++------ eco_epics/__pycache__/__init__.cpython-35.pyc | Bin 193 -> 180 bytes eco_epics/__pycache__/device.cpython-35.pyc | Bin 11124 -> 11110 bytes eco_epics/__pycache__/motor.cpython-35.pyc | Bin 20251 -> 20238 bytes 4 files changed, 44 insertions(+), 22 deletions(-) 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 9fb2f4bb7bf1e5702cd2959f13a228d41c68c9b9..5e8f89a8c55385c07a4edf78987113fabd95b3bd 100644 GIT binary patch delta 47 zcmX@exP_5jjF*>7s_64X_FNeq{fzwFRQ;UP-0al&4E@~7f=d0=oek>dNIa#vnUCll_ zO)i``a6~I4E`T_41fQT6;MBk2{Q*640WOFG^Sw=*P07KZ-oE)}zL|M5{%hyqPHAdl zVswW7{IRrIHtgixa@e+u-LM<=V^wGi-wRYpdVvUg(k=x(>F)YMm0aI*V-edUho0Pb zqR{v4Ji92Ujzrj*>40#(NRORLj0V;mC3J+`ZG+Ui+~FZ zDtBfmotx7R^N+o%I6>=#Imk`rjXTqPVdZHO_j3#?AN8bF zqQ`2g(0BcwphYm20C2I3a^H)iel{R%%gOfi?@dHg`8^>m^E42xf?xqMS>Urax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5c 100644 GIT binary patch delta 36 scmbO|kFjqaBfA(cFIQ>N=Z);HOl+F^8Tq-Xo8y_xeHf!APxos90L=djcK`qY delta 49 zcmeC1$2fZ)BfA(cFV~L4Z#J^KG6|dMC#Dta7ZhjeC1>cD7N-{J=WGsQGWTJ;HMz^L F1pt`{5fT6Z