minor fixes

Change-Id: I4be15d264e402be000811dffc1b28a2bc93ab297
Reviewed-on: https://forge.frm2.tum.de/review/18941
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
Enrico Faulhaber
2018-09-03 12:03:15 +02:00
parent 5f640ce299
commit 7e54cd93b7
10 changed files with 165 additions and 26 deletions

View File

@ -605,7 +605,7 @@ DATATYPES = dict(
enum=lambda kwds: EnumType('', **kwds),
struct=lambda named_subtypes: StructOf(
**dict((n, get_datatype(t)) for n, t in list(named_subtypes.items()))),
command=lambda args, res: CommandType(map(get_datatype, args), res),
command=lambda args, res: CommandType(map(get_datatype, args), get_datatype(res)),
)

View File

@ -71,7 +71,7 @@ class Has_PIDTable(HAS_PID):
class HAS_Persistent(Feature):
#extra_Status {
# 'decoupled' : Status.OK+1, # to be discussed.
# 'decoupled' : Status.IDLE+1, # to be discussed.
# 'coupling' : Status.BUSY+1, # to be discussed.
# 'coupled' : Status.BUSY+2, # to be discussed.
# 'decoupling' : Status.BUSY+3, # to be discussed.

View File

@ -78,7 +78,7 @@ def showCommandResultDialog(command, args, result, extras=''):
m = QMessageBox()
if not args:
args = ''
m.setText('calling: %s(%s)\nyielded: %s\nqualifiers: %s' %
m.setText('calling: %s(%s)\nyielded: %r\nqualifiers: %s' %
(command, args, result, extras))
m.exec_()

View File

@ -26,7 +26,6 @@
from time import sleep
from secop.lib import mkthread
from secop.protocol import status
from secop.errors import IsBusyError
@ -128,18 +127,18 @@ class SequencerMixin(object):
def read_status(self, maxage=0):
if self.seq_is_alive():
return status.BUSY, u'moving: ' + self._seq_phase
return self.Status.BUSY, u'moving: ' + self._seq_phase
elif self._seq_error:
if self._seq_fault_on_error:
return status.ERROR, self._seq_error
return status.WARN, self._seq_error
return self.Status.ERROR, self._seq_error
return self.Status.WARN, self._seq_error
elif self._seq_stopped:
if self._seq_fault_on_stop:
return status.ERROR, self._seq_stopped
return status.WARN, self._seq_stopped
return self.Status.ERROR, self._seq_stopped
return self.Status.WARN, self._seq_stopped
if hasattr(self, u'read_hw_status'):
return self.read_hw_status(maxage)
return status.OK, u''
return self.Status.IDLE, u''
def do_stop(self):
if self.seq_is_alive():

View File

@ -192,7 +192,7 @@ class Dispatcher(object):
if moduleobj is None:
raise NoSuchModuleError(module=modulename)
cmdspec = moduleobj.commands.get(command, None)
cmdspec = moduleobj.accessibles.get(command, None)
if cmdspec is None:
raise NoSuchCommandError(module=modulename, command=command)
if len(cmdspec.datatype.argtypes) != len(arguments):

View File

@ -31,6 +31,7 @@ except ImportError:
from secop.lib import formatExtendedStack, formatException
from secop.protocol.messages import HELPREPLY, Message, HelpMessage
from secop.errors import SECoPError
DEF_PORT = 10767
@ -161,6 +162,9 @@ class TCPRequestHandler(socketserver.BaseRequestHandler):
msgObj = Message(*msg)
msgObj.origin = origin.decode('latin-1')
msgObj = serverobj.dispatcher.handle_request(self, msgObj)
except SECoPError as err:
msgObj.set_error(err.name, str(err), {'exception': formatException(),
'traceback': formatExtendedStack()})
except Exception as err:
# create Error Obj instead
msgObj.set_error(u'Internal', str(err), {'exception': formatException(),
@ -179,7 +183,7 @@ class TCPRequestHandler(socketserver.BaseRequestHandler):
if data:
self._queue.append(data)
else:
self.log.error('should asynq_queue %s' % data)
self.log.error('should async_queue empty data!')
def queue_reply(self, data):
"""called by dispatcher to queue (sync) replies"""
@ -187,7 +191,7 @@ class TCPRequestHandler(socketserver.BaseRequestHandler):
if data:
self._queue.appendleft(data)
else:
self.log.error('should queue %s' % data)
self.log.error('should queue empty data!')
def finish(self):
"""called when handle() terminates, i.e. the socket closed"""
@ -215,16 +219,8 @@ class TCPServer(socketserver.ThreadingTCPServer):
if ':' in bindto:
bindto, _port = bindto.rsplit(':')
portnum = int(_port)
# tcp is a byte stream, so we need Framers (to get frames)
# and encoders (to en/decode messages from frames)
interfaceopts.pop('framing') # HACK
interfaceopts.pop('encoding') # HACK
# self.framingCLS = FRAMERS[interfaceopts.pop('framing', 'none')]
# self.encodingCLS = ENCODERS[interfaceopts.pop('encoding', 'pickle')]
self.log.info("TCPServer binding to %s:%d" % (bindto, portnum))
# self.log.debug("TCPServer using framing=%s" % self.framingCLS.__name__)
# self.log.debug("TCPServer using encoding=%s" % self.encodingCLS.__name__)
socketserver.ThreadingTCPServer.__init__(
self, (bindto, portnum), TCPRequestHandler, bind_and_activate=True)
self.log.info("TCPServer initiated")

View File

@ -29,7 +29,7 @@ from secop.protocol.errors import EXCEPTIONS
IDENTREQUEST = u'*IDN?' # literal
# literal! first part is fixed!
IDENTREPLY = u'SINE2020&ISSE,SECoP,V2018-02-13,rc2'
IDENTREPLY = u'SINE2020&ISSE,SECoP,V2018-06-16,rc1'
DESCRIPTIONREQUEST = u'describe' # literal
DESCRIPTIONREPLY = u'describing' # +<id> +json

View File

@ -98,6 +98,8 @@ class SimWritable(SimBase, Writable):
def write_target(self, value):
self.value = value
def _hw_wait(self):
pass
class SimDrivable(SimBase, Drivable):
def __init__(self, logger, cfgdict, devname, dispatcher):
@ -126,4 +128,8 @@ class SimDrivable(SimBase, Drivable):
else:
self._value = self.target
sleep(0.3)
self.status = self.Status.OK, ''
self.status = self.Status.IDLE, ''
def _hw_wait(self):
while self.status[0] == self.Status.BUSY:
sleep(0.3)