Code Duplication    Length = 69-71 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 locations

@@ 3655-3725 (lines=71) @@
3652
    __repr__ = __str__
3653
3654
3655
class ActivateSessionParameters(FrozenClass):
3656
    '''
3657
    :ivar ClientSignature:
3658
    :vartype ClientSignature: SignatureData
3659
    :ivar ClientSoftwareCertificates:
3660
    :vartype ClientSoftwareCertificates: SignedSoftwareCertificate
3661
    :ivar LocaleIds:
3662
    :vartype LocaleIds: String
3663
    :ivar UserIdentityToken:
3664
    :vartype UserIdentityToken: ExtensionObject
3665
    :ivar UserTokenSignature:
3666
    :vartype UserTokenSignature: SignatureData
3667
    '''
3668
3669
    ua_types = {
3670
        'ClientSignature': 'SignatureData',
3671
        'ClientSoftwareCertificates': 'SignedSoftwareCertificate',
3672
        'LocaleIds': 'String',
3673
        'UserIdentityToken': 'ExtensionObject',
3674
        'UserTokenSignature': 'SignatureData',
3675
               }
3676
3677
    def __init__(self, binary=None):
3678
        if binary is not None:
3679
            self._binary_init(binary)
3680
            self._freeze = True
3681
            return
3682
        self.ClientSignature = SignatureData()
3683
        self.ClientSoftwareCertificates = []
3684
        self.LocaleIds = []
3685
        self.UserIdentityToken = None
3686
        self.UserTokenSignature = SignatureData()
3687
        self._freeze = True
3688
3689
    def to_binary(self):
3690
        packet = []
3691
        packet.append(self.ClientSignature.to_binary())
3692
        packet.append(uabin.Primitives.Int32.pack(len(self.ClientSoftwareCertificates)))
3693
        for fieldname in self.ClientSoftwareCertificates:
3694
            packet.append(fieldname.to_binary())
3695
        packet.append(uabin.Primitives.Int32.pack(len(self.LocaleIds)))
3696
        for fieldname in self.LocaleIds:
3697
            packet.append(uabin.Primitives.String.pack(fieldname))
3698
        packet.append(extensionobject_to_binary(self.UserIdentityToken))
3699
        packet.append(self.UserTokenSignature.to_binary())
3700
        return b''.join(packet)
3701
3702
    @staticmethod
3703
    def from_binary(data):
3704
        return ActivateSessionParameters(data)
3705
3706
    def _binary_init(self, data):
3707
        self.ClientSignature = SignatureData.from_binary(data)
3708
        length = uabin.Primitives.Int32.unpack(data)
3709
        array = []
3710
        if length != -1:
3711
            for _ in range(0, length):
3712
                array.append(SignedSoftwareCertificate.from_binary(data))
3713
        self.ClientSoftwareCertificates = array
3714
        self.LocaleIds = uabin.Primitives.String.unpack_array(data)
3715
        self.UserIdentityToken = extensionobject_from_binary(data)
3716
        self.UserTokenSignature = SignatureData.from_binary(data)
3717
3718
    def __str__(self):
3719
        return 'ActivateSessionParameters(' + 'ClientSignature:' + str(self.ClientSignature) + ', ' + \
3720
               'ClientSoftwareCertificates:' + str(self.ClientSoftwareCertificates) + ', ' + \
3721
               'LocaleIds:' + str(self.LocaleIds) + ', ' + \
3722
               'UserIdentityToken:' + str(self.UserIdentityToken) + ', ' + \
3723
               'UserTokenSignature:' + str(self.UserTokenSignature) + ')'
3724
3725
    __repr__ = __str__
3726
3727
3728
class ActivateSessionRequest(FrozenClass):
@@ 9261-9329 (lines=69) @@
9258
    __repr__ = __str__
9259
9260
9261
class ReadProcessedDetails(FrozenClass):
9262
    '''
9263
    :ivar StartTime:
9264
    :vartype StartTime: DateTime
9265
    :ivar EndTime:
9266
    :vartype EndTime: DateTime
9267
    :ivar ProcessingInterval:
9268
    :vartype ProcessingInterval: Double
9269
    :ivar AggregateType:
9270
    :vartype AggregateType: NodeId
9271
    :ivar AggregateConfiguration:
9272
    :vartype AggregateConfiguration: AggregateConfiguration
9273
    '''
9274
9275
    ua_types = {
9276
        'StartTime': 'DateTime',
9277
        'EndTime': 'DateTime',
9278
        'ProcessingInterval': 'Double',
9279
        'AggregateType': 'NodeId',
9280
        'AggregateConfiguration': 'AggregateConfiguration',
9281
               }
9282
9283
    def __init__(self, binary=None):
9284
        if binary is not None:
9285
            self._binary_init(binary)
9286
            self._freeze = True
9287
            return
9288
        self.StartTime = datetime.utcnow()
9289
        self.EndTime = datetime.utcnow()
9290
        self.ProcessingInterval = 0
9291
        self.AggregateType = []
9292
        self.AggregateConfiguration = AggregateConfiguration()
9293
        self._freeze = True
9294
9295
    def to_binary(self):
9296
        packet = []
9297
        packet.append(uabin.Primitives.DateTime.pack(self.StartTime))
