Code Duplication    Length = 61-74 lines in 2 locations

opcua/ua/uaprotocol_auto.py 1 location

@@ 297-370 (lines=74) @@
294
    View = 1335532
295
296
297
class AttributeWriteMask(IntEnum):
298
    '''
299
    Define bits used to indicate which attributes are writable.
300
301
    :ivar None_:
302
    :vartype None_: 0
303
    :ivar AccessLevel:
304
    :vartype AccessLevel: 1
305
    :ivar ArrayDimensions:
306
    :vartype ArrayDimensions: 2
307
    :ivar BrowseName:
308
    :vartype BrowseName: 4
309
    :ivar ContainsNoLoops:
310
    :vartype ContainsNoLoops: 8
311
    :ivar DataType:
312
    :vartype DataType: 16
313
    :ivar Description:
314
    :vartype Description: 32
315
    :ivar DisplayName:
316
    :vartype DisplayName: 64
317
    :ivar EventNotifier:
318
    :vartype EventNotifier: 128
319
    :ivar Executable:
320
    :vartype Executable: 256
321
    :ivar Historizing:
322
    :vartype Historizing: 512
323
    :ivar InverseName:
324
    :vartype InverseName: 1024
325
    :ivar IsAbstract:
326
    :vartype IsAbstract: 2048
327
    :ivar MinimumSamplingInterval:
328
    :vartype MinimumSamplingInterval: 4096
329
    :ivar NodeClass:
330
    :vartype NodeClass: 8192
331
    :ivar NodeId:
332
    :vartype NodeId: 16384
333
    :ivar Symmetric:
334
    :vartype Symmetric: 32768
335
    :ivar UserAccessLevel:
336
    :vartype UserAccessLevel: 65536
337
    :ivar UserExecutable:
338
    :vartype UserExecutable: 131072
339
    :ivar UserWriteMask:
340
    :vartype UserWriteMask: 262144
341
    :ivar ValueRank:
342
    :vartype ValueRank: 524288
343
    :ivar WriteMask:
344
    :vartype WriteMask: 1048576
345
    :ivar ValueForVariableType:
346
    :vartype ValueForVariableType: 2097152
347
    '''
348
    None_ = 0
349
    AccessLevel = 1
350
    ArrayDimensions = 2
351
    BrowseName = 4
352
    ContainsNoLoops = 8
353
    DataType = 16
354
    Description = 32
355
    DisplayName = 64
356
    EventNotifier = 128
357
    Executable = 256
358
    Historizing = 512
359
    InverseName = 1024
360
    IsAbstract = 2048
361
    MinimumSamplingInterval = 4096
362
    NodeClass = 8192
363
    NodeId = 16384
364
    Symmetric = 32768
365
    UserAccessLevel = 65536
366
    UserExecutable = 131072
367
    UserWriteMask = 262144
368
    ValueRank = 524288
369
    WriteMask = 1048576
370
    ValueForVariableType = 2097152
371
372
373
class BrowseDirection(IntEnum):

opcua/ua/uatypes.py 1 location

@@ 805-865 (lines=61) @@
802
803
    def __ne__(self, other):
804
        return not self.__eq__(other)
805
806
807
class ExtensionObject(FrozenClass):
808
809
    '''
810
811
    Any UA object packed as an ExtensionObject
812
813
814
    :ivar TypeId:
815
    :vartype TypeId: NodeId
816
    :ivar Body:
817
    :vartype Body: bytes
818
819
    '''
820
821
    def __init__(self):
822
        self.TypeId = NodeId()
823
        self.Encoding = 0
824
        self.Body = b''
825
        self._freeze = True
826
827
    def to_binary(self):
828
        packet = []
829
        if self.Body:
830
            self.Encoding |= (1 << 0)
831
        packet.append(self.TypeId.to_binary())
832
        packet.append(pack_uatype('UInt8', self.Encoding))
833
        if self.Body:
834
            packet.append(pack_uatype('ByteString', self.Body))
835
        return b''.join(packet)
836
837
    @staticmethod
838
    def from_binary(data):
839
        obj = ExtensionObject()
840
        obj.TypeId = NodeId.from_binary(data)
841
        obj.Encoding = unpack_uatype('UInt8', data)
842
        if obj.Encoding & (1 << 0):
843
            obj.Body = unpack_uatype('ByteString', data)
844
        return obj
845
846
    @staticmethod
847
    def from_object(obj):
848
        ext = ExtensionObject()
849
        oid = getattr(ObjectIds, "{}_Encoding_DefaultBinary".format(obj.__class__.__name__))
850
        ext.TypeId = FourByteNodeId(oid)
851
        ext.Body = obj.to_binary()
852
        return ext
853
854
    def __str__(self):
855
        return 'ExtensionObject(' + 'TypeId:' + str(self.TypeId) + ', ' + \
856
            'Encoding:' + str(self.Encoding) + ', ' + str(len(self.Body)) + ' bytes)'
857
858
    __repr__ = __str__
859
860
861
class VariantType(Enum):
862
863
    '''
864
    The possible types of a variant.
865
866
    :ivar Null:
867
    :ivar Boolean:
868
    :ivar SByte: