Code Duplication    Length = 51-51 lines in 7 locations

opcua/ua/uaprotocol_auto.py 7 locations

@@ 12518-12568 (lines=51) @@
12515
    __repr__ = __str__
12516
12517
12518
class NotificationMessage(FrozenClass):
12519
    '''
12520
    :ivar SequenceNumber:
12521
    :vartype SequenceNumber: UInt32
12522
    :ivar PublishTime:
12523
    :vartype PublishTime: DateTime
12524
    :ivar NotificationData:
12525
    :vartype NotificationData: ExtensionObject
12526
    '''
12527
12528
    ua_types = [
12529
12530
        ('SequenceNumber', 'UInt32'),
12531
        ('PublishTime', 'DateTime'),
12532
        ('NotificationData', 'ListOfExtensionObject'),
12533
               ]
12534
12535
    def __init__(self):
12536
        self.SequenceNumber = 0
12537
        self.PublishTime = datetime.utcnow()
12538
        self.NotificationData = []
12539
        self._freeze = True
12540
12541
    def to_binary(self):
12542
        packet = []
12543
        packet.append(uabin.Primitives.UInt32.pack(self.SequenceNumber))
12544
        packet.append(uabin.Primitives.DateTime.pack(self.PublishTime))
12545
        packet.append(uabin.Primitives.Int32.pack(len(self.NotificationData)))
12546
        for fieldname in self.NotificationData:
12547
            packet.append(extensionobject_to_binary(fieldname))
12548
        return b''.join(packet)
12549
12550
    @staticmethod
12551
    def from_binary(data):
12552
        obj = NotificationMessage()
12553
        self.SequenceNumber = uabin.Primitives.UInt32.unpack(data)
12554
        self.PublishTime = uabin.Primitives.DateTime.unpack(data)
12555
        length = uabin.Primitives.Int32.unpack(data)
12556
        array = []
12557
        if length != -1:
12558
            for _ in range(0, length):
12559
                array.append(extensionobject_from_binary(data))
12560
        obj.NotificationData = array
12561
        return obj
12562
12563
    def __str__(self):
12564
        return 'NotificationMessage(' + 'SequenceNumber:' + str(self.SequenceNumber) + ', ' + \
12565
               'PublishTime:' + str(self.PublishTime) + ', ' + \
12566
               'NotificationData:' + str(self.NotificationData) + ')'
12567
12568
    __repr__ = __str__
12569
12570
12571
class NotificationData(FrozenClass):
@@ 11172-11222 (lines=51) @@
11169
    __repr__ = __str__
11170
11171
11172
class ModifyMonitoredItemsParameters(FrozenClass):
11173
    '''
11174
    :ivar SubscriptionId:
11175
    :vartype SubscriptionId: UInt32
11176
    :ivar TimestampsToReturn:
11177
    :vartype TimestampsToReturn: TimestampsToReturn
11178
    :ivar ItemsToModify:
11179
    :vartype ItemsToModify: MonitoredItemModifyRequest
11180
    '''
11181
11182
    ua_types = [
11183
11184
        ('SubscriptionId', 'UInt32'),
11185
        ('TimestampsToReturn', 'TimestampsToReturn'),
11186
        ('ItemsToModify', 'ListOfMonitoredItemModifyRequest'),
11187
               ]
11188
11189
    def __init__(self):
11190
        self.SubscriptionId = 0
11191
        self.TimestampsToReturn = TimestampsToReturn(0)
11192
        self.ItemsToModify = []
11193
        self._freeze = True
11194
11195
    def to_binary(self):
11196
        packet = []
11197
        packet.append(uabin.Primitives.UInt32.pack(self.SubscriptionId))
11198
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
11199
        packet.append(uabin.Primitives.Int32.pack(len(self.ItemsToModify)))
11200
        for fieldname in self.ItemsToModify:
11201
            packet.append(fieldname.to_binary())
11202
        return b''.join(packet)
11203
11204
    @staticmethod
11205
    def from_binary(data):
11206
        obj = ModifyMonitoredItemsParameters()
11207
        self.SubscriptionId = uabin.Primitives.UInt32.unpack(data)
