Code Duplication    Length = 62-64 lines in 4 locations

opcua/ua/uaprotocol_auto.py 4 locations

@@ 4169-4232 (lines=64) @@
4166
    __repr__ = __str__
4167
4168
4169
class NodeAttributes(FrozenClass):
4170
    '''
4171
    The base attributes for all nodes.
4172
4173
    :ivar SpecifiedAttributes:
4174
    :vartype SpecifiedAttributes: UInt32
4175
    :ivar DisplayName:
4176
    :vartype DisplayName: LocalizedText
4177
    :ivar Description:
4178
    :vartype Description: LocalizedText
4179
    :ivar WriteMask:
4180
    :vartype WriteMask: UInt32
4181
    :ivar UserWriteMask:
4182
    :vartype UserWriteMask: UInt32
4183
    '''
4184
4185
    ua_types = {
4186
        'SpecifiedAttributes': 'UInt32',
4187
        'DisplayName': 'LocalizedText',
4188
        'Description': 'LocalizedText',
4189
        'WriteMask': 'UInt32',
4190
        'UserWriteMask': 'UInt32',
4191
               }
4192
4193
    def __init__(self, binary=None):
4194
        if binary is not None:
4195
            self._binary_init(binary)
4196
            self._freeze = True
4197
            return
4198
        self.SpecifiedAttributes = 0
4199
        self.DisplayName = LocalizedText()
4200
        self.Description = LocalizedText()
4201
        self.WriteMask = 0
4202
        self.UserWriteMask = 0
4203
        self._freeze = True
4204
4205
    def to_binary(self):
4206
        packet = []
4207
        packet.append(uabin.Primitives.UInt32.pack(self.SpecifiedAttributes))
4208
        packet.append(self.DisplayName.to_binary())
4209
        packet.append(self.Description.to_binary())
4210
        packet.append(uabin.Primitives.UInt32.pack(self.WriteMask))
4211
        packet.append(uabin.Primitives.UInt32.pack(self.UserWriteMask))
4212
        return b''.join(packet)
4213
4214
    @staticmethod
4215
    def from_binary(data):
4216
        return NodeAttributes(data)
4217
4218
    def _binary_init(self, data):
4219
        self.SpecifiedAttributes = uabin.Primitives.UInt32.unpack(data)
4220
        self.DisplayName = LocalizedText.from_binary(data)
4221
        self.Description = LocalizedText.from_binary(data)
4222
        self.WriteMask = uabin.Primitives.UInt32.unpack(data)
4223
        self.UserWriteMask = uabin.Primitives.UInt32.unpack(data)
4224
4225
    def __str__(self):
4226
        return 'NodeAttributes(' + 'SpecifiedAttributes:' + str(self.SpecifiedAttributes) + ', ' + \
4227
               'DisplayName:' + str(self.DisplayName) + ', ' + \
4228
               'Description:' + str(self.Description) + ', ' + \
4229
               'WriteMask:' + str(self.WriteMask) + ', ' + \
4230
               'UserWriteMask:' + str(self.UserWriteMask) + ')'
4231
4232
    __repr__ = __str__
4233
4234
4235
class ObjectAttributes(FrozenClass):
@@ 11375-11436 (lines=62) @@
11372
    __repr__ = __str__
11373
11374
11375
class MonitoredItemCreateResult(FrozenClass):
11376
    '''
11377
    :ivar StatusCode:
11378
    :vartype StatusCode: StatusCode
11379
    :ivar MonitoredItemId:
11380
    :vartype MonitoredItemId: UInt32
11381
    :ivar RevisedSamplingInterval:
11382
    :vartype RevisedSamplingInterval: Double
11383
    :ivar RevisedQueueSize:
11384
    :vartype RevisedQueueSize: UInt32
11385
    :ivar FilterResult:
11386
    :vartype FilterResult: ExtensionObject
11387
    '''
11388
11389
    ua_types = {
11390
        'StatusCode': 'StatusCode',
11391
        'MonitoredItemId': 'UInt32',
11392
        'RevisedSamplingInterval': 'Double',
11393
        'RevisedQueueSize': 'UInt32',
11394
        'FilterResult': 'ExtensionObject',
11395
               }
