From 2cd1faf458163c3010bf8c3b20406f42e509eddf Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Wed, 12 Jul 2017 16:46:14 +0200 Subject: [PATCH] Pt100 python package: str(PT100BoardDatagram) implemented --- .../pt100_board/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 + -- 2.43.0