Code Duplication    Length = 55-57 lines in 9 locations

opcua/ua/uaprotocol_auto.py 9 locations

@@ 6150-6206 (lines=57) @@
6147
    __repr__ = __str__
6148
6149
6150
class BrowseResult(FrozenClass):
6151
    '''
6152
    The result of a browse operation.
6153
6154
    :ivar StatusCode:
6155
    :vartype StatusCode: StatusCode
6156
    :ivar ContinuationPoint:
6157
    :vartype ContinuationPoint: ByteString
6158
    :ivar References:
6159
    :vartype References: ReferenceDescription
6160
    '''
6161
6162
    ua_types = {
6163
        'StatusCode': 'StatusCode',
6164
        'ContinuationPoint': 'ByteString',
6165
        'References': 'ReferenceDescription',
6166
               }
6167
6168
    def __init__(self, binary=None):
6169
        if binary is not None:
6170
            self._binary_init(binary)
6171
            self._freeze = True
6172
            return
6173
        self.StatusCode = StatusCode()
6174
        self.ContinuationPoint = None
6175
        self.References = []
6176
        self._freeze = True
6177
6178
    def to_binary(self):
6179
        packet = []
6180
        packet.append(self.StatusCode.to_binary())
6181
        packet.append(uabin.Primitives.ByteString.pack(self.ContinuationPoint))
6182
        packet.append(uabin.Primitives.Int32.pack(len(self.References)))
6183
        for fieldname in self.References:
6184
            packet.append(fieldname.to_binary())
6185
        return b''.join(packet)
6186
6187
    @staticmethod
6188
    def from_binary(data):
6189
        return BrowseResult(data)
6190
6191
    def _binary_init(self, data):
6192
        self.StatusCode = StatusCode.from_binary(data)
6193
        self.ContinuationPoint = uabin.Primitives.ByteString.unpack(data)
6194
        length = uabin.Primitives.Int32.unpack(data)
6195
        array = []
6196
        if length != -1:
6197
            for _ in range(0, length):
6198
                array.append(ReferenceDescription.from_binary(data))
6199
        self.References = array
6200
6201
    def __str__(self):
6202
        return 'BrowseResult(' + 'StatusCode:' + str(self.StatusCode) + ', ' + \
6203
               'ContinuationPoint:' + str(self.ContinuationPoint) + ', ' + \
6204
               'References:' + str(self.References) + ')'
6205
6206
    __repr__ = __str__
6207
6208
6209
class BrowseParameters(FrozenClass):
@@ 13167-13221 (lines=55) @@
13164
    __repr__ = __str__
13165
13166
13167
class NotificationMessage(FrozenClass):
13168
    '''
13169
    :ivar SequenceNumber:
13170
    :vartype SequenceNumber: UInt32
13171
    :ivar PublishTime:
13172
    :vartype PublishTime: DateTime
13173
    :ivar NotificationData:
13174
    :vartype NotificationData: ExtensionObject
13175
    '''
13176
13177
    ua_types = {
13178
        'SequenceNumber': 'UInt32',
13179
        'PublishTime': 'DateTime',
13180
        'NotificationData': 'ExtensionObject',
13181
               }
13182
13183
    def __init__(self, binary=None):
13184
        if binary is not None:
13185
            self._binary_init(binary)
13186
            self._freeze = True
13187
            return
13188
        self.SequenceNumber = 0
13189
        self.PublishTime = datetime.utcnow()
13190
        self.NotificationData = []
13191
        self._freeze = True
13192
13193
    def to_binary(self):
13194
        packet = []
13195
        packet.append(uabin.Primitives.UInt32.pack(self.SequenceNumber))
13196
        packet.append(uabin.Primitives.DateTime.pack(self.PublishTime))
13197
        packet.append(uabin.Primitives.Int32.pack(len(self.NotificationData)))
13198
        for fieldname in self.NotificationData:
13199
            packet.append(extensionobject_to_binary(fieldname))
13200
        return b''.join(packet)
13201
13202
    @staticmethod
13203
    def from_binary(data):
13204
        return NotificationMessage(data)
13205
13206
    def _binary_init(self, data):
13207
        self.SequenceNumber = uabin.Primitives.UInt32.unpack(data)
13208
        self.PublishTime = uabin.Primitives.DateTime.unpack(data)
13209
        length = uabin.Primitives.Int32.unpack(data)
13210
        array = []
13211
        if length != -1:
13212
            for _ in range(0, length):
13213
                array.append(extensionobject_from_binary(data))
13214
        self.NotificationData = array