11208
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
11209
        length = uabin.Primitives.Int32.unpack(data)
11210
        array = []
11211
        if length != -1:
11212
            for _ in range(0, length):
11213
                array.append(MonitoredItemModifyRequest.from_binary(data))
11214
        obj.ItemsToModify = array
11215
        return obj
11216
11217
    def __str__(self):
11218
        return 'ModifyMonitoredItemsParameters(' + 'SubscriptionId:' + str(self.SubscriptionId) + ', ' + \
11219
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
11220
               'ItemsToModify:' + str(self.ItemsToModify) + ')'
11221
11222
    __repr__ = __str__
11223
11224
11225
class ModifyMonitoredItemsRequest(FrozenClass):
@@ 10914-10964 (lines=51) @@
10911
    __repr__ = __str__
10912
10913
10914
class CreateMonitoredItemsParameters(FrozenClass):
10915
    '''
10916
    :ivar SubscriptionId:
10917
    :vartype SubscriptionId: UInt32
10918
    :ivar TimestampsToReturn:
10919
    :vartype TimestampsToReturn: TimestampsToReturn
10920
    :ivar ItemsToCreate:
10921
    :vartype ItemsToCreate: MonitoredItemCreateRequest
10922
    '''
10923
10924
    ua_types = [
10925
10926
        ('SubscriptionId', 'UInt32'),
10927
        ('TimestampsToReturn', 'TimestampsToReturn'),
10928
        ('ItemsToCreate', 'ListOfMonitoredItemCreateRequest'),
10929
               ]
10930
10931
    def __init__(self):
10932
        self.SubscriptionId = 0
10933
        self.TimestampsToReturn = TimestampsToReturn(0)
10934
        self.ItemsToCreate = []
10935
        self._freeze = True
10936
10937
    def to_binary(self):
10938
        packet = []
10939
        packet.append(uabin.Primitives.UInt32.pack(self.SubscriptionId))
10940
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
10941
        packet.append(uabin.Primitives.Int32.pack(len(self.ItemsToCreate)))
10942
        for fieldname in self.ItemsToCreate:
10943
            packet.append(fieldname.to_binary())
10944
        return b''.join(packet)
10945
10946
    @staticmethod
10947
    def from_binary(data):
10948
        obj = CreateMonitoredItemsParameters()
10949
        self.SubscriptionId = uabin.Primitives.UInt32.unpack(data)
10950
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
10951
        length = uabin.Primitives.Int32.unpack(data)
10952
        array = []
10953
        if length != -1:
10954
            for _ in range(0, length):
10955
                array.append(MonitoredItemCreateRequest.from_binary(data))
10956
        obj.ItemsToCreate = array
10957
        return obj
10958
10959
    def __str__(self):
10960
        return 'CreateMonitoredItemsParameters(' + 'SubscriptionId:' + str(self.SubscriptionId) + ', ' + \
10961
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
10962
               'ItemsToCreate:' + str(self.ItemsToCreate) + ')'
10963
10964
    __repr__ = __str__
10965
10966
10967
class CreateMonitoredItemsRequest(FrozenClass):
@@ 9646-9696 (lines=51) @@
9643
    __repr__ = __str__
9644
9645
9646
class UpdateStructureDataDetails(FrozenClass):
9647
    '''
9648
    :ivar NodeId:
9649
    :vartype NodeId: NodeId
9650
    :ivar PerformInsertReplace:
9651
    :vartype PerformInsertReplace: PerformUpdateType
9652
    :ivar UpdateValues:
9653
    :vartype UpdateValues: DataValue
9654
    '''
9655
9656
    ua_types = [
9657
9658
        ('NodeId', 'NodeId'),
9659
        ('PerformInsertReplace', 'PerformUpdateType'),
9660
        ('UpdateValues', 'ListOfDataValue'),
9661
               ]
9662
9663
    def __init__(self):
9664
        self.NodeId = NodeId()
9665
        self.PerformInsertReplace = PerformUpdateType(0)
9666
        self.UpdateValues = []
9667
        self._freeze = True
9668
9669
    def to_binary(self):
9670
        packet = []
9671
        packet.append(self.NodeId.to_binary())
9672
        packet.append(uabin.Primitives.UInt32.pack(self.PerformInsertReplace.value))
9673
        packet.append(uabin.Primitives.Int32.pack(len(self.UpdateValues)))
9674
        for fieldname in self.UpdateValues:
9675
            packet.append(fieldname.to_binary())
9676
        return b''.join(packet)
9677
9678
    @staticmethod
9679
    def from_binary(data):
9680
        obj = UpdateStructureDataDetails()
9681
        obj.NodeId = NodeId.from_binary(data)
9682
        self.PerformInsertReplace = PerformUpdateType(uabin.Primitives.UInt32.unpack(data))
9683
        length = uabin.Primitives.Int32.unpack(data)
9684
        array = []
9685
        if length != -1:
9686
            for _ in range(0, length):
9687
                array.append(DataValue.from_binary(data))
9688
        obj.UpdateValues = array
9689
        return obj
9690
9691
    def __str__(self):
9692
        return 'UpdateStructureDataDetails(' + 'NodeId:' + str(self.NodeId) + ', ' + \
9693
               'PerformInsertReplace:' + str(self.PerformInsertReplace) + ', ' + \
9694
               'UpdateValues:' + str(self.UpdateValues) + ')'
9695
9696
    __repr__ = __str__
9697
9698
9699
class UpdateEventDetails(FrozenClass):
@@ 9593-9643 (lines=51) @@
9590
    __repr__ = __str__
9591
9592
9593
class UpdateDataDetails(FrozenClass):
9594
    '''
9595
    :ivar NodeId:
9596
    :vartype NodeId: NodeId
9597
    :ivar PerformInsertReplace:
9598
    :vartype PerformInsertReplace: PerformUpdateType
9599
    :ivar UpdateValues:
9600
    :vartype UpdateValues: DataValue
9601
    '''
9602
9603
    ua_types = [
9604
9605
        ('NodeId', 'NodeId'),
9606
        ('PerformInsertReplace', 'PerformUpdateType'),
9607
        ('UpdateValues', 'ListOfDataValue'),
9608
               ]
9609
9610
    def __init__(self):
9611
        self.NodeId = NodeId()
9612
        self.PerformInsertReplace = PerformUpdateType(0)
9613
        self.UpdateValues = []
9614
        self._freeze = True
9615
9616
    def to_binary(self):
9617
        packet = []
9618
        packet.append(self.NodeId.to_binary())
9619
        packet.append(uabin.Primitives.UInt32.pack(self.PerformInsertReplace.value))
9620
        packet.append(uabin.Primitives.Int32.pack(len(self.UpdateValues)))
9621
        for fieldname in self.UpdateValues:
9622
            packet.append(fieldname.to_binary())
9623
        return b''.join(packet)
9624
9625
    @staticmethod
9626
    def from_binary(data):
9627
        obj = UpdateDataDetails()
9628
        obj.NodeId = NodeId.from_binary(data)
9629
        self.PerformInsertReplace = PerformUpdateType(uabin.Primitives.UInt32.unpack(data))
9630
        length = uabin.Primitives.Int32.unpack(data)
9631
        array = []
9632
        if length != -1:
9633
            for _ in range(0, length):
9634
                array.append(DataValue.from_binary(data))
9635
        obj.UpdateValues = array
9636
        return obj
9637
9638
    def __str__(self):
9639
        return 'UpdateDataDetails(' + 'NodeId:' + str(self.NodeId) + ', ' + \
9640
               'PerformInsertReplace:' + str(self.PerformInsertReplace) + ', ' + \
9641
               'UpdateValues:' + str(self.UpdateValues) + ')'
9642
9643
    __repr__ = __str__
9644
9645
9646
class UpdateStructureDataDetails(FrozenClass):
@@ 8494-8544 (lines=51) @@
8491
    __repr__ = __str__
8492
8493
8494
class ReadParameters(FrozenClass):
8495
    '''
8496
    :ivar MaxAge:
8497
    :vartype MaxAge: Double
8498
    :ivar TimestampsToReturn:
8499
    :vartype TimestampsToReturn: TimestampsToReturn
8500
    :ivar NodesToRead:
8501
    :vartype NodesToRead: ReadValueId
8502
    '''
