MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / read

Method read

opcua/client/ua_client.py:343–361  ·  view source on GitHub ↗
(self, parameters)

Source from the content-addressed store, hash-verified

341 return response.Parameters.Results
342
343 def read(self, parameters):
344 self.logger.info("read")
345 request = ua.ReadRequest()
346 request.Parameters = parameters
347 data = self._uasocket.send_request(request)
348 response = struct_from_binary(ua.ReadResponse, data)
349 self.logger.debug(response)
350 response.ResponseHeader.ServiceResult.check()
351 # cast to Enum attributes that need to
352 for idx, rv in enumerate(parameters.NodesToRead):
353 if rv.AttributeId == ua.AttributeIds.NodeClass:
354 dv = response.Results[idx]
355 if dv.StatusCode.is_good():
356 dv.Value.Value = ua.NodeClass(dv.Value.Value)
357 elif rv.AttributeId == ua.AttributeIds.ValueRank:
358 dv = response.Results[idx]
359 if dv.StatusCode.is_good() and dv.Value.Value in (-3, -2, -1, 0, 1, 2, 3, 4):
360 dv.Value.Value = ua.ValueRank(dv.Value.Value)
361 return response.Results
362
363 def write(self, params):
364 self.logger.info("read")

Callers

nothing calls this directly

Calls 4

struct_from_binaryFunction · 0.90
send_requestMethod · 0.80
checkMethod · 0.80
is_goodMethod · 0.80

Tested by

no test coverage detected