/// <summary> /// Creates an instance of the COM server. /// </summary> public void CreateInstance() { // multiple calls are not allowed - may block for a while due to network operation. lock (m_lock) { ServerFactory factory = new ServerFactory(); try { // create the server. Unknown = factory.CreateServer(new Uri(m_url), null); // fetch the available locales. m_availableLocaleIds = QueryAvailableLocales(); // do any post-connect processing. OnConnected(); } catch (Exception e) { ComUtils.TraceComError(e, "Could not connect to server ({0}).", m_url); // cleanup on error. Close(); } finally { factory.Dispose(); } } }
/// <summary> /// Gets the available servers. /// </summary> /// <param name="factory">The factory.</param> /// <param name="specification">The specification.</param> private void GetAvailableServers(Opc.Ua.Com.ServerFactory factory, Specification specification) { Uri[] serverUrls = factory.GetAvailableServers(specification); for (int ii = 0; ii < serverUrls.Length; ii++) { ComServerDescription server = factory.ParseUrl(serverUrls[ii]); // don't wrap proxies. if (ConfigUtils.CLSID_UaComDaProxyServer == server.Clsid) { continue; } if (ConfigUtils.CLSID_UaComAeProxyServer == server.Clsid) { continue; } if (ConfigUtils.CLSID_UaComHdaProxyServer == server.Clsid) { continue; } // don't wrap UA psuedo-servers. List <Guid> catids = ConfigUtils.GetImplementedCategories(server.Clsid); bool suppress = false; for (int jj = 0; jj < catids.Count; jj++) { if (catids[jj] == ConfigUtils.CATID_PseudoComServers) { suppress = true; break; } } if (suppress) { continue; } // assume regular COM server. ListViewItem item = new ListViewItem(server.ProgId); item.SubItems.Add(server.Description); item.SubItems.Add(specification.ToString()); item.Tag = new Item(specification, server); ServersLV.Items.Add(item); } }
/// <summary> /// Updates the list of servers. /// </summary> private void UpdateServers() { // populate the list of servers. Opc.Ua.Com.ServerFactory factory = new ServerFactory(); try { ServersLV.Items.Clear(); string hostName = HostCB.Text; if (HostCB.SelectedIndex != -1) { hostName = (string)HostCB.SelectedItem; } factory.Connect(hostName, null); Uri[] serverUrls = factory.GetAvailableServers(Specification.Da20, Specification.Da30); for (int ii = 0; ii < serverUrls.Length; ii++) { ComServerDescription server = factory.ParseUrl(serverUrls[ii]); ListViewItem item = new ListViewItem(server.ProgId); item.SubItems.Add(server.Description); item.Tag = server; ServersLV.Items.Add(item); } for (int ii = 0; ii < ServersLV.Columns.Count; ii++) { ServersLV.Columns[ii].Width = -2; } } finally { factory.Disconnect(); } }
/// <summary> /// Creates an instance of the COM server. /// </summary> public void CreateInstance() { // multiple calls are not allowed - may block for a while due to network operation. lock (m_lock) { ServerFactory factory = new ServerFactory(); try { // create the server. Unknown = factory.CreateServer(new Uri(m_url), null); // set the locale. SetLocale(LocaleId); if (UserIdentity != null) { SetUserIdentity(UserIdentity); } // do any post-connect processing. OnConnected(); } catch (Exception e) { ComUtils.TraceComError(e, "Could not connect to server ({0}).", m_url); // cleanup on error. Close(); } finally { factory.Dispose(); } } }
/// <summary> /// Updates the list of servers. /// </summary> private void UpdateServers() { // populate the list of servers. Opc.Ua.Com.ServerFactory factory = new ServerFactory(); try { ServersLV.Items.Clear(); string hostName = HostCB.Text; if (HostCB.SelectedIndex != -1) { hostName = (string)HostCB.SelectedItem; } factory.Connect(hostName, null); GetAvailableServers(factory, Specification.Da20); GetAvailableServers(factory, Specification.Da30); GetAvailableServers(factory, Specification.Ae10); GetAvailableServers(factory, Specification.Hda10); for (int ii = 0; ii < ServersLV.Columns.Count; ii++) { ServersLV.Columns[ii].Width = -2; } } finally { factory.Disconnect(); } }