.NET Based OPC UA Client/Server SDK  3.3.3.537
Creating Instances

Finally, we are creating instances in Lesson1NodeManager::Startup() as shown in the following code snippet.

// Create a Folder for Controllers
CreateObjectSettings settings = new CreateObjectSettings()
{
ParentNodeId = ObjectIds.ObjectsFolder,
ReferenceTypeId = ReferenceTypeIds.Organizes,
RequestedNodeId = new NodeId("Controllers", InstanceNamespaceIndex),
BrowseName = new QualifiedName("Controllers", InstanceNamespaceIndex),
TypeDefinitionId = ObjectTypeIds.FolderType
};
ObjectNode controllersNode = CreateObject(Server.DefaultRequestContext, settings);
// Create an Air Conditioner Controller
settings = new CreateObjectSettings()
{
ParentNodeId = controllersNode.NodeId,
ReferenceTypeId = ReferenceTypeIds.Organizes,
RequestedNodeId = new NodeId("AirConditioner1", InstanceNamespaceIndex),
BrowseName = new QualifiedName("AirConditioner1", InstanceNamespaceIndex),
TypeDefinitionId = new NodeId(yourorganisation.BA.ObjectTypes.AirConditionerControllerType, TypeNamespaceIndex)
};
CreateObject(Server.DefaultRequestContext, settings);
// Create a Furnace Controller
settings = new CreateObjectSettings()
{
ParentNodeId = controllersNode.NodeId,
ReferenceTypeId = ReferenceTypeIds.Organizes,
RequestedNodeId = new NodeId("Furnace1", InstanceNamespaceIndex),
BrowseName = new QualifiedName("Furnace1", InstanceNamespaceIndex),
TypeDefinitionId = new NodeId(yourorganisation.BA.ObjectTypes.FurnaceControllerType, TypeNamespaceIndex)
};
CreateObject(Server.DefaultRequestContext, settings);

The following figure shows the result in the server’s address space.

serverlesson02a_st7_create_instances.png
Figure 2.14: Result in the server’s address space