Fix gui (leftover from extending datatypes)
Change-Id: Id12d37d9381f622c3cc1bba2c388784169690b85 Reviewed-on: https://forge.frm2.tum.de/review/16916 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
parent
b0c3ac01d4
commit
8220067795
@ -25,9 +25,11 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import socket
|
import socket
|
||||||
import serial
|
|
||||||
from select import select
|
from select import select
|
||||||
import threading
|
import threading
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
import serial
|
||||||
|
|
||||||
# Py2/3
|
# Py2/3
|
||||||
try:
|
try:
|
||||||
@ -35,16 +37,14 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import queue as Queue
|
import queue as Queue
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
import mlzlog
|
import mlzlog
|
||||||
|
|
||||||
from secop.datatypes import get_datatype
|
from secop.datatypes import get_datatype
|
||||||
from secop.lib import mkthread, formatException
|
from secop.lib import mkthread, formatException
|
||||||
from secop.lib.parsing import parse_time, format_time
|
from secop.lib.parsing import parse_time, format_time
|
||||||
from secop.protocol.encoding import ENCODERS
|
#from secop.protocol.encoding import ENCODERS
|
||||||
from secop.protocol.framing import FRAMERS
|
#from secop.protocol.framing import FRAMERS
|
||||||
from secop.protocol.messages import *
|
#from secop.protocol.messages import *
|
||||||
from secop.protocol.errors import EXCEPTIONS
|
from secop.protocol.errors import EXCEPTIONS
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,6 @@ class TCPConnection(object):
|
|||||||
# disguise a TCP connection as serial one
|
# disguise a TCP connection as serial one
|
||||||
|
|
||||||
def __init__(self, host, port):
|
def __init__(self, host, port):
|
||||||
import mlzlog
|
|
||||||
self.log = mlzlog.getLogger('TCPConnection')
|
self.log = mlzlog.getLogger('TCPConnection')
|
||||||
self._host = host
|
self._host = host
|
||||||
self._port = int(port)
|
self._port = int(port)
|
||||||
@ -131,13 +130,14 @@ class TCPConnection(object):
|
|||||||
|
|
||||||
|
|
||||||
class Value(object):
|
class Value(object):
|
||||||
t = None
|
t = None # pylint: disable = C0103
|
||||||
u = None
|
u = None
|
||||||
e = None
|
e = None
|
||||||
fmtstr = '%s'
|
fmtstr = '%s'
|
||||||
|
|
||||||
def __init__(self, value, qualifiers={}):
|
def __init__(self, value, qualifiers=None):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
if qualifiers:
|
||||||
self.__dict__.update(qualifiers)
|
self.__dict__.update(qualifiers)
|
||||||
if 't' in qualifiers:
|
if 't' in qualifiers:
|
||||||
try:
|
try:
|
||||||
@ -310,15 +310,15 @@ class Client(object):
|
|||||||
self.log.warning("deprecated specifier %r" % spec)
|
self.log.warning("deprecated specifier %r" % spec)
|
||||||
spec = '%s:value' % spec
|
spec = '%s:value' % spec
|
||||||
modname, pname = spec.split(':', 1)
|
modname, pname = spec.split(':', 1)
|
||||||
previous = '<unset>'
|
# previous = '<unset>'
|
||||||
if modname in self._cache:
|
# if modname in self._cache:
|
||||||
if pname in self._cache:
|
# if pname in self._cache:
|
||||||
previous = self._cache[modname][pname]
|
# previous = self._cache[modname][pname]
|
||||||
if data:
|
if data:
|
||||||
self._cache.setdefault(modname, {})[pname] = Value(*data)
|
self._cache.setdefault(modname, {})[pname] = Value(*data)
|
||||||
else:
|
else:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
'got malformed answer! (spec data)' % (spec, data))
|
'got malformed answer! (%s,%s)' % (spec, data))
|
||||||
# self.log.info('cache: %s:%s=%r (was: %s)', modname, pname, data, previous)
|
# self.log.info('cache: %s:%s=%r (was: %s)', modname, pname, data, previous)
|
||||||
if spec in self.callbacks:
|
if spec in self.callbacks:
|
||||||
for func in self.callbacks[spec]:
|
for func in self.callbacks[spec]:
|
||||||
@ -353,7 +353,7 @@ class Client(object):
|
|||||||
result[key] = value
|
result[key] = value
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _decode_substruct(self, specialkeys=[], data={}):
|
def _decode_substruct(self, specialkeys=[], data={}): # pylint: disable=W0102
|
||||||
# take a dict and move all keys which are not in specialkeys
|
# take a dict and move all keys which are not in specialkeys
|
||||||
# into a 'properties' subdict
|
# into a 'properties' subdict
|
||||||
# specialkeys entries are converted from list to ordereddict
|
# specialkeys entries are converted from list to ordereddict
|
||||||
@ -386,11 +386,11 @@ class Client(object):
|
|||||||
datatype = get_datatype(parameterData['datatype'])
|
datatype = get_datatype(parameterData['datatype'])
|
||||||
self.describing_data['modules'][module]['parameters'] \
|
self.describing_data['modules'][module]['parameters'] \
|
||||||
[parameter]['datatype'] = datatype
|
[parameter]['datatype'] = datatype
|
||||||
for cmdname, cmdData in moduleData[
|
for _cmdname, cmdData in moduleData[
|
||||||
'commands'].items():
|
'commands'].items():
|
||||||
cmdData['arguments'] = map(get_datatype, cmdData['arguments'])
|
cmdData['arguments'] = map(get_datatype, cmdData['arguments'])
|
||||||
cmdData['resulttype'] = get_datatype(cmdData['resulttype'])
|
cmdData['resulttype'] = get_datatype(cmdData['resulttype'])
|
||||||
except Exception as exc:
|
except Exception as _exc:
|
||||||
print(formatException(verbose=True))
|
print(formatException(verbose=True))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ class Client(object):
|
|||||||
def _get_reply_from_request(self, requesttype):
|
def _get_reply_from_request(self, requesttype):
|
||||||
# maps each (sync) request to the corresponding reply
|
# maps each (sync) request to the corresponding reply
|
||||||
# XXX: should go to the encoder! and be imported here
|
# XXX: should go to the encoder! and be imported here
|
||||||
REPLYMAP = {
|
REPLYMAP = { # pylint: disable=C0103
|
||||||
"describe": "describing",
|
"describe": "describing",
|
||||||
"do": "done",
|
"do": "done",
|
||||||
"change": "changed",
|
"change": "changed",
|
||||||
@ -494,12 +494,12 @@ class Client(object):
|
|||||||
if self._thread and self._thread.is_alive():
|
if self._thread and self._thread.is_alive():
|
||||||
self.thread.join(self._thread)
|
self.thread.join(self._thread)
|
||||||
|
|
||||||
def startup(self, async=False):
|
def startup(self, _async=False):
|
||||||
self._issueDescribe()
|
self._issueDescribe()
|
||||||
# always fill our cache
|
# always fill our cache
|
||||||
self.communicate('activate')
|
self.communicate('activate')
|
||||||
# deactivate updates if not wanted
|
# deactivate updates if not wanted
|
||||||
if not async:
|
if not _async:
|
||||||
self.communicate('deactivate')
|
self.communicate('deactivate')
|
||||||
|
|
||||||
def queryCache(self, module, parameter=None):
|
def queryCache(self, module, parameter=None):
|
||||||
@ -517,7 +517,7 @@ class Client(object):
|
|||||||
datatype = self._getDescribingParameterData(module,
|
datatype = self._getDescribingParameterData(module,
|
||||||
parameter)['datatype']
|
parameter)['datatype']
|
||||||
|
|
||||||
value = datatype.export(datatype.validate(value))
|
value = datatype.export_value(datatype.validate(value))
|
||||||
self.communicate('change', '%s:%s' % (module, parameter), value)
|
self.communicate('change', '%s:%s' % (module, parameter), value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -560,13 +560,13 @@ class Client(object):
|
|||||||
return self.describing_data['modules'][module]['parameters'][parameter]
|
return self.describing_data['modules'][module]['parameters'][parameter]
|
||||||
|
|
||||||
def syncCommunicate(self, *msg):
|
def syncCommunicate(self, *msg):
|
||||||
res = self._communicate(*msg)
|
res = self._communicate(*msg) # pylint: disable=E1120
|
||||||
try:
|
try:
|
||||||
res = self.encode_message(*res)
|
res = self.encode_message(*res)
|
||||||
except Exception:
|
except Exception:
|
||||||
res = str(res)
|
res = str(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def ping(self, pingctr=[0]):
|
def ping(self, pingctr=[0]): # pylint: disable=W0102
|
||||||
pingctr[0] = pingctr[0] + 1
|
pingctr[0] = pingctr[0] + 1
|
||||||
self.communicate("ping", pingctr[0])
|
self.communicate("ping", pingctr[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user