13215
13216
    def __str__(self):
13217
        return 'NotificationMessage(' + 'SequenceNumber:' + str(self.SequenceNumber) + ', ' + \
13218
               'PublishTime:' + str(self.PublishTime) + ', ' + \
13219
               'NotificationData:' + str(self.NotificationData) + ')'
13220
13221
    __repr__ = __str__
13222
13223
13224
class NotificationData(FrozenClass):
@@ 11717-11771 (lines=55) @@
11714
    __repr__ = __str__
11715
11716
11717
class ModifyMonitoredItemsParameters(FrozenClass):
11718
    '''
11719
    :ivar SubscriptionId:
11720
    :vartype SubscriptionId: UInt32
11721
    :ivar TimestampsToReturn:
11722
    :vartype TimestampsToReturn: TimestampsToReturn
11723
    :ivar ItemsToModify:
11724
    :vartype ItemsToModify: MonitoredItemModifyRequest
11725
    '''
11726
11727
    ua_types = {
11728
        'SubscriptionId': 'UInt32',
11729
        'TimestampsToReturn': 'TimestampsToReturn',
11730
        'ItemsToModify': 'MonitoredItemModifyRequest',
11731
               }
11732
11733
    def __init__(self, binary=None):
11734
        if binary is not None:
11735
            self._binary_init(binary)
11736
            self._freeze = True
11737
            return
11738
        self.SubscriptionId = 0
11739
        self.TimestampsToReturn = TimestampsToReturn(0)
11740
        self.ItemsToModify = []
11741
        self._freeze = True
11742
11743
    def to_binary(self):
11744
        packet = []
11745
        packet.append(uabin.Primitives.UInt32.pack(self.SubscriptionId))
11746
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
11747
        packet.append(uabin.Primitives.Int32.pack(len(self.ItemsToModify)))
11748
        for fieldname in self.ItemsToModify:
11749
            packet.append(fieldname.to_binary())
11750
        return b''.join(packet)
11751
11752
    @staticmethod
11753
    def from_binary(data):
11754
        return ModifyMonitoredItemsParameters(data)
11755
11756
    def _binary_init(self, data):
11757
        self.SubscriptionId = uabin.Primitives.UInt32.unpack(data)
11758
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
11759
        length = uabin.Primitives.Int32.unpack(data)
11760
        array = []
11761
        if length != -1:
11762
            for _ in range(0, length):
11763
                array.append(MonitoredItemModifyRequest.from_binary(data))
11764
        self.ItemsToModify = array
11765
11766
    def __str__(self):
11767
        return 'ModifyMonitoredItemsParameters(' + 'SubscriptionId:' + str(self.SubscriptionId) + ', ' + \
11768
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
11769
               'ItemsToModify:' + str(self.ItemsToModify) + ')'
11770
11771
    __repr__ = __str__
11772
11773
11774
class ModifyMonitoredItemsRequest(FrozenClass):
@@ 11439-11493 (lines=55) @@
11436
    __repr__ = __str__
11437
11438
11439
class CreateMonitoredItemsParameters(FrozenClass):
11440
    '''
11441
    :ivar SubscriptionId:
11442
    :vartype SubscriptionId: UInt32
11443
    :ivar TimestampsToReturn:
11444
    :vartype TimestampsToReturn: TimestampsToReturn
11445
    :ivar ItemsToCreate:
11446
    :vartype ItemsToCreate: MonitoredItemCreateRequest
11447
    '''
11448
11449
    ua_types = {
11450
        'SubscriptionId': 'UInt32',
11451
        'TimestampsToReturn': 'TimestampsToReturn',
11452
        'ItemsToCreate': 'MonitoredItemCreateRequest',
11453
               }
11454
11455
    def __init__(self, binary=None):
11456
        if binary is not None:
11457
            self._binary_init(binary)
11458
            self._freeze = True
11459
            return
11460
        self.SubscriptionId = 0
11461
        self.TimestampsToReturn = TimestampsToReturn(0)
11462
        self.ItemsToCreate = []
11463
        self._freeze = True
11464
11465
    def to_binary(self):
11466
        packet = []
11467
        packet.append(uabin.Primitives.UInt32.pack(self.SubscriptionId))
11468
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
11469
        packet.append(uabin.Primitives.Int32.pack(len(self.ItemsToCreate)))
11470
        for fieldname in self.ItemsToCreate:
11471
            packet.append(fieldname.to_binary())
11472
        return b''.join(packet)
11473
11474
    @staticmethod
11475
    def from_binary(data):
