12/16/2019
Yeah I spent considerable time looking at CreateAddressSpace in the Node Managers derived from CustomNodeManager2. From looking at the Boiler Server in Quickstarts, it appears the folder and objects are created using modeling. I was hoping to find an example that:
- Created a folder
- Created a simple tag in that folder
I suppose the answer is there in one of the samples, but I've not found it yet.
05/30/2017
This code creates a new Node from a predefined class. If you don't have you own model you can use one of the built in Nodes such as FolderState. The MemoryBuffer show how to create Nodes from arbitrary structures.
/// <summary> /// Creates a boiler and adds it to the address space. /// </summary> /// <param name="context">The context to use.</param> /// <param name="unitNumber">The unit number for the boiler.</param> private void CreateBoiler(SystemContext context, int unitNumber) { BoilerState boiler = new BoilerState(null); string name = Utils.Format("Boiler #{0}", unitNumber); boiler.Create( context, null, new QualifiedName(name, m_namespaceIndex), null, true); NodeState folder = (NodeState)FindPredefinedNode( ExpandedNodeId.ToNodeId(ObjectIds.Boilers, Server.NamespaceUris), typeof(NodeState)); folder.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, false, boiler.NodeId); boiler.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, true, folder.NodeId); string unitLabel = Utils.Format("{0}0", unitNumber); UpdateDisplayName(boiler.InputPipe, unitLabel); UpdateDisplayName(boiler.Drum, unitLabel); UpdateDisplayName(boiler.OutputPipe, unitLabel); UpdateDisplayName(boiler.LevelController, unitLabel); UpdateDisplayName(boiler.FlowController, unitLabel); UpdateDisplayName(boiler.CustomController, unitLabel); m_boilers.Add(boiler); AddPredefinedNode(context, boiler); // Autostart boiler simulation state machine MethodState start = boiler.Simulation.Start; IList<Variant> inputArguments = new List<Variant>(); IList<Variant> outputArguments = new List<Variant>(); List<ServiceResult> errors = new List<ServiceResult>(); start.Call(context, boiler.NodeId, inputArguments, errors, outputArguments); }
12/16/2019
I've had some success in adding both folders and points, using the "UA Sample Applications" and some of the Workshop projects, specifically, the "Empty Server" workshop, and interpolating the code in the "EmptyNodeManager", inherited from "CustomNodeManager2".
My ultimate goal is to replicate the contents of some other Customer UA server. I first extract the configuration from the Customer server, and re-create it using the same Node ID's in my server.
What has me puzzled at the moment is that one of the Customer UA servers I am trying to replicate has a Folder with a Node ID that has NameSpaceIndex of 1, and I can't seem to create anything with a NameSpaceIndex of 1 that will appear when I connect a Client to the Server I created. What am I doing wrong?
Thanks..
1 Guest(s)