/// <summary> /// Creates and indexes an area defined for the server. /// </summary> private AreaState CreateAndIndexAreas(AreaState parent, AreaConfiguration configuration) { // create a unique path to the area. string areaPath = Utils.Format("{0}/{1}", (parent != null)?parent.SymbolicName:String.Empty, configuration.Name); NodeId areaId = ModelUtils.ConstructIdForArea(areaPath, NamespaceIndex); // create the object that will be used to access the area and any variables contained within it. AreaState area = new AreaState(SystemContext, parent, areaId, configuration); m_areas[areaPath] = area; if (parent != null) { parent.AddChild(area); } // create an index any sub-areas defined for the area. if (configuration.SubAreas != null) { for (int ii = 0; ii < configuration.SubAreas.Count; ii++) { CreateAndIndexAreas(area, configuration.SubAreas[ii]); } } // add references to sources. if (configuration.SourcePaths != null) { for (int ii = 0; ii < configuration.SourcePaths.Count; ii++) { string sourcePath = configuration.SourcePaths[ii]; // check if the source already exists because it is referenced by another area. SourceState source = null; if (!m_sources.TryGetValue(sourcePath, out source)) { NodeId sourceId = ModelUtils.ConstructIdForSource(sourcePath, NamespaceIndex); m_sources[sourcePath] = source = new SourceState(this, sourceId, sourcePath); } // HasEventSource and HasNotifier control the propagation of event notifications so // they are not like other references. These calls set up a link between the source // and area that will cause events produced by the source to be automatically // propagated to the area. source.AddNotifier(SystemContext, ReferenceTypeIds.HasEventSource, true, area); area.AddNotifier(SystemContext, ReferenceTypeIds.HasEventSource, false, source); } } return(area); }
/// <summary> /// Creates the NodeId for the specified node. /// </summary> /// <param name="context">The context.</param> /// <param name="node">The node.</param> /// <returns>The new NodeId.</returns> /// <remarks> /// This method is called by the NodeState.Create() method which initializes a Node from /// the type model. During initialization a number of child nodes are created and need to /// have NodeIds assigned to them. This implementation constructs NodeIds by constructing /// strings. Other implementations could assign unique integers or Guids and save the new /// Node in a dictionary for later lookup. /// </remarks> public override NodeId New(ISystemContext context, NodeState node) { return(ModelUtils.ConstructIdForComponent(node, NamespaceIndex)); }