From: Philipp Klaus Date: Wed, 12 Jul 2017 14:46:14 +0000 (+0200) Subject: Pt100 python package: str(PT100BoardDatagram) implemented X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=2cd1faf458163c3010bf8c3b20406f42e509eddf;p=labtools.git Pt100 python package: str(PT100BoardDatagram) implemented --- diff --git a/sensors/pt100-board-python-package/pt100_board/__init__.py b/sensors/pt100-board-python-package/pt100_board/__init__.py index 5c2d473..9e7c588 100755 --- a/sensors/pt100-board-python-package/pt100_board/__init__.py +++ b/sensors/pt100-board-python-package/pt100_board/__init__.py @@ -29,3 +29,14 @@ class PT100BoardDatagram(object): value /= 1000. self.temperature = value + def __str__(self): + fmt = "{cls}: kind={kind} board={board}" + descr_str = fmt.format(cls=self.__class__.__name__, **self.__dict__) + if self.kind == 'temperature': + descr_str += ' sensor={}'.format(self.sensor) + if self.connected: + descr_str += ' T={:.3f}'.format(self.temperature) + else: + descr_str += ' n.c.' + return descr_str +