11476
        return CreateMonitoredItemsParameters(data)
11477
11478
    def _binary_init(self, data):
11479
        self.SubscriptionId = uabin.Primitives.UInt32.unpack(data)
11480
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
11481
        length = uabin.Primitives.Int32.unpack(data)
11482
        array = []
11483
        if length != -1:
11484
            for _ in range(0, length):
11485
                array.append(MonitoredItemCreateRequest.from_binary(data))
11486
        self.ItemsToCreate = array
11487
11488
    def __str__(self):
11489
        return 'CreateMonitoredItemsParameters(' + 'SubscriptionId:' + str(self.SubscriptionId) + ', ' + \
11490
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
11491
               'ItemsToCreate:' + str(self.ItemsToCreate) + ')'
11492
11493
    __repr__ = __str__
11494
11495
11496
class CreateMonitoredItemsRequest(FrozenClass):
@@ 10069-10123 (lines=55) @@
10066
    __repr__ = __str__
10067
10068
10069
class UpdateStructureDataDetails(FrozenClass):
10070
    '''
10071
    :ivar NodeId:
10072
    :vartype NodeId: NodeId
10073
    :ivar PerformInsertReplace:
10074
    :vartype PerformInsertReplace: PerformUpdateType
10075
    :ivar UpdateValues:
10076
    :vartype UpdateValues: DataValue
10077
    '''
10078
10079
    ua_types = {
10080
        'NodeId': 'NodeId',
10081
        'PerformInsertReplace': 'PerformUpdateType',
10082
        'UpdateValues': 'DataValue',
10083
               }
10084
10085
    def __init__(self, binary=None):
10086
        if binary is not None:
10087
            self._binary_init(binary)
10088
            self._freeze = True
10089
            return
10090
        self.NodeId = NodeId()
10091
        self.PerformInsertReplace = PerformUpdateType(0)
10092
        self.UpdateValues = []
10093
        self._freeze = True
10094
10095
    def to_binary(self):
10096
        packet = []
10097
        packet.append(self.NodeId.to_binary())
10098
        packet.append(uabin.Primitives.UInt32.pack(self.PerformInsertReplace.value))
10099
        packet.append(uabin.Primitives.Int32.pack(len(self.UpdateValues)))
10100
        for fieldname in self.UpdateValues:
10101
            packet.append(fieldname.to_binary())
10102
        return b''.join(packet)
10103
10104
    @staticmethod
10105
    def from_binary(data):
10106
        return UpdateStructureDataDetails(data)
10107
10108
    def _binary_init(self, data):
10109
        self.NodeId = NodeId.from_binary(data)
10110
        self.PerformInsertReplace = PerformUpdateType(uabin.Primitives.UInt32.unpack(data))
10111
        length = uabin.Primitives.Int32.unpack(data)
10112
        array = []
10113
        if length != -1:
10114
            for _ in range(0, length):
10115
                array.append(DataValue.from_binary(data))
10116
        self.UpdateValues = array
10117
10118
    def __str__(self):
10119
        return 'UpdateStructureDataDetails(' + 'NodeId:' + str(self.NodeId) + ', ' + \
10120
               'PerformInsertReplace:' + str(self.PerformInsertReplace) + ', ' + \
10121
               'UpdateValues:' + str(self.UpdateValues) + ')'
10122
10123
    __repr__ = __str__
10124
10125
10126
class UpdateEventDetails(FrozenClass):
@@ 10012-10066 (lines=55) @@
10009
    __repr__ = __str__
10010
10011
10012
class UpdateDataDetails(FrozenClass):
10013
    '''
10014
    :ivar NodeId:
10015
    :vartype NodeId: NodeId
10016
    :ivar PerformInsertReplace:
10017
    :vartype PerformInsertReplace: PerformUpdateType
10018
    :ivar UpdateValues:
10019
    :vartype UpdateValues: DataValue
10020
    '''
10021
10022
    ua_types = {
10023
        'NodeId': 'NodeId',
10024
        'PerformInsertReplace': 'PerformUpdateType',
10025
        'UpdateValues': 'DataValue',
10026
               }
10027
10028
    def __init__(self, binary=None):
10029
        if binary is not None:
10030
            self._binary_init(binary)
10031
            self._freeze = True
10032
            return
10033
        self.NodeId = NodeId()
10034
        self.PerformInsertReplace = PerformUpdateType(0)
10035
        self.UpdateValues = []
10036
        self._freeze = True
10037
10038
    def to_binary(self):
10039
        packet = []
10040
        packet.append(self.NodeId.to_binary())
