Code Duplication    Length = 65-67 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 locations

@@ 3677-3743 (lines=67) @@
3674
    __repr__ = __str__
3675
3676
3677
class ActivateSessionParameters(FrozenClass):
3678
    '''
3679
    :ivar ClientSignature:
3680
    :vartype ClientSignature: SignatureData
3681
    :ivar ClientSoftwareCertificates:
3682
    :vartype ClientSoftwareCertificates: SignedSoftwareCertificate
3683
    :ivar LocaleIds:
3684
    :vartype LocaleIds: String
3685
    :ivar UserIdentityToken:
3686
    :vartype UserIdentityToken: ExtensionObject
3687
    :ivar UserTokenSignature:
3688
    :vartype UserTokenSignature: SignatureData
3689
    '''
3690
3691
    ua_types = [
3692
3693
        ('ClientSignature', 'SignatureData'),
3694
        ('ClientSoftwareCertificates', 'ListOfSignedSoftwareCertificate'),
3695
        ('LocaleIds', 'ListOfString'),
3696
        ('UserIdentityToken', 'ExtensionObject'),
3697
        ('UserTokenSignature', 'SignatureData'),
3698
               ]
3699
3700
    def __init__(self):
3701
        self.ClientSignature = SignatureData()
3702
        self.ClientSoftwareCertificates = []
3703
        self.LocaleIds = []
3704
        self.UserIdentityToken = None
3705
        self.UserTokenSignature = SignatureData()
3706
        self._freeze = True
3707
3708
    def to_binary(self):
3709
        packet = []
3710
        packet.append(self.ClientSignature.to_binary())
3711
        packet.append(uabin.Primitives.Int32.pack(len(self.ClientSoftwareCertificates)))
3712
        for fieldname in self.ClientSoftwareCertificates:
3713
            packet.append(fieldname.to_binary())
3714
        packet.append(uabin.Primitives.Int32.pack(len(self.LocaleIds)))
3715
        for fieldname in self.LocaleIds:
3716
            packet.append(uabin.Primitives.String.pack(fieldname))
3717
        packet.append(extensionobject_to_binary(self.UserIdentityToken))
3718
        packet.append(self.UserTokenSignature.to_binary())
3719
        return b''.join(packet)
3720
3721
    @staticmethod
3722
    def from_binary(data):
3723
        obj = ActivateSessionParameters()
3724
        obj.ClientSignature = SignatureData.from_binary(data)
3725
        length = uabin.Primitives.Int32.unpack(data)
3726
        array = []
3727
        if length != -1:
3728
            for _ in range(0, length):
3729
                array.append(SignedSoftwareCertificate.from_binary(data))
3730
        obj.ClientSoftwareCertificates = array
3731
        obj.LocaleIds = uabin.Primitives.String.unpack_array(data)
3732
        obj.UserIdentityToken = extensionobject_from_binary(data)
3733
        obj.UserTokenSignature = SignatureData.from_binary(data)
3734
        return obj
3735
3736
    def __str__(self):
3737
        return 'ActivateSessionParameters(' + 'ClientSignature:' + str(self.ClientSignature) + ', ' + \
3738
               'ClientSoftwareCertificates:' + str(self.ClientSoftwareCertificates) + ', ' + \
3739
               'LocaleIds:' + str(self.LocaleIds) + ', ' + \
3740
               'UserIdentityToken:' + str(self.UserIdentityToken) + ', ' + \
3741
               'UserTokenSignature:' + str(self.UserTokenSignature) + ')'
3742
3743
    __repr__ = __str__
3744
3745
3746
class ActivateSessionRequest(FrozenClass):
@@ 8898-8962 (lines=65) @@
8895
    __repr__ = __str__
8896
8897
8898
class ReadProcessedDetails(FrozenClass):
8899
    '''
8900
    :ivar StartTime:
8901
    :vartype StartTime: DateTime
8902
    :ivar EndTime:
8903
    :vartype EndTime: DateTime
8904
    :ivar ProcessingInterval:
8905
    :vartype ProcessingInterval: Double
8906
    :ivar AggregateType:
8907
    :vartype AggregateType: NodeId
8908
    :ivar AggregateConfiguration:
8909
    :vartype AggregateConfiguration: AggregateConfiguration
8910
    '''
8911
8912
    ua_types = [
8913
8914
        ('StartTime', 'DateTime'),
8915
        ('EndTime', 'DateTime'),
8916
        ('ProcessingInterval', 'Double'),
8917
        ('AggregateType', 'ListOfNodeId'),
8918
        ('AggregateConfiguration', 'AggregateConfiguration'),
8919
               ]
8920
8921
    def __init__(self):
8922
        self.StartTime = datetime.utcnow()
8923
        self.EndTime = datetime.utcnow()
8924
        self.ProcessingInterval = 0
8925
        self.AggregateType = []
8926
        self.AggregateConfiguration = AggregateConfiguration()
8927
        self._freeze = True
8928
8929
    def to_binary(self):
8930
        packet = []
8931
        packet.append(uabin.Primitives.DateTime.pack(self.StartTime))
