first motorrecord class working with basic functionality

This commit is contained in:
2017-10-27 19:55:00 +02:00
parent f695745b89
commit 5d37904540
4 changed files with 44 additions and 22 deletions
+44 -22
View File
@@ -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()
Binary file not shown.
Binary file not shown.
Binary file not shown.