Code Duplication    Length = 53-57 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 locations

@@ 890-946 (lines=57) @@
887
    __repr__ = __str__
888
889
890
class Argument(FrozenClass):
891
    '''
892
    An argument for a method.
893
894
    :ivar Name:
895
    :vartype Name: String
896
    :ivar DataType:
897
    :vartype DataType: NodeId
898
    :ivar ValueRank:
899
    :vartype ValueRank: Int32
900
    :ivar ArrayDimensions:
901
    :vartype ArrayDimensions: UInt32
902
    :ivar Description:
903
    :vartype Description: LocalizedText
904
    '''
905
    def __init__(self, binary=None):
906
        if binary is not None:
907
            self._binary_init(binary)
908
            self._freeze = True
909
            return
910
        self.Name = None
911
        self.DataType = NodeId()
912
        self.ValueRank = 0
913
        self.ArrayDimensions = []
914
        self.Description = LocalizedText()
915
        self._freeze = True
916
917
    def to_binary(self):
918
        packet = []
919
        packet.append(pack_string(self.Name))
920
        packet.append(self.DataType.to_binary())
921
        packet.append(uatype_Int32.pack(self.ValueRank))
922
        packet.append(uatype_Int32.pack(len(self.ArrayDimensions)))
923
        for fieldname in self.ArrayDimensions:
924
            packet.append(uatype_UInt32.pack(fieldname))
925
        packet.append(self.Description.to_binary())
926
        return b''.join(packet)
927
928
    @staticmethod
929
    def from_binary(data):
930
        return Argument(data)
931
932
    def _binary_init(self, data):
933
        self.Name = unpack_string(data)
934
        self.DataType = NodeId.from_binary(data)
935
        self.ValueRank = uatype_Int32.unpack(data.read(4))[0]
936
        self.ArrayDimensions = unpack_uatype_array('UInt32', data)
937
        self.Description = LocalizedText.from_binary(data)
938
939
    def __str__(self):
940
        return 'Argument(' + 'Name:' + str(self.Name) + ', ' + \
941
               'DataType:' + str(self.DataType) + ', ' + \
942
               'ValueRank:' + str(self.ValueRank) + ', ' + \
943
               'ArrayDimensions:' + str(self.ArrayDimensions) + ', ' + \
944
               'Description:' + str(self.Description) + ')'
945
946
    __repr__ = __str__
947
948
949
class EnumValueType(FrozenClass):
@@ 13848-13902 (lines=55) @@
13845
13846
    __repr__ = __str__
13847
13848
13849
class AxisInformation(FrozenClass):
13850
    '''
13851
    :ivar EngineeringUnits:
13852
    :vartype EngineeringUnits: EUInformation
13853
    :ivar EURange:
13854
    :vartype EURange: Range
13855
    :ivar Title:
13856
    :vartype Title: LocalizedText
13857
    :ivar AxisScaleType:
13858
    :vartype AxisScaleType: AxisScaleEnumeration
13859
    :ivar AxisSteps:
13860
    :vartype AxisSteps: Double
13861
    '''
13862
    def __init__(self, binary=None):
13863
        if binary is not None:
13864
            self._binary_init(binary)
13865
            self._freeze = True
13866
            return
13867
        self.EngineeringUnits = EUInformation()
13868
        self.EURange = Range()
13869
        self.Title = LocalizedText()
13870
        self.AxisScaleType = AxisScaleEnumeration(0)
13871
        self.AxisSteps = []
13872
        self._freeze = True
13873
13874
    def to_binary(self):
13875
        packet = []
13876
        packet.append(self.EngineeringUnits.to_binary())
13877
        packet.append(self.EURange.to_binary())
13878
        packet.append(self.Title.to_binary())
13879
        packet.append(uatype_UInt32.pack(self.AxisScaleType.value))
13880
        packet.append(uatype_Int32.pack(len(self.AxisSteps)))
13881
        for fieldname in self.AxisSteps:
13882
            packet.append(uatype_Double.pack(fieldname))
13883
        return b''.join(packet)
13884
13885
    @staticmethod
13886
    def from_binary(data):
13887
        return AxisInformation(data)
13888
13889
    def _binary_init(self, data):
13890
        self.EngineeringUnits = EUInformation.from_binary(data)
13891
        self.EURange = Range.from_binary(data)
13892
        self.Title = LocalizedText.from_binary(data)
13893
        self.AxisScaleType = AxisScaleEnumeration(uatype_UInt32.unpack(data.read(4))[0])
13894
        self.AxisSteps = unpack_uatype_array('Double', data)
13895
13896
    def __str__(self):
13897
        return 'AxisInformation(' + 'EngineeringUnits:' + str(self.EngineeringUnits) + ', ' + \
13898
               'EURange:' + str(self.EURange) + ', ' + \
13899
               'Title:' + str(self.Title) + ', ' + \
13900
               'AxisScaleType:' + str(self.AxisScaleType) + ', ' + \
13901
               'AxisSteps:' + str(self.AxisSteps) + ')'
13902
13903
    __repr__ = __str__
13904
13905
@@ 7031-7083 (lines=53) @@
7028
7029
    __repr__ = __str__
7030
7031
7032
class AttributeOperand(FrozenClass):
7033
    '''
7034
    :ivar NodeId:
7035
    :vartype NodeId: NodeId
7036
    :ivar Alias:
7037
    :vartype Alias: String
7038
    :ivar BrowsePath:
7039
    :vartype BrowsePath: RelativePath
7040
    :ivar AttributeId:
7041
    :vartype AttributeId: UInt32
7042
    :ivar IndexRange:
7043
    :vartype IndexRange: String
7044
    '''
7045
    def __init__(self, binary=None):
7046
        if binary is not None:
7047
            self._binary_init(binary)
7048
            self._freeze = True
7049
            return
7050
        self.NodeId = NodeId()
7051
        self.Alias = None
7052
        self.BrowsePath = RelativePath()
7053
        self.AttributeId = 0
7054
        self.IndexRange = None
7055
        self._freeze = True
7056
7057
    def to_binary(self):
7058
        packet = []
7059
        packet.append(self.NodeId.to_binary())
7060
        packet.append(pack_string(self.Alias))
7061
        packet.append(self.BrowsePath.to_binary())
7062
        packet.append(uatype_UInt32.pack(self.AttributeId))
7063
        packet.append(pack_string(self.IndexRange))
7064
        return b''.join(packet)
7065
7066
    @staticmethod
7067
    def from_binary(data):
7068
        return AttributeOperand(data)
7069
7070
    def _binary_init(self, data):
7071
        self.NodeId = NodeId.from_binary(data)
7072
        self.Alias = unpack_string(data)
7073
        self.BrowsePath = RelativePath.from_binary(data)
7074
        self.AttributeId = uatype_UInt32.unpack(data.read(4))[0]
7075
        self.IndexRange = unpack_string(data)
7076
7077
    def __str__(self):
7078
        return 'AttributeOperand(' + 'NodeId:' + str(self.NodeId) + ', ' + \
7079
               'Alias:' + str(self.Alias) + ', ' + \
7080
               'BrowsePath:' + str(self.BrowsePath) + ', ' + \
7081
               'AttributeId:' + str(self.AttributeId) + ', ' + \
7082
               'IndexRange:' + str(self.IndexRange) + ')'
7083
7084
    __repr__ = __str__
7085
7086