/// <summary> /// Initializes the manager by creating the default instance. /// </summary> public void Initialize( ServerSystemContext context, ComClientConfiguration configuration, ComServerStatusState statusNode, object statusNodeLock, WaitCallback reconnectCallback) { m_defaultSystemContext = context; m_configuration = configuration; m_statusNode = statusNode; m_statusNodeLock = statusNodeLock; m_statusUpdateInterval = m_configuration.MaxReconnectWait; m_reconnectCallback = reconnectCallback; // limit status updates to once per 10 seconds. if (m_statusUpdateInterval < 10000) { m_statusUpdateInterval = 10000; } StartStatusTimer(OnStatusTimerExpired); }
/// <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) { // check if the type model needs to be loaded. if (NamespaceIndexes.Length > 1) { LoadPredefinedNodes(SystemContext, externalReferences); } // create the root node. string serverName = m_configuration.ServerName; if (String.IsNullOrEmpty(serverName)) { serverName = "ComDaServer"; } DaElement element = new DaElement(); element.ItemId = String.Empty; element.Name = serverName; element.ElementType = DaElementType.Branch; DaBranchState root = new DaBranchState(SystemContext, element, NamespaceIndex); root.AddReference(ReferenceTypeIds.Organizes, true, ObjectIds.ObjectsFolder); // link root to objects folder. IList<IReference> references = null; if (!externalReferences.TryGetValue(ObjectIds.ObjectsFolder, out references)) { externalReferences[ObjectIds.ObjectsFolder] = references = new List<IReference>(); } references.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, root.NodeId)); // create the status node. ComServerStatusState status = new ComServerStatusState(root); status.ReferenceTypeId = ReferenceTypeIds.Organizes; // get the type namepace for the browse name. int typeNamepaceIndex = Server.NamespaceUris.GetIndex(Namespaces.ComInterop); if (typeNamepaceIndex < 0) { typeNamepaceIndex = NamespaceIndex; } status.Create( SystemContext, DaModelUtils.ConstructIdForInternalNode("ServerStatus", NamespaceIndex), new QualifiedName("ServerStatus", (ushort)typeNamepaceIndex), null, true); root.AddChild(status); // store root folder in the pre-defined nodes. AddPredefinedNode(SystemContext, root); // create the COM server. m_system.Initialize(SystemContext, m_configuration, status, Lock, OnServerReconnected); StartMetadataUpdates(null, null, 5000, m_configuration.MaxReconnectWait); } }
/// <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) { // check if the type model needs to be loaded. if (NamespaceIndexes.Length > 1) { LoadPredefinedNodes(SystemContext, externalReferences); } // create the root node. string serverName = m_configuration.ServerName; if (String.IsNullOrEmpty(serverName)) { serverName = "ComHdaServer"; } HdaBranchState root = new HdaBranchState(String.Empty, serverName, NamespaceIndex); root.AddReference(ReferenceTypeIds.Organizes, true, ObjectIds.ObjectsFolder); // link root to objects folder. IList<IReference> references = null; if (!externalReferences.TryGetValue(ObjectIds.ObjectsFolder, out references)) { externalReferences[ObjectIds.ObjectsFolder] = references = new List<IReference>(); } references.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, root.NodeId)); // create the status node. ComServerStatusState status = new ComServerStatusState(root); status.ReferenceTypeId = ReferenceTypeIds.Organizes; // get the type namepace for the browse name. int typeNamepaceIndex = Server.NamespaceUris.GetIndex(Namespaces.ComInterop); if (typeNamepaceIndex < 0) { typeNamepaceIndex = NamespaceIndex; } status.Create( SystemContext, HdaModelUtils.ConstructIdForInternalNode("ServerStatus", NamespaceIndex), new QualifiedName("ServerStatus", (ushort)typeNamepaceIndex), null, true); root.AddChild(status); // store root folder in the pre-defined nodes. AddPredefinedNode(SystemContext, root); // create the server capabilities object. HistoryServerCapabilitiesState capabilities = m_capabilities = new HistoryServerCapabilitiesState(null); CreateNode( SystemContext, root.NodeId, ReferenceTypeIds.Organizes, new QualifiedName(Opc.Ua.BrowseNames.HistoryServerCapabilities), capabilities); capabilities.AccessHistoryDataCapability.Value = true; capabilities.AccessHistoryEventsCapability.Value = false; capabilities.MaxReturnDataValues.Value = 0; capabilities.MaxReturnEventValues.Value = 0; capabilities.ReplaceDataCapability.Value = false; capabilities.UpdateDataCapability.Value = false; capabilities.InsertEventCapability.Value = false; capabilities.ReplaceEventCapability.Value = false; capabilities.UpdateEventCapability.Value = false; capabilities.InsertAnnotationCapability.Value = false; capabilities.InsertDataCapability.Value = false; capabilities.DeleteRawCapability.Value = false; capabilities.DeleteAtTimeCapability.Value = false; AddPredefinedNode(SystemContext, capabilities); // create the default aggregate configuration object. AggregateConfigurationState aggregateConfiguration = new AggregateConfigurationState(null); aggregateConfiguration.ReferenceTypeId = ReferenceTypeIds.Organizes; aggregateConfiguration.Create( SystemContext, HdaModelUtils.ConstructIdForInternalNode(Opc.Ua.BrowseNames.AggregateConfiguration, NamespaceIndex), Opc.Ua.BrowseNames.AggregateConfiguration, null, true); aggregateConfiguration.TreatUncertainAsBad.Value = m_configuration.TreatUncertainAsBad; aggregateConfiguration.PercentDataBad.Value = m_configuration.PercentDataBad; aggregateConfiguration.PercentDataGood.Value = m_configuration.PercentDataGood; aggregateConfiguration.UseSlopedExtrapolation.Value = m_configuration.SteppedSlopedExtrapolation; AddPredefinedNode(SystemContext, aggregateConfiguration); // create the COM server. m_system.Initialize(SystemContext, m_configuration, status, Lock, OnServerReconnected); StartMetadataUpdates(DoMetadataUpdate, null, 5000, m_configuration.MaxReconnectWait); } }
/// <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) { // check if the type model needs to be loaded. if (NamespaceIndexes.Length > 1) { LoadPredefinedNodes(SystemContext, externalReferences); } IList<IReference> references = null; // create the root node. string serverName = m_configuration.ServerName; if (String.IsNullOrEmpty(serverName)) { serverName = "ComAeServer"; } AeAreaState root = new AeAreaState(SystemContext, String.Empty, serverName, NamespaceIndex); root.AddReference(ReferenceTypeIds.Organizes, true, ObjectIds.ObjectsFolder); // link root to objects folder. if (!externalReferences.TryGetValue(ObjectIds.ObjectsFolder, out references)) { externalReferences[ObjectIds.ObjectsFolder] = references = new List<IReference>(); } references.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, root.NodeId)); // link root to server object. if (!externalReferences.TryGetValue(ObjectIds.Server, out references)) { externalReferences[ObjectIds.Server] = references = new List<IReference>(); } references.Add(new NodeStateReference(ReferenceTypeIds.HasNotifier, false, root.NodeId)); // create the status node. ComServerStatusState status = new ComServerStatusState(root); status.ReferenceTypeId = ReferenceTypeIds.Organizes; // get the type namepace for the browse name. int typeNamepaceIndex = Server.NamespaceUris.GetIndex(Namespaces.ComInterop); if (typeNamepaceIndex < 0) { typeNamepaceIndex = NamespaceIndex; } status.Create( SystemContext, AeModelUtils.ConstructIdForInternalNode("ServerStatus", NamespaceIndex), new QualifiedName("ServerStatus", (ushort)typeNamepaceIndex), null, true); root.AddChild(status); // store root folder in the pre-defined nodes. AddPredefinedNode(SystemContext, root); AddRootNotifier(root); // create the COM server. m_system.Initialize(SystemContext, m_configuration, status, Lock, OnServerReconnected); // create a template condition that can be used to initialize static metadata. m_templateAlarm = new AlarmConditionState(null); m_templateAlarm.SymbolicName = "TemplateAlarm"; m_templateAlarm.Create( SystemContext, null, new QualifiedName(m_templateAlarm.SymbolicName, NamespaceIndex), null, false); m_templateAlarm.Acknowledge.OnCall = OnAcknowledge; StartMetadataUpdates(DoMetadataUpdate, null, 5000, m_configuration.MaxReconnectWait); } }