8932
        packet.append(uabin.Primitives.DateTime.pack(self.EndTime))
8933
        packet.append(uabin.Primitives.Double.pack(self.ProcessingInterval))
8934
        packet.append(uabin.Primitives.Int32.pack(len(self.AggregateType)))
8935
        for fieldname in self.AggregateType:
8936
            packet.append(fieldname.to_binary())
8937
        packet.append(self.AggregateConfiguration.to_binary())
8938
        return b''.join(packet)
8939
8940
    @staticmethod
8941
    def from_binary(data):
8942
        obj = ReadProcessedDetails()
8943
        self.StartTime = uabin.Primitives.DateTime.unpack(data)
8944
        self.EndTime = uabin.Primitives.DateTime.unpack(data)
8945
        self.ProcessingInterval = uabin.Primitives.Double.unpack(data)
8946
        length = uabin.Primitives.Int32.unpack(data)
8947
        array = []
8948
        if length != -1:
8949
            for _ in range(0, length):
8950
                array.append(NodeId.from_binary(data))
8951
        obj.AggregateType = array
8952
        obj.AggregateConfiguration = AggregateConfiguration.from_binary(data)
8953
        return obj
8954
8955
    def __str__(self):
8956
        return 'ReadProcessedDetails(' + 'StartTime:' + str(self.StartTime) + ', ' + \
8957
               'EndTime:' + str(self.EndTime) + ', ' + \
8958
               'ProcessingInterval:' + str(self.ProcessingInterval) + ', ' + \
8959
               'AggregateType:' + str(self.AggregateType) + ', ' + \
8960
               'AggregateConfiguration:' + str(self.AggregateConfiguration) + ')'
8961
8962
    __repr__ = __str__
8963
8964
8965
class ReadAtTimeDetails(FrozenClass):
@@ 8024-8088 (lines=65) @@
8021
    __repr__ = __str__
8022
8023
8024
class QueryFirstParameters(FrozenClass):
8025
    '''
8026
    :ivar View:
8027
    :vartype View: ViewDescription
8028
    :ivar NodeTypes:
8029
    :vartype NodeTypes: NodeTypeDescription
8030
    :ivar Filter:
8031
    :vartype Filter: ContentFilter
8032
    :ivar MaxDataSetsToReturn:
8033
    :vartype MaxDataSetsToReturn: UInt32
8034
    :ivar MaxReferencesToReturn:
8035
    :vartype MaxReferencesToReturn: UInt32
8036
    '''
8037
8038
    ua_types = [
8039
8040
        ('View', 'ViewDescription'),
8041
        ('NodeTypes', 'ListOfNodeTypeDescription'),
8042
        ('Filter', 'ContentFilter'),
8043
        ('MaxDataSetsToReturn', 'UInt32'),
8044
        ('MaxReferencesToReturn', 'UInt32'),
8045
               ]
8046
8047
    def __init__(self):
8048
        self.View = ViewDescription()
8049
        self.NodeTypes = []
8050
        self.Filter = ContentFilter()
8051
        self.MaxDataSetsToReturn = 0
8052
        self.MaxReferencesToReturn = 0
8053
        self._freeze = True
8054
8055
    def to_binary(self):
8056
        packet = []
8057
        packet.append(self.View.to_binary())
8058
        packet.append(uabin.Primitives.Int32.pack(len(self.NodeTypes)))
8059
        for fieldname in self.NodeTypes:
8060
            packet.append(fieldname.to_binary())
8061
        packet.append(self.Filter.to_binary())
8062
        packet.append(uabin.Primitives.UInt32.pack(self.MaxDataSetsToReturn))
8063
        packet.append(uabin.Primitives.UInt32.pack(self.MaxReferencesToReturn))
8064
        return b''.join(packet)
8065
8066
    @staticmethod
8067
    def from_binary(data):
8068
        obj = QueryFirstParameters()
8069
        obj.View = ViewDescription.from_binary(data)
8070
        length = uabin.Primitives.Int32.unpack(data)
8071
        array = []
8072
        if length != -1:
8073
            for _ in range(0, length):
8074
                array.append(NodeTypeDescription.from_binary(data))
8075
        obj.NodeTypes = array
8076
        obj.Filter = ContentFilter.from_binary(data)
8077
        self.MaxDataSetsToReturn = uabin.Primitives.UInt32.unpack(data)
8078
        self.MaxReferencesToReturn = uabin.Primitives.UInt32.unpack(data)
8079
        return obj
8080
8081
    def __str__(self):
8082
        return 'QueryFirstParameters(' + 'View:' + str(self.View) + ', ' + \
8083
               'NodeTypes:' + str(self.NodeTypes) + ', ' + \
8084
               'Filter:' + str(self.Filter) + ', ' + \
8085
               'MaxDataSetsToReturn:' + str(self.MaxDataSetsToReturn) + ', ' + \
8086
               'MaxReferencesToReturn:' + str(self.MaxReferencesToReturn) + ')'
8087
8088
    __repr__ = __str__
8089
8090
8091
class QueryFirstRequest(FrozenClass):