⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servers.cs

📁 OPC工具包是用来简化OPC规范服务器/客户端开发的工具包
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;


namespace DAC_CSDEMO
{
    public partial class Servers : Form
    {
        public class OPCServer
        {
            public string m_Host;
            public string m_ClassID;
            public string m_ProgID;
            public OPCServer(string Host, string classID, string progID)
            {
                m_Host = Host;
                m_ClassID = classID;
                m_ProgID = progID;
            }
            public override string ToString()
            {
                return m_ProgID;
            }
        }
        public OPCServer Server;

        public Servers()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            object clsIDs, progIDs;
            OPCServer svr;
            clsIDs = null;
            progIDs = null;

            listBox1.Items.Clear();
            uint count = Form1.ASDAC_GetServers(textBox1.Text, 2, ref progIDs, ref clsIDs);
            for(int I=0;I<count; I++)
            {
                string clsID, progID;
                clsID = ((string[])clsIDs)[I];
                progID = ((string[])progIDs)[I];
                svr = new OPCServer(textBox1.Text, clsID, progID);
                listBox1.Items.Add(svr);
            }
        }


        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
            {
                Server = (OPCServer)listBox1.SelectedItem;
                textBox1.Text = Server.m_Host;
                textBox2.Text = Server.m_ProgID;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (Server==null)
            {
                if (textBox2.Text.Length > 0)
                {
                    Server = new OPCServer(textBox1.Text, textBox2.Text, textBox2.Text);
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -