Opc.Ua.Com.ServerFactory.GetAvailableServers C# (CSharp) Method

GetAvailableServers() public method

Returns a list of servers that support the specified specification.
public GetAvailableServers ( ) : System.Uri[]
return System.Uri[]
		public Uri[] GetAvailableServers(params Specification[] specifications)
		{
			// enumerate servers on specified machine.
			try
			{                				
				// convert the interface version to a guid.
                Guid[] catids = new Guid[specifications.Length];

                for (int ii = 0; ii < catids.Length; ii++)
                {
                    catids[ii] = new Guid(specifications[ii].Id);
                }
		
				// get list of servers in the specified specification.
				IOPCEnumGUID enumerator = null;

				m_server.EnumClassesOfCategories(
                    catids.Length,
                    catids,
					0,
					null,
					out enumerator);

				// read clsids.
				List<Guid> clsids = ReadClasses(enumerator);

				// release enumerator object.					
				ComUtils.ReleaseServer(enumerator);
				enumerator = null;

				// fetch class descriptions.
				Uri[] uris = new Uri[clsids.Count];

				for (int ii = 0; ii < uris.Length; ii++)
				{
					uris[ii] = CreateUri(clsids[ii]);
				}

				return uris;
			}
			catch (Exception e)
			{
                throw ServiceResultException.Create(StatusCodes.BadCommunicationError, e, "Could not enumerate COM servers.");
			}
		}
		

Usage Example

コード例 #1
0
        /// <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);
            }
        }
All Usage Examples Of Opc.Ua.Com.ServerFactory::GetAvailableServers