UA Bundle SDK .NET  2.2.3.276
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups Pages
Creating Instances

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

Console.WriteLine("Loading the Controller Model.");
ImportUaNodeset(Assembly.GetEntryAssembly(), "buildingautomation.xml");
// New Code Begin
// 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
};
CreateObject(Server.DefaultRequestContext, settings);
// Create an Air Conditioner Controller
settings = new CreateObjectSettings()
{
ParentNodeId = new NodeId("Controllers", InstanceNamespaceIndex),
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 = new NodeId("Controllers", InstanceNamespaceIndex),
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);
// New Code End

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

Figure 2.13 Result in the server’s address space

Resulting Address Space