Merge branch 'Patrick762:main' into main
This commit is contained in:
8 files changed
+50
-3
No files matched your search
@@ -0,0 +1,8 @@
|
||||
"""AC70 fields."""
|
||||
|
||||
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||
|
||||
|
||||
class AC70(ProtocolV2Device):
|
||||
def __init__(self, address: str, sn: str):
|
||||
super().__init__(address, "AC70", sn)
|
||||
@@ -0,0 +1,8 @@
|
||||
"""AC70P fields."""
|
||||
|
||||
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||
|
||||
|
||||
class AC70P(ProtocolV2Device):
|
||||
def __init__(self, address: str, sn: str):
|
||||
super().__init__(address, "AC70P", sn)
|
||||
@@ -3,6 +3,8 @@
|
||||
import re
|
||||
|
||||
from ..devices.ac60 import AC60
|
||||
from ..devices.ac70 import AC70
|
||||
from ..devices.ac70p import AC70P
|
||||
from ..devices.ac180 import AC180
|
||||
from ..devices.ac180p import AC180P
|
||||
from ..devices.ac200l import AC200L
|
||||
@@ -17,7 +19,7 @@ from ..devices.ep760 import EP760
|
||||
from ..devices.ep800 import EP800
|
||||
|
||||
DEVICE_NAME_RE = re.compile(
|
||||
r"^(AC60|AC180|AC180P|AC200L|AC200M|AC300|AC500|EB3A|EP500|EP500P|EP600|EP760|EP800)(\d+)$"
|
||||
r"^(AC60|AC70|AC70P|AC180|AC180P|AC200L|AC200M|AC300|AC500|EB3A|EP500|EP500P|EP600|EP760|EP800)(\d+)$"
|
||||
)
|
||||
|
||||
|
||||
@@ -25,6 +27,10 @@ def build_device(address: str, name: str):
|
||||
match = DEVICE_NAME_RE.match(name)
|
||||
if match[1] == "AC60":
|
||||
return AC60(address, match[2])
|
||||
if match[1] == "AC70":
|
||||
return AC70(address, match[2])
|
||||
if match[1] == "AC70P":
|
||||
return AC70P(address, match[2])
|
||||
if match[1] == "AC180":
|
||||
return AC180(address, match[2])
|
||||
if match[1] == "AC180P":
|
||||
|
||||
@@ -91,7 +91,7 @@ class DecimalField(DeviceField):
|
||||
|
||||
def parse(self, data: bytes) -> Decimal:
|
||||
val = Decimal(struct.unpack("!H", data)[0])
|
||||
return (val / 10 ** self.scale) * self.multiplier
|
||||
return (val / 10 ** self.scale) * Decimal(self.multiplier)
|
||||
|
||||
def in_range(self, val: Decimal) -> bool:
|
||||
if self.range is None:
|
||||
|
||||
Reference in new issue
Block a user