/// <summary> /// Initializes the node manager. /// </summary> public ComDaClientNodeManager(IServerInternal server, string namespaceUri, ComDaClientConfiguration configuration, bool ownsTypeModel) : base(server, namespaceUri, ownsTypeModel) { SystemContext.SystemHandle = m_system = new ComDaClientManager(); SystemContext.NodeIdFactory = this; // save the configuration for the node manager. m_configuration = configuration; // set the alias root. AliasRoot = m_configuration.ServerName; if (String.IsNullOrEmpty(AliasRoot)) { AliasRoot = "DA"; } // set the default parser if none provided. if (configuration.ItemIdParser == null) { configuration.ItemIdParser = new ComItemIdParser(); } // create the list of subscriptions. m_subscriptionManagers = new Dictionary <string, SubscribeRequestManager>(); m_subscriptionManagers[String.Empty] = new SubscribeRequestManager(SystemContext, null, 1000); m_monitoredItems = new Dictionary <uint, SubscribeRequestManager>(); }
/// <summary> /// Initializes the node manager. /// </summary> public ComDaClientNodeManager(IServerInternal server, string namespaceUri, ComDaClientConfiguration configuration, bool ownsTypeModel) : base(server, namespaceUri, ownsTypeModel) { SystemContext.SystemHandle = m_system = new ComDaClientManager(); SystemContext.NodeIdFactory = this; // save the configuration for the node manager. m_configuration = configuration; // set the alias root. AliasRoot = m_configuration.ServerName; if (String.IsNullOrEmpty(AliasRoot)) { AliasRoot = "DA"; } // set the default parser if none provided. if (configuration.ItemIdParser == null) { configuration.ItemIdParser = new ComItemIdParser(); } // create the list of subscriptions. m_subscriptionManagers = new Dictionary<string, SubscribeRequestManager>(); m_subscriptionManagers[String.Empty] = new SubscribeRequestManager(SystemContext, null, 1000); m_monitoredItems = new Dictionary<uint, SubscribeRequestManager>(); }
/// <summary> /// Creates the node managers for the server. /// </summary> /// <remarks> /// This method allows the sub-class create any additional node managers which it uses. The SDK /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification. /// Any additional NodeManagers are expected to handle application specific nodes. /// </remarks> protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration) { Utils.Trace("Creating the Node Managers."); List<INodeManager> nodeManagers = new List<INodeManager>(); // create the custom node managers. nodeManagers.Add(new TutorialNodeManager(server, configuration)); #region Task #C4 - Add Support for COM Wrapper // manually configure the COM server to prevent unapproved wrappers. ComDaClientConfiguration wrapperConfig = new ComDaClientConfiguration(); wrapperConfig.ServerName = "COM"; wrapperConfig.ServerUrl = "opc.com://localhost/OPCSample.OpcDaServer"; wrapperConfig.MaxReconnectWait = 10000; wrapperConfig.SeperatorChars = null; wrapperConfig.BrowseToNotSupported = false; wrapperConfig.ItemIdParser = new ItemIdParser(); // create an instance of the wrapper node manager. TutorialDaComNodeManager manager = new TutorialDaComNodeManager( server, wrapperConfig.ServerUrl, wrapperConfig, true); nodeManagers.Add(manager); #endregion // create master node manager. return new MasterNodeManager(server, configuration, null, nodeManagers.ToArray()); }
/// <summary> /// Initializes a new instance of the <see cref="ComDaClient"/> class. /// </summary> /// <param name="configuration"></param> public ComDaClient(ComDaClientConfiguration configuration) : base(configuration) { m_cache = new Dictionary<string, DaElement>(); m_configuration = configuration; }
/// <summary> /// Handles the Click event of the OkBTN control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OkBTN_Click(object sender, EventArgs e) { try { if (ServersLV.SelectedItems.Count != 1) { return; } // extract the wrapper configuration from the application configuration. ComWrapperServerConfiguration wrapperConfig = m_configuration.ParseExtension<ComWrapperServerConfiguration>(); if (wrapperConfig == null) { wrapperConfig = new ComWrapperServerConfiguration(); } if (wrapperConfig.WrappedServers == null) { wrapperConfig.WrappedServers = new ComClientConfigurationCollection(); } if (!m_delete) { // get the selected server. ComServerDescription server = (ComServerDescription)ServersLV.SelectedItems[0].Tag; // create a new new COM client entry for the selected server. ComDaClientConfiguration clientConfig = new ComDaClientConfiguration(); clientConfig.ServerUrl = server.Url; clientConfig.ServerName = server.VersionIndependentProgId; clientConfig.MaxReconnectWait = 100000; wrapperConfig.WrappedServers.Add(clientConfig); // update the configuration. m_configuration.UpdateExtension<ComWrapperServerConfiguration>(null, wrapperConfig); } else { // get the selected server. ComDaClientConfiguration server = (ComDaClientConfiguration)ServersLV.SelectedItems[0].Tag; for (int ii = 0; ii < wrapperConfig.WrappedServers.Count; ii++) { if (wrapperConfig.WrappedServers[ii].ServerUrl == server.ServerUrl) { wrapperConfig.WrappedServers.RemoveAt(ii); break; } } // update the configuration. m_configuration.UpdateExtension<ComWrapperServerConfiguration>(null, wrapperConfig); } // close the dialog. DialogResult = DialogResult.OK; } catch (Exception exception) { MessageBox.Show(exception.Message); } }
/// <summary> /// Initializes the node manager. /// </summary> public TutorialDaComNodeManager(IServerInternal server, string namespaceUri, ComDaClientConfiguration configuration, bool ownsTypeModel) : base(server, namespaceUri, configuration, ownsTypeModel) { }
/// <summary> /// Handles the Click event of the OkBTN control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OkBTN_Click(object sender, EventArgs e) { try { if (ServersLV.SelectedItems.Count != 1) { return; } // extract the wrapper configuration from the application configuration. ComWrapperServerConfiguration wrapperConfig = m_configuration.ParseExtension<ComWrapperServerConfiguration>(); if (wrapperConfig == null) { wrapperConfig = new ComWrapperServerConfiguration(); } if (wrapperConfig.WrappedServers == null) { wrapperConfig.WrappedServers = new ComClientConfigurationCollection(); } // get the selected server. Item item = (Item)ServersLV.SelectedItems[0].Tag; // create a new new COM client entry for the selected server. ComClientConfiguration clientConfig = null; if (item.Specification == Specification.Da20 || item.Specification == Specification.Da30) { clientConfig = new ComDaClientConfiguration(); } else if (item.Specification == Specification.Ae10) { clientConfig = new ComAeClientConfiguration(); } else if (item.Specification == Specification.Hda10) { clientConfig = new ComHdaClientConfiguration(); } clientConfig.ServerUrl = item.Server.Url; clientConfig.ServerName = item.Server.VersionIndependentProgId; clientConfig.MaxReconnectWait = 100000; wrapperConfig.WrappedServers.Add(clientConfig); // update the configuration. m_configuration.UpdateExtension<ComWrapperServerConfiguration>(null, wrapperConfig); // close the dialog. DialogResult = DialogResult.OK; } catch (Exception exception) { MessageBox.Show(exception.Message); } }