11396
11397
    def __init__(self, binary=None):
11398
        if binary is not None:
11399
            self._binary_init(binary)
11400
            self._freeze = True
11401
            return
11402
        self.StatusCode = StatusCode()
11403
        self.MonitoredItemId = 0
11404
        self.RevisedSamplingInterval = 0
11405
        self.RevisedQueueSize = 0
11406
        self.FilterResult = None
11407
        self._freeze = True
11408
11409
    def to_binary(self):
11410
        packet = []
11411
        packet.append(self.StatusCode.to_binary())
11412
        packet.append(uabin.Primitives.UInt32.pack(self.MonitoredItemId))
11413
        packet.append(uabin.Primitives.Double.pack(self.RevisedSamplingInterval))
11414
        packet.append(uabin.Primitives.UInt32.pack(self.RevisedQueueSize))
11415
        packet.append(extensionobject_to_binary(self.FilterResult))
11416
        return b''.join(packet)
11417
11418
    @staticmethod
11419
    def from_binary(data):
11420
        return MonitoredItemCreateResult(data)
11421
11422
    def _binary_init(self, data):
11423
        self.StatusCode = StatusCode.from_binary(data)
11424
        self.MonitoredItemId = uabin.Primitives.UInt32.unpack(data)
11425
        self.RevisedSamplingInterval = uabin.Primitives.Double.unpack(data)
11426
        self.RevisedQueueSize = uabin.Primitives.UInt32.unpack(data)
11427
        self.FilterResult = extensionobject_from_binary(data)
11428
11429
    def __str__(self):
11430
        return 'MonitoredItemCreateResult(' + 'StatusCode:' + str(self.StatusCode) + ', ' + \
11431
               'MonitoredItemId:' + str(self.MonitoredItemId) + ', ' + \
11432
               'RevisedSamplingInterval:' + str(self.RevisedSamplingInterval) + ', ' + \
11433
               'RevisedQueueSize:' + str(self.RevisedQueueSize) + ', ' + \
11434
               'FilterResult:' + str(self.FilterResult) + ')'
11435
11436
    __repr__ = __str__
11437
11438
11439
class CreateMonitoredItemsParameters(FrozenClass):
@@ 11261-11322 (lines=62) @@
11258
    __repr__ = __str__
11259
11260
11261
class MonitoringParameters(FrozenClass):
11262
    '''
11263
    :ivar ClientHandle:
11264
    :vartype ClientHandle: UInt32
11265
    :ivar SamplingInterval:
11266
    :vartype SamplingInterval: Double
11267
    :ivar Filter:
11268
    :vartype Filter: ExtensionObject
11269
    :ivar QueueSize:
11270
    :vartype QueueSize: UInt32
11271
    :ivar DiscardOldest:
11272
    :vartype DiscardOldest: Boolean
11273
    '''
11274
11275
    ua_types = {
11276
        'ClientHandle': 'UInt32',
11277
        'SamplingInterval': 'Double',
11278
        'Filter': 'ExtensionObject',
11279
        'QueueSize': 'UInt32',
11280
        'DiscardOldest': 'Boolean',
11281
               }
11282
11283
    def __init__(self, binary=None):
11284
        if binary is not None:
11285
            self._binary_init(binary)
11286
            self._freeze = True
11287
            return
11288
        self.ClientHandle = 0
11289
        self.SamplingInterval = 0
11290
        self.Filter = None
11291
        self.QueueSize = 0
11292
        self.DiscardOldest = True
11293
        self._freeze = True
11294
11295
    def to_binary(self):
11296
        packet = []
11297
        packet.append(uabin.Primitives.UInt32.pack(self.ClientHandle))
11298
        packet.append(uabin.Primitives.Double.pack(self.SamplingInterval))
11299
        packet.append(extensionobject_to_binary(self.Filter))
11300
        packet.append(uabin.Primitives.UInt32.pack(self.QueueSize))