9298
        packet.append(uabin.Primitives.DateTime.pack(self.EndTime))
9299
        packet.append(uabin.Primitives.Double.pack(self.ProcessingInterval))
9300
        packet.append(uabin.Primitives.Int32.pack(len(self.AggregateType)))
9301
        for fieldname in self.AggregateType:
9302
            packet.append(fieldname.to_binary())
9303
        packet.append(self.AggregateConfiguration.to_binary())
9304
        return b''.join(packet)
9305
9306
    @staticmethod
9307
    def from_binary(data):
9308
        return ReadProcessedDetails(data)
9309
9310
    def _binary_init(self, data):
9311
        self.StartTime = uabin.Primitives.DateTime.unpack(data)
9312
        self.EndTime = uabin.Primitives.DateTime.unpack(data)
9313
        self.ProcessingInterval = uabin.Primitives.Double.unpack(data)
9314
        length = uabin.Primitives.Int32.unpack(data)
9315
        array = []
9316
        if length != -1:
9317
            for _ in range(0, length):
9318
                array.append(NodeId.from_binary(data))
9319
        self.AggregateType = array
9320
        self.AggregateConfiguration = AggregateConfiguration.from_binary(data)
9321
9322
    def __str__(self):
9323
        return 'ReadProcessedDetails(' + 'StartTime:' + str(self.StartTime) + ', ' + \
9324
               'EndTime:' + str(self.EndTime) + ', ' + \
9325
               'ProcessingInterval:' + str(self.ProcessingInterval) + ', ' + \
9326
               'AggregateType:' + str(self.AggregateType) + ', ' + \
9327
               'AggregateConfiguration:' + str(self.AggregateConfiguration) + ')'
9328
9329
    __repr__ = __str__
9330
9331
9332
class ReadAtTimeDetails(FrozenClass):
@@ 8318-8386 (lines=69) @@
8315
    __repr__ = __str__
8316
8317
8318
class QueryFirstParameters(FrozenClass):
8319
    '''
8320
    :ivar View:
8321
    :vartype View: ViewDescription
8322
    :ivar NodeTypes:
8323
    :vartype NodeTypes: NodeTypeDescription
8324
    :ivar Filter:
8325
    :vartype Filter: ContentFilter
8326
    :ivar MaxDataSetsToReturn:
8327
    :vartype MaxDataSetsToReturn: UInt32
8328
    :ivar MaxReferencesToReturn:
8329
    :vartype MaxReferencesToReturn: UInt32
8330
    '''
8331
8332
    ua_types = {
8333
        'View': 'ViewDescription',
8334
        'NodeTypes': 'NodeTypeDescription',
8335
        'Filter': 'ContentFilter',
8336
        'MaxDataSetsToReturn': 'UInt32',
8337
        'MaxReferencesToReturn': 'UInt32',
8338
               }
8339
8340
    def __init__(self, binary=None):
8341
        if binary is not None:
8342
            self._binary_init(binary)
8343
            self._freeze = True
8344
            return
8345
        self.View = ViewDescription()
8346
        self.NodeTypes = []
8347
        self.Filter = ContentFilter()
8348
        self.MaxDataSetsToReturn = 0
8349
        self.MaxReferencesToReturn = 0
8350
        self._freeze = True
8351
8352
    def to_binary(self):
8353
        packet = []
8354
        packet.append(self.View.to_binary())
8355
        packet.append(uabin.Primitives.Int32.pack(len(self.NodeTypes)))
8356
        for fieldname in self.NodeTypes:
8357
            packet.append(fieldname.to_binary())
8358
        packet.append(self.Filter.to_binary())
8359
        packet.append(uabin.Primitives.UInt32.pack(self.MaxDataSetsToReturn))
8360
        packet.append(uabin.Primitives.UInt32.pack(self.MaxReferencesToReturn))
8361
        return b''.join(packet)
8362
8363
    @staticmethod
8364
    def from_binary(data):
8365
        return QueryFirstParameters(data)
8366
8367
    def _binary_init(self, data):
8368
        self.View = ViewDescription.from_binary(data)
8369
        length = uabin.Primitives.Int32.unpack(data)
8370
        array = []
8371
        if length != -1:
8372
            for _ in range(0, length):
8373
                array.append(NodeTypeDescription.from_binary(data))
8374
        self.NodeTypes = array
8375
        self.Filter = ContentFilter.from_binary(data)
8376
        self.MaxDataSetsToReturn = uabin.Primitives.UInt32.unpack(data)
8377
        self.MaxReferencesToReturn = uabin.Primitives.UInt32.unpack(data)
8378
8379
    def __str__(self):
8380
        return 'QueryFirstParameters(' + 'View:' + str(self.View) + ', ' + \
8381
               'NodeTypes:' + str(self.NodeTypes) + ', ' + \
8382
               'Filter:' + str(self.Filter) + ', ' + \
8383
               'MaxDataSetsToReturn:' + str(self.MaxDataSetsToReturn) + ', ' + \
8384
               'MaxReferencesToReturn:' + str(self.MaxReferencesToReturn) + ')'
8385
8386
    __repr__ = __str__
8387
8388
8389
class QueryFirstRequest(FrozenClass):