]> jspc29.x-matter.uni-frankfurt.de Git - labtools.git/commitdiff
Pt100 python package: str(PT100BoardDatagram) implemented
authorPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Wed, 12 Jul 2017 14:46:14 +0000 (16:46 +0200)
committerPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Wed, 12 Jul 2017 14:46:21 +0000 (16:46 +0200)
sensors/pt100-board-python-package/pt100_board/__init__.py

index 5c2d4738957e86262e40e8519cc250025d5cd13e..9e7c588eedefa5bdac6959ab759281849d87eafe 100755 (executable)
@@ -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
+