コード例 #1
0
        public void ListAllServers()
        {
            OpcDaSrvList.Items.Clear();

            OpcServerList lst = new OpcServerList();

            OpcServers[] svs = null;
            try
            {
                lst.ListAllData20(out svs);
            }
            catch (COMException)
            {
                MessageBox.Show(this, "Enum OPC servers failed!", "Select Server", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (svs == null)
            {
                return;
            }

            string[] itemstrings = new string[3];
            foreach (OpcServers l in svs)
            {
                itemstrings[0] = l.ServerName;
                itemstrings[1] = l.ProgID;
                itemstrings[2] = l.ClsID.ToString();
                OpcDaSrvList.Items.Add(new ListViewItem(itemstrings));
            }

            // preselect top item in ListView
            OpcDaSrvList.Items[0].Selected = true;
        }
コード例 #2
0
        static void Main()
        {
            Console.WriteLine("OPC Data Access 1.0");
            foreach (var server in OpcServerList.ListAll(OpcServerList.OpcDataAccess10))
            {
                Console.WriteLine("'{0}' ID={1} [{2}]", server.Name, server.ProgID, server.ClsID);
            }

            Console.WriteLine("OPC Data Access 2.0");
            foreach (var server in OpcServerList.ListAllData20())
            {
                Console.WriteLine("'{0}' ID={1} [{2}]", server.Name, server.ProgID, server.ClsID);
            }

            Console.WriteLine("OPC Data Access 3.0");
            foreach (var server in OpcServerList.ListAll(OpcServerList.OpcDataAccess30))
            {
                Console.WriteLine("'{0}' ID={1} [{2}]", server.Name, server.ProgID, server.ClsID);
            }

            Console.WriteLine("OPC XML Data Access");
            foreach (var server in OpcServerList.ListAll(OpcServerList.OpcDataAccessXML))
            {
                Console.WriteLine("'{0}' ID={1} [{2}]", server.Name, server.ProgID, server.ClsID);
            }
        }
コード例 #3
0
ファイル: SelServer.cs プロジェクト: fedorsai/MonitoringViam
        public List <OpcServerDescription> GetListAllServers()
        {
            List <OpcServerDescription> result = new List <OpcServerDescription>();

            OpcServerList lst = new OpcServerList();

            OpcServers[] svs = null;

            lst.ListAllData20(out svs);

            if (svs == null)
            {
                return(result);
            }

            string[] itemstrings = new string[3];
            foreach (OpcServers l in svs)
            {
                itemstrings[0] = l.ServerName;
                itemstrings[1] = l.ProgID;
                itemstrings[2] = l.ClsID.ToString();
                result.Add(new OpcServerDescription
                {
                    ServerName = l.ServerName,
                    ProgId     = l.ProgID,
                    ClsId      = l.ClsID
                });
            }
            return(result);
        }