Skip to content

Instantly share code, notes, and snippets.

@kevinherron
Created October 5, 2023 19:12
Show Gist options
  • Save kevinherron/75ebdca52bbaf4fc433c0886c00208bc to your computer and use it in GitHub Desktop.
Save kevinherron/75ebdca52bbaf4fc433c0886c00208bc to your computer and use it in GitHub Desktop.
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
import org.eclipse.milo.opcua.stack.core.NodeIds;
import org.eclipse.milo.opcua.stack.core.UaException;
import org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection;
import org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseResultMask;
import org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass;
import org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription;
import org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult;
import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint;
class Scratch {
public static void main(String[] args) throws UaException {
var client = OpcUaClient.create("opc.tcp://localhost:4840");
client.connect();
BrowseResult result = client.browse(new BrowseDescription(
NodeIds.Server_ServerStatus,
BrowseDirection.Forward,
NodeIds.HasTypeDefinition,
false,
uint(NodeClass.ObjectType.getValue() | NodeClass.VariableType.getValue()),
uint(BrowseResultMask.All.getValue())
));
System.out.println("Browse returned " + result.getReferences().length + " references");
}
}
@kevinherron
Copy link
Author

You changed the requested reference type from HasTypeDefinition to HasComponent. This is asking for a different set of references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment