美女露出让男生揉视频_狍和女人一级毛片免费的_欧美人欧美人妖videos12_护士潮湿的小内裤bd播放

sakura12345
級別: 正式會員
精華主題: 0
發帖數量: 34 個
工控威望: 92 點
下載積分: 732 分
在線時間: 25(小時)
注冊時間: 2018-07-25
最后登錄: 2018-12-21
查看sakura12345的 主題 / 回貼
樓主  發表于: 2018-11-13 16:42
c#寫opc服務器,有點問題,多點指教
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using OPCAutomation;
using System.Net;

namespace OPC通訊
{
    public partial class Form1 : Form
    {
        #region 私有變量
        OPCServer myOPCServer;//OPC服務器變量聲明
        OPCGroups myOPCGroups;//OPC服務器組集合
        OPCGroup myOPCGroup;//OPCGroups 是OPCGroup對象的集合,外加創建,移除,管理他們的方法。
        OPCItems myOPCItems;//OPCItems OPCItems OPCItem對象的集合這是OPCgroup對象的默認屬性。
        OPCItem myOPCItem;
        string strHostIP = "";
        string strHostName = "";
        bool opc_connected = false;
        int itmHandleClient = 0;//客戶端句柄
        int itmHandleServer = 0;//服務端句柄
        #endregion
        public Form1()
        {
            InitializeComponent();
        }
        #region 加載Form1_Load
        private void Form1_Load(object sender, EventArgs e)
        {
            //獲取本地計算機IP、計算機名稱
            IPHostEntry IPHost = Dns.Resolve(Environment.MachineName);
            if (IPHost.AddressList.Length > 0)
            {
                strHostIP = IPHost.AddressList[0].ToString();
                textBox1.Text = strHostIP;
            }
            else
            {
                return;
            }

            //通過IP來獲取計算機名稱,可用在局域網內
            IPHostEntry ipHostEntry = Dns.GetHostByAddress(strHostIP);
            strHostName = ipHostEntry.HostName.ToString();

            //獲取本地計算機上的OPCServerName
            try
            {
                myOPCServer = new OPCServer();
                object serverList = myOPCServer.GetOPCServers(strHostName);
                foreach (string turn in (Array)serverList)
                {
                    comboBox1.Items.Add(turn);
                }
                comboBox1.SelectedIndex = 0;
              button1.Enabled = true;
            }
            catch (Exception err)
            {
                MessageBox.Show("枚舉本地OPC服務器出錯:" + err.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        #endregion
        #region 建立連接
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ConnectRemoteServer(textBox1.Text, comboBox1.Text))
                {
                    return;
                }
                btnSetGroupPro.Enabled = true;
                opc_connected = true;
                GetServerInfo();
                RecurBrowse(myOPCServer.CreateBrowser());
                if (!CreateGroup())
                {
                    return;
                }
              
            }
            catch (Exception err)
            {
                MessageBox.Show("初始化出錯:" + err.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

        }
[ 此帖被sakura12345在2018-11-13 17:01重新編輯 ]