I am a beginner in OPC UA server development. I am working on .NET environment to create an server with my own Information Model which is created on UAModeler.
when I instantiate the nodes available in my information model, only those which are set as Mandatory are successfully instantiated. I am trying to find a way how can I instantiate the remaining nodes also which are by purpose set as Optional for Modeling rule.
Below snippet of my code from Node Manager class :
`Console.WriteLine("Loading the Im 2.1 Model."); ImportUaNodeset(Assembly.GetEntryAssembly(), "informationmodel_2.0.xml"); Console.WriteLine("IM Sucessfully Loaded");
CreateObjectSettings settings = new CreateObjectSettings()
{
ParentNodeId = UnifiedAutomation.UaBase.ObjectIds.ObjectsFolder,
ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
RequestedNodeId = new NodeId("IM", DefaultNamespaceIndex),
BrowseName = new QualifiedName("Departments", DefaultNamespaceIndex),
TypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.FolderType
};
ObjectNode controllersNode = CreateObject(Server.DefaultRequestContext, settings);
settings = new CreateObjectSettings()
{
ParentNodeId = controllersNode.NodeId,
ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
RequestedNodeId = new NodeId(DepartmentA, DefaultNamespaceIndex),
BrowseName = new QualifiedName(DepartmentA, DefaultNamespaceIndex),
TypeDefinitionId = new NodeId(My.MyIm.ObjectTypes.BodyshopProductionEquipmentType, DefaultNamespaceIndex)
};
CreateObject(Server.DefaultRequestContext, settings);
ProductionDataNode = FindInMemoryNode(new NodeId(DepartmentA + ".ProductionData", DefaultNamespaceIndex)) as VariableNode;
CounterPerTypeNode = FindInMemoryNode(new NodeId(DepartmentA + ".ProductionData.CounterPerType", DefaultNamespaceIndex)) as VariableNode;`
any suggestions or similar solved examples would be highly appreaciated.
thanks