Also fix decimal handling for Melcor floats based on DECIMAL_1 during writes.
authorW. Trevor King <wking@drexel.edu>
Mon, 23 Jan 2012 19:16:26 +0000 (14:16 -0500)
committerW. Trevor King <wking@drexel.edu>
Mon, 23 Jan 2012 19:16:26 +0000 (14:16 -0500)
This should have gone in with the last commit.

pypid/backend/melcor.py

index 1777da8bece8453e1be21e6d2e24decce43fa936..c3924d3e1095c78e138f8458f9c532935942be4c 100644 (file)
@@ -470,8 +470,10 @@ class MelcorBackend (_Backend, _ManualMixin, _PIDMixin, _TemperatureMixin):
         register = self._register[register_name]
         if 'w' not in register.direction:
             raise ValueError(register_name)
-        if register.needs_decimal and not self._decimal:
-            self._decimal = self._get_decimal()
+        if register.needs_decimal:
+            if not self._decimal:
+                self._decimal = self._get_decimal()
+            register.decimal = self._decimal
         v = register.encode(value, decimal=self._decimal)
         _LOG.info('write %s: %s (%s)' % (register_name, v, value))
         rc = self._client.write_register(