This commit is contained in:
@@ -1,29 +1,15 @@
|
|||||||
import epics
|
import epics
|
||||||
from epics import get_pv as _get_pv
|
from epics import get_pv as _get_pv
|
||||||
from epics import PV as _PV
|
|
||||||
import time
|
|
||||||
|
|
||||||
from epics.device import Device
|
from epics.device import Device
|
||||||
from epics.motor import MotorException
|
from epics.motor import MotorException
|
||||||
|
|
||||||
################################################################ en +++++++++++
|
|
||||||
class HastyPV(_PV):
|
|
||||||
def put(self, value, *args, **kwargs):
|
|
||||||
kwargs.setdefault("wait", True)
|
|
||||||
result = super().put(value, *args, **kwargs)
|
|
||||||
time.sleep(0.1)
|
|
||||||
return result
|
|
||||||
###################################################################
|
|
||||||
|
|
||||||
'''
|
|
||||||
# speed up: do not wait for the connection to happen
|
# speed up: do not wait for the connection to happen
|
||||||
def get_pv(*args, connect=False, timeout=0, **kwargs):
|
def get_pv(*args, connect=False, timeout=0, **kwargs):
|
||||||
return _get_pv(*args, connect=connect, timeout=timeout, **kwargs)
|
return _get_pv(*args, connect=connect, timeout=timeout, **kwargs)
|
||||||
'''
|
|
||||||
|
|
||||||
# speed up: do not wait for the connection to happen
|
|
||||||
def get_pv(*args, connect=False, timeout=0, **kwargs):
|
|
||||||
return HastyPV(*args, connect=connect, timeout=timeout, **kwargs)
|
|
||||||
|
|
||||||
# this is a copy of the epics.Motor constructor with some modifications
|
# this is a copy of the epics.Motor constructor with some modifications
|
||||||
class Motor(epics.Motor):
|
class Motor(epics.Motor):
|
||||||
@@ -34,23 +20,15 @@ class Motor(epics.Motor):
|
|||||||
raise MotorException("must supply motor name")
|
raise MotorException("must supply motor name")
|
||||||
|
|
||||||
if name.endswith('.VAL'):
|
if name.endswith('.VAL'):
|
||||||
print("Before :", name, "\n")
|
|
||||||
name = name[:-4]
|
name = name[:-4]
|
||||||
print("After :", name, "\n")
|
|
||||||
if name.endswith('.'):
|
if name.endswith('.'):
|
||||||
print("Before :", name, "\n")
|
|
||||||
name = name[:-1]
|
name = name[:-1]
|
||||||
print("After :", name, "\n")
|
|
||||||
|
|
||||||
|
|
||||||
self._prefix = name
|
self._prefix = name
|
||||||
print("LATER:", getattr(self, '_prefix'), "\n")
|
|
||||||
print("Prefix :", name, "\n")
|
|
||||||
Device.__init__(self, name, delim='.',
|
Device.__init__(self, name, delim='.',
|
||||||
attrs=self._init_list,
|
attrs=self._init_list,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
print("LATER:", getattr(self, '_prefix'), "\n")
|
|
||||||
print("After device :", name, "\n")
|
|
||||||
# speed up: do not get any data from PVs during construction
|
# speed up: do not get any data from PVs during construction
|
||||||
# # make sure this is really a motor!
|
# # make sure this is really a motor!
|
||||||
# rectype = self.get('RTYP')
|
# rectype = self.get('RTYP')
|
||||||
@@ -60,10 +38,8 @@ class Motor(epics.Motor):
|
|||||||
for key, val in self._extras.items():
|
for key, val in self._extras.items():
|
||||||
pvname = "%s%s" % (name, val)
|
pvname = "%s%s" % (name, val)
|
||||||
self.add_pv(pvname, attr=key)
|
self.add_pv(pvname, attr=key)
|
||||||
print("After add_pv:", name, "\n")
|
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
print("LATER:", getattr(self, '_prefix'), "\n")
|
|
||||||
print("End :", name, "\n")
|
|
||||||
|
|
||||||
|
|
||||||
# speed up: used by Motor.get_pv() with connect=True, i.e., waiting for connection
|
# speed up: used by Motor.get_pv() with connect=True, i.e., waiting for connection
|
||||||
|
|||||||
Reference in New Issue
Block a user