various small fixes
- fix some earlyInit and initModules methods - remove some comments - change name of Done unique value to 'Done', this seems more useful for __repr__ and debug logging Change-Id: I73f0e09bfef858ddca11bba0e92e941ebc151160 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27907 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
e0fe7e46d1
commit
f58ab263e7
@ -879,6 +879,8 @@ class StructOf(DataType):
|
|||||||
:param optional: a list of optional members
|
:param optional: a list of optional members
|
||||||
:param members: names as keys and types as values for all members
|
:param members: names as keys and types as values for all members
|
||||||
"""
|
"""
|
||||||
|
# Remark: assignment of parameters containing partial structs in their datatype
|
||||||
|
# are (and can) not be handled here! This has to be done manually in the write method
|
||||||
def __init__(self, optional=None, **members):
|
def __init__(self, optional=None, **members):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.members = members
|
self.members = members
|
||||||
|
@ -253,6 +253,7 @@ class StringIO(IOBase):
|
|||||||
if not self.is_connected:
|
if not self.is_connected:
|
||||||
self.read_is_connected() # try to reconnect
|
self.read_is_connected() # try to reconnect
|
||||||
if not self._conn:
|
if not self._conn:
|
||||||
|
self.log.debug('can not connect to %r' % self.uri)
|
||||||
raise CommunicationSilentError('can not connect to %r' % self.uri)
|
raise CommunicationSilentError('can not connect to %r' % self.uri)
|
||||||
try:
|
try:
|
||||||
with self._lock:
|
with self._lock:
|
||||||
@ -410,7 +411,7 @@ class BytesIO(IOBase):
|
|||||||
:return: the full reply (replyheader + additional bytes)
|
:return: the full reply (replyheader + additional bytes)
|
||||||
|
|
||||||
When the reply length is variable, :meth:`communicate` should be called
|
When the reply length is variable, :meth:`communicate` should be called
|
||||||
with the `replylen` argument set to minimum expected length of the reply.
|
with the `replylen` argument set to the minimum expected length of the reply.
|
||||||
Typically this method determines then the length of additional bytes from
|
Typically this method determines then the length of additional bytes from
|
||||||
the already received bytes (replyheader) and/or the request and calls
|
the already received bytes (replyheader) and/or the request and calls
|
||||||
:meth:`readBytes` to get the remaining bytes.
|
:meth:`readBytes` to get the remaining bytes.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
# the terms of the GNU General Public License as published by the Free Software
|
# the terms of the GNU General Public License as published by the Free Software
|
||||||
# Foundation; either version 2 of the License, or (at your option) any later
|
# Foundation; either version 2 of the License, or (at your option) any later
|
||||||
@ -17,6 +18,7 @@
|
|||||||
#
|
#
|
||||||
# Module authors:
|
# Module authors:
|
||||||
# Markus Zolliker <markus.zolliker@psi.ch>
|
# Markus Zolliker <markus.zolliker@psi.ch>
|
||||||
|
#
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ from secop.logging import RemoteLogHandler, HasComlog
|
|||||||
|
|
||||||
generalConfig.defaults['disable_value_range_check'] = False # check for problematic value range by default
|
generalConfig.defaults['disable_value_range_check'] = False # check for problematic value range by default
|
||||||
|
|
||||||
Done = UniqueObject('already set')
|
Done = UniqueObject('Done')
|
||||||
"""a special return value for a read/write function
|
"""a special return value for a read/write function
|
||||||
|
|
||||||
indicating that the setter is triggered already"""
|
indicating that the setter is triggered already"""
|
||||||
|
@ -42,7 +42,6 @@ class Ls370Sim(Communicator):
|
|||||||
for fmt, v in self.CHANNEL_COMMANDS:
|
for fmt, v in self.CHANNEL_COMMANDS:
|
||||||
for chan in range(1,17):
|
for chan in range(1,17):
|
||||||
self._data[fmt % chan] = v
|
self._data[fmt % chan] = v
|
||||||
# mkthread(self.run)
|
|
||||||
|
|
||||||
def communicate(self, command):
|
def communicate(self, command):
|
||||||
self.comLog('> %s' % command)
|
self.comLog('> %s' % command)
|
||||||
|
@ -168,7 +168,7 @@ class Channel(PpmsBase):
|
|||||||
datatype=IntRange(1, 4), export=False)
|
datatype=IntRange(1, 4), export=False)
|
||||||
|
|
||||||
def earlyInit(self):
|
def earlyInit(self):
|
||||||
Readable.earlyInit(self)
|
super().earlyInit()
|
||||||
if not self.channel:
|
if not self.channel:
|
||||||
self.channel = self.name
|
self.channel = self.name
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import time
|
|||||||
def num(string):
|
def num(string):
|
||||||
return json.loads(string)
|
return json.loads(string)
|
||||||
|
|
||||||
|
|
||||||
class NamedList:
|
class NamedList:
|
||||||
def __init__(self, keys, *args, **kwargs):
|
def __init__(self, keys, *args, **kwargs):
|
||||||
self.__keys__ = keys.split()
|
self.__keys__ = keys.split()
|
||||||
@ -49,8 +50,10 @@ class NamedList:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return ",".join("%.7g" % val for val in self.aslist())
|
return ",".join("%.7g" % val for val in self.aslist())
|
||||||
|
|
||||||
|
|
||||||
class PpmsSim:
|
class PpmsSim:
|
||||||
CHANNELS = 'st t mf pos r1 i1 r2 i2'.split()
|
CHANNELS = 'st t mf pos r1 i1 r2 i2'.split()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.status = NamedList('t mf ch pos', 1, 1, 1, 1)
|
self.status = NamedList('t mf ch pos', 1, 1, 1, 1)
|
||||||
self.st = 0x1111
|
self.st = 0x1111
|
||||||
@ -176,7 +179,6 @@ class PpmsSim:
|
|||||||
if abs(self.t - self.temp.target) < 1:
|
if abs(self.t - self.temp.target) < 1:
|
||||||
self.status.t = 6 # outside tolerance
|
self.status.t = 6 # outside tolerance
|
||||||
|
|
||||||
|
|
||||||
if abs(self.pos - self.move.target) < 0.01:
|
if abs(self.pos - self.move.target) < 0.01:
|
||||||
self.status.pos = 1
|
self.status.pos = 1
|
||||||
else:
|
else:
|
||||||
@ -188,7 +190,6 @@ class PpmsSim:
|
|||||||
self.r2 = 1000 / self.t
|
self.r2 = 1000 / self.t
|
||||||
self.i2 = math.log(self.t)
|
self.i2 = math.log(self.t)
|
||||||
self.level.value = 100 - (self.time - self.start) * 0.01 % 100
|
self.level.value = 100 - (self.time - self.start) * 0.01 % 100
|
||||||
# print('PROGRESS T=%.7g B=%.7g x=%.7g' % (self.t, self.mf, self.pos))
|
|
||||||
|
|
||||||
def getdat(self, mask):
|
def getdat(self, mask):
|
||||||
mask = int(mask) & 0xff # all channels up to i2
|
mask = int(mask) & 0xff # all channels up to i2
|
||||||
@ -198,6 +199,7 @@ class PpmsSim:
|
|||||||
output.append("%.7g" % getattr(self, chan))
|
output.append("%.7g" % getattr(self, chan))
|
||||||
return ",".join(output)
|
return ",".join(output)
|
||||||
|
|
||||||
|
|
||||||
class QDevice:
|
class QDevice:
|
||||||
def __init__(self, classid):
|
def __init__(self, classid):
|
||||||
self.sim = PpmsSim()
|
self.sim = PpmsSim()
|
||||||
@ -225,5 +227,6 @@ class QDevice:
|
|||||||
result = "OK"
|
result = "OK"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def shutdown():
|
def shutdown():
|
||||||
pass
|
pass
|
||||||
|
@ -165,6 +165,7 @@ class Sensor(Readable):
|
|||||||
enablePoll = False
|
enablePoll = False
|
||||||
|
|
||||||
def initModule(self):
|
def initModule(self):
|
||||||
|
super().initModule()
|
||||||
self._rawsensor.registerCallbacks(self, ['status']) # auto update status
|
self._rawsensor.registerCallbacks(self, ['status']) # auto update status
|
||||||
self._calib = CalCurve(self.calib)
|
self._calib = CalCurve(self.calib)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user