From 5fec06fed03ac9ae4870ddc51da718a591f3235a Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Wed, 21 Jun 2023 10:31:14 -0500 Subject: [PATCH] Avoid using class variables --- productivity/mock.py | 1 + productivity/util.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/productivity/mock.py b/productivity/mock.py index e8e258b..a42bc26 100644 --- a/productivity/mock.py +++ b/productivity/mock.py @@ -38,6 +38,7 @@ def __init__(self, address, tag_filepath, timeout=1, *args, **kwargs): self._coils = defaultdict(bool) self._discrete_inputs = defaultdict(bool) self._registers = defaultdict(bytes) + self._register_types = ['holding', 'input'] self._detect_pymodbus_version() if self.pymodbus33plus: self.client.close = lambda: None diff --git a/productivity/util.py b/productivity/util.py index e62ad8b..0137822 100644 --- a/productivity/util.py +++ b/productivity/util.py @@ -45,12 +45,11 @@ class AsyncioModbusClient: including standard timeouts, async context manager, and queued requests. """ - _register_types = ['holding', 'input'] - def __init__(self, address, timeout=1): """Set up communication parameters.""" self.ip = address self.timeout = timeout + self._register_types = ['holding', 'input'] self._detect_pymodbus_version() if self.pymodbus30plus: self.client = AsyncModbusTcpClient(address, timeout=timeout)