/// <summary> /// Does any initialization required before the address space can be used. /// </summary> /// <remarks> /// The externalReferences is an out parameter that allows the node manager to link to nodes /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and /// should have a reference to the root folder node(s) exposed by this node manager. /// </remarks> public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences) { lock (Lock) { base.CreateAddressSpace(externalReferences); // create the nodes from configuration. ushort namespaceIndex = Server.NamespaceUris.GetIndexOrAppend(Namespaces.MemoryBuffer); BaseInstanceState root = (BaseInstanceState)FindPredefinedNode( new NodeId(Objects.MemoryBuffers, namespaceIndex), typeof(BaseInstanceState)); // create the nodes from configuration. namespaceIndex = Server.NamespaceUris.GetIndexOrAppend(Namespaces.MemoryBuffer + "/Instance"); if (m_configuration != null && m_configuration.Buffers != null) { for (int ii = 0; ii < m_configuration.Buffers.Count; ii++) { MemoryBufferInstance instance = m_configuration.Buffers[ii]; // create a new buffer. MemoryBufferState bufferNode = new MemoryBufferState(SystemContext, instance); // assign node ids. bufferNode.Create( SystemContext, new NodeId(bufferNode.SymbolicName, namespaceIndex), new QualifiedName(bufferNode.SymbolicName, namespaceIndex), null, true); bufferNode.CreateBuffer(instance.DataType, instance.TagCount); bufferNode.InitializeMonitoring(Server, this); // save the buffers for easy look up later. m_buffers[bufferNode.SymbolicName] = bufferNode; // link to root. root.AddChild(bufferNode); } } } }
/// <summary> /// Initializes the buffer from the configuration. /// </summary> public MemoryBufferState(ISystemContext context, MemoryBufferInstance configuration) : base(null) { #pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor Initialize(context); #pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor var dataType = "UInt32"; var name = dataType; var count = 10; if (configuration != null) { count = configuration.TagCount; if (!string.IsNullOrEmpty(configuration.DataType)) { dataType = configuration.DataType; } if (!string.IsNullOrEmpty(configuration.Name)) { name = dataType; } } SymbolicName = name; var elementType = BuiltInType.UInt32; switch (dataType) { case "Double": { elementType = BuiltInType.Double; break; } } CreateBuffer(elementType, count); }
/// <summary> /// Initializes the buffer from the configuration. /// </summary> public MemoryBufferState(ISystemContext context, MemoryBufferInstance configuration) : base(null) { Initialize(context); string dataType = "UInt32"; string name = dataType; int count = 10; if (configuration != null) { count = configuration.TagCount; if (!String.IsNullOrEmpty(configuration.DataType)) { dataType = configuration.DataType; } if (!String.IsNullOrEmpty(configuration.Name)) { name = dataType; } } this.SymbolicName = name; BuiltInType elementType = BuiltInType.UInt32; switch (dataType) { case "Double": { elementType = BuiltInType.Double; break; } } CreateBuffer(elementType, count); }