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