Code Duplication    Length = 54-60 lines in 5 locations

opcua/ua/uaprotocol_auto.py 5 locations

@@ 8126-8185 (lines=60) @@
8123
    __repr__ = __str__
8124
8125
8126
class ReadProcessedDetails(FrozenClass):
8127
    '''
8128
    :ivar StartTime:
8129
    :vartype StartTime: DateTime
8130
    :ivar EndTime:
8131
    :vartype EndTime: DateTime
8132
    :ivar ProcessingInterval:
8133
    :vartype ProcessingInterval: Double
8134
    :ivar AggregateType:
8135
    :vartype AggregateType: NodeId
8136
    :ivar AggregateConfiguration:
8137
    :vartype AggregateConfiguration: AggregateConfiguration
8138
    '''
8139
    def __init__(self, binary=None):
8140
        if binary is not None:
8141
            self._binary_init(binary)
8142
            self._freeze = True
8143
            return
8144
        self.StartTime = datetime.now()
8145
        self.EndTime = datetime.now()
8146
        self.ProcessingInterval = 0
8147
        self.AggregateType = []
8148
        self.AggregateConfiguration = AggregateConfiguration()
8149
        self._freeze = True
8150
8151
    def to_binary(self):
8152
        packet = []
8153
        packet.append(pack_datetime(self.StartTime))
8154
        packet.append(pack_datetime(self.EndTime))
8155
        packet.append(uatype_Double.pack(self.ProcessingInterval))
8156
        packet.append(uatype_Int32.pack(len(self.AggregateType)))
8157
        for fieldname in self.AggregateType:
8158
            packet.append(fieldname.to_binary())
8159
        packet.append(self.AggregateConfiguration.to_binary())
8160
        return b''.join(packet)
8161
8162
    @staticmethod
8163
    def from_binary(data):
8164
        return ReadProcessedDetails(data)
8165
8166
    def _binary_init(self, data):
8167
        self.StartTime = unpack_datetime(data)
8168
        self.EndTime = unpack_datetime(data)
8169
        self.ProcessingInterval = uatype_Double.unpack(data.read(8))[0]
8170
        length = uatype_Int32.unpack(data.read(4))[0]
8171
        array = []
8172
        if length != -1:
8173
            for _ in range(0, length):
8174
                array.append(NodeId.from_binary(data))
8175
        self.AggregateType = array
8176
        self.AggregateConfiguration = AggregateConfiguration.from_binary(data)
8177
8178
    def __str__(self):
8179
        return 'ReadProcessedDetails(' + 'StartTime:' + str(self.StartTime) + ', ' + \
8180
               'EndTime:' + str(self.EndTime) + ', ' + \
8181
               'ProcessingInterval:' + str(self.ProcessingInterval) + ', ' + \
8182
               'AggregateType:' + str(self.AggregateType) + ', ' + \
8183
               'AggregateConfiguration:' + str(self.AggregateConfiguration) + ')'
8184
8185
    __repr__ = __str__
8186
8187
8188
class ReadAtTimeDetails(FrozenClass):
@@ 7307-7366 (lines=60) @@
7304
    __repr__ = __str__
7305
7306
7307
class QueryFirstParameters(FrozenClass):
7308
    '''
7309
    :ivar View:
7310
    :vartype View: ViewDescription
7311
    :ivar NodeTypes:
7312
    :vartype NodeTypes: NodeTypeDescription
7313
    :ivar Filter:
7314
    :vartype Filter: ContentFilter
7315
    :ivar MaxDataSetsToReturn:
7316
    :vartype MaxDataSetsToReturn: UInt32
7317
    :ivar MaxReferencesToReturn:
7318
    :vartype MaxReferencesToReturn: UInt32
7319
    '''
7320
    def __init__(self, binary=None):
7321
        if binary is not None:
7322
            self._binary_init(binary)
7323
            self._freeze = True
7324
            return
7325
        self.View = ViewDescription()
7326
        self.NodeTypes = []
7327
        self.Filter = ContentFilter()
7328
        self.MaxDataSetsToReturn = 0
7329
        self.MaxReferencesToReturn = 0
7330
        self._freeze = True
7331
7332
    def to_binary(self):
7333
        packet = []
7334
        packet.append(self.View.to_binary())
7335
        packet.append(uatype_Int32.pack(len(self.NodeTypes)))
7336
        for fieldname in self.NodeTypes:
7337
            packet.append(fieldname.to_binary())
7338
        packet.append(self.Filter.to_binary())
7339
        packet.append(uatype_UInt32.pack(self.MaxDataSetsToReturn))
7340
        packet.append(uatype_UInt32.pack(self.MaxReferencesToReturn))