11301
        packet.append(uabin.Primitives.Boolean.pack(self.DiscardOldest))
11302
        return b''.join(packet)
11303
11304
    @staticmethod
11305
    def from_binary(data):
11306
        return MonitoringParameters(data)
11307
11308
    def _binary_init(self, data):
11309
        self.ClientHandle = uabin.Primitives.UInt32.unpack(data)
11310
        self.SamplingInterval = uabin.Primitives.Double.unpack(data)
11311
        self.Filter = extensionobject_from_binary(data)
11312
        self.QueueSize = uabin.Primitives.UInt32.unpack(data)
11313
        self.DiscardOldest = uabin.Primitives.Boolean.unpack(data)
11314
11315
    def __str__(self):
11316
        return 'MonitoringParameters(' + 'ClientHandle:' + str(self.ClientHandle) + ', ' + \
11317
               'SamplingInterval:' + str(self.SamplingInterval) + ', ' + \
11318
               'Filter:' + str(self.Filter) + ', ' + \
11319
               'QueueSize:' + str(self.QueueSize) + ', ' + \
11320
               'DiscardOldest:' + str(self.DiscardOldest) + ')'
11321
11322
    __repr__ = __str__
11323
11324
11325
class MonitoredItemCreateRequest(FrozenClass):
@@ 8005-8066 (lines=62) @@
8002
    __repr__ = __str__
8003
8004
8005
class AttributeOperand(FrozenClass):
8006
    '''
8007
    :ivar NodeId:
8008
    :vartype NodeId: NodeId
8009
    :ivar Alias:
8010
    :vartype Alias: String
8011
    :ivar BrowsePath:
8012
    :vartype BrowsePath: RelativePath
8013
    :ivar AttributeId:
8014
    :vartype AttributeId: UInt32
8015
    :ivar IndexRange:
8016
    :vartype IndexRange: String
8017
    '''
8018
8019
    ua_types = {
8020
        'NodeId': 'NodeId',
8021
        'Alias': 'String',
8022
        'BrowsePath': 'RelativePath',
8023
        'AttributeId': 'UInt32',
8024
        'IndexRange': 'String',
8025
               }
8026
8027
    def __init__(self, binary=None):
8028
        if binary is not None:
8029
            self._binary_init(binary)
8030
            self._freeze = True
8031
            return
8032
        self.NodeId = NodeId()
8033
        self.Alias = None
8034
        self.BrowsePath = RelativePath()
8035
        self.AttributeId = 0
8036
        self.IndexRange = None
8037
        self._freeze = True
8038
8039
    def to_binary(self):
8040
        packet = []
8041
        packet.append(self.NodeId.to_binary())
8042
        packet.append(uabin.Primitives.String.pack(self.Alias))
8043
        packet.append(self.BrowsePath.to_binary())
8044
        packet.append(uabin.Primitives.UInt32.pack(self.AttributeId))
8045
        packet.append(uabin.Primitives.String.pack(self.IndexRange))
8046
        return b''.join(packet)
8047
8048
    @staticmethod
8049
    def from_binary(data):
8050
        return AttributeOperand(data)
8051
8052
    def _binary_init(self, data):
8053
        self.NodeId = NodeId.from_binary(data)
8054
        self.Alias = uabin.Primitives.String.unpack(data)
8055
        self.BrowsePath = RelativePath.from_binary(data)
8056
        self.AttributeId = uabin.Primitives.UInt32.unpack(data)
8057
        self.IndexRange = uabin.Primitives.String.unpack(data)
8058
8059
    def __str__(self):
8060
        return 'AttributeOperand(' + 'NodeId:' + str(self.NodeId) + ', ' + \
8061
               'Alias:' + str(self.Alias) + ', ' + \
8062
               'BrowsePath:' + str(self.BrowsePath) + ', ' + \
8063
               'AttributeId:' + str(self.AttributeId) + ', ' + \
8064
               'IndexRange:' + str(self.IndexRange) + ')'
8065
8066
    __repr__ = __str__
8067
8068
8069
class SimpleAttributeOperand(FrozenClass):