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