8503
8504
    ua_types = [
8505
8506
        ('MaxAge', 'Double'),
8507
        ('TimestampsToReturn', 'TimestampsToReturn'),
8508
        ('NodesToRead', 'ListOfReadValueId'),
8509
               ]
8510
8511
    def __init__(self):
8512
        self.MaxAge = 0
8513
        self.TimestampsToReturn = TimestampsToReturn(0)
8514
        self.NodesToRead = []
8515
        self._freeze = True
8516
8517
    def to_binary(self):
8518
        packet = []
8519
        packet.append(uabin.Primitives.Double.pack(self.MaxAge))
8520
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
8521
        packet.append(uabin.Primitives.Int32.pack(len(self.NodesToRead)))
8522
        for fieldname in self.NodesToRead:
8523
            packet.append(fieldname.to_binary())
8524
        return b''.join(packet)
8525
8526
    @staticmethod
8527
    def from_binary(data):
8528
        obj = ReadParameters()
8529
        self.MaxAge = uabin.Primitives.Double.unpack(data)
8530
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
8531
        length = uabin.Primitives.Int32.unpack(data)
8532
        array = []
8533
        if length != -1:
8534
            for _ in range(0, length):
8535
                array.append(ReadValueId.from_binary(data))
8536
        obj.NodesToRead = array
8537
        return obj
8538
8539
    def __str__(self):
8540
        return 'ReadParameters(' + 'MaxAge:' + str(self.MaxAge) + ', ' + \
8541
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
8542
               'NodesToRead:' + str(self.NodesToRead) + ')'
8543
8544
    __repr__ = __str__
8545
8546
8547
class ReadRequest(FrozenClass):
@@ 6067-6117 (lines=51) @@
6064
    __repr__ = __str__
6065
6066
6067
class BrowseParameters(FrozenClass):
6068
    '''
6069
    :ivar View:
6070
    :vartype View: ViewDescription
6071
    :ivar RequestedMaxReferencesPerNode:
6072
    :vartype RequestedMaxReferencesPerNode: UInt32
6073
    :ivar NodesToBrowse:
6074
    :vartype NodesToBrowse: BrowseDescription
6075
    '''
6076
6077
    ua_types = [
6078
6079
        ('View', 'ViewDescription'),
6080
        ('RequestedMaxReferencesPerNode', 'UInt32'),
6081
        ('NodesToBrowse', 'ListOfBrowseDescription'),
6082
               ]
6083
6084
    def __init__(self):
6085
        self.View = ViewDescription()
6086
        self.RequestedMaxReferencesPerNode = 0
6087
        self.NodesToBrowse = []
6088
        self._freeze = True
6089
6090
    def to_binary(self):
6091
        packet = []
6092
        packet.append(self.View.to_binary())
6093
        packet.append(uabin.Primitives.UInt32.pack(self.RequestedMaxReferencesPerNode))
6094
        packet.append(uabin.Primitives.Int32.pack(len(self.NodesToBrowse)))
6095
        for fieldname in self.NodesToBrowse:
6096
            packet.append(fieldname.to_binary())
6097
        return b''.join(packet)
6098
6099
    @staticmethod
6100
    def from_binary(data):
6101
        obj = BrowseParameters()
6102
        obj.View = ViewDescription.from_binary(data)
6103
        self.RequestedMaxReferencesPerNode = uabin.Primitives.UInt32.unpack(data)
6104
        length = uabin.Primitives.Int32.unpack(data)
6105
        array = []
6106
        if length != -1:
6107
            for _ in range(0, length):
6108
                array.append(BrowseDescription.from_binary(data))
6109
        obj.NodesToBrowse = array
6110
        return obj
6111
6112
    def __str__(self):
6113
        return 'BrowseParameters(' + 'View:' + str(self.View) + ', ' + \
6114
               'RequestedMaxReferencesPerNode:' + str(self.RequestedMaxReferencesPerNode) + ', ' + \
6115
               'NodesToBrowse:' + str(self.NodesToBrowse) + ')'
6116
6117
    __repr__ = __str__
6118
6119
6120
class BrowseRequest(FrozenClass):