91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 7.91KB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2024-04-29
  • 語言: C#
  • 標簽: Server??PLC??連接??代碼??

資源簡介

【實例簡介】該實例介紹一個簡單的通過kepserver通過OPC 連接PLC的代碼

【文件目錄】

KepServer-OPC-connect-to-PLC-master

├── C# Code
├── OPC_PLC_Code1.cs
└── OPC_PLC_Code2.cs

0 directories, 3 files


資源截圖

代碼片段和文件信息

///摘要
///程式使用C#.NET?2005?編寫
///引用類庫OPCDAAuto.dll
///OPCServer采用KEPWare
///在windows?xp?sp2、sp3、windows?2003上測試通過
///完成于:2008年12月31日
///測試于:2009年01月05日
///
///作者:瀟灑草
///Email:zhkai868@163.com
///QQ:44649029
///?
///如分發,請保留此摘要。
///鄙視那些拿代碼當寶貝的人,鄙視那些你不拿源碼換就不稀罕你的人,鄙視那些自私的人。
///別人看到你的代碼,你能死啊?對你有多大威脅啊?強烈鄙視~~~
///如果你是這樣的人,趕緊關了。。偶不歡迎。。
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Net;
using?System.Collections;
using?OPCAutomation;
namespace?OPC測試通過
{
????public?partial?class?MainFrom?:?Form
????{
????????public?MainFrom()
????????{
????????????InitializeComponent();
????????}
????????#region?私有變量
????????///?
????????///?OPCServer?object
????????///?

????????OPCServer?KepServer;
????????///?
????????///?OPCGroups?object
????????///?

????????OPCGroups?KepGroups;
????????///?
????????///?OPCGroup?object
????????///?

????????OPCGroup?KepGroup;
????????///?
????????///?OPCItems?object
????????///?

????????OPCItems?KepItems;
????????///?
????????///?OPCItem?object
????????///?

????????OPCItem?KepItem;
????????///?
????????///?主機IP
????????///?

????????string?strHostIP?=?““;
????????///?
????????///?主機名稱
????????///?

????????string?strHostName?=?““;
????????///?
????????///?連接狀態
????????///?

????????bool?opc_connected?=?false;
????????///?
????????///?客戶端句柄
????????///?

????????int?itmHandleClient?=?0;
????????///?
????????///?服務端句柄
????????///?

????????int?itmHandleServer?=?0;
????????#endregion
????????#region?方法
????????///?
????????///?枚舉本地OPC服務器
????????///?

????????private?void?GetLocalServer()
????????{
????????????//獲取本地計算機IP計算機名稱
????????????IPHostEntry?IPHost?=?Dns.Resolve(Environment.MachineName);
????????????if?(IPHost.AddressList.Length?>?0)
????????????{
????????????????strHostIP?=?IPHost.AddressList[0].ToString();
????????????}
????????????else
????????????{
????????????????return;
????????????}
????????????//通過IP來獲取計算機名稱,可用在局域網內
????????????IPHostEntry?ipHostEntry?=?Dns.GetHostByAddress(strHostIP);
????????????strHostName=ipHostEntry.HostName.ToString();
????????????//獲取本地計算機上的OPCServerName
????????????try
????????????{
????????????????KepServer?=?new?OPCServer();
????????????????object?serverList?=?KepServer.GetOPCServers(strHostName);
????????????????foreach?(string?turn?in?(Array)serverList)
????????????????{
????????????????????cmbServerName.Items.Add(turn);
????????????????}
????????????????cmbServerName.SelectedIndex?=?0;
????????????????btnConnServer.Enabled?=?true;
????????????}
????????????catch(Exception?err)
????????????{
????????????????MessageBox.Show(“枚舉本地OPC服務器出錯:“+err.Message“提示信息“MessageBoxButtons.OKMessageBoxIcon.Warning);
????????????}
????????}
????????///?

????????///?創建組
?????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-08?03:47??KepServer-OPC-connect-to-PLC-master\
?????文件?????????154??2017-12-08?03:47??KepServer-OPC-connect-to-PLC-master\C#?Code
?????文件???????12880??2017-12-08?03:47??KepServer-OPC-connect-to-PLC-master\OPC_PLC_Code1.cs
?????文件???????15035??2017-12-08?03:47??KepServer-OPC-connect-to-PLC-master\OPC_PLC_Code2.cs

評論

共有 條評論