Code Duplication    Length = 58-58 lines in 4 locations

opcua/ua/uaprotocol_auto.py 4 locations

@@ 9699-9756 (lines=58) @@
9696
    __repr__ = __str__
9697
9698
9699
class UpdateEventDetails(FrozenClass):
9700
    '''
9701
    :ivar NodeId:
9702
    :vartype NodeId: NodeId
9703
    :ivar PerformInsertReplace:
9704
    :vartype PerformInsertReplace: PerformUpdateType
9705
    :ivar Filter:
9706
    :vartype Filter: EventFilter
9707
    :ivar EventData:
9708
    :vartype EventData: HistoryEventFieldList
9709
    '''
9710
9711
    ua_types = [
9712
9713
        ('NodeId', 'NodeId'),
9714
        ('PerformInsertReplace', 'PerformUpdateType'),
9715
        ('Filter', 'EventFilter'),
9716
        ('EventData', 'ListOfHistoryEventFieldList'),
9717
               ]
9718
9719
    def __init__(self):
9720
        self.NodeId = NodeId()
9721
        self.PerformInsertReplace = PerformUpdateType(0)
9722
        self.Filter = EventFilter()
9723
        self.EventData = []
9724
        self._freeze = True
9725
9726
    def to_binary(self):
9727
        packet = []
9728
        packet.append(self.NodeId.to_binary())
9729
        packet.append(uabin.Primitives.UInt32.pack(self.PerformInsertReplace.value))
9730
        packet.append(self.Filter.to_binary())
9731
        packet.append(uabin.Primitives.Int32.pack(len(self.EventData)))
9732
        for fieldname in self.EventData:
9733
            packet.append(fieldname.to_binary())
9734
        return b''.join(packet)
9735
9736
    @staticmethod
9737
    def from_binary(data):
9738
        obj = UpdateEventDetails()
9739
        obj.NodeId = NodeId.from_binary(data)
9740
        self.PerformInsertReplace = PerformUpdateType(uabin.Primitives.UInt32.unpack(data))
9741
        obj.Filter = EventFilter.from_binary(data)
9742
        length = uabin.Primitives.Int32.unpack(data)
9743
        array = []
9744
        if length != -1:
9745
            for _ in range(0, length):
9746
                array.append(HistoryEventFieldList.from_binary(data))
9747
        obj.EventData = array
9748
        return obj
9749
9750
    def __str__(self):
9751
        return 'UpdateEventDetails(' + 'NodeId:' + str(self.NodeId) + ', ' + \
9752
               'PerformInsertReplace:' + str(self.PerformInsertReplace) + ', ' + \
9753
               'Filter:' + str(self.Filter) + ', ' + \
9754
               'EventData:' + str(self.EventData) + ')'
9755
9756
    __repr__ = __str__
9757
9758
9759
class DeleteRawModifiedDetails(FrozenClass):
@@ 9183-9240 (lines=58) @@
9180
    __repr__ = __str__
9181
9182
9183
class HistoryReadParameters(FrozenClass):
9184
    '''
9185
    :ivar HistoryReadDetails:
9186
    :vartype HistoryReadDetails: ExtensionObject
9187
    :ivar TimestampsToReturn:
9188
    :vartype TimestampsToReturn: TimestampsToReturn
9189
    :ivar ReleaseContinuationPoints:
9190
    :vartype ReleaseContinuationPoints: Boolean
9191
    :ivar NodesToRead:
9192
    :vartype NodesToRead: HistoryReadValueId
9193
    '''
9194
9195
    ua_types = [
9196
9197
        ('HistoryReadDetails', 'ExtensionObject'),
9198
        ('TimestampsToReturn', 'TimestampsToReturn'),
9199
        ('ReleaseContinuationPoints', 'Boolean'),
9200
        ('NodesToRead', 'ListOfHistoryReadValueId'),
9201
               ]
9202
9203
    def __init__(self):
9204
        self.HistoryReadDetails = None
9205
        self.TimestampsToReturn = TimestampsToReturn(0)
9206
        self.ReleaseContinuationPoints = True
9207
        self.NodesToRead = []
9208
        self._freeze = True
9209
9210
    def to_binary(self):
9211
        packet = []
9212
        packet.append(extensionobject_to_binary(self.HistoryReadDetails))
9213
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
9214
        packet.append(uabin.Primitives.Boolean.pack(self.ReleaseContinuationPoints))
9215
        packet.append(uabin.Primitives.Int32.pack(len(self.NodesToRead)))
9216
        for fieldname in self.NodesToRead:
9217
            packet.append(fieldname.to_binary())
9218
        return b''.join(packet)
9219
9220
    @staticmethod
9221
    def from_binary(data):
9222
        obj = HistoryReadParameters()
9223
        obj.HistoryReadDetails = extensionobject_from_binary(data)
9224
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
9225
        self.ReleaseContinuationPoints = uabin.Primitives.Boolean.unpack(data)
9226
        length = uabin.Primitives.Int32.unpack(data)
9227
        array = []
9228
        if length != -1:
9229
            for _ in range(0, length):
9230
                array.append(HistoryReadValueId.from_binary(data))
9231
        obj.NodesToRead = array
9232
        return obj
9233
9234
    def __str__(self):
9235
        return 'HistoryReadParameters(' + 'HistoryReadDetails:' + str(self.HistoryReadDetails) + ', ' + \
9236
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
9237
               'ReleaseContinuationPoints:' + str(self.ReleaseContinuationPoints) + ', ' + \
9238
               'NodesToRead:' + str(self.NodesToRead) + ')'
