Code Duplication    Length = 69-71 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 locations

@@ 3657-3727 (lines=71) @@
3654
    __repr__ = __str__
3655
3656
3657
class ActivateSessionParameters(FrozenClass):
3658
    '''
3659
    :ivar ClientSignature:
3660
    :vartype ClientSignature: SignatureData
3661
    :ivar ClientSoftwareCertificates:
3662
    :vartype ClientSoftwareCertificates: SignedSoftwareCertificate
3663
    :ivar LocaleIds:
3664
    :vartype LocaleIds: String
3665
    :ivar UserIdentityToken:
3666
    :vartype UserIdentityToken: ExtensionObject
3667
    :ivar UserTokenSignature:
3668
    :vartype UserTokenSignature: SignatureData
3669
    '''
3670
3671
    ua_types = {
3672
        'ClientSignature': 'SignatureData',
3673
        'ClientSoftwareCertificates': 'SignedSoftwareCertificate',
3674
        'LocaleIds': 'String',
3675
        'UserIdentityToken': 'ExtensionObject',
3676
        'UserTokenSignature': 'SignatureData',
3677
               }
3678
3679
    def __init__(self, binary=None):
3680
        if binary is not None:
3681
            self._binary_init(binary)
3682
            self._freeze = True
3683
            return
3684
        self.ClientSignature = SignatureData()
3685
        self.ClientSoftwareCertificates = []
3686
        self.LocaleIds = []
3687
        self.UserIdentityToken = None
3688
        self.UserTokenSignature = SignatureData()
3689
        self._freeze = True
3690
3691
    def to_binary(self):
3692
        packet = []
3693
        packet.append(self.ClientSignature.to_binary())
3694
        packet.append(uabin.Primitives.Int32.pack(len(self.ClientSoftwareCertificates)))
3695
        for fieldname in self.ClientSoftwareCertificates:
3696
            packet.append(fieldname.to_binary())
3697
        packet.append(uabin.Primitives.Int32.pack(len(self.LocaleIds)))
3698
        for fieldname in self.LocaleIds:
3699
            packet.append(uabin.Primitives.String.pack(fieldname))
3700
        packet.append(extensionobject_to_binary(self.UserIdentityToken))
3701
        packet.append(self.UserTokenSignature.to_binary())
3702
        return b''.join(packet)
3703
3704
    @staticmethod
3705
    def from_binary(data):
3706
        return ActivateSessionParameters(data)
3707
3708
    def _binary_init(self, data):
3709
        self.ClientSignature = SignatureData.from_binary(data)
3710
        length = uabin.Primitives.Int32.unpack(data)
3711
        array = []
3712
        if length != -1:
3713
            for _ in range(0, length):
3714
                array.append(SignedSoftwareCertificate.from_binary(data))
3715
        self.ClientSoftwareCertificates = array
3716
        self.LocaleIds = uabin.Primitives.String.unpack_array(data)
3717
        self.UserIdentityToken = extensionobject_from_binary(data)
3718
        self.UserTokenSignature = SignatureData.from_binary(data)
3719
3720
    def __str__(self):
3721
        return 'ActivateSessionParameters(' + 'ClientSignature:' + str(self.ClientSignature) + ', ' + \
3722
               'ClientSoftwareCertificates:' + str(self.ClientSoftwareCertificates) + ', ' + \
3723
               'LocaleIds:' + str(self.LocaleIds) + ', ' + \
3724
               'UserIdentityToken:' + str(self.UserIdentityToken) + ', ' + \
3725
               'UserTokenSignature:' + str(self.UserTokenSignature) + ')'
3726
3727
    __repr__ = __str__
3728
3729
3730
class ActivateSessionRequest(FrozenClass):
@@ 9227-9295 (lines=69) @@
9224
    __repr__ = __str__
9225
9226
9227
class ReadProcessedDetails(FrozenClass):
9228
    '''
9229
    :ivar StartTime:
9230
    :vartype StartTime: DateTime
9231
    :ivar EndTime:
9232
    :vartype EndTime: DateTime
9233
    :ivar ProcessingInterval:
9234
    :vartype ProcessingInterval: Double
9235
    :ivar AggregateType:
9236
    :vartype AggregateType: NodeId
9237
    :ivar AggregateConfiguration:
9238
    :vartype AggregateConfiguration: AggregateConfiguration
9239
    '''
9240
9241
    ua_types = {
9242
        'StartTime': 'DateTime',
9243
        'EndTime': 'DateTime',
9244
        'ProcessingInterval': 'Double',
9245
        'AggregateType': 'NodeId',
9246
        'AggregateConfiguration': 'AggregateConfiguration',
9247
               }
9248
9249
    def __init__(self, binary=None):
9250
        if binary is not None:
9251
            self._binary_init(binary)
9252
            self._freeze = True
9253
            return
9254
        self.StartTime = datetime.now()
9255
        self.EndTime = datetime.now()
9256
        self.ProcessingInterval = 0
9257
        self.AggregateType = []
9258
        self.AggregateConfiguration = AggregateConfiguration()
9259
        self._freeze = True
9260
9261
    def to_binary(self):
9262
        packet = []
9263
        packet.append(uabin.Primitives.DateTime.pack(self.StartTime))