10041
        packet.append(uabin.Primitives.UInt32.pack(self.PerformInsertReplace.value))
10042
        packet.append(uabin.Primitives.Int32.pack(len(self.UpdateValues)))
10043
        for fieldname in self.UpdateValues:
10044
            packet.append(fieldname.to_binary())
10045
        return b''.join(packet)
10046
10047
    @staticmethod
10048
    def from_binary(data):
10049
        return UpdateDataDetails(data)
10050
10051
    def _binary_init(self, data):
10052
        self.NodeId = NodeId.from_binary(data)
10053
        self.PerformInsertReplace = PerformUpdateType(uabin.Primitives.UInt32.unpack(data))
10054
        length = uabin.Primitives.Int32.unpack(data)
10055
        array = []
10056
        if length != -1:
10057
            for _ in range(0, length):
10058
                array.append(DataValue.from_binary(data))
10059
        self.UpdateValues = array
10060
10061
    def __str__(self):
10062
        return 'UpdateDataDetails(' + 'NodeId:' + str(self.NodeId) + ', ' + \
10063
               'PerformInsertReplace:' + str(self.PerformInsertReplace) + ', ' + \
10064
               'UpdateValues:' + str(self.UpdateValues) + ')'
10065
10066
    __repr__ = __str__
10067
10068
10069
class UpdateStructureDataDetails(FrozenClass):
@@ 8824-8878 (lines=55) @@
8821
    __repr__ = __str__
8822
8823
8824
class ReadParameters(FrozenClass):
8825
    '''
8826
    :ivar MaxAge:
8827
    :vartype MaxAge: Double
8828
    :ivar TimestampsToReturn:
8829
    :vartype TimestampsToReturn: TimestampsToReturn
8830
    :ivar NodesToRead:
8831
    :vartype NodesToRead: ReadValueId
8832
    '''
8833
8834
    ua_types = {
8835
        'MaxAge': 'Double',
8836
        'TimestampsToReturn': 'TimestampsToReturn',
8837
        'NodesToRead': 'ReadValueId',
8838
               }
8839
8840
    def __init__(self, binary=None):
8841
        if binary is not None:
8842
            self._binary_init(binary)
8843
            self._freeze = True
8844
            return
8845
        self.MaxAge = 0
8846
        self.TimestampsToReturn = TimestampsToReturn(0)
8847
        self.NodesToRead = []
8848
        self._freeze = True
8849
8850
    def to_binary(self):
8851
        packet = []
8852
        packet.append(uabin.Primitives.Double.pack(self.MaxAge))
8853
        packet.append(uabin.Primitives.UInt32.pack(self.TimestampsToReturn.value))
8854
        packet.append(uabin.Primitives.Int32.pack(len(self.NodesToRead)))
8855
        for fieldname in self.NodesToRead:
8856
            packet.append(fieldname.to_binary())
8857
        return b''.join(packet)
8858
8859
    @staticmethod
8860
    def from_binary(data):
8861
        return ReadParameters(data)
8862
8863
    def _binary_init(self, data):
8864
        self.MaxAge = uabin.Primitives.Double.unpack(data)
8865
        self.TimestampsToReturn = TimestampsToReturn(uabin.Primitives.UInt32.unpack(data))
8866
        length = uabin.Primitives.Int32.unpack(data)
8867
        array = []
8868
        if length != -1:
8869
            for _ in range(0, length):
8870
                array.append(ReadValueId.from_binary(data))
8871
        self.NodesToRead = array
8872
8873
    def __str__(self):
8874
        return 'ReadParameters(' + 'MaxAge:' + str(self.MaxAge) + ', ' + \
8875
               'TimestampsToReturn:' + str(self.TimestampsToReturn) + ', ' + \
8876
               'NodesToRead:' + str(self.NodesToRead) + ')'
8877
8878
    __repr__ = __str__
8879
8880
8881
class ReadRequest(FrozenClass):
@@ 7662-7716 (lines=55) @@
7659
    __repr__ = __str__
7660
7661
7662
class NodeTypeDescription(FrozenClass):
7663
    '''
7664
    :ivar TypeDefinitionNode:
7665
    :vartype TypeDefinitionNode: ExpandedNodeId
7666
    :ivar IncludeSubTypes:
7667
    :vartype IncludeSubTypes: Boolean
7668
    :ivar DataToReturn:
7669
    :vartype DataToReturn: QueryDataDescription
7670
    '''
7671
7672
    ua_types = {
7673
        'TypeDefinitionNode': 'ExpandedNodeId',
7674
        'IncludeSubTypes': 'Boolean',
7675
        'DataToReturn': 'QueryDataDescription',
7676
               }
