Device implementation, managing system.opc.read request

Ignition 8.1,

In a module driver implementing the Device interface**,** I’m looking for the method for managing system.opc.read responses.

With AbstractTagDriver, we just have to override this method:

@Override
// readItems(java.util.List<? extends ReadItem> items)
// Asynchronous read call for a list of items.
public void readItems(List<? extends ReadItem> items){
system.opc.readValue(opcServer, itemPath)

return the value from the opcua server, but we probably want to process a synchronous request to the device ?

I suppose we need to add a filter to the node, but it will concern all read operation ?

  // an AttributeFilter is used so that when this node is asked for its value, it will call out to the
  // simulator
  node.getFilterChain().addLast(AttributeFilters.getValue(
      getAttributeContext ->
          simulator.getTrackedValue(formattedName))
  );

If you're using a ManagedAddressSpace like the SDK example does then adding a filter is the way to intercept attributes reads of UaNode instances.

If you need to do something smart, group the reads, reach out to a device, etc... then you want to override AddressSpace::read with your own logic for servicing a read request.

2 Likes

can we have long-lasting operations (few seconds) in AddressSpace::read or AddressSpace::write method ?
or it will block the caller and we have to avoid that ?

I was thinking of adding synchronous request to the device in AddressSpace::write ?

Yes, you can block. It will block the thread servicing the request in the OPC UA server, but that's expected.

2 Likes