コード例 #1
0
        public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
        {
            base.CreateAddressSpace(externalReferences);
            
            // hard code  a sample branch that has the method added.
            NodeId branchId = DaModelUtils.ConstructIdForDaElement("Static/Simple Types", -1, NamespaceIndex);

            // create the method.
            MethodState method = new MethodState(null);

            method.NodeId = GenerateNodeId();
            method.BrowseName = new QualifiedName("GenerateRandomValues", NamespaceIndex);
            method.DisplayName = method.BrowseName.Name;
            method.Executable = true;
            method.UserExecutable = true;
            method.ReferenceTypeId = ReferenceTypeIds.HasComponent;
            method.Handle = "Static/Simple Types";
            
            method.AddReference(ReferenceTypeIds.HasComponent, true, branchId);
            m_references[branchId] = new IReference[] { new NodeStateReference(ReferenceTypeIds.HasComponent, false, method) };
            
            // save the node for later lookup (all tightly coupled children are added with this call).
            AddPredefinedNode(SystemContext, method);
            
            // register handler.
            method.OnCallMethod = new GenericMethodCalledEventHandler(DoGenerateRandomValues);
        }