9239
9240
    __repr__ = __str__
9241
9242
9243
class HistoryReadRequest(FrozenClass):
@@ 7791-7848 (lines=58) @@
7788
    __repr__ = __str__
7789
7790
7791
class SimpleAttributeOperand(FrozenClass):
7792
    '''
7793
    :ivar TypeDefinitionId:
7794
    :vartype TypeDefinitionId: NodeId
7795
    :ivar BrowsePath:
7796
    :vartype BrowsePath: QualifiedName
7797
    :ivar AttributeId:
7798
    :vartype AttributeId: UInt32
7799
    :ivar IndexRange:
7800
    :vartype IndexRange: String
7801
    '''
7802
7803
    ua_types = [
7804
7805
        ('TypeDefinitionId', 'NodeId'),
7806
        ('BrowsePath', 'ListOfQualifiedName'),
7807
        ('AttributeId', 'UInt32'),
7808
        ('IndexRange', 'String'),
7809
               ]
7810
7811
    def __init__(self):
7812
        self.TypeDefinitionId = NodeId()
7813
        self.BrowsePath = []
7814
        self.AttributeId = 0
7815
        self.IndexRange = None
7816
        self._freeze = True
7817
7818
    def to_binary(self):
7819
        packet = []
7820
        packet.append(self.TypeDefinitionId.to_binary())
7821
        packet.append(uabin.Primitives.Int32.pack(len(self.BrowsePath)))
7822
        for fieldname in self.BrowsePath:
7823
            packet.append(fieldname.to_binary())
7824
        packet.append(uabin.Primitives.UInt32.pack(self.AttributeId))
7825
        packet.append(uabin.Primitives.String.pack(self.IndexRange))
7826
        return b''.join(packet)
7827
7828
    @staticmethod
7829
    def from_binary(data):
7830
        obj = SimpleAttributeOperand()
7831
        obj.TypeDefinitionId = NodeId.from_binary(data)
7832
        length = uabin.Primitives.Int32.unpack(data)
7833
        array = []
7834
        if length != -1:
7835
            for _ in range(0, length):
7836
                array.append(QualifiedName.from_binary(data))
7837
        obj.BrowsePath = array
7838
        self.AttributeId = uabin.Primitives.UInt32.unpack(data)
7839
        self.IndexRange = uabin.Primitives.String.unpack(data)
7840
        return obj
7841
7842
    def __str__(self):
7843
        return 'SimpleAttributeOperand(' + 'TypeDefinitionId:' + str(self.TypeDefinitionId) + ', ' + \
7844
               'BrowsePath:' + str(self.BrowsePath) + ', ' + \
7845
               'AttributeId:' + str(self.AttributeId) + ', ' + \
7846
               'IndexRange:' + str(self.IndexRange) + ')'
7847
7848
    __repr__ = __str__
7849
7850
7851
class ContentFilterElementResult(FrozenClass):
@@ 7522-7579 (lines=58) @@
7519
    __repr__ = __str__
7520
7521
7522
class NodeReference(FrozenClass):
7523
    '''
7524
    :ivar NodeId:
7525
    :vartype NodeId: NodeId
7526
    :ivar ReferenceTypeId:
7527
    :vartype ReferenceTypeId: NodeId
7528
    :ivar IsForward:
7529
    :vartype IsForward: Boolean
7530
    :ivar ReferencedNodeIds:
7531
    :vartype ReferencedNodeIds: NodeId
7532
    '''
7533
7534
    ua_types = [
7535
7536
        ('NodeId', 'NodeId'),
7537
        ('ReferenceTypeId', 'NodeId'),
7538
        ('IsForward', 'Boolean'),
7539
        ('ReferencedNodeIds', 'ListOfNodeId'),
7540
               ]
7541
7542
    def __init__(self):
7543
        self.NodeId = NodeId()
7544
        self.ReferenceTypeId = NodeId()
7545
        self.IsForward = True
7546
        self.ReferencedNodeIds = []
7547
        self._freeze = True
7548
7549
    def to_binary(self):
7550
        packet = []
7551
        packet.append(self.NodeId.to_binary())
7552
        packet.append(self.ReferenceTypeId.to_binary())
7553
        packet.append(uabin.Primitives.Boolean.pack(self.IsForward))
7554
        packet.append(uabin.Primitives.Int32.pack(len(self.ReferencedNodeIds)))
7555
        for fieldname in self.ReferencedNodeIds:
7556
            packet.append(fieldname.to_binary())
7557
        return b''.join(packet)
7558
7559
    @staticmethod
7560
    def from_binary(data):
7561
        obj = NodeReference()
7562
        obj.NodeId = NodeId.from_binary(data)
7563
        obj.ReferenceTypeId = NodeId.from_binary(data)
7564
        self.IsForward = uabin.Primitives.Boolean.unpack(data)
7565
        length = uabin.Primitives.Int32.unpack(data)
7566
        array = []
7567
        if length != -1:
7568
            for _ in range(0, length):
7569
                array.append(NodeId.from_binary(data))
7570
        obj.ReferencedNodeIds = array
7571
        return obj
7572
7573
    def __str__(self):
7574
        return 'NodeReference(' + 'NodeId:' + str(self.NodeId) + ', ' + \
7575
               'ReferenceTypeId:' + str(self.ReferenceTypeId) + ', ' + \
7576
               'IsForward:' + str(self.IsForward) + ', ' + \
7577
               'ReferencedNodeIds:' + str(self.ReferencedNodeIds) + ')'
7578
7579
    __repr__ = __str__
7580
7581
7582
class ContentFilterElement(FrozenClass):