provide setup for MLZ_Amagnet to be used @PSI soon
Also implement lots of fixes and improvements. fixes: #3381 Change-Id: Ibe6664da00756ae5813b90f190295045808b2ff0
This commit is contained in:
@ -223,10 +223,10 @@ def getfqdn(name=''):
|
||||
return socket.getfqdn(name)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print "minimal testing: lib"
|
||||
d = attrdict(a=1, b=2)
|
||||
_ = d.a + d['b']
|
||||
d.c = 9
|
||||
d['d'] = 'c'
|
||||
assert d[d.d] == 9
|
||||
# if __name__ == '__main__':
|
||||
# print "minimal testing: lib"
|
||||
# d = attrdict(a=1, b=2)
|
||||
# _ = d.a + d['b']
|
||||
# d.c = 9
|
||||
# d['d'] = 'c'
|
||||
# assert d[d.d] == 9
|
||||
|
@ -177,7 +177,6 @@ class ArgsParser(object):
|
||||
self.length = len(string)
|
||||
|
||||
def setstring(self, string):
|
||||
print repr(string)
|
||||
self.string = string
|
||||
self.idx = 0
|
||||
self.length = len(string)
|
||||
@ -191,7 +190,6 @@ class ArgsParser(object):
|
||||
def get(self):
|
||||
res = self.peek()
|
||||
self.idx += 1
|
||||
print "get->", res
|
||||
return res
|
||||
|
||||
def skip(self):
|
||||
@ -222,17 +220,14 @@ class ArgsParser(object):
|
||||
idx = self.idx
|
||||
res = self.parse_array()
|
||||
if res:
|
||||
print "is Array"
|
||||
return res
|
||||
self.idx = idx
|
||||
res = self.parse_record()
|
||||
if res:
|
||||
print "is record"
|
||||
return res
|
||||
self.idx = idx
|
||||
res = self.parse_string()
|
||||
if res:
|
||||
print "is string"
|
||||
return res
|
||||
self.idx = idx
|
||||
return self.parse_number()
|
||||
@ -388,26 +383,26 @@ def parse_args(s):
|
||||
|
||||
__ALL__ = ['format_time', 'parse_time', 'parse_args']
|
||||
|
||||
if __name__ == '__main__':
|
||||
print "minimal testing: lib/parsing:"
|
||||
print "time_formatting:",
|
||||
t = time.time()
|
||||
s = format_time(t)
|
||||
assert (abs(t - parse_time(s)) < 1e-6)
|
||||
print "OK"
|
||||
# if __name__ == '__main__':
|
||||
# print "minimal testing: lib/parsing:"
|
||||
# print "time_formatting:",
|
||||
# t = time.time()
|
||||
# s = format_time(t)
|
||||
# assert (abs(t - parse_time(s)) < 1e-6)
|
||||
# print "OK"#
|
||||
#
|
||||
# print "ArgsParser:"
|
||||
# a = ArgsParser()
|
||||
# print a.parse('[ "\'\\\"A" , "<>\'", \'",C\', [1.23e1, 123.0e-001] , ]')
|
||||
|
||||
print "ArgsParser:"
|
||||
a = ArgsParser()
|
||||
print a.parse('[ "\'\\\"A" , "<>\'", \'",C\', [1.23e1, 123.0e-001] , ]')
|
||||
# #import pdb
|
||||
# #pdb.run('print a.parse()', globals(), locals())
|
||||
|
||||
#import pdb
|
||||
#pdb.run('print a.parse()', globals(), locals())
|
||||
|
||||
print "args_formatting:",
|
||||
for obj in [1, 2.3, 'X', (1, 2, 3), [1, (3, 4), 'X,y']]:
|
||||
s = format_args(obj)
|
||||
p = a.parse(s)
|
||||
print p,
|
||||
assert (parse_args(format_args(obj)) == obj)
|
||||
print "OK"
|
||||
print "OK"
|
||||
# print "args_formatting:",
|
||||
# for obj in [1, 2.3, 'X', (1, 2, 3), [1, (3, 4), 'X,y']]:
|
||||
# s = format_args(obj)
|
||||
# p = a.parse(s)
|
||||
# print p,
|
||||
# assert (parse_args(format_args(obj)) == obj)
|
||||
# print "OK"
|
||||
# print "OK"
|
||||
|
@ -36,6 +36,7 @@ class Namespace(object):
|
||||
|
||||
|
||||
class Step(object):
|
||||
|
||||
def __init__(self, desc, waittime, func, *args, **kwds):
|
||||
self.desc = desc
|
||||
self.waittime = waittime
|
||||
@ -126,7 +127,7 @@ class SequencerMixin(object):
|
||||
"""Can be called to check if a sequence is currently running."""
|
||||
return self._seq_thread and self._seq_thread.isAlive()
|
||||
|
||||
def read_status(self):
|
||||
def read_status(self, maxage=0):
|
||||
if self.seq_is_alive():
|
||||
return status.BUSY, 'moving: ' + self._seq_phase
|
||||
elif self._seq_error:
|
||||
@ -138,7 +139,7 @@ class SequencerMixin(object):
|
||||
return status.ERROR, self._seq_stopped
|
||||
return status.WARN, self._seq_stopped
|
||||
if hasattr(self, 'read_hw_status'):
|
||||
return self.read_hw_status()
|
||||
return self.read_hw_status(maxage)
|
||||
return OK, ''
|
||||
|
||||
def do_stop(self):
|
||||
@ -151,6 +152,9 @@ class SequencerMixin(object):
|
||||
except Exception as e:
|
||||
self.log.exception('unhandled error in sequence thread: %s', e)
|
||||
self._seq_error = str(e)
|
||||
finally:
|
||||
self._seq_thread = None
|
||||
self.poll(0)
|
||||
|
||||
def _seq_thread_inner(self, seq, store_init):
|
||||
store = Namespace()
|
||||
@ -163,19 +167,24 @@ class SequencerMixin(object):
|
||||
try:
|
||||
while True:
|
||||
result = step.func(store, *step.args)
|
||||
if self._seq_.stopflag:
|
||||
if self._seq_stopflag:
|
||||
if result:
|
||||
self._seq_stopped = 'stopped while %s' % step.desc
|
||||
else:
|
||||
self._seq_stopped = 'stopped after %s' % step.desc
|
||||
cleanup_func = step.kwds.get('cleanup', None)
|
||||
if callable(cleanup_func):
|
||||
cleanup_func(store, *step.args)
|
||||
try:
|
||||
cleanup_func(store, result, *step.args)
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
raise
|
||||
return
|
||||
sleep(step.waittime)
|
||||
if not result:
|
||||
break
|
||||
except Exception as e:
|
||||
self.log.exception('error in sequence step: %s', e)
|
||||
self.log.exception(
|
||||
'error in sequence step %r: %s', step.desc, e)
|
||||
self._seq_error = 'during %s: %s' % (step.desc, e)
|
||||
break
|
||||
|
Reference in New Issue
Block a user