9264
        packet.append(uabin.Primitives.DateTime.pack(self.EndTime))
9265
        packet.append(uabin.Primitives.Double.pack(self.ProcessingInterval))
9266
        packet.append(uabin.Primitives.Int32.pack(len(self.AggregateType)))
9267
        for fieldname in self.AggregateType:
9268
            packet.append(fieldname.to_binary())
9269
        packet.append(self.AggregateConfiguration.to_binary())
9270
        return b''.join(packet)
9271
9272
    @staticmethod
9273
    def from_binary(data):
9274
        return ReadProcessedDetails(data)
9275
9276
    def _binary_init(self, data):
9277
        self.StartTime = uabin.Primitives.DateTime.unpack(data)
9278
        self.EndTime = uabin.Primitives.DateTime.unpack(data)
9279
        self.ProcessingInterval = uabin.Primitives.Double.unpack(data)
9280
        length = uabin.Primitives.Int32.unpack(data)
9281
        array = []
9282
        if length != -1:
9283
            for _ in range(0, length):
9284
                array.append(NodeId.from_binary(data))
9285
        self.AggregateType = array
9286
        self.AggregateConfiguration = AggregateConfiguration.from_binary(data)
9287
9288
    def __str__(self):
9289
        return 'ReadProcessedDetails(' + 'StartTime:' + str(self.StartTime) + ', ' + \
9290
               'EndTime:' + str(self.EndTime) + ', ' + \
9291
               'ProcessingInterval:' + str(self.ProcessingInterval) + ', ' + \
9292
               'AggregateType:' + str(self.AggregateType) + ', ' + \
9293
               'AggregateConfiguration:' + str(self.AggregateConfiguration) + ')'
9294
9295
    __repr__ = __str__
9296
9297
9298
class ReadAtTimeDetails(FrozenClass):
@@ 8284-8352 (lines=69) @@
8281
    __repr__ = __str__
8282
8283
8284
class QueryFirstParameters(FrozenClass):
8285
    '''
8286
    :ivar View:
8287
    :vartype View: ViewDescription
8288
    :ivar NodeTypes:
8289
    :vartype NodeTypes: NodeTypeDescription
8290
    :ivar Filter:
8291
    :vartype Filter: ContentFilter
8292
    :ivar MaxDataSetsToReturn:
8293
    :vartype MaxDataSetsToReturn: UInt32
8294
    :ivar MaxReferencesToReturn:
8295
    :vartype MaxReferencesToReturn: UInt32
8296
    '''
8297
8298
    ua_types = {
8299
        'View': 'ViewDescription',
8300
        'NodeTypes': 'NodeTypeDescription',
8301
        'Filter': 'ContentFilter',
8302
        'MaxDataSetsToReturn': 'UInt32',
8303
        'MaxReferencesToReturn': 'UInt32',
8304
               }
8305
8306
    def __init__(self, binary=None):
8307
        if binary is not None:
8308
            self._binary_init(binary)
8309
            self._freeze = True
8310
            return
8311
        self.View = ViewDescription()
8312
        self.NodeTypes = []
8313
        self.Filter = ContentFilter()
8314
        self.MaxDataSetsToReturn = 0
8315
        self.MaxReferencesToReturn = 0
8316
        self._freeze = True
8317
8318
    def to_binary(self):
8319
        packet = []
8320
        packet.append(self.View.to_binary())
8321
        packet.append(uabin.Primitives.Int32.pack(len(self.NodeTypes)))
8322
        for fieldname in self.NodeTypes:
8323
            packet.append(fieldname.to_binary())
8324
        packet.append(self.Filter.to_binary())
8325
        packet.append(uabin.Primitives.UInt32.pack(self.MaxDataSetsToReturn))
8326
        packet.append(uabin.Primitives.UInt32.pack(self.MaxReferencesToReturn))
8327
        return b''.join(packet)
8328
8329
    @staticmethod
8330
    def from_binary(data):
8331
        return QueryFirstParameters(data)
8332
8333
    def _binary_init(self, data):
8334
        self.View = ViewDescription.from_binary(data)
8335
        length = uabin.Primitives.Int32.unpack(data)
8336
        array = []
8337
        if length != -1:
8338
            for _ in range(0, length):
8339
                array.append(NodeTypeDescription.from_binary(data))
8340
        self.NodeTypes = array
8341
        self.Filter = ContentFilter.from_binary(data)
8342
        self.MaxDataSetsToReturn = uabin.Primitives.UInt32.unpack(data)
8343
        self.MaxReferencesToReturn = uabin.Primitives.UInt32.unpack(data)
8344
8345
    def __str__(self):
8346
        return 'QueryFirstParameters(' + 'View:' + str(self.View) + ', ' + \
8347
               'NodeTypes:' + str(self.NodeTypes) + ', ' + \
8348
               'Filter:' + str(self.Filter) + ', ' + \
8349
               'MaxDataSetsToReturn:' + str(self.MaxDataSetsToReturn) + ', ' + \
8350
               'MaxReferencesToReturn:' + str(self.MaxReferencesToReturn) + ')'
8351
8352
    __repr__ = __str__
8353
8354
8355
class QueryFirstRequest(FrozenClass):