COSEMpdu 0.2.0__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.
COSEMpdu/apdu.py ADDED
@@ -0,0 +1,1440 @@
1
+ """
2
+ COSEM PDU Types Implementation
3
+ Based on COSEMpdu_GB83.txt (Green Book 8.3)
4
+ Implements A-XDR encoding/decoding according to IEC 61334-6
5
+ """
6
+ from dataclasses import dataclass
7
+ from typing import ClassVar, Optional, Self
8
+ from .data import Data, NullData
9
+ from .x680.tagged_type import TaggingMode
10
+ from .x680.enumerated_type import EnumerationList, EnumerationMember
11
+ from .axdr import (
12
+ ConstrainedIntegerType, EnumeratedType, IntegerType, ConstrainedOctetStringType,
13
+ OctetStringType, BitStringType, SequenceType, SequenceOfType, create_alternatives,
14
+ ChoiceType, TaggedType, NullType, BooleanType, VisibleString, Utf8String, GeneralizedTime, NullType0
15
+ )
16
+ from .x680.type import STRING, NamedType, OptionalNamedType
17
+ from .useful_types import Integer8, Unsigned16, Unsigned8, ObjectName, Unsigned32
18
+ from .byte_buffer import ByteBuffer
19
+ from .types_used import (
20
+ CosemAttributeDescriptor,
21
+ CosemAttributeDescriptorWithSelection,
22
+ CosemMethodDescriptor,
23
+ InvokeIdAndPriority,
24
+ SelectiveAccessDescriptor,
25
+ VariableAccessSpecification,
26
+ Data0,
27
+ DataAccesResult1,
28
+ DataBlockResult,
29
+ LongInvokeIdAndPriority,
30
+ GetDataResult,
31
+ DataBlockG,
32
+ DataBlockSA,
33
+ DataAccessResult,
34
+ ActionResponseWithOptionalData,
35
+ AccessRequestBody,
36
+ AccessResponseBody
37
+ )
38
+ from .service_error import ConfirmedServiceError
39
+ from .user_information import InitiateRequest, InitiateResponse
40
+ from .key_info import KeyInfo
41
+
42
+
43
+ @dataclass
44
+ class InitialRequest1(TaggedType[InitiateRequest]):
45
+ """initialRequest"""
46
+ tag = 1
47
+ mode = TaggingMode.IMPLICIT
48
+ value: InitiateRequest
49
+
50
+
51
+ @dataclass
52
+ class InitialResponse8(TaggedType[InitiateResponse]):
53
+ """initialResponse"""
54
+ tag = 8
55
+ mode = TaggingMode.IMPLICIT
56
+ value: InitiateResponse
57
+
58
+
59
+ # ============================================================================
60
+ # -- Read/Write Request/Response (COSEMpdu_GB83.txt)
61
+ # ============================================================================
62
+
63
+ @dataclass
64
+ class ReadRequest(SequenceOfType[VariableAccessSpecification]):
65
+ """ReadRequest"""
66
+ component_type = VariableAccessSpecification
67
+
68
+
69
+ @dataclass
70
+ class ReadRequest5(TaggedType[ReadRequest]):
71
+ """readRequest"""
72
+ tag = 5
73
+ mode = TaggingMode.IMPLICIT
74
+ value: ReadRequest
75
+
76
+
77
+ @dataclass
78
+ class DataBlockResult2(TaggedType[DataBlockResult]):
79
+ """[2] IMPLICIT Data-Block-Result"""
80
+ tag = 2
81
+ mode = TaggingMode.IMPLICIT
82
+ value: DataBlockResult
83
+
84
+
85
+ @dataclass
86
+ class BlockNumber3(TaggedType[Unsigned16]):
87
+ """[3] IMPLICIT Unsigned16"""
88
+ tag = 3
89
+ mode = TaggingMode.IMPLICIT
90
+ value: Unsigned16
91
+
92
+
93
+ class ReadResponseChoice(ChoiceType):
94
+ """CHOICE {
95
+ data [0] Data,
96
+ data-access-error [1] IMPLICIT Data-Access-Result,
97
+ data-block-result [2] IMPLICIT Data-Block-Result,
98
+ block-number [3] IMPLICIT Unsigned16
99
+ }
100
+ """
101
+ alternatives = create_alternatives(
102
+ NamedType("data", Data0),
103
+ NamedType("data-access-error", DataAccesResult1),
104
+ NamedType("data-block-result", DataBlockResult2),
105
+ NamedType("block-number", BlockNumber3),
106
+ )
107
+ value: DataBlockResult2 | DataAccesResult1 | DataBlockResult2 | BlockNumber3
108
+
109
+
110
+ @dataclass
111
+ class ReadResponse(SequenceOfType[ReadResponseChoice]):
112
+ """ReadResponse"""
113
+ component_type = ReadResponseChoice
114
+
115
+
116
+ @dataclass
117
+ class ReadResponse12(TaggedType[ReadResponse]):
118
+ """[12] IMPLICIT ReadResponse"""
119
+ tag = 12
120
+ mode = TaggingMode.IMPLICIT
121
+ value: ReadResponse
122
+
123
+
124
+ @dataclass
125
+ class WriteRequest(SequenceType):
126
+ """WriteRequest"""
127
+ components = (
128
+ NamedType("variable-access-specification", SequenceOfType[VariableAccessSpecification]),
129
+ NamedType("list-of-data", SequenceOfType[Data]),
130
+ )
131
+
132
+
133
+ @dataclass
134
+ class WriteRequest6(TaggedType[WriteRequest]):
135
+ """writeRequest"""
136
+ tag = 6
137
+ mode = TaggingMode.IMPLICIT
138
+ value: WriteRequest
139
+
140
+
141
+ @dataclass
142
+ class BlockNumber2(TaggedType[Unsigned16]):
143
+ """[2] Unsigned16"""
144
+ tag = 2
145
+ mode = TaggingMode.DEFAULT
146
+ value: Unsigned16
147
+
148
+
149
+ @dataclass
150
+ class WriteResponseChoice(ChoiceType):
151
+ """CHOICE {
152
+ success [0] IMPLICIT NULL,
153
+ data-access-error [1] IMPLICIT Data-Access-Result,
154
+ block-number [2] Unsigned16
155
+ }
156
+ """
157
+ alternatives = {
158
+ 0: NamedType("success", NullType0),
159
+ 1: NamedType("data-access-error", DataAccesResult1),
160
+ 2: NamedType("block-number", BlockNumber2),
161
+ }
162
+ value: NullType0 | DataAccesResult1 | BlockNumber2
163
+ SUCCESS: ClassVar["WriteResponseChoice"]
164
+
165
+
166
+ WriteResponseChoice.SUCCESS = WriteResponseChoice(NullType0(NullType(None)))
167
+
168
+
169
+ @dataclass
170
+ class WriteResponse(SequenceOfType[WriteResponseChoice]):
171
+ """WriteResponse"""
172
+ component_type = WriteResponseChoice
173
+
174
+
175
+ @dataclass
176
+ class writeResponse(TaggedType[WriteResponse]):
177
+ """writeResponse"""
178
+ tag = 13
179
+ mode = TaggingMode.IMPLICIT
180
+ value: WriteResponse
181
+
182
+
183
+ @dataclass
184
+ class confirmedServiceError(TaggedType[ConfirmedServiceError]):
185
+ """confirmedServiceError"""
186
+ tag = 14
187
+ mode = TaggingMode.IMPLICIT
188
+ value: ConfirmedServiceError
189
+
190
+
191
+ @dataclass
192
+ class NotificationBody(SequenceType):
193
+ """NotificationBody"""
194
+ components = (
195
+ NamedType("data-value", Data),
196
+ )
197
+
198
+
199
+ @dataclass
200
+ class DataNotification(SequenceType):
201
+ """DataNotification"""
202
+ components = (
203
+ NamedType("long-invoke-id-and-priority", LongInvokeIdAndPriority),
204
+ NamedType("date-time", OctetStringType),
205
+ NamedType("notification-body", NotificationBody),
206
+ )
207
+
208
+
209
+ @dataclass
210
+ class DataNotification15(TaggedType[DataNotification]):
211
+ """data-notification"""
212
+ tag = 15
213
+ mode = TaggingMode.IMPLICIT
214
+ value: DataNotification
215
+
216
+
217
+ @dataclass
218
+ class DataNotificationConfirm(SequenceType):
219
+ """DataNotificationConfirm"""
220
+ components = (
221
+ NamedType("long-invoke-id-and-priority", LongInvokeIdAndPriority),
222
+ NamedType("date-time", OctetStringType),
223
+ )
224
+
225
+
226
+ @dataclass
227
+ class DataNotificationConfirm16(TaggedType[DataNotificationConfirm]):
228
+ """data-notification-confirm"""
229
+ tag = 16
230
+ mode = TaggingMode.IMPLICIT
231
+ value: DataNotificationConfirm
232
+
233
+
234
+ @dataclass
235
+ class UnconfirmedWriteRequest(SequenceType):
236
+ """UnconfirmedWriteRequest"""
237
+ components = (
238
+ NamedType("variable-access-specification", SequenceOfType[VariableAccessSpecification]),
239
+ NamedType("list-of-data", SequenceOfType[Data]),
240
+ )
241
+
242
+
243
+ @dataclass
244
+ class UnconfirmedWriteRequest22(TaggedType[UnconfirmedWriteRequest]):
245
+ """unconfirmedWriteRequest"""
246
+ tag = 22
247
+ mode = TaggingMode.IMPLICIT
248
+ value: UnconfirmedWriteRequest
249
+
250
+
251
+ @dataclass
252
+ class InformationReportRequest(SequenceType):
253
+ """InformationReportRequest"""
254
+ components = (
255
+ OptionalNamedType("current-time", GeneralizedTime),
256
+ NamedType("variable-access-specification", SequenceOfType[VariableAccessSpecification]),
257
+ NamedType("list-of-data", SequenceOfType[Data]),
258
+ )
259
+
260
+
261
+ @dataclass
262
+ class InformationReportRequest24(TaggedType[InformationReportRequest]):
263
+ """informationReportRequest"""
264
+ tag = 24
265
+ mode = TaggingMode.IMPLICIT
266
+ value: InformationReportRequest
267
+
268
+
269
+ @dataclass
270
+ class GloInitiateRequest(TaggedType[OctetStringType]):
271
+ """glo-initiateRequest"""
272
+ tag = 33
273
+ mode = TaggingMode.IMPLICIT
274
+ value: OctetStringType
275
+
276
+ @dataclass
277
+ class GloReadRequest(TaggedType[OctetStringType]):
278
+ """glo-readRequest"""
279
+ tag = 37
280
+ mode = TaggingMode.IMPLICIT
281
+ value: OctetStringType
282
+
283
+ @dataclass
284
+ class GloWriteRequest(TaggedType[OctetStringType]):
285
+ """glo-writeRequest"""
286
+ tag = 38
287
+ mode = TaggingMode.IMPLICIT
288
+ value: OctetStringType
289
+
290
+ @dataclass
291
+ class GloInitiateResponse(TaggedType[OctetStringType]):
292
+ """glo-initiateResponse"""
293
+ tag = 40
294
+ mode = TaggingMode.IMPLICIT
295
+ value: OctetStringType
296
+
297
+ @dataclass
298
+ class GloReadResponse(TaggedType[OctetStringType]):
299
+ """glo-readResponse"""
300
+ tag = 44
301
+ mode = TaggingMode.IMPLICIT
302
+ value: OctetStringType
303
+
304
+ @dataclass
305
+ class GloWriteResponse(TaggedType[OctetStringType]):
306
+ """glo-writeResponse"""
307
+ tag = 45
308
+ mode = TaggingMode.IMPLICIT
309
+ value: OctetStringType
310
+
311
+ @dataclass
312
+ class GloConfirmedServiceError(TaggedType[OctetStringType]):
313
+ """glo-confirmedServiceError"""
314
+ tag = 46
315
+ mode = TaggingMode.IMPLICIT
316
+ value: OctetStringType
317
+
318
+ @dataclass
319
+ class GloUnconfirmedWriteRequest(TaggedType[OctetStringType]):
320
+ """glo-unconfirmedWriteRequest"""
321
+ tag = 54
322
+ mode = TaggingMode.IMPLICIT
323
+ value: OctetStringType
324
+
325
+ @dataclass
326
+ class GloInformationReportRequest(TaggedType[OctetStringType]):
327
+ """glo-informationReportRequest"""
328
+ tag = 56
329
+ mode = TaggingMode.IMPLICIT
330
+ value: OctetStringType
331
+
332
+
333
+ @dataclass
334
+ class DedInitiateRequest(TaggedType[OctetStringType]):
335
+ """ded-initiateRequest"""
336
+ tag = 65
337
+ mode = TaggingMode.IMPLICIT
338
+ value: OctetStringType
339
+
340
+ @dataclass
341
+ class DedReadRequest(TaggedType[OctetStringType]):
342
+ """ded-readRequest"""
343
+ tag = 69
344
+ mode = TaggingMode.IMPLICIT
345
+ value: OctetStringType
346
+
347
+ @dataclass
348
+ class DedWriteRequest(TaggedType[OctetStringType]):
349
+ """ded-writeRequest"""
350
+ tag = 70
351
+ mode = TaggingMode.IMPLICIT
352
+ value: OctetStringType
353
+
354
+ @dataclass
355
+ class DedInitiateResponse(TaggedType[OctetStringType]):
356
+ """ded-initiateResponse"""
357
+ tag = 72
358
+ mode = TaggingMode.IMPLICIT
359
+ value: OctetStringType
360
+
361
+ @dataclass
362
+ class DedReadResponse(TaggedType[OctetStringType]):
363
+ """ded-readResponse"""
364
+ tag = 76
365
+ mode = TaggingMode.IMPLICIT
366
+ value: OctetStringType
367
+
368
+ @dataclass
369
+ class DedWriteResponse(TaggedType[OctetStringType]):
370
+ """ded-writeResponse"""
371
+ tag = 77
372
+ mode = TaggingMode.IMPLICIT
373
+ value: OctetStringType
374
+
375
+ @dataclass
376
+ class DedConfirmedServiceError(TaggedType[OctetStringType]):
377
+ """ded-confirmedServiceError"""
378
+ tag = 78
379
+ mode = TaggingMode.IMPLICIT
380
+ value: OctetStringType
381
+
382
+ @dataclass
383
+ class DedUnconfirmedWriteRequest(TaggedType[OctetStringType]):
384
+ """ded-unconfirmedWriteRequest"""
385
+ tag = 86
386
+ mode = TaggingMode.IMPLICIT
387
+ value: OctetStringType
388
+
389
+ @dataclass
390
+ class DedInformationReportRequest(TaggedType[OctetStringType]):
391
+ """ded-informationReportRequest"""
392
+ tag = 88
393
+ mode = TaggingMode.IMPLICIT
394
+ value: OctetStringType
395
+
396
+
397
+ @dataclass
398
+ class GetRequestNormal(SequenceType):
399
+ """Get-Request-Normal"""
400
+ components = (
401
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
402
+ NamedType("cosem-attribute-descriptor", CosemAttributeDescriptor),
403
+ OptionalNamedType("access-selection", SelectiveAccessDescriptor),
404
+ )
405
+
406
+
407
+ @dataclass
408
+ class GetRequestNormal1(TaggedType[GetRequestNormal]):
409
+ """[1] IMPLICIT Get-Request-Normal"""
410
+ tag = 1
411
+ mode = TaggingMode.IMPLICIT
412
+ value: GetRequestNormal
413
+
414
+
415
+ @dataclass
416
+ class GetRequestNext(SequenceType):
417
+ """Get-Request-Next"""
418
+ components = (
419
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
420
+ NamedType("block-number", Unsigned32),
421
+ )
422
+
423
+
424
+ @dataclass
425
+ class GetRequestNext2(TaggedType[GetRequestNext]):
426
+ """[2] IMPLICIT Get-Request-Next"""
427
+ tag = 2
428
+ mode = TaggingMode.IMPLICIT
429
+ value: GetRequestNext
430
+
431
+
432
+ @dataclass
433
+ class GetRequestWithList(SequenceType):
434
+ """Get-Request-With-List"""
435
+ components = (
436
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
437
+ NamedType("attribute-descriptor-list", SequenceOfType[CosemAttributeDescriptorWithSelection]),
438
+ )
439
+
440
+
441
+ @dataclass
442
+ class GetRequestWithList3(TaggedType[GetRequestWithList]):
443
+ """[3] IMPLICIT Get-Request-With-List"""
444
+ tag = 3
445
+ mode = TaggingMode.IMPLICIT
446
+ value: GetRequestWithList
447
+
448
+
449
+ @dataclass
450
+ class GetRequest(ChoiceType):
451
+ """Get-Request"""
452
+ alternatives = {
453
+ 1: NamedType("get-request-normal", GetRequestNormal1),
454
+ 2: NamedType("get-request-next", GetRequestNext2),
455
+ 3: NamedType("get-request-with-list", GetRequestWithList3),
456
+ }
457
+
458
+
459
+ class getRequest(TaggedType[GetRequest]):
460
+ """[192] IMPLICIT Get-Request"""
461
+ tag = 192
462
+ mode = TaggingMode.IMPLICIT
463
+ value: GetRequest
464
+
465
+
466
+ @dataclass
467
+ class GetResponseNormal(SequenceType):
468
+ """Get-Response-Normal"""
469
+ components = (
470
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
471
+ NamedType("result", GetDataResult),
472
+ )
473
+
474
+
475
+ @dataclass
476
+ class GetResponseNormal1(TaggedType[GetResponseNormal]):
477
+ """[1] IMPLICIT Get-Response-Normal"""
478
+ tag = 1
479
+ mode = TaggingMode.IMPLICIT
480
+ value: GetResponseNormal
481
+
482
+
483
+ @dataclass
484
+ class GetResponseWithDatablock(SequenceType):
485
+ """Get-Response-With-Datablock ::= SEQUENCE {invoke-id-and-priority, result}"""
486
+ components = (
487
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
488
+ NamedType("result", DataBlockG),
489
+ )
490
+
491
+
492
+ @dataclass
493
+ class GetResponseWithDatablock2(TaggedType[GetResponseWithDatablock]):
494
+ """[2] IMPLICIT Get-Response-With-Datablock"""
495
+ tag = 2
496
+ mode = TaggingMode.IMPLICIT
497
+ value: GetResponseWithDatablock
498
+
499
+
500
+ @dataclass
501
+ class GetResponseWithList(SequenceType):
502
+ """Get-Response-With-List ::= SEQUENCE {invoke-id-and-priority, result}"""
503
+ components = (
504
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
505
+ NamedType("result", SequenceOfType[GetDataResult]),
506
+ )
507
+
508
+
509
+ @dataclass
510
+ class GetResponseWithList3(TaggedType[GetResponseWithList]):
511
+ """[3] IMPLICIT Get-Response-With-List"""
512
+ tag = 3
513
+ mode = TaggingMode.IMPLICIT
514
+ value: GetResponseWithList
515
+
516
+
517
+ @dataclass
518
+ class GetResponse(ChoiceType):
519
+ """Get-Response"""
520
+ alternatives = {
521
+ 1: NamedType("get-response-normal", GetResponseNormal1),
522
+ 2: NamedType("get-response-with-datablock", GetResponseWithDatablock2),
523
+ 3: NamedType("get-response-with-list", GetResponseWithList3),
524
+ }
525
+
526
+
527
+ @dataclass
528
+ class getResponse(TaggedType[GetResponse]):
529
+ """[196] IMPLICIT Get-Response"""
530
+ tag = 196
531
+ mode = TaggingMode.IMPLICIT
532
+ value: GetResponse
533
+
534
+
535
+ @dataclass
536
+ class SetRequestNormal(SequenceType):
537
+ """Set-Request-Normal"""
538
+ components = (
539
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
540
+ NamedType("cosem-attribute-descriptor", CosemAttributeDescriptor),
541
+ OptionalNamedType("access-selection", SelectiveAccessDescriptor),
542
+ NamedType("value", Data),
543
+ )
544
+
545
+
546
+ @dataclass
547
+ class SetRequestNormal1(TaggedType[SetRequestNormal]):
548
+ """[1] IMPLICIT Set-Request-Normal"""
549
+ tag = 1
550
+ mode = TaggingMode.IMPLICIT
551
+ value: SetRequestNormal
552
+
553
+
554
+ @dataclass
555
+ class SetRequestWithFirstDatablock(SequenceType):
556
+ """Set-Request-With-First-Datablock"""
557
+ components = (
558
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
559
+ NamedType("cosem-attribute-descriptor", CosemAttributeDescriptor),
560
+ OptionalNamedType("access-selection", SelectiveAccessDescriptor),
561
+ NamedType("datablock", DataBlockSA),
562
+ )
563
+
564
+
565
+ @dataclass
566
+ class SetRequestWithFirstDatablock2(TaggedType[SetRequestWithFirstDatablock]):
567
+ """[2] IMPLICIT Set-Request-With-First-Datablock"""
568
+ tag = 2
569
+ mode = TaggingMode.IMPLICIT
570
+ value: SetRequestWithFirstDatablock
571
+
572
+
573
+ @dataclass
574
+ class SetRequestWithDatablock(SequenceType):
575
+ """Set-Request-With-Datablock"""
576
+ components = (
577
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
578
+ NamedType("cosem-attribute-descriptor", CosemAttributeDescriptor),
579
+ OptionalNamedType("access-selection", SelectiveAccessDescriptor),
580
+ NamedType("datablock", DataBlockSA)
581
+ )
582
+
583
+
584
+ @dataclass
585
+ class SetRequestWithDatablock3(TaggedType[SetRequestWithDatablock]):
586
+ """[3] IMPLICIT Set-Request-With-Datablock"""
587
+ tag = 3
588
+ mode = TaggingMode.IMPLICIT
589
+ value: SetRequestWithDatablock
590
+
591
+
592
+ @dataclass
593
+ class SetRequestWithList(SequenceType):
594
+ """Set-Request-With-List"""
595
+ components = (
596
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
597
+ NamedType("attribute-descriptor-list", SequenceOfType[CosemAttributeDescriptorWithSelection]),
598
+ NamedType("value-list", SequenceOfType[Data])
599
+ )
600
+
601
+
602
+ @dataclass
603
+ class SetRequestWithList4(TaggedType[SetRequestWithList]):
604
+ """[4] IMPLICIT Set-Request-With-List"""
605
+ tag = 4
606
+ mode = TaggingMode.IMPLICIT
607
+ value: SetRequestWithList
608
+
609
+
610
+ @dataclass
611
+ class SetRequestWithListAndFirstDatablock(SequenceType):
612
+ """Set-Request-With-List-And-First-Datablock"""
613
+ components = (
614
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
615
+ NamedType("attribute-descriptor-list", SequenceOfType[CosemAttributeDescriptorWithSelection]),
616
+ NamedType("datablock", DataBlockSA)
617
+ )
618
+
619
+
620
+ @dataclass
621
+ class SetRequestWithListAndFirstDatablock5(TaggedType[SetRequestWithListAndFirstDatablock]):
622
+ """[5] IMPLICIT Set-Request-With-List-And-First-Datablock"""
623
+ tag = 5
624
+ mode = TaggingMode.IMPLICIT
625
+ value: SetRequestWithListAndFirstDatablock
626
+
627
+
628
+ @dataclass
629
+ class SetRequest(ChoiceType):
630
+ """Set-Request"""
631
+ alternatives = {
632
+ 1: NamedType("set-request-normal", SetRequestNormal1),
633
+ 2: NamedType("set-request-with-first-datablock", SetRequestWithFirstDatablock2),
634
+ 3: NamedType("set-request-with-datablock", SetRequestWithDatablock3),
635
+ 4: NamedType("set-request-with-list", SetRequestWithList4),
636
+ 5: NamedType("set-request-with-list-and-first-datablock", SetRequestWithListAndFirstDatablock5),
637
+ }
638
+
639
+
640
+ @dataclass
641
+ class setRequest(TaggedType[SetRequest]):
642
+ """[193] IMPLICIT Set-Request"""
643
+ tag = 193
644
+ mode = TaggingMode.IMPLICIT
645
+ value: SetRequest
646
+
647
+
648
+ @dataclass
649
+ class SetResponseNormal(SequenceType):
650
+ """Set-Response-Normal"""
651
+ components = (
652
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
653
+ NamedType("result", GetDataResult),
654
+ )
655
+
656
+
657
+ @dataclass
658
+ class SetResponseNormal1(TaggedType[SetResponseNormal]):
659
+ """[1] IMPLICIT Set-Response-Normal"""
660
+ tag = 1
661
+ mode = TaggingMode.IMPLICIT
662
+ value: SetResponseNormal
663
+
664
+
665
+ @dataclass
666
+ class SetResponseDatablock(SequenceType):
667
+ """Set-Response-Datablock"""
668
+ components = (
669
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
670
+ NamedType("block-number", Unsigned32)
671
+ )
672
+
673
+
674
+ @dataclass
675
+ class SetResponseDatablock2(TaggedType[SetResponseDatablock]):
676
+ """[2] IMPLICIT Set-Response-Datablock"""
677
+ tag = 2
678
+ mode = TaggingMode.IMPLICIT
679
+ value: SetResponseDatablock
680
+
681
+
682
+ @dataclass
683
+ class SetResponseLastDatablock(SequenceType):
684
+ """Set-Response-Last-Datablock"""
685
+ components = (
686
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
687
+ NamedType("result", DataAccessResult),
688
+ NamedType("block-number", Unsigned32)
689
+ )
690
+
691
+
692
+ @dataclass
693
+ class SetResponseLastDatablock3(TaggedType[SetResponseLastDatablock]):
694
+ """[3] IMPLICIT Set-Response-Last-Datablock"""
695
+ tag = 3
696
+ mode = TaggingMode.IMPLICIT
697
+ value: SetResponseLastDatablock
698
+
699
+
700
+ @dataclass
701
+ class SetResponseLastDatablockWithList(SequenceType):
702
+ """Set-Response-Last-Datablock-With-List"""
703
+ components = (
704
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
705
+ NamedType("result", SequenceOfType[DataAccessResult]),
706
+ NamedType("block-number", Unsigned32)
707
+ )
708
+
709
+
710
+ @dataclass
711
+ class SetResponseLastDatablockWithList4(TaggedType[SetResponseLastDatablockWithList]):
712
+ """[4] IMPLICIT Set-Response-Last-Datablock-With-List"""
713
+ tag = 4
714
+ mode = TaggingMode.IMPLICIT
715
+ value: SetResponseLastDatablockWithList
716
+
717
+
718
+ @dataclass
719
+ class SetResponseWithList(SequenceType):
720
+ """Set-Response-With-List"""
721
+ components = (
722
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
723
+ NamedType("result", SequenceOfType[DataAccessResult]),
724
+ )
725
+
726
+
727
+ @dataclass
728
+ class SetResponseWithList5(TaggedType[SetResponseWithList]):
729
+ """[5] IMPLICIT Set-Response-With-List"""
730
+ tag = 5
731
+ mode = TaggingMode.IMPLICIT
732
+ value: SetResponseWithList
733
+
734
+
735
+ @dataclass
736
+ class SetResponse(ChoiceType):
737
+ """Set-Response"""
738
+ alternatives = {
739
+ 1: NamedType("set-response-normal", SetResponseNormal1),
740
+ 2: NamedType("set-response-datablock", SetResponseDatablock2),
741
+ 3: NamedType("set-response-last-datablock", SetResponseLastDatablock3),
742
+ 4: NamedType("set-response-last-datablock-with-list", SetResponseLastDatablockWithList4),
743
+ 5: NamedType("set-response-with-list", SetResponseWithList5)
744
+ }
745
+
746
+
747
+ @dataclass
748
+ class setResponse(TaggedType[SetResponse]):
749
+ """[197] IMPLICIT Set-Response"""
750
+ tag = 197
751
+ mode = TaggingMode.IMPLICIT
752
+ value: SetResponse
753
+
754
+
755
+ @dataclass
756
+ class ActionRequestNormal(SequenceType):
757
+ """Action-Request-Normal"""
758
+ components = (
759
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
760
+ NamedType("cosem-method-descriptor", CosemMethodDescriptor),
761
+ OptionalNamedType("method-invocation-parameters", Data)
762
+ )
763
+
764
+
765
+ @dataclass
766
+ class ActionRequestNormal1(TaggedType[ActionRequestNormal]):
767
+ """[1] IMPLICIT Action-Request-Normal"""
768
+ tag = 1
769
+ mode = TaggingMode.IMPLICIT
770
+ value: ActionRequestNormal
771
+
772
+
773
+ @dataclass
774
+ class ActionRequestNextPblock(SequenceType):
775
+ """Action-Request-Next-Pblock"""
776
+ components = (
777
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
778
+ NamedType("block-number", Unsigned32)
779
+ )
780
+
781
+ @dataclass
782
+ class ActionRequestNextPblock2(TaggedType[ActionRequestNextPblock]):
783
+ """[2] IMPLICIT Action-Request-Next-Pblock"""
784
+ tag = 2
785
+ mode = TaggingMode.IMPLICIT
786
+ value: ActionRequestNextPblock
787
+
788
+
789
+ @dataclass
790
+ class ActionRequestWithList(SequenceType):
791
+ """Action-Request-With-List"""
792
+ components = (
793
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
794
+ NamedType("cosem-method-descriptor-list", SequenceOfType[CosemMethodDescriptor]),
795
+ NamedType("method-invocation-parameters", SequenceOfType[Data])
796
+ )
797
+
798
+ @dataclass
799
+ class ActionRequestWithList3(TaggedType[ActionRequestWithList]):
800
+ """[3] IMPLICIT Action-Request-With-List"""
801
+ tag = 3
802
+ mode = TaggingMode.IMPLICIT
803
+ value: ActionRequestWithList
804
+
805
+
806
+ @dataclass
807
+ class ActionRequestWithFirstPblock(SequenceType):
808
+ """Action-Request-With-First-Pblock"""
809
+ components = (
810
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
811
+ NamedType("cosem-method-descriptor", CosemMethodDescriptor),
812
+ NamedType("pblock", DataBlockSA)
813
+ )
814
+
815
+ @dataclass
816
+ class ActionRequestWithFirstPblock4(TaggedType[ActionRequestWithFirstPblock]):
817
+ """[4] IMPLICIT Action-Request-With-First-Pblock"""
818
+ tag = 4
819
+ mode = TaggingMode.IMPLICIT
820
+ value: ActionRequestWithFirstPblock
821
+
822
+
823
+ @dataclass
824
+ class ActionRequestWithListAndFirstPblock(SequenceType):
825
+ """Action-Request-With-List-And-First-Pblock"""
826
+ components = (
827
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
828
+ NamedType("cosem-method-descriptor-list", SequenceOfType[CosemMethodDescriptor]),
829
+ NamedType("pblock", DataBlockSA)
830
+ )
831
+
832
+ @dataclass
833
+ class ActionRequestWithListAndFirstPblock5(TaggedType[ActionRequestWithListAndFirstPblock]):
834
+ """[5] IMPLICIT Action-Request-With-List-And-First-Pblock"""
835
+ tag = 5
836
+ mode = TaggingMode.IMPLICIT
837
+ value: ActionRequestWithListAndFirstPblock
838
+
839
+
840
+ @dataclass
841
+ class ActionRequestWithPblock(SequenceType):
842
+ """Action-Request-With-Pblock"""
843
+ components = (
844
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
845
+ NamedType("pblock", DataBlockSA)
846
+ )
847
+
848
+ @dataclass
849
+ class ActionRequestWithPblock6(TaggedType[ActionRequestWithPblock]):
850
+ """[6] IMPLICIT Action-Request-With-Pblock"""
851
+ tag = 6
852
+ mode = TaggingMode.IMPLICIT
853
+ value: ActionRequestWithPblock
854
+
855
+
856
+ @dataclass
857
+ class ActionRequest(ChoiceType):
858
+ """Action-Request"""
859
+ alternatives = {
860
+ 1: NamedType("action-request-normal", ActionRequestNormal1),
861
+ 2: NamedType("action-request-next-pblock", ActionRequestNextPblock2),
862
+ 3: NamedType("action-request-with-list", ActionRequestWithList3),
863
+ 4: NamedType("action-request-with-first-pblock", ActionRequestWithFirstPblock4),
864
+ 5: NamedType("action-request-with-list-and-first-pblock", ActionRequestWithListAndFirstPblock5),
865
+ 6: NamedType("action-request-with-pblock", ActionRequestWithPblock6)
866
+ }
867
+
868
+
869
+ @dataclass
870
+ class actionRequest(TaggedType[ActionRequest]):
871
+ """[195] IMPLICIT Action-Request"""
872
+ tag = 195
873
+ mode = TaggingMode.IMPLICIT
874
+ value: ActionRequest
875
+
876
+
877
+ @dataclass
878
+ class ActionResponseNormal(SequenceType):
879
+ """Action-Response-Normal"""
880
+ components = (
881
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
882
+ NamedType("single-response", ActionResponseWithOptionalData)
883
+ )
884
+
885
+
886
+ @dataclass
887
+ class ActionResponseNormal1(TaggedType[ActionResponseNormal]):
888
+ """[1] IMPLICIT Action-Response-Normal"""
889
+ tag = 1
890
+ mode = TaggingMode.IMPLICIT
891
+ value: ActionResponseNormal
892
+
893
+
894
+ @dataclass
895
+ class ActionResponseWithPblock(SequenceType):
896
+ """Action-Response-With-Pblock"""
897
+ components = (
898
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
899
+ NamedType("pblock", DataBlockSA)
900
+ )
901
+
902
+ @dataclass
903
+ class ActionResponseWithPblock2(TaggedType[ActionResponseWithPblock]):
904
+ """[2] IMPLICIT Action-Response-With-Pblock"""
905
+ tag = 2
906
+ mode = TaggingMode.IMPLICIT
907
+ value: ActionResponseWithPblock
908
+
909
+
910
+ @dataclass
911
+ class ActionResponseWithList(SequenceType):
912
+ """Action-Response-With-List"""
913
+ components = (
914
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
915
+ NamedType("list-of-responses", SequenceOfType[ActionResponseWithOptionalData])
916
+ )
917
+
918
+ @dataclass
919
+ class ActionResponseWithList3(TaggedType[ActionResponseWithList]):
920
+ """[3] IMPLICIT Action-Response-With-List"""
921
+ tag = 3
922
+ mode = TaggingMode.IMPLICIT
923
+ value: ActionResponseWithList
924
+
925
+
926
+ @dataclass
927
+ class ActionResponseNextPblock(SequenceType):
928
+ """Action-Response-Next-Pblock"""
929
+ components = (
930
+ NamedType("invoke-id-and-priority", InvokeIdAndPriority),
931
+ NamedType("block-number", Unsigned32)
932
+ )
933
+
934
+ @dataclass
935
+ class ActionResponseNextPblock4(TaggedType[ActionResponseNextPblock]):
936
+ """[4] IMPLICIT Action-Response-Next-Pblock"""
937
+ tag = 4
938
+ mode = TaggingMode.IMPLICIT
939
+ value: ActionResponseNextPblock
940
+
941
+
942
+ @dataclass
943
+ class ActionResponse(ChoiceType):
944
+ """Action-Response"""
945
+ alternatives = {
946
+ 1: NamedType("action-response-normal", ActionResponseNormal1),
947
+ 2: NamedType("action-response-with-pblock", ActionResponseWithPblock2),
948
+ 3: NamedType("action-response-with-list", ActionResponseWithList3),
949
+ 4: NamedType("action-response-next-pblock", ActionResponseNextPblock4)
950
+ }
951
+
952
+
953
+ @dataclass
954
+ class actionResponse(TaggedType[ActionResponse]):
955
+ """[199] IMPLICIT Action-Response"""
956
+ tag = 199
957
+ mode = TaggingMode.IMPLICIT
958
+ value: ActionResponse
959
+
960
+
961
+ @dataclass
962
+ class EventNotificationRequest(SequenceType):
963
+ """EventNotificationRequest"""
964
+ components = (
965
+ OptionalNamedType("time", OctetStringType),
966
+ NamedType("cosem-attribute-descriptor", CosemAttributeDescriptor),
967
+ NamedType("attribute-value", Data)
968
+ )
969
+
970
+
971
+ @dataclass
972
+ class eventNotificationRequest(TaggedType[EventNotificationRequest]):
973
+ """[194] IMPLICIT EventNotificationRequest"""
974
+ tag = 194
975
+ mode = TaggingMode.IMPLICIT
976
+ value: EventNotificationRequest
977
+
978
+
979
+ @dataclass
980
+ class gloGetRequest(TaggedType[OctetStringType]):
981
+ """[200] IMPLICIT glo-get-request"""
982
+ tag = 200
983
+ mode = TaggingMode.IMPLICIT
984
+ value: OctetStringType
985
+
986
+
987
+ @dataclass
988
+ class gloSetRequest(TaggedType[OctetStringType]):
989
+ """[201] IMPLICIT glo-set-request"""
990
+ tag = 201
991
+ mode = TaggingMode.IMPLICIT
992
+ value: OctetStringType
993
+
994
+
995
+ @dataclass
996
+ class gloEventNotificationRequest(TaggedType[OctetStringType]):
997
+ """[202] IMPLICIT glo-event-notification-request"""
998
+ tag = 202
999
+ mode = TaggingMode.IMPLICIT
1000
+ value: OctetStringType
1001
+
1002
+
1003
+ @dataclass
1004
+ class gloActionRequest(TaggedType[OctetStringType]):
1005
+ """[203] IMPLICIT glo-action-request"""
1006
+ tag = 203
1007
+ mode = TaggingMode.IMPLICIT
1008
+ value: OctetStringType
1009
+
1010
+
1011
+ @dataclass
1012
+ class gloGetResponse(TaggedType[OctetStringType]):
1013
+ """[204] IMPLICIT glo-get-response"""
1014
+ tag = 204
1015
+ mode = TaggingMode.IMPLICIT
1016
+ value: OctetStringType
1017
+
1018
+
1019
+ @dataclass
1020
+ class gloSetResponse(TaggedType[OctetStringType]):
1021
+ """[205] IMPLICIT glo-set-response"""
1022
+ tag = 205
1023
+ mode = TaggingMode.IMPLICIT
1024
+ value: OctetStringType
1025
+
1026
+
1027
+ @dataclass
1028
+ class gloActionResponse(TaggedType[OctetStringType]):
1029
+ """[207] IMPLICIT glo-action-response"""
1030
+ tag = 207
1031
+ mode = TaggingMode.IMPLICIT
1032
+ value: OctetStringType
1033
+
1034
+
1035
+ @dataclass
1036
+ class dedGetRequest(TaggedType[OctetStringType]):
1037
+ """[208] IMPLICIT ded-get-request"""
1038
+ tag = 208
1039
+ mode = TaggingMode.IMPLICIT
1040
+ value: OctetStringType
1041
+
1042
+
1043
+ @dataclass
1044
+ class dedSetRequest(TaggedType[OctetStringType]):
1045
+ """[209] IMPLICIT ded-set-request"""
1046
+ tag = 209
1047
+ mode = TaggingMode.IMPLICIT
1048
+ value: OctetStringType
1049
+
1050
+
1051
+ @dataclass
1052
+ class dedEventNotificationRequest(TaggedType[OctetStringType]):
1053
+ """[210] IMPLICIT ded-event-notification-request"""
1054
+ tag = 210
1055
+ mode = TaggingMode.IMPLICIT
1056
+ value: OctetStringType
1057
+
1058
+
1059
+ @dataclass
1060
+ class dedActionRequest(TaggedType[OctetStringType]):
1061
+ """[211] IMPLICIT ded-action-request"""
1062
+ tag = 211
1063
+ mode = TaggingMode.IMPLICIT
1064
+ value: OctetStringType
1065
+
1066
+
1067
+ @dataclass
1068
+ class dedGetResponse(TaggedType[OctetStringType]):
1069
+ """[212] IMPLICIT ded-get-response"""
1070
+ tag = 212
1071
+ mode = TaggingMode.IMPLICIT
1072
+ value: OctetStringType
1073
+
1074
+
1075
+ @dataclass
1076
+ class dedSetResponse(TaggedType[OctetStringType]):
1077
+ """[213] IMPLICIT ded-set-response"""
1078
+ tag = 213
1079
+ mode = TaggingMode.IMPLICIT
1080
+ value: OctetStringType
1081
+
1082
+
1083
+ @dataclass
1084
+ class dedActionResponse(TaggedType[OctetStringType]):
1085
+ """[215] IMPLICIT ded-action-response"""
1086
+ tag = 215
1087
+ mode = TaggingMode.IMPLICIT
1088
+ value: OctetStringType
1089
+
1090
+
1091
+ @dataclass
1092
+ class StateErrorList(EnumerationList):
1093
+ members = (
1094
+ EnumerationMember("service-not-allowed", 1),
1095
+ EnumerationMember("service-unknown", 2)
1096
+ )
1097
+
1098
+
1099
+ @dataclass(frozen=True)
1100
+ class StateErrorEnum(EnumeratedType):
1101
+ named_members = StateErrorList()
1102
+
1103
+
1104
+ @dataclass
1105
+ class StateError(TaggedType[StateErrorEnum]):
1106
+ """[0] IMPLICIT state-error"""
1107
+ tag = 0
1108
+ mode = TaggingMode.IMPLICIT
1109
+ value: StateErrorEnum
1110
+ SERVICE_NOT_ALLOWED: ClassVar["StateError"]
1111
+ SERVICE_UNKNOWN: ClassVar["StateError"]
1112
+
1113
+
1114
+ StateError.SERVICE_NOT_ALLOWED = StateError(StateErrorEnum(1))
1115
+ StateError.SERVICE_UNKNOWN = StateError(StateErrorEnum(2))
1116
+
1117
+
1118
+ @dataclass
1119
+ class OperationNotPossible(TaggedType[NullType]):
1120
+ """operation-not-possible"""
1121
+ tag = 1
1122
+ mode = TaggingMode.IMPLICIT
1123
+ value: NullType
1124
+
1125
+
1126
+ @dataclass
1127
+ class ServiceNotSupported(TaggedType[NullType]):
1128
+ """service-not-supported"""
1129
+ tag = 2
1130
+ mode = TaggingMode.IMPLICIT
1131
+ value: NullType
1132
+
1133
+
1134
+ @dataclass
1135
+ class OtherReason(TaggedType[NullType]):
1136
+ """other-reason"""
1137
+ tag = 3
1138
+ mode = TaggingMode.IMPLICIT
1139
+ value: NullType
1140
+
1141
+
1142
+ @dataclass
1143
+ class PduTooLong(TaggedType[NullType]):
1144
+ """pdu-too-long"""
1145
+ tag = 4
1146
+ mode = TaggingMode.IMPLICIT
1147
+ value: NullType
1148
+
1149
+
1150
+ @dataclass
1151
+ class DecipheringError(TaggedType[NullType]):
1152
+ """deciphering-error"""
1153
+ tag = 5
1154
+ mode = TaggingMode.IMPLICIT
1155
+ value: NullType
1156
+
1157
+
1158
+ @dataclass
1159
+ class InvocationCounterError(TaggedType[Unsigned32]):
1160
+ """invocation-counter-error"""
1161
+ tag = 6
1162
+ mode = TaggingMode.IMPLICIT
1163
+ value: Unsigned32
1164
+
1165
+
1166
+ @dataclass
1167
+ class ServiceErrorChoice(ChoiceType):
1168
+ """service-error"""
1169
+ alternatives = {
1170
+ 1: NamedType("operation-not-possible", OperationNotPossible),
1171
+ 2: NamedType("service-not-supported", ServiceNotSupported),
1172
+ 3: NamedType("other-reason", OtherReason),
1173
+ 4: NamedType("pdu-too-long", PduTooLong),
1174
+ 5: NamedType("deciphering-error", DecipheringError),
1175
+ 6: NamedType("invocation-counter-error", InvocationCounterError)
1176
+ }
1177
+
1178
+
1179
+ @dataclass
1180
+ class ServiceError(TaggedType[ServiceErrorChoice]):
1181
+ """[1] IMPLICIT service-error"""
1182
+ tag = 1
1183
+ mode = TaggingMode.DEFAULT
1184
+ value: ServiceErrorChoice
1185
+ OPERATION_NOT_POSSIBLE: ClassVar["ServiceError"]
1186
+ SERVICE_NOT_SUPPORTED: ClassVar["ServiceError"]
1187
+ OTHER_REASON: ClassVar["ServiceError"]
1188
+ PDU_TOO_LONG: ClassVar["ServiceError"]
1189
+ DECIPHERING_ERROR: ClassVar["ServiceError"]
1190
+
1191
+
1192
+ ServiceError.OPERATION_NOT_POSSIBLE = ServiceError(ServiceErrorChoice(OperationNotPossible(NullType(None))))
1193
+ ServiceError.SERVICE_NOT_SUPPORTED = ServiceError(ServiceErrorChoice(ServiceNotSupported(NullType(None))))
1194
+ ServiceError.OTHER_REASON = ServiceError(ServiceErrorChoice(OtherReason(NullType(None))))
1195
+ ServiceError.PDU_TOO_LONG = ServiceError(ServiceErrorChoice(PduTooLong(NullType(None))))
1196
+ ServiceError.DECIPHERING_ERROR = ServiceError(ServiceErrorChoice(DecipheringError(NullType(None))))
1197
+
1198
+
1199
+ @dataclass
1200
+ class ExceptionResponse(SequenceType):
1201
+ """ExceptionResponse"""
1202
+ components = (
1203
+ NamedType("state-error", StateError),
1204
+ NamedType("service-error", ServiceError)
1205
+ )
1206
+
1207
+
1208
+ @dataclass
1209
+ class exceptionResponse(TaggedType[ExceptionResponse]):
1210
+ """[216] IMPLICIT exception-response"""
1211
+ tag = 216
1212
+ mode = TaggingMode.IMPLICIT
1213
+ value: ExceptionResponse
1214
+
1215
+
1216
+ @dataclass
1217
+ class AccessRequest(SequenceType):
1218
+ """Access-Request"""
1219
+ components = (
1220
+ NamedType("long-invoke-id-and-priority", LongInvokeIdAndPriority),
1221
+ NamedType("date-time", OctetStringType),
1222
+ NamedType("access-request-body", AccessRequestBody)
1223
+ )
1224
+
1225
+
1226
+ @dataclass
1227
+ class accessRequest(TaggedType[AccessRequest]):
1228
+ """[217] IMPLICIT Access-Request"""
1229
+ tag = 217
1230
+ mode = TaggingMode.IMPLICIT
1231
+ value: AccessRequest
1232
+
1233
+
1234
+ @dataclass
1235
+ class AccessResponse(SequenceType):
1236
+ """Access-Response"""
1237
+ components = (
1238
+ NamedType("long-invoke-id-and-priority", LongInvokeIdAndPriority),
1239
+ NamedType("date-time", OctetStringType),
1240
+ NamedType("access-response-body", AccessResponseBody)
1241
+ )
1242
+
1243
+
1244
+ @dataclass
1245
+ class accessResponse(TaggedType[AccessResponse]):
1246
+ """[218] IMPLICIT Access-Response"""
1247
+ tag = 218
1248
+ mode = TaggingMode.IMPLICIT
1249
+ value: AccessResponse
1250
+
1251
+
1252
+ @dataclass
1253
+ class BlockControl(Unsigned8):
1254
+ """Block-Control"""
1255
+
1256
+ def window_bits(self) -> int:
1257
+ """Extract window bits (0-5)"""
1258
+ return self.value.value & 0x3F
1259
+
1260
+ def is_streaming(self) -> bool:
1261
+ """Check if streaming bit (6) is set"""
1262
+ return bool(self.value.value & 0x40)
1263
+
1264
+ def is_last_block(self) -> bool:
1265
+ """Check if last-block bit (7) is set"""
1266
+ return bool(self.value.value & 0x80)
1267
+
1268
+
1269
+ @dataclass
1270
+ class GeneralDedCiphering(SequenceType):
1271
+ """General-Ded-Ciphering"""
1272
+ components = (
1273
+ NamedType("system-title", OctetStringType),
1274
+ NamedType("ciphered-content", OctetStringType)
1275
+ )
1276
+
1277
+
1278
+ @dataclass
1279
+ class generalDedCiphering(TaggedType[GeneralDedCiphering]):
1280
+ """[220] IMPLICIT generalDedCiphering"""
1281
+ tag = 220
1282
+ mode = TaggingMode.IMPLICIT
1283
+ value: GeneralDedCiphering
1284
+
1285
+
1286
+ @dataclass
1287
+ class GeneralGloCiphering(SequenceType):
1288
+ """General-Glo-Ciphering"""
1289
+ components = (
1290
+ NamedType("system-title", OctetStringType),
1291
+ NamedType("ciphered-content", OctetStringType)
1292
+ )
1293
+
1294
+ @dataclass
1295
+ class generalGloCiphering(TaggedType[GeneralGloCiphering]):
1296
+ """[219] IMPLICIT generalGloCiphering"""
1297
+ tag = 219
1298
+ mode = TaggingMode.IMPLICIT
1299
+ value: GeneralGloCiphering
1300
+
1301
+
1302
+ @dataclass
1303
+ class GeneralCiphering(SequenceType):
1304
+ """General-Ciphering"""
1305
+ components = (
1306
+ NamedType("transaction-id", OctetStringType),
1307
+ NamedType("originator-system-title", OctetStringType),
1308
+ NamedType("recipient-system-title", OctetStringType),
1309
+ NamedType("date-time", OctetStringType),
1310
+ NamedType("other-information", OctetStringType),
1311
+ NamedType("key-info", KeyInfo),
1312
+ NamedType("ciphered-content", OctetStringType)
1313
+ )
1314
+
1315
+
1316
+ @dataclass
1317
+ class generalCiphering(TaggedType[GeneralCiphering]):
1318
+ """[221] IMPLICIT generalCiphering"""
1319
+ tag = 221
1320
+ mode = TaggingMode.IMPLICIT
1321
+ value: GeneralCiphering
1322
+
1323
+
1324
+ @dataclass
1325
+ class GeneralSigning(SequenceType):
1326
+ """General-Signing"""
1327
+ components = (
1328
+ NamedType("transaction-id", OctetStringType),
1329
+ NamedType("originator-system-title", OctetStringType),
1330
+ NamedType("recipient-system-title", OctetStringType),
1331
+ NamedType("date-time", OctetStringType),
1332
+ NamedType("other-information", OctetStringType),
1333
+ NamedType("content", OctetStringType),
1334
+ NamedType("signature", OctetStringType)
1335
+ )
1336
+
1337
+
1338
+ class generalSigning(TaggedType[GeneralSigning]):
1339
+ """[223] IMPLICIT generalSigning"""
1340
+ tag = 223
1341
+ mode = TaggingMode.IMPLICIT
1342
+ value: GeneralSigning
1343
+
1344
+
1345
+ @dataclass
1346
+ class GeneralBlockTransfer(SequenceType):
1347
+ """General-Block-Transfer"""
1348
+ components = (
1349
+ NamedType("block-control", BlockControl),
1350
+ NamedType("block-number", Unsigned16),
1351
+ NamedType("block-number-ack", Unsigned16),
1352
+ NamedType("block-data", OctetStringType)
1353
+ )
1354
+
1355
+
1356
+ @dataclass
1357
+ class generalBlockTransfer(TaggedType[GeneralBlockTransfer]):
1358
+ """[224] IMPLICIT generalBlockTransfer"""
1359
+ tag = 224
1360
+ mode = TaggingMode.IMPLICIT
1361
+ value: GeneralBlockTransfer
1362
+
1363
+
1364
+ # ============================================================================
1365
+ # -- XDLMS-APDU Top-Level Choice (COSEMpdu_GB83.txt)
1366
+ # ============================================================================
1367
+
1368
+
1369
+ @dataclass
1370
+ class XDLMS_APDU(ChoiceType):
1371
+ """XDLMS-APDU"""
1372
+ alternatives = {
1373
+ 1: NamedType("initiateRequest", InitialRequest1),
1374
+ 5: NamedType("readRequest", ReadRequest5),
1375
+ 6: NamedType("writeRequest", WriteRequest6),
1376
+ 8: NamedType("initiateResponse", InitialResponse8),
1377
+ 12: NamedType("readResponse", ReadResponse12),
1378
+ 13: NamedType("writeResponse", writeResponse),
1379
+ 14: NamedType("confirmedServiceError", confirmedServiceError),
1380
+ 15: NamedType("data-notification", DataNotification15),
1381
+ 16: NamedType("data-notification-confirm", DataNotificationConfirm16),
1382
+ 22: NamedType("unconfirmedWriteRequest", UnconfirmedWriteRequest22),
1383
+ 24: NamedType("informationReportRequest", InformationReportRequest24),
1384
+ # -- with global ciphering (OCTET STRING)
1385
+ 33: NamedType("glo-initiateRequest", GloInitiateRequest),
1386
+ 37: NamedType("glo-readRequest", GloReadRequest),
1387
+ 38: NamedType("glo-writeRequest", GloWriteRequest),
1388
+ 40: NamedType("glo-initiateResponse", GloInitiateResponse),
1389
+ 44: NamedType("glo-readResponse", GloReadResponse),
1390
+ 45: NamedType("glo-writeResponse", GloWriteResponse),
1391
+ 46: NamedType("glo-confirmedServiceError", GloConfirmedServiceError),
1392
+ 54: NamedType("glo-unconfirmedWriteRequest", GloUnconfirmedWriteRequest),
1393
+ 56: NamedType("glo-informationReportRequest", GloInformationReportRequest),
1394
+ # -- with dedicated ciphering (OCTET STRING)
1395
+ 65: NamedType("ded-initiateRequest", DedInitiateRequest),
1396
+ 69: NamedType("ded-readRequest", DedReadRequest),
1397
+ 70: NamedType("ded-writeRequest", DedWriteRequest),
1398
+ 72: NamedType("ded-initiateResponse", DedInitiateResponse),
1399
+ 76: NamedType("ded-readResponse", DedReadResponse),
1400
+ 77: NamedType("ded-writeResponse", DedWriteResponse),
1401
+ 78: NamedType("ded-confirmedServiceError", DedConfirmedServiceError),
1402
+ 86: NamedType("ded-unconfirmedWriteRequest", DedUnconfirmedWriteRequest),
1403
+ 88: NamedType("ded-informationReportRequest", DedInformationReportRequest),
1404
+ # -- xDLMS APDUs used with LN referencing -- with no ciphering
1405
+ 192: NamedType("get-request", getRequest),
1406
+ 193: NamedType("set-request", setRequest),
1407
+ 194: NamedType("event-notification-request", eventNotificationRequest),
1408
+ 195: NamedType("action-request", actionRequest),
1409
+ 196: NamedType("get-response", getResponse),
1410
+ 197: NamedType("set-response", setResponse),
1411
+ 199: NamedType("action-response", actionResponse),
1412
+ # -- with global ciphering (LN)
1413
+ 200: NamedType("glo-get-request", gloGetRequest),
1414
+ 201: NamedType("glo-set-request", gloSetRequest),
1415
+ 202: NamedType("glo-event-notification-request", gloEventNotificationRequest),
1416
+ 203: NamedType("glo-action-request", gloActionRequest),
1417
+ 204: NamedType("glo-get-response", gloGetResponse),
1418
+ 205: NamedType("glo-set-response", gloSetResponse),
1419
+ 207: NamedType("glo-action-response", gloActionResponse),
1420
+ # -- with dedicated ciphering (LN)
1421
+ 208: NamedType("ded-get-request", dedGetRequest),
1422
+ 209: NamedType("ded-set-request", dedSetRequest),
1423
+ 210: NamedType("ded-event-notification-request", dedEventNotificationRequest),
1424
+ 211: NamedType("ded-actionRequest", dedActionRequest),
1425
+ 212: NamedType("ded-get-response", dedGetResponse),
1426
+ 213: NamedType("ded-set-response", dedSetResponse),
1427
+ 215: NamedType("ded-action-response", dedActionResponse),
1428
+ # -- the exception response pdu
1429
+ 216: NamedType("exception-response", exceptionResponse),
1430
+ # -- access
1431
+ 217: NamedType("access-request", accessRequest),
1432
+ 218: NamedType("access-response", accessResponse),
1433
+ # -- general APDUs
1434
+ 219: NamedType("general-glo-ciphering", generalGloCiphering),
1435
+ 220: NamedType("general-ded-ciphering", generalDedCiphering),
1436
+ 221: NamedType("general-ciphering", generalCiphering),
1437
+ 223: NamedType("general-signing", generalSigning),
1438
+ 224: NamedType("general-block-transfer", generalBlockTransfer),
1439
+ # -- The tags 230 and 231 are reserved for DLMS Gateway
1440
+ }