DLMS-SPODES 0.87.2__py3-none-any.whl → 0.87.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,11 +14,11 @@ class Data(Parameter):
14
14
  class ActiveFirmwareIdentifier(Data):
15
15
 
16
16
  @classmethod
17
- def from_b(cls, b: int) -> "ActiveFirmwareIdentifier":
17
+ def from_b(cls, b: int = 0) -> "ActiveFirmwareIdentifier":
18
18
  return cls.parse(f"0.{b}.0.2.0.255")
19
19
 
20
20
 
21
- ACTIVE_FIRMWARE_IDENTIFIER_0 = ActiveFirmwareIdentifier.from_b(0)
21
+ ACTIVE_FIRMWARE_IDENTIFIER_0 = ActiveFirmwareIdentifier.from_b()
22
22
 
23
23
 
24
24
  @dataclass(frozen=True)
@@ -28,6 +28,77 @@ class Register(Data):
28
28
  return self.get_attr(3)
29
29
 
30
30
 
31
+ @dataclass(frozen=True)
32
+ class Clock(Parameter):
33
+ @classmethod
34
+ def from_be(cls, b: int = 0, e: int = 0) -> "Clock":
35
+ return cls.parse(f"0.{b}.1.0.{e}.255")
36
+
37
+ @property
38
+ def time(self) -> "Clock":
39
+ return self.get_attr(2)
40
+
41
+ @property
42
+ def time_zone(self) -> "Clock":
43
+ return self.get_attr(3)
44
+
45
+ @property
46
+ def status(self) -> "Clock":
47
+ return self.get_attr(4)
48
+
49
+ @property
50
+ def time_zone(self) -> "Clock":
51
+ return self.get_attr(3)
52
+
53
+ @property
54
+ def status(self) -> "Clock":
55
+ return self.get_attr(4)
56
+
57
+ @property
58
+ def daylight_savings_begin(self) -> "Clock":
59
+ return self.get_attr(5)
60
+
61
+ @property
62
+ def daylight_savings_end(self) -> "Clock":
63
+ return self.get_attr(6)
64
+
65
+ @property
66
+ def daylight_savings_deviation(self) -> "Clock":
67
+ return self.get_attr(7)
68
+
69
+ @property
70
+ def daylight_savings_enabled(self) -> "Clock":
71
+ return self.get_attr(8)
72
+
73
+ @property
74
+ def clock_base(self) -> "Clock":
75
+ return self.get_attr(9)
76
+
77
+ @property
78
+ def adjust_to_quarter(self) -> "Clock":
79
+ return self.get_meth(1)
80
+
81
+ @property
82
+ def adjust_to_measuring_period(self) -> "Clock":
83
+ return self.get_meth(2)
84
+
85
+ @property
86
+ def adjust_to_minute(self) -> "Clock":
87
+ return self.get_meth(3)
88
+
89
+ @property
90
+ def adjust_to_preset_time(self) -> "Clock":
91
+ return self.get_meth(4)
92
+
93
+ @property
94
+ def preset_adjusting_time(self) -> "Clock":
95
+ return self.get_meth(5)
96
+
97
+ @property
98
+ def shift_time(self) -> "Clock":
99
+ return self.get_meth(6)
100
+
101
+
31
102
  @dataclass(frozen=True)
32
103
  class DisconnectControl(Parameter):
33
104
 
@@ -1,72 +1,70 @@
1
- from typing import Any
2
- from .collection import ic, cdt
1
+ from typing import Any, Iterable
2
+ from StructResult import result
3
+ from . import cosem_interface_class as ic
4
+ from ..types import cdt
5
+ from .parameter import Parameter
3
6
  from ..cosem_interface_classes import collection
4
7
  from ..config_parser import get_values
8
+ from ..settings import settings
5
9
 
6
10
 
7
- def get_obj_report(
11
+ def from_obj(
12
+ col: collection.Collection,
8
13
  obj: ic.COSEMInterfaceClasses,
9
- attr_index_par: tuple[int | Any, ...]) -> str:
10
- struct_report: dict | None = get_values("DLMS", "report", "struct")
11
- ret = str()
12
- ret += F"[{collection.get_name(obj.logical_name)}]\n"
14
+ attr_index_par: tuple[int, ...]
15
+ ) -> result.SimpleOrError[str]:
16
+ if not hasattr(from_obj, "struct_pattern"):
17
+ from_obj.struct_pattern = dict(settings.report.struct)
18
+ ret: str = F"[{collection.get_name(obj.logical_name)}]\n"
13
19
  for i in attr_index_par:
14
- if isinstance(i, int):
15
- pass
16
- else:
17
- i, par = i[0], i[1:]
18
- value = obj.get_attr(i)
19
- if isinstance(value, cdt.SimpleDataType):
20
- match obj, i:
21
- case collection.impl.data.DLMSDeviceIDObject(), 2: value = value.to_str()
22
- case _: pass
23
- if isinstance(value, cdt.OctetString):
24
- pass
25
- if hasattr(value, "report"):
26
- value = value.report
27
- ret += F" {obj.get_attr_element(i)}: {value}\n"
28
- elif isinstance(value, cdt.ComplexDataType):
20
+ par = Parameter(obj.logical_name.contents).set_i(i)
21
+ if isinstance(res_data := col.par2data(par), result.Error):
22
+ return res_data
23
+ a_data = res_data.value
24
+ if isinstance(a_data, cdt.SimpleDataType):
25
+ rep = col.par2rep(par, a_data)
26
+ ret += F" {obj.get_attr_element(i)}: {rep.msg}{f" {rep.unit}" if rep.unit else ""}\n"
27
+ elif isinstance(a_data, cdt.ComplexDataType):
29
28
  ret += F" [{obj.get_attr_element(i)}]\n"
30
- stack: list = [("", iter(value))]
29
+ stack: list[tuple[Any, Any]] = [("", iter(a_data))]
31
30
  while stack:
32
31
  name, value_it = stack[-1]
33
- indent = F"{' '*(len(stack) + 1)}"
34
- value = next(value_it, None)
35
- if value:
32
+ indent = F"{' ' * (len(stack) + 1)}"
33
+ data = next(value_it, None)
34
+ if data:
36
35
  if not isinstance(name, str):
37
- name = next(name).NAME
38
- if isinstance(value, cdt.Array):
36
+ name = str(next(name))
37
+ if isinstance(data, cdt.Array):
39
38
  ret += F"{indent}[{name}]\n"
40
- stack.append(("*", iter(value)))
41
- elif isinstance(value, cdt.Structure):
42
- if struct_report and (pattern := struct_report.get(value.__class__.__name__)):
39
+ stack.append(("*", iter(data)))
40
+ elif isinstance(data, cdt.Structure):
41
+ if (pattern := from_obj.struct_pattern.get(data.__class__.__name__)):
43
42
  val = list(pattern)
44
43
  val.reverse()
45
- result = str()
44
+ result_ = str()
46
45
  while val:
47
- i = val.pop()
48
- match i:
46
+ match val.pop():
49
47
  case "%":
50
- par = val.pop()
48
+ par_ = val.pop()
51
49
  index = int(val.pop() + val.pop())
52
- match par:
50
+ match par_:
53
51
  case "n":
54
- result += value.ELEMENTS[index].NAME
52
+ result_ += str(data.ELEMENTS[index])
55
53
  case "v":
56
- result += str(value[index])
54
+ result_ += str(data[index])
57
55
  case err:
58
56
  raise ValueError(F"unknown macros &{err}{index}")
59
57
  case symbol:
60
- result += symbol
61
- ret += F"{indent}{result}\n"
58
+ result_ += symbol
59
+ ret += F"{indent}{result_}\n"
62
60
  else:
63
- if name == "":
61
+ if name=="":
64
62
  ret += "\n"
65
63
  else:
66
64
  ret += F"{indent}[{name}]\n"
67
- stack.append((iter(value.ELEMENTS), iter(value)))
65
+ stack.append((iter(data.ELEMENTS), iter(data)))
68
66
  else:
69
- ret += F"{indent}{name}: {value}\n"
67
+ ret += F"{indent}{name}: {data}\n"
70
68
  else:
71
69
  stack.pop()
72
- return ret
70
+ return result.Simple(ret)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DLMS_SPODES
3
- Version: 0.87.2
3
+ Version: 0.87.3
4
4
  Summary: dlms-spodes
5
5
  Author-email: Serj Kotilevski <youserj@outlook.com>
6
6
  Project-URL: Source, https://github.com/youserj/DlmsSPODES-project