7341
        return b''.join(packet)
7342
7343
    @staticmethod
7344
    def from_binary(data):
7345
        return QueryFirstParameters(data)
7346
7347
    def _binary_init(self, data):
7348
        self.View = ViewDescription.from_binary(data)
7349
        length = uatype_Int32.unpack(data.read(4))[0]
7350
        array = []
7351
        if length != -1:
7352
            for _ in range(0, length):
7353
                array.append(NodeTypeDescription.from_binary(data))
7354
        self.NodeTypes = array
7355
        self.Filter = ContentFilter.from_binary(data)
7356
        self.MaxDataSetsToReturn = uatype_UInt32.unpack(data.read(4))[0]
7357
        self.MaxReferencesToReturn = uatype_UInt32.unpack(data.read(4))[0]
7358
7359
    def __str__(self):
7360
        return 'QueryFirstParameters(' + 'View:' + str(self.View) + ', ' + \
7361
               'NodeTypes:' + str(self.NodeTypes) + ', ' + \
7362
               'Filter:' + str(self.Filter) + ', ' + \
7363
               'MaxDataSetsToReturn:' + str(self.MaxDataSetsToReturn) + ', ' + \
7364
               'MaxReferencesToReturn:' + str(self.MaxReferencesToReturn) + ')'
7365
7366
    __repr__ = __str__
7367
7368
7369
class QueryFirstRequest(FrozenClass):
@@ 8883-8936 (lines=54) @@
8880
    __repr__ = __str__
8881
8882
8883
class UpdateEventDetails(FrozenClass):
8884
    '''
8885
    :ivar NodeId:
8886
    :vartype NodeId: NodeId
8887
    :ivar PerformInsertReplace:
8888
    :vartype PerformInsertReplace: PerformUpdateType
8889
    :ivar Filter:
8890
    :vartype Filter: EventFilter
8891
    :ivar EventData:
8892
    :vartype EventData: HistoryEventFieldList
8893
    '''
8894
    def __init__(self, binary=None):
8895
        if binary is not None:
8896
            self._binary_init(binary)
8897
            self._freeze = True
8898
            return
8899
        self.NodeId = NodeId()
8900
        self.PerformInsertReplace = PerformUpdateType(0)
8901
        self.Filter = EventFilter()
8902
        self.EventData = []
8903
        self._freeze = True
8904
8905
    def to_binary(self):
8906
        packet = []
8907
        packet.append(self.NodeId.to_binary())
8908
        packet.append(uatype_UInt32.pack(self.PerformInsertReplace.value))
8909
        packet.append(self.Filter.to_binary())
8910
        packet.append(uatype_Int32.pack(len(self.EventData)))
8911
        for fieldname in self.EventData:
8912
            packet.append(fieldname.to_binary())
8913
        return b''.join(packet)
8914
8915
    @staticmethod
8916
    def from_binary(data):
8917
        return UpdateEventDetails(data)
8918
8919
    def _binary_init(self, data):
8920
        self.NodeId = NodeId.from_binary(data)
8921
        self.PerformInsertReplace = PerformUpdateType(uatype_UInt32.unpack(data.read(4))[0])
8922
        self.Filter = EventFilter.from_binary(data)
8923
        length = uatype_Int32.unpack(data.read(4))[0]
8924
        array = []
8925
        if length != -1:
8926
            for _ in range(0, length):
8927
                array.append(HistoryEventFieldList.from_binary(data))
8928
        self.EventData = array
8929
8930
    def __str__(self):
8931
        return 'UpdateEventDetails(' + 'NodeId:' + str(self.NodeId) + ', ' + \
8932
               'PerformInsertReplace:' + str(self.PerformInsertReplace) + ', ' + \
8933
               'Filter:' + str(self.Filter) + ', ' + \
8934
               'EventData:' + str(self.EventData) + ')'
8935
8936
    __repr__ = __str__
8937
8938
8939
class DeleteRawModifiedDetails(FrozenClass):
@@ 8397-8450 (lines=54) @@
8394
    __repr__ = __str__
8395
8396
8397
class HistoryReadParameters(FrozenClass):
8398
    '''
8399
    :ivar HistoryReadDetails:
8400
    :vartype HistoryReadDetails: ExtensionObject
8401
    :ivar TimestampsToReturn:
8402
    :vartype TimestampsToReturn: TimestampsToReturn
8403
    :ivar ReleaseContinuationPoints:
8404
    :vartype ReleaseContinuationPoints: Boolean
8405
    :ivar NodesToRead:
8406
    :vartype NodesToRead: HistoryReadValueId
8407
    '''
8408
    def __init__(self, binary=None):
8409
        if binary is not None:
8410
            self._binary_init(binary)
8411
            self._freeze = True
8412
            return
8413
        self.HistoryReadDetails = None
8414
        self.TimestampsToReturn = TimestampsToReturn(0)
8415
        self.ReleaseContinuationPoints = True
8416
        self.NodesToRead = []
8417
        self._freeze = True
8418
8419
    def to_binary(self):
8420
        packet = []
8421
        packet.append(extensionobject_to_binary(self.HistoryReadDetails))
8422
        packet.append(uatype_UInt32.pack(self.TimestampsToReturn.value))
8423
        packet.append(uatype_Boolean.pack(self.ReleaseContinuationPoints))
8424
        packet.append(uatype_Int32.pack(len(self.NodesToRead)))
8425
        for fieldname in self.NodesToRead:
8426
            packet.append(fieldname.to_binary())
8427
        return b''.join(packet)
8428
8429
    @staticmethod
8430
    def from_binary(data):
8431
        return HistoryReadParameters(data)
8432
8433
    def _binary_init(self, data):
8434
        self.HistoryReadDetails = extensionobject_from_binary(data)
8435
        self.TimestampsToReturn = TimestampsToReturn(uatype_UInt32.unpack(data.read(4))[0])
8436
        self.ReleaseContinuationPoints = uatype_Boolean.unpack(data.read(1))[0]
8437
        length = uatype_Int32.unpack(data.read(4))[0]
8438
        array = []
8439
        if length != -1:
8440
            for _ in range(0, length):
8441
                array.append(HistoryReadValueId.from_binary(data))
8442
        self.NodesToRead = array
8443
8444
    def __str__(self):
8445
        return 'HistoryReadParameters(' + 'HistoryReadDetails:' + str(self.HistoryReadDetails) + ', ' + \
8446
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
8447
               'ReleaseContinuationPoints:' + str(self.ReleaseContinuationPoints) + ', ' + \
8448
               'NodesToRead:' + str(self.NodesToRead) + ')'
8449
8450
    __repr__ = __str__
8451
8452
8453
class HistoryReadRequest(FrozenClass):
@@ 6831-6884 (lines=54) @@
6828
    __repr__ = __str__
6829
6830
6831
class NodeReference(FrozenClass):
6832
    '''
6833
    :ivar NodeId:
6834
    :vartype NodeId: NodeId
6835
    :ivar ReferenceTypeId:
6836
    :vartype ReferenceTypeId: NodeId
6837
    :ivar IsForward:
6838
    :vartype IsForward: Boolean
6839
    :ivar ReferencedNodeIds:
6840
    :vartype ReferencedNodeIds: NodeId
6841
    '''
6842
    def __init__(self, binary=None):
6843
        if binary is not None:
6844
            self._binary_init(binary)
6845
            self._freeze = True
6846
            return
6847
        self.NodeId = NodeId()
6848
        self.ReferenceTypeId = NodeId()
6849
        self.IsForward = True
6850
        self.ReferencedNodeIds = []
6851
        self._freeze = True
6852
6853
    def to_binary(self):
6854
        packet = []
6855
        packet.append(self.NodeId.to_binary())
6856
        packet.append(self.ReferenceTypeId.to_binary())
6857
        packet.append(uatype_Boolean.pack(self.IsForward))
6858
        packet.append(uatype_Int32.pack(len(self.ReferencedNodeIds)))
6859
        for fieldname in self.ReferencedNodeIds:
6860
            packet.append(fieldname.to_binary())
6861
        return b''.join(packet)
6862
6863
    @staticmethod
6864
    def from_binary(data):
6865
        return NodeReference(data)
6866
6867
    def _binary_init(self, data):
6868
        self.NodeId = NodeId.from_binary(data)
6869
        self.ReferenceTypeId = NodeId.from_binary(data)
6870
        self.IsForward = uatype_Boolean.unpack(data.read(1))[0]
6871
        length = uatype_Int32.unpack(data.read(4))[0]
6872
        array = []
6873
        if length != -1:
6874
            for _ in range(0, length):
6875
                array.append(NodeId.from_binary(data))
6876
        self.ReferencedNodeIds = array
6877
6878
    def __str__(self):
6879
        return 'NodeReference(' + 'NodeId:' + str(self.NodeId) + ', ' + \
6880
               'ReferenceTypeId:' + str(self.ReferenceTypeId) + ', ' + \
6881
               'IsForward:' + str(self.IsForward) + ', ' + \
6882
               'ReferencedNodeIds:' + str(self.ReferencedNodeIds) + ')'
6883
6884
    __repr__ = __str__
6885
6886
6887
class ContentFilterElement(FrozenClass):