async def read_attributes(self, nodeids, attr): self.logger.info("read_attributes of several nodes") request = ua.ReadRequest() for nodeid in nodeids: rv = ua.ReadValueId() rv.NodeId = nodeid rv.AttributeId = attr request.Parameters.NodesToRead.append(rv) data = await self.protocol.send_request(request) response = struct_from_binary(ua.ReadResponse, data) response.ResponseHeader.ServiceResult.check() return response.Results
async def read_attribute(self, attr): """ Read one attribute of a node result code from server is checked and an exception is raised in case of error """ rv = ua.ReadValueId() rv.NodeId = self.nodeid rv.AttributeId = attr params = ua.ReadParameters() params.NodesToRead.append(rv) result = await self.server.read(params) result[0].StatusCode.check() return result[0]
async def read_attributes(self, attrs): """ Read several attributes of a node list of DataValue is returned """ params = ua.ReadParameters() for attr in attrs: rv = ua.ReadValueId() rv.NodeId = self.nodeid rv.AttributeId = attr params.NodesToRead.append(rv) results = await self.server.read(params) return results
async def read_attribute(self, attr, indexrange=None): """ Read one attribute of a node attributeid is a member of ua.AttributeIds indexrange is a NumericRange (a string; e.g. "1" or "1:3". result code from server is checked and an exception is raised in case of error """ rv = ua.ReadValueId() rv.NodeId = self.nodeid rv.AttributeId = attr rv.IndexRange = indexrange params = ua.ReadParameters() params.NodesToRead.append(rv) result = await self.server.read(params) result[0].StatusCode.check() return result[0]
def _make_monitored_item_request(self, node: Node, attr, mfilter, queuesize) -> ua.MonitoredItemCreateRequest: rv = ua.ReadValueId() rv.NodeId = node.nodeid rv.AttributeId = attr # rv.IndexRange //We leave it null, then the entire array is returned mparams = ua.MonitoringParameters() self._client_handle += 1 mparams.ClientHandle = self._client_handle mparams.SamplingInterval = self.parameters.RequestedPublishingInterval mparams.QueueSize = queuesize mparams.DiscardOldest = True if mfilter: mparams.Filter = mfilter mir = ua.MonitoredItemCreateRequest() mir.ItemToMonitor = rv mir.MonitoringMode = ua.MonitoringMode.Reporting mir.RequestedParameters = mparams return mir