servers.cs

来自「OPC工具包是用来简化OPC规范服务器/客户端开发的工具包」· CS 代码 · 共 79 行

CS
79
字号
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 + =
减小字号Ctrl + -
显示快捷键?