Code Duplication    Length = 54-60 lines in 5 locations

opcua/ua/uaprotocol_auto.py 5 locations

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