7677
7678
    def __init__(self, binary=None):
7679
        if binary is not None:
7680
            self._binary_init(binary)
7681
            self._freeze = True
7682
            return
7683
        self.TypeDefinitionNode = ExpandedNodeId()
7684
        self.IncludeSubTypes = True
7685
        self.DataToReturn = []
7686
        self._freeze = True
7687
7688
    def to_binary(self):
7689
        packet = []
7690
        packet.append(self.TypeDefinitionNode.to_binary())
7691
        packet.append(uabin.Primitives.Boolean.pack(self.IncludeSubTypes))
7692
        packet.append(uabin.Primitives.Int32.pack(len(self.DataToReturn)))
7693
        for fieldname in self.DataToReturn:
7694
            packet.append(fieldname.to_binary())
7695
        return b''.join(packet)
7696
7697
    @staticmethod
7698
    def from_binary(data):
7699
        return NodeTypeDescription(data)
7700
7701
    def _binary_init(self, data):
7702
        self.TypeDefinitionNode = ExpandedNodeId.from_binary(data)
7703
        self.IncludeSubTypes = uabin.Primitives.Boolean.unpack(data)
7704
        length = uabin.Primitives.Int32.unpack(data)
7705
        array = []
7706
        if length != -1:
7707
            for _ in range(0, length):
7708
                array.append(QueryDataDescription.from_binary(data))
7709
        self.DataToReturn = array
7710
7711
    def __str__(self):
7712
        return 'NodeTypeDescription(' + 'TypeDefinitionNode:' + str(self.TypeDefinitionNode) + ', ' + \
7713
               'IncludeSubTypes:' + str(self.IncludeSubTypes) + ', ' + \
7714
               'DataToReturn:' + str(self.DataToReturn) + ')'
7715
7716
    __repr__ = __str__
7717
7718
7719
class QueryDataSet(FrozenClass):
@@ 6209-6263 (lines=55) @@
6206
    __repr__ = __str__
6207
6208
6209
class BrowseParameters(FrozenClass):
6210
    '''
6211
    :ivar View:
6212
    :vartype View: ViewDescription
6213
    :ivar RequestedMaxReferencesPerNode:
6214
    :vartype RequestedMaxReferencesPerNode: UInt32
6215
    :ivar NodesToBrowse:
6216
    :vartype NodesToBrowse: BrowseDescription
6217
    '''
6218
6219
    ua_types = {
6220
        'View': 'ViewDescription',
6221
        'RequestedMaxReferencesPerNode': 'UInt32',
6222
        'NodesToBrowse': 'BrowseDescription',
6223
               }
6224
6225
    def __init__(self, binary=None):
6226
        if binary is not None:
6227
            self._binary_init(binary)
6228
            self._freeze = True
6229
            return
6230
        self.View = ViewDescription()
6231
        self.RequestedMaxReferencesPerNode = 0
6232
        self.NodesToBrowse = []
6233
        self._freeze = True
6234
6235
    def to_binary(self):
6236
        packet = []
6237
        packet.append(self.View.to_binary())
6238
        packet.append(uabin.Primitives.UInt32.pack(self.RequestedMaxReferencesPerNode))
6239
        packet.append(uabin.Primitives.Int32.pack(len(self.NodesToBrowse)))
6240
        for fieldname in self.NodesToBrowse:
6241
            packet.append(fieldname.to_binary())
6242
        return b''.join(packet)
6243
6244
    @staticmethod
6245
    def from_binary(data):
6246
        return BrowseParameters(data)
6247
6248
    def _binary_init(self, data):
6249
        self.View = ViewDescription.from_binary(data)
6250
        self.RequestedMaxReferencesPerNode = uabin.Primitives.UInt32.unpack(data)
6251
        length = uabin.Primitives.Int32.unpack(data)
6252
        array = []
6253
        if length != -1:
6254
            for _ in range(0, length):
6255
                array.append(BrowseDescription.from_binary(data))
6256
        self.NodesToBrowse = array
6257
6258
    def __str__(self):
6259
        return 'BrowseParameters(' + 'View:' + str(self.View) + ', ' + \
6260
               'RequestedMaxReferencesPerNode:' + str(self.RequestedMaxReferencesPerNode) + ', ' + \
6261
               'NodesToBrowse:' + str(self.NodesToBrowse) + ')'
6262
6263
    __repr__ = __str__
6264
6265
6266
class BrowseRequest(FrozenClass):