@@ -38,10 +38,10 @@ DLMS_SPODES/cosem_interface_classes/ln_pattern.py,sha256=IPluhyGWJQLBEUjOjdfEMct
38
38
  DLMS_SPODES/cosem_interface_classes/obis.py,sha256=yEwYm5CshJx8X8uSy3QH8XIbdVPg8Tt6zPUjFgkAB0M,575
39
39
  DLMS_SPODES/cosem_interface_classes/overview.py,sha256=0eko1CW0eH397J5kM20G7RSQUzCGV6lGCMPbLsKPEqQ,7146
40
40
  DLMS_SPODES/cosem_interface_classes/parameter.py,sha256=esTD-1VzvX0rnazsHSVIR8mLuVxpdqwdjzppxj5Zz7s,18961
41
- DLMS_SPODES/cosem_interface_classes/parameters.py,sha256=mrLO0eIi_0Q5Wyug_3pAX2ucZUNyxTuV_5QPbuETbFI,2678
41
+ DLMS_SPODES/cosem_interface_classes/parameters.py,sha256=VZDBm9H25VIGxUGGJ-OcVu0pAO8VJhFF2XdZTQMnmoM,4354
42
42
  DLMS_SPODES/cosem_interface_classes/register.py,sha256=Cfikftpo1Nzg_B2drOmJDwoGkbS2wXlqQpxVgXL1w2U,1886
43
43
  DLMS_SPODES/cosem_interface_classes/register_monitor.py,sha256=fNM-JrjHxQB8b5DgUOtDcnkO_hxu5bFICiuKEoZa37g,1792
44
- DLMS_SPODES/cosem_interface_classes/reports.py,sha256=9kOt9Ztyp5D59j3k3x5URy7WD1qlFNMa8xFlMu7nUmA,3320
44
+ DLMS_SPODES/cosem_interface_classes/reports.py,sha256=zsWmKGqdP6uiZrH8hR5aqHJPMsyHwyrSCRf6khhFoSg,3365
45
45
  DLMS_SPODES/cosem_interface_classes/schedule.py,sha256=IT9sVrkOCdWV4uuTt8Kbu5bL6jchiVTgUqA15x1fq5s,8041
46
46
  DLMS_SPODES/cosem_interface_classes/script_table.py,sha256=aPDXwjCkrvT-yGkCOOZXWjiOZViRy6N-Tb_Gl1aTIik,3455
47
47
  DLMS_SPODES/cosem_interface_classes/single_action_schedule.py,sha256=UGRO-x2q1du3CupfB4KQtUyyUAcbJGqph_apIe0QfFY,1708
@@ -112,7 +112,7 @@ DLMS_SPODES/types/implementations/integers.py,sha256=Asy4X260t1Fzw_V5iw0uiDOxtfB
112
112
  DLMS_SPODES/types/implementations/long_unsigneds.py,sha256=SxmFvD2moQ03p-KZSBYK1Rv7bQSaywlHVXBfkTZG1OQ,8761
113
113
  DLMS_SPODES/types/implementations/octet_string.py,sha256=Jo_sfWcsfstiP4O6mXfBOOQlksx1c2qJMI-vbAOV-yM,294
114
114
  DLMS_SPODES/types/implementations/structs.py,sha256=GMOo6Jy8jA9d6KTLs0D-j5t0oSRvxUIwtBr_4UePwbA,2059
115
- dlms_spodes-0.87.2.dist-info/METADATA,sha256=u0_IQbaywetOsTcXCN1Yckn9qduLGkK__ANW4LAH1Uk,1027
116
- dlms_spodes-0.87.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
- dlms_spodes-0.87.2.dist-info/top_level.txt,sha256=k26SRuRdwBZrSM3NgNZECAUNIDZREbJuLCnPbWtTNak,12
118
- dlms_spodes-0.87.2.dist-info/RECORD,,
115
+ dlms_spodes-0.87.3.dist-info/METADATA,sha256=ANlxJv9tqVDNQ2qtmssUfyu_kFHEl4V8FglWBADITRQ,1027
116
+ dlms_spodes-0.87.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
+ dlms_spodes-0.87.3.dist-info/top_level.txt,sha256=k26SRuRdwBZrSM3NgNZECAUNIDZREbJuLCnPbWtTNak,12
118
+ dlms_spodes-0.87.3.dist-info/RECORD,,