Code Duplication    Length = 61-74 lines in 2 locations

opcua/ua/uaprotocol_auto.py 1 location

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

opcua/ua/uatypes.py 1 location

@@ 805-865 (lines=61) @@
802
        'ServerPicoseconds': ('Encoding', 5),
803
    }
804
805
    ua_types = (
806
            ('Encoding', 'Byte'), 
807
            ('Value', 'Variant'), 
808
            ('StatusCode', 'StatusCode'), 
809
            ('SourceTimestamp', 'DateTime'),
810
            ('SourcePicoseconds', 'UInt16'), 
811
            ('ServerTimestamp', 'DateTime'), 
812
            ('ServerPicoseconds', 'UInt16'), 
813
            )
814
815
    def __init__(self, variant=None, status=None):
816
        self.Encoding = 0
817
        if not isinstance(variant, Variant):
818
            variant = Variant(variant)
819
        self.Value = variant
820
        if status is None:
821
            self.StatusCode = StatusCode()
822
        else:
823
            self.StatusCode = status
824
        self.SourceTimestamp = None  # DateTime()
825
        self.SourcePicoseconds = None
826
        self.ServerTimestamp = None  # DateTime()
827
        self.ServerPicoseconds = None
828
        self._freeze = True
829
830
    def __str__(self):
831
        s = 'DataValue(Value:{0}'.format(self.Value)
832
        if self.StatusCode is not None:
833
            s += ', StatusCode:{0}'.format(self.StatusCode)
834
        if self.SourceTimestamp is not None:
835
            s += ', SourceTimestamp:{0}'.format(self.SourceTimestamp)
836
        if self.ServerTimestamp is not None:
837
            s += ', ServerTimestamp:{0}'.format(self.ServerTimestamp)
838
        if self.SourcePicoseconds is not None:
839
            s += ', SourcePicoseconds:{0}'.format(self.SourcePicoseconds)
840
        if self.ServerPicoseconds is not None:
841
            s += ', ServerPicoseconds:{0}'.format(self.ServerPicoseconds)
842
        s += ')'
843
        return s
844
845
    __repr__ = __str__
846
847
848
def datatype_to_varianttype(int_type):
849
    """
850
    Takes a NodeId or int and return a VariantType
851
    This is only supported if int_type < 63 due to VariantType encoding
852
    At low level we do not have access to address space thus decoding is limited
853
    a better version of this method can be find in ua_utils.py
854
    """
855
    if isinstance(int_type, NodeId):
856
        int_type = int_type.Identifier
857
858
    if int_type <= 25:
859
        return VariantType(int_type)
860
    else:
861
        return VariantTypeCustom(int_type)
862
863
864
def get_default_value(vtype):
865
    """
866
    Given a variant type return default value for this type
867
    """
868
    if vtype == VariantType.Null: