From f58ab263e7d933938458c1fe176cd609123c913e Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Wed, 12 Jan 2022 16:43:21 +0100 Subject: [PATCH] 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 Reviewed-by: Enrico Faulhaber Reviewed-by: Markus Zolliker --- secop/datatypes.py | 2 ++ secop/io.py | 3 ++- secop/logging.py | 2 ++ secop/modules.py | 2 +- secop_psi/ls370sim.py | 1 - secop_psi/ppms.py | 2 +- secop_psi/ppmssim.py | 7 +++++-- secop_psi/softcal.py | 1 + 8 files changed, 14 insertions(+), 6 deletions(-) diff --git a/secop/datatypes.py b/secop/datatypes.py index ada53f6..12ce4ec 100644 --- a/secop/datatypes.py +++ b/secop/datatypes.py @@ -879,6 +879,8 @@ class StructOf(DataType): :param optional: a list of optional 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): super().__init__() self.members = members diff --git a/secop/io.py b/secop/io.py index 48edf0c..9aad8f8 100644 --- a/secop/io.py +++ b/secop/io.py @@ -253,6 +253,7 @@ class StringIO(IOBase): if not self.is_connected: self.read_is_connected() # try to reconnect if not self._conn: + self.log.debug('can not connect to %r' % self.uri) raise CommunicationSilentError('can not connect to %r' % self.uri) try: with self._lock: @@ -410,7 +411,7 @@ class BytesIO(IOBase): :return: the full reply (replyheader + additional bytes) 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 the already received bytes (replyheader) and/or the request and calls :meth:`readBytes` to get the remaining bytes. diff --git a/secop/logging.py b/secop/logging.py index 2b3291e..cd8cf41 100644 --- a/secop/logging.py +++ b/secop/logging.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # ***************************************************************************** +# # 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 # Foundation; either version 2 of the License, or (at your option) any later @@ -17,6 +18,7 @@ # # Module authors: # Markus Zolliker +# # ***************************************************************************** diff --git a/secop/modules.py b/secop/modules.py index fc1929c..5623d93 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -41,7 +41,7 @@ from secop.logging import RemoteLogHandler, HasComlog 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 indicating that the setter is triggered already""" diff --git a/secop_psi/ls370sim.py b/secop_psi/ls370sim.py index cde2d64..969d566 100644 --- a/secop_psi/ls370sim.py +++ b/secop_psi/ls370sim.py @@ -42,7 +42,6 @@ class Ls370Sim(Communicator): for fmt, v in self.CHANNEL_COMMANDS: for chan in range(1,17): self._data[fmt % chan] = v - # mkthread(self.run) def communicate(self, command): self.comLog('> %s' % command) diff --git a/secop_psi/ppms.py b/secop_psi/ppms.py index 1fe265f..d376e2b 100644 --- a/secop_psi/ppms.py +++ b/secop_psi/ppms.py @@ -168,7 +168,7 @@ class Channel(PpmsBase): datatype=IntRange(1, 4), export=False) def earlyInit(self): - Readable.earlyInit(self) + super().earlyInit() if not self.channel: self.channel = self.name diff --git a/secop_psi/ppmssim.py b/secop_psi/ppmssim.py index 5ade05f..1ab0e89 100644 --- a/secop_psi/ppmssim.py +++ b/secop_psi/ppmssim.py @@ -26,6 +26,7 @@ import time def num(string): return json.loads(string) + class NamedList: def __init__(self, keys, *args, **kwargs): self.__keys__ = keys.split() @@ -49,8 +50,10 @@ class NamedList: def __repr__(self): return ",".join("%.7g" % val for val in self.aslist()) + class PpmsSim: CHANNELS = 'st t mf pos r1 i1 r2 i2'.split() + def __init__(self): self.status = NamedList('t mf ch pos', 1, 1, 1, 1) self.st = 0x1111 @@ -176,7 +179,6 @@ class PpmsSim: if abs(self.t - self.temp.target) < 1: self.status.t = 6 # outside tolerance - if abs(self.pos - self.move.target) < 0.01: self.status.pos = 1 else: @@ -188,7 +190,6 @@ class PpmsSim: self.r2 = 1000 / self.t self.i2 = math.log(self.t) 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): mask = int(mask) & 0xff # all channels up to i2 @@ -198,6 +199,7 @@ class PpmsSim: output.append("%.7g" % getattr(self, chan)) return ",".join(output) + class QDevice: def __init__(self, classid): self.sim = PpmsSim() @@ -225,5 +227,6 @@ class QDevice: result = "OK" return result + def shutdown(): pass diff --git a/secop_psi/softcal.py b/secop_psi/softcal.py index d3bcefb..d30b03b 100644 --- a/secop_psi/softcal.py +++ b/secop_psi/softcal.py @@ -165,6 +165,7 @@ class Sensor(Readable): enablePoll = False def initModule(self): + super().initModule() self._rawsensor.registerCallbacks(self, ['status']) # auto update status self._calib = CalCurve(self.calib)