This commit is contained in:
2024-06-10 10:44:16 +02:00
parent 9256184430
commit 3093557c99
79 changed files with 2747 additions and 189 deletions

View File

@@ -178,9 +178,7 @@ def on_abort(parent_thread):
print ("Abort command: Run Engine pause request")
RE.request_pause()
return
tid=parent_thread.ident
exception = KeyboardInterrupt
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(exception))
_default_abort(parent_thread)
def on_close(parent_thread):
on_abort(parent_thread)
@@ -399,13 +397,7 @@ class ReaderWrapper():
self.precision = self.dev.getPrecision()
except:
self.precision = None
self.description = {self.name: { \
'dtype':'number', \
'shape': self.shape, \
'source': self.source, \
'precision': self.precision \
}}
self.dtype = 'number'
self.cfg_description = {"shape_str":{"dtype":"string", 'shape':(len(self.shape_str),), "source":""}, }
self.configuration = {"shape_str":{"value":self.shape_str, "timestamp":time.time()}}
self.name = self.name+self.shape_str
@@ -422,7 +414,13 @@ class ReaderWrapper():
raise __exception__
return {self.name:{"value":__return__, "timestamp":time.time()}}
def describe(self):
def describe(self):
self.description = {self.name: { \
'dtype':self.dtype , \
'shape': self.shape, \
'source': self.source, \
'precision': self.precision \
}}
return self.description
def describe_configuration(self):
@@ -470,6 +468,26 @@ class MoverWrapper(ReaderWrapper):
self.dev.stop()
#Wraps an Ophyd device as a Readable, so can be used in *scan commands
class Ophyd(Readable):
def __init__(self, dev):
for k in dev.describe().keys():
Nameable.__init__(self, k, Readable.__interfaces__ )
break
self.dev=dev
def read(self):
v = self.dev.read()
if (v is None) or (len(v)==0):
return None
v = v[self.getName()]
try:
timestamp = int(v["timestamp"]*1000)
except:
timestamp = time.time()
ret = TimestampedValue (v["value"], timestamp)
return ret
RE = RunEngine({}, during_task=EventProcessingTask())
if CAN_PAUSE: