資源簡介
C# 讀取OPC 數據。

資源截圖
代碼片段和文件信息
///摘要
///程式使用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.OKMe
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-12-19?11:38??OPC測試通過\
?????目錄???????????0??2015-12-19?11:38??OPC測試通過\Backup\
?????目錄???????????0??2015-12-19?11:38??OPC測試通過\Backup\OPC測試通過\
?????文件???????21665??2009-01-13?14:06??OPC測試通過\Backup\OPC測試通過\MainFrom.Designer.cs
?????文件???????13180??2009-01-13?15:14??OPC測試通過\Backup\OPC測試通過\MainFrom.cs
?????文件????????6014??2009-01-13?14:06??OPC測試通過\Backup\OPC測試通過\MainFrom.resx
?????文件????????3918??2009-01-13?13:55??OPC測試通過\Backup\OPC測試通過\OPC測試通過.csproj
?????文件?????????728??2009-01-05?14:04??OPC測試通過\Backup\OPC測試通過\OPC測試通過.csproj.user
?????文件?????????477??2008-12-31?14:45??OPC測試通過\Backup\OPC測試通過\Program.cs
?????目錄???????????0??2015-12-19?11:38??OPC測試通過\Backup\OPC測試通過\Properties\
?????文件????????1177??2009-01-05?13:37??OPC測試通過\Backup\OPC測試通過\Properties\AssemblyInfo.cs
?????文件????????2886??2008-12-31?14:03??OPC測試通過\Backup\OPC測試通過\Properties\Resources.Designer.cs
?????文件????????5612??2008-12-31?14:03??OPC測試通過\Backup\OPC測試通過\Properties\Resources.resx
?????文件????????1100??2008-12-31?14:03??OPC測試通過\Backup\OPC測試通過\Properties\Settings.Designer.cs
?????文件?????????249??2008-12-31?14:03??OPC測試通過\Backup\OPC測試通過\Properties\Settings.settings
?????文件?????????655??2009-01-05?14:55??OPC測試通過\Backup\OPC測試通過\Properties\app.manifest
?????文件??????????74??2009-01-06?11:00??OPC測試通過\Backup\OPC測試通過\app.config
?????文件?????????934??2009-01-07?13:24??OPC測試通過\Backup\OPC測試通過.sln
?????文件???????17408??2009-01-13?15:14??OPC測試通過\Backup\OPC測試通過.suo
?????目錄???????????0??2015-12-19?11:38??OPC測試通過\OPC測試通過\
?????文件???????21665??2016-03-01?11:30??OPC測試通過\OPC測試通過\MainFrom.Designer.cs
?????文件???????13180??2016-03-11?11:00??OPC測試通過\OPC測試通過\MainFrom.cs
?????文件????????6014??2016-03-01?11:31??OPC測試通過\OPC測試通過\MainFrom.resx
?????文件????????6179??2016-03-01?11:31??OPC測試通過\OPC測試通過\OPC測試通過.csproj
?????文件?????????768??2015-12-19?11:38??OPC測試通過\OPC測試通過\OPC測試通過.csproj.user
?????文件?????????477??2008-12-31?14:45??OPC測試通過\OPC測試通過\Program.cs
?????目錄???????????0??2016-03-01?11:30??OPC測試通過\OPC測試通過\Properties\
?????文件????????1177??2009-01-05?13:37??OPC測試通過\OPC測試通過\Properties\AssemblyInfo.cs
?????文件????????2870??2015-12-20?16:40??OPC測試通過\OPC測試通過\Properties\Resources.Designer.cs
?????文件????????5612??2008-12-31?14:03??OPC測試通過\OPC測試通過\Properties\Resources.resx
?????文件????????1115??2015-12-20?16:40??OPC測試通過\OPC測試通過\Properties\Settings.Designer.cs
............此處省略55個文件信息
評論
共有 條評論