DLMS-SPODES 0.87.10__py3-none-any.whl → 0.87.12__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.
@@ -57,37 +57,58 @@ class RangeDescriptorValueChoice(CommonDataTypeChoiceBase, types=(
57
57
  """Types of range_descriptor.from_value/to_value"""
58
58
 
59
59
 
60
- class RangeDescriptor(cdt.Structure):
61
- restricting_object: structs.CaptureObjectDefinition
62
- from_value: RangeDescriptorValueChoice
63
- to_value: RangeDescriptorValueChoice
64
- selected_values: CaptureObjects
65
-
66
-
67
- class Data(ut.Data):
68
- restricting_object: structs.CaptureObjectDefinition
69
- from_value: cdt.SimpleDataType
70
- to_value: cdt.SimpleDataType
71
- selected_values: CaptureObjects
72
- from_entry: FromEntry
73
- to_entry: cdt.DoubleLongUnsigned
74
- from_selected_value: cdt.LongUnsigned
75
- to_selected_value: cdt.LongUnsigned
76
- ELEMENTS = {1: ut.SequenceElement('range_descriptor', RangeDescriptor),
77
- 2: ut.SequenceElement('entry_descriptor', EntryDescriptor)}
78
-
79
-
80
- class SelectiveAccessDescriptor(ut.SelectiveAccessDescriptor):
81
- access_selector: AccessSelector
82
- access_parameters: Data
83
- ELEMENTS = (ut.SequenceElement('access_selector', AccessSelector),
84
- ut.SequenceElement('access_parameters', Data))
85
-
86
-
87
- class CosemAttributeDescriptorWithSelection(ut.CosemAttributeDescriptorWithSelection):
88
- access_selection: SelectiveAccessDescriptor
89
- ELEMENTS = (ut.SequenceElement('cosem_attribute_descriptor', ut.CosemAttributeDescriptor),
90
- ut.SequenceElement('access_selection', SelectiveAccessDescriptor))
60
+ # class RangeDescriptor(cdt.Structure):
61
+ # restricting_object: structs.CaptureObjectDefinition
62
+ # from_value: RangeDescriptorValueChoice
63
+ # to_value: RangeDescriptorValueChoice
64
+ # selected_values: CaptureObjects
65
+ #
66
+ # def __setattr__(self, key, value):
67
+ # """Allow setting from_value and to_value with a CommonDataType of allowed types.
68
+ # Other attributes remain immutable as per base Structure behavior."""
69
+ # if key in ("from_value", "to_value"):
70
+ # index = 1 if key == "from_value" else 2
71
+ # # Accept only CommonDataType instances of allowed types
72
+ # if isinstance(value, cdt.CommonDataType):
73
+ # # Build allowed types tuple from Choice definition
74
+ # allowed_types = tuple(el.TYPE if isinstance(el, ut.SequenceElement) else None for el in RangeDescriptorValueChoice.ELEMENTS.values())
75
+ # allowed_types = tuple(t for t in allowed_types if t is not None)
76
+ # if isinstance(value, allowed_types):
77
+ # self.values[index] = value
78
+ # return
79
+ # else:
80
+ # raise ValueError(F"Type got {value.__class__.__name__}, expected one of: "
81
+ # + ", ".join(t.__name__ for t in allowed_types))
82
+ # else:
83
+ # raise TypeError(F"Unsupported value type for {key}: {value.__class__.__name__}. Provide a CommonDataType instance.")
84
+ # else:
85
+ # super().__setattr__(key, value)
86
+ #
87
+ #
88
+ # class Data(ut.Data):
89
+ # restricting_object: structs.CaptureObjectDefinition
90
+ # from_value: cdt.SimpleDataType
91
+ # to_value: cdt.SimpleDataType
92
+ # selected_values: CaptureObjects
93
+ # from_entry: FromEntry
94
+ # to_entry: cdt.DoubleLongUnsigned
95
+ # from_selected_value: cdt.LongUnsigned
96
+ # to_selected_value: cdt.LongUnsigned
97
+ # ELEMENTS = {1: ut.SequenceElement('range_descriptor', RangeDescriptor),
98
+ # 2: ut.SequenceElement('entry_descriptor', EntryDescriptor)}
99
+ #
100
+ #
101
+ # class SelectiveAccessDescriptor(ut.SelectiveAccessDescriptor):
102
+ # access_selector: AccessSelector
103
+ # access_parameters: Data
104
+ # ELEMENTS = (ut.SequenceElement('access_selector', AccessSelector),
105
+ # ut.SequenceElement('access_parameters', Data))
106
+ #
107
+ #
108
+ # class CosemAttributeDescriptorWithSelection(ut.CosemAttributeDescriptorWithSelection):
109
+ # access_selection: SelectiveAccessDescriptor
110
+ # ELEMENTS = (ut.SequenceElement('cosem_attribute_descriptor', ut.CosemAttributeDescriptor),
111
+ # ut.SequenceElement('access_selection', SelectiveAccessDescriptor))
91
112
 
92
113
 
93
114
  class ProfileGeneric(ver0.ProfileGeneric):
@@ -186,6 +207,45 @@ class ProfileGeneric(ver0.ProfileGeneric):
186
207
  """ Available after got sort object. TODO: need rewrite. maybe replace to collection level. Wrong used sort_obj, it can be any element from capture_objects"""
187
208
  if self.sort_object is None:
188
209
  raise exc.EmptyObj(F"<sort object> is empty")
210
+ sort_obj: ic.COSEMInterfaceClasses = self.collection.get_object(self.sort_object.logical_name)
211
+ if sort_obj.CLASS_ID.contents == self.sort_object.class_id.contents:
212
+ value_type: Type[cdt.CommonDataType] = sort_obj.get_attr_data_type(int(self.sort_object.attribute_index))
213
+ else:
214
+ exc.NoObject(F"got {self.sort_object.class_id=}, expected {sort_obj.CLASS_ID=} from collection")
215
+
216
+ class RangeDescriptor(cdt.Structure):
217
+ # cb_preset = TODO: make check 'selected_values' from self.capture_objects or
218
+ # cb_post_set = TODO: make check 'selected_values' from self.capture_objects
219
+ DEFAULT = b'\x02\x04\x02\x04\x12\x00\x01\x09\x06\x00\x00\x01\x00\x00\xff\x0f\x02\x12\x00\x00\x09\x0c\x07\xe4\x01\x01\xff\xff\xff\xff\xff\x80\x00\xff' \
220
+ b'\x09\x0c\x07\xe4\x01\x02\xff\xff\xff\xff\xff\x80\x00\xff\x01\x00'
221
+ restricting_object: structs.CaptureObjectDefinition
222
+ from_value: value_type
223
+ to_value: value_type
224
+ selected_values: CaptureObjects
225
+
226
+ class Data(ut.Data):
227
+ restricting_object: structs.CaptureObjectDefinition
228
+ from_value: cdt.SimpleDataType
229
+ to_value: cdt.SimpleDataType
230
+ selected_values: CaptureObjects
231
+ from_entry: FromEntry
232
+ to_entry: cdt.DoubleLongUnsigned
233
+ from_selected_value: cdt.LongUnsigned
234
+ to_selected_value: cdt.LongUnsigned
235
+ ELEMENTS = {1: ut.SequenceElement('range_descriptor', RangeDescriptor),
236
+ 2: ut.SequenceElement('entry_descriptor', EntryDescriptor)}
237
+
238
+ class SelectiveAccessDescriptor(ut.SelectiveAccessDescriptor):
239
+ access_selector: AccessSelector
240
+ access_parameters: Data
241
+ ELEMENTS = (ut.SequenceElement('access_selector', AccessSelector),
242
+ ut.SequenceElement('access_parameters', Data))
243
+
244
+ class CosemAttributeDescriptorWithSelection(ut.CosemAttributeDescriptorWithSelection):
245
+ access_selection: SelectiveAccessDescriptor
246
+ ELEMENTS = (ut.SequenceElement('cosem_attribute_descriptor', ut.CosemAttributeDescriptor),
247
+ ut.SequenceElement('access_selection', SelectiveAccessDescriptor))
248
+
189
249
  self.attr_descriptor_with_selection = CosemAttributeDescriptorWithSelection
190
250
  self.buffer.selective_access = SelectiveAccessDescriptor()
191
251
 
DLMS_SPODES/hdlc/frame.py CHANGED
@@ -735,6 +735,7 @@ class Frame:
735
735
  """ return SA, DA for reusing """
736
736
  return self.__destination_address, self.__source_address
737
737
 
738
+ # todo: make <parse> with Result
738
739
  @classmethod
739
740
  def try_from(cls, value: bytearray) -> Frame | None:
740
741
  """ Search of HDLC start flag and return Frame and value remains for next searching. If wrong frame when return value with out start flag for parsing """
@@ -749,7 +750,7 @@ class Frame:
749
750
  print(F'Wrong Frame: {e.args[0]}')
750
751
  return None
751
752
  except NotEnoughDataError as e:
752
- print(F'Frame Error: {e.args[0]}')
753
+ # print(F'Frame Error: {e.args[0]}')
753
754
  return None
754
755
  except FormatDataError as e:
755
756
  print(F'Frame Error: {e.args[0]}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DLMS_SPODES
3
- Version: 0.87.10
3
+ Version: 0.87.12
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
@@ -81,7 +81,7 @@ DLMS_SPODES/cosem_interface_classes/ntp_setup/__init__.py,sha256=47DEQpj8HBSa-_T
81
81
  DLMS_SPODES/cosem_interface_classes/ntp_setup/ver0.py,sha256=1Eaf9dnqK8kFbn38Op-PxbHg1b63QwAQEY41f3ZXF2E,2044
82
82
  DLMS_SPODES/cosem_interface_classes/profile_generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
83
  DLMS_SPODES/cosem_interface_classes/profile_generic/ver0.py,sha256=AhOPl9gCwWNCZ-Hvn-pG5SRg2yP1kPljnG_Uelr_BXg,4220
84
- DLMS_SPODES/cosem_interface_classes/profile_generic/ver1.py,sha256=-B8CWiWXif2bhjhepMz5iVwJFrwoT2kRBKJct1CzXws,10293
84
+ DLMS_SPODES/cosem_interface_classes/profile_generic/ver1.py,sha256=kHnPGpATAiSXxrvpFU_RpY87gYo_gbEuZk7fe8_aup4,14005
85
85
  DLMS_SPODES/cosem_interface_classes/push_setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
86
  DLMS_SPODES/cosem_interface_classes/push_setup/ver0.py,sha256=JDbN0uyXM9iAWQe7JOgkz5DxibdcUQQrxPfTCII7CJ8,385
87
87
  DLMS_SPODES/cosem_interface_classes/push_setup/ver1.py,sha256=D25GXpg2uLl2nQ6eQMScFyId4ZhKdUwcU7jWUP3egG4,348
@@ -93,7 +93,7 @@ DLMS_SPODES/cosem_interface_classes/security_setup/ver0.py,sha256=INRPYsWdVKOngm
93
93
  DLMS_SPODES/cosem_interface_classes/security_setup/ver1.py,sha256=Xs8aSme9Qu4ekT9E4FQrapdxP7yS2B6pE8SKDQaFDtk,4956
94
94
  DLMS_SPODES/cosem_interface_classes/security_setup/__pycache__/__init__.cpython-311.pyc,sha256=1ZbhthOjr77pX0c1vW5wX8q9pGvIcz_kAKr6ZemvpSA,210
95
95
  DLMS_SPODES/hdlc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
- DLMS_SPODES/hdlc/frame.py,sha256=ar5DvkPK5tUGSZcQYCpeku1Ansx7QecugvmcV-xekqI,34784
96
+ DLMS_SPODES/hdlc/frame.py,sha256=KCvP36LHaMKLEbDsKUCtOIw3tfWRC7YfEawbu_Q9kis,34824
97
97
  DLMS_SPODES/hdlc/sub_layer.py,sha256=zTxe5ddTt8tliFSY145HhluLwIh57gvOG19Mc8-vnEM,2147
98
98
  DLMS_SPODES/obis/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
99
99
  DLMS_SPODES/obis/media_id.py,sha256=D_Vm7aT6XevrIN22NQgMHReVju_VGH9mYphfh1Nn09c,22516
@@ -111,7 +111,7 @@ DLMS_SPODES/types/implementations/integers.py,sha256=Asy4X260t1Fzw_V5iw0uiDOxtfB
111
111
  DLMS_SPODES/types/implementations/long_unsigneds.py,sha256=SxmFvD2moQ03p-KZSBYK1Rv7bQSaywlHVXBfkTZG1OQ,8761
112
112
  DLMS_SPODES/types/implementations/octet_string.py,sha256=Jo_sfWcsfstiP4O6mXfBOOQlksx1c2qJMI-vbAOV-yM,294
113
113
  DLMS_SPODES/types/implementations/structs.py,sha256=GMOo6Jy8jA9d6KTLs0D-j5t0oSRvxUIwtBr_4UePwbA,2059
114
- dlms_spodes-0.87.10.dist-info/METADATA,sha256=LYDbBhwz-TQQ0qB5RiEJxllBfXGjj1YMchcBmB0dLT4,1109
115
- dlms_spodes-0.87.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
116
- dlms_spodes-0.87.10.dist-info/top_level.txt,sha256=k26SRuRdwBZrSM3NgNZECAUNIDZREbJuLCnPbWtTNak,12
117
- dlms_spodes-0.87.10.dist-info/RECORD,,
114
+ dlms_spodes-0.87.12.dist-info/METADATA,sha256=gV1hjz0LLnGH1qFEG9OA1yssLqQNcogMWb_XjUFfzk4,1109
115
+ dlms_spodes-0.87.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
116
+ dlms_spodes-0.87.12.dist-info/top_level.txt,sha256=k26SRuRdwBZrSM3NgNZECAUNIDZREbJuLCnPbWtTNak,12
117
+ dlms_spodes-0.87.12.dist-info/RECORD,,