Skip to content

[UA] Defined default nodes

Hsu edited this page Mar 20, 2023 · 1 revision

If you want to define default nodes, you should override OpcUaStandardNodeManager and OpcUaStandardNodeManager

  • OpcUaStandardNodeManager

add nodes to root folder.

/// <inheritdoc/>
public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
{
	base.CreateAddressSpace(externalReferences);

	lock (Lock)
	{
		if (!externalReferences.TryGetValue(ObjectIds.ObjectsFolder, out References))
		{
			externalReferences[ObjectIds.ObjectsFolder] = References = new List<IReference>();
		}

		FolderState root = CreateFolder(null, "Devices", "Devices");
		FolderState statc = CreateFolder(root, "Statics", "Statics");

		var array = Enum.GetValues(typeof(BuiltInType));
		foreach (var item in array)
		{
			CreateVariable(statc, (BuiltInType)item);
		}
	}

	CreateAddressSpaceFinished = true;
}
  • OpcUaStandardNodeManager

replace OpcUaStandardNodeManager in CreateMasterNodeManager

/// <inheritdoc/>
protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
{
	Utils.LogInfo(Utils.TraceMasks.StartStop, "Creating the Reference Server Node Manager.");
	var nodeManager = new OpcUaStandardNodeManager(server, configuration, configuration.ProductUri);
	ProxyNodeManager = nodeManager;

	IList<INodeManager> nodeManagers = new List<INodeManager>
	{
		// create the custom node manager.
		nodeManager
	};

	foreach (var nodeManagerFactory in NodeManagerFactories)
	{
		nodeManagers.Add(nodeManagerFactory.Create(server, configuration));
	}

	// create master node manager.
	return new MasterNodeManager(server, configuration, null, nodeManagers.ToArray());
}
Clone this wiki locally