@@ 255-274 (lines=20) @@ | ||
252 | ltext = ua.LocalizedText() |
|
253 | for name, val in obj.value: |
|
254 | if name == "Text": |
|
255 | ltext.Text = val.encode("utf-8") |
|
256 | else: |
|
257 | self.logger.warning("While parsing localizedText value, unkown element: %s with val: %s", name, val) |
|
258 | return ua.Variant(ltext, ua.VariantType.LocalizedText) |
|
259 | elif obj.valuetype == 'NodeId': |
|
260 | return ua.Variant(ua.NodeId.from_string(obj.value)) |
|
261 | else: |
|
262 | return ua.Variant(obj.value, getattr(ua.VariantType, obj.valuetype)) |
|
263 | ||
264 | def add_variable_type(self, obj): |
|
265 | node = self._get_node(obj) |
|
266 | attrs = ua.VariableTypeAttributes() |
|
267 | if obj.desc: |
|
268 | attrs.Description = ua.LocalizedText(obj.desc) |
|
269 | attrs.DisplayName = ua.LocalizedText(obj.displayname) |
|
270 | attrs.DataType = self.to_nodeid(obj.datatype) |
|
271 | if obj.value and len(obj.value) == 1: |
|
272 | attrs.Value = obj.value[0] |
|
273 | if obj.rank: |
|
274 | attrs.ValueRank = obj.rank |
|
275 | if obj.abstract: |
|
276 | attrs.IsAbstract = obj.abstract |
|
277 | if obj.dimensions: |
|
@@ 276-294 (lines=19) @@ | ||
273 | if obj.rank: |
|
274 | attrs.ValueRank = obj.rank |
|
275 | if obj.abstract: |
|
276 | attrs.IsAbstract = obj.abstract |
|
277 | if obj.dimensions: |
|
278 | attrs.ArrayDimensions = obj.dimensions |
|
279 | node.NodeAttributes = attrs |
|
280 | res = self.server.iserver.isession.add_nodes([node]) |
|
281 | self._add_refs(obj) |
|
282 | res[0].StatusCode.check() |
|
283 | return res[0].AddedNodeId |
|
284 | ||
285 | def add_method(self, obj): |
|
286 | node = self._get_node(obj) |
|
287 | attrs = ua.MethodAttributes() |
|
288 | if obj.desc: |
|
289 | attrs.Description = ua.LocalizedText(obj.desc) |
|
290 | attrs.DisplayName = ua.LocalizedText(obj.displayname) |
|
291 | if obj.accesslevel: |
|
292 | attrs.AccessLevel = obj.accesslevel |
|
293 | if obj.useraccesslevel: |
|
294 | attrs.UserAccessLevel = obj.useraccesslevel |
|
295 | if obj.minsample: |
|
296 | attrs.MinimumSamplingInterval = obj.minsample |
|
297 | if obj.dimensions: |