资源简介
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个文件信息
相关资源
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
评论
共有 条评论