Esempio n. 1
0
 public static List <Tuple <string, Guid> > GetOPCServiceList(string opcSerHostIp)
 {
     try
     {
         Host             host             = new Host(opcSerHostIp);
         OpcServerBrowser opcServerBrowser = new OpcServerBrowser(host);
         string[]         servers;
         Guid[]           serverGuids;
         opcServerBrowser.GetServerList(out servers, out serverGuids);
         if (null != servers)
         {
             List <Tuple <string, Guid> > serverList = new List <Tuple <string, Guid> >();
             for (int i = 0; i < servers.Length; i++)
             {
                 serverList.Add(new Tuple <string, Guid>(servers[i], serverGuids[i]));
             }
             return(serverList);
         }
     }
     catch (Exception ex)
     {
         NLogHelper.ExceptionInfo(ex, "GetOPCServiceList error :{0}", ex.Message);
     }
     return(null);
 }
Esempio n. 2
0
        public string[] DisplayLocalOpcV2V3Servers()
        {
            string[]         Servers;
            OpcServerBrowser srvBrowse = new OpcServerBrowser();  // local server

            srvBrowse.GetServerList(out Servers);
            return(Servers);
        }
Esempio n. 3
0
        public static Dictionary <string, Guid> GetServersNameAndGuid(string hostNameOrAddress)
        {
            string[] servers = null;
            Guid[]   guids   = null;
            Dictionary <string, Guid> serverAndGuidDic = new Dictionary <string, Guid>();

            try
            {
                IPHostEntry      ip_host = Dns.GetHostEntry(hostNameOrAddress);
                Host             host    = new Host(ip_host.HostName);
                OpcServerBrowser browser = new OpcServerBrowser(host);
                browser.GetServerList(out servers, out guids);
                for (int i = 0; i < servers.Length; i++)
                {
                    serverAndGuidDic[servers[i]] = guids[i];
                }
            }
            catch (Exception err)
            {
                NLogHelper.ExceptionInfo(err, "GetServersNameAndGuid error :{0}", err.Message);
            }
            return(serverAndGuidDic);
        }