Code Duplication    Length = 54-60 lines in 3 locations

opcua/ua/uaprotocol_auto.py 3 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):