OPC数据共享,可用于通讯,C#源代码实现,加快通讯模块的开发
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6294 2013-05-10 12:13 bank_pepoleBackupOPC_ClientForm1.cs
文件 10059 2013-05-10 12:13 bank_pepoleBackupOPC_ClientForm1.Designer.cs
文件 5814 2013-05-10 12:13 bank_pepoleBackupOPC_ClientForm1.resx
文件 5975 2013-05-10 13:33 bank_pepoleBackupOPC_ClientOPC_Client.csproj
文件 564 2013-05-10 13:33 bank_pepoleBackupOPC_ClientOPC_Client.csproj.user
文件 468 2012-12-12 14:43 bank_pepoleBackupOPC_ClientProgram.cs
文件 1383 2013-05-10 12:09 bank_pepoleBackupOPC_ClientPropertiesAssemblyInfo.cs
文件 2864 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesResources.Designer.cs
文件 5612 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesResources.resx
文件 1092 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesSettings.Designer.cs
文件 249 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesSettings.settings
文件 920 2013-05-10 12:14 bank_pepoleBackupOPC_Client.sln
..A..H. 13824 2013-05-14 15:27 bank_pepoleBackupOPC_Client.v11.suo
文件 50449456 2014-11-10 15:29 bank_pepoledocumentdotNetFx40_Full_x86_x64.exe
文件 899584 2015-11-19 22:40 bank_pepoledocumentOPC Core Components 2.00 SDK 2.30.msi
文件 1278001 2015-11-05 15:19 bank_pepoledocumentWin7系统下的OPC运行配置.pdf
文件 4608 2016-01-05 16:32 bank_pepoleOpcEnumLib.dll
文件 200704 2005-11-25 17:07 bank_pepoleOpcNetApi.Com.dll
文件 225280 2005-11-25 17:07 bank_pepoleOpcNetApi.dll
文件 9216 2008-07-09 16:50 bank_pepoleOpcRcw.Cmd.dll
文件 6656 2008-07-09 16:50 bank_pepoleOpcRcw.Comn.dll
文件 20992 2008-07-09 16:50 bank_pepoleOpcRcw.Da.dll
文件 15872 2008-07-09 16:50 bank_pepoleOpcRcw.Dx.dll
文件 12800 2008-07-09 16:50 bank_pepoleOpcRcw.Hda.dll
文件 474 2016-06-23 14:56 bank_pepoleOPC_Clientapp.config
文件 474 2016-06-23 14:56 bank_pepoleOPC_ClientinDebugapp.config
文件 0 2015-11-29 08:56 bank_pepoleOPC_ClientinDebugloglog.txt
文件 26773 2015-12-04 09:47 bank_pepoleOPC_ClientinDebugloglog_2015-12-04.txt
文件 12006 2015-12-08 16:25 bank_pepoleOPC_ClientinDebugloglog_2015-12-08.txt
文件 4624 2015-12-09 12:36 bank_pepoleOPC_ClientinDebugloglog_2015-12-09.txt
............此处省略106个文件信息
using System;
using System.Windows.Forms;
using Opc;
using Opc.Da;
using OpcCom;
namespace opcTest
{
public partial class Form1 : Form
{
private Opc.Da.Server m_server = null;//定义数据存取服务器
private Opc.Da.Subscription subscription = null;//定义组对象(订阅者)
private Opc.Da.SubscriptionState state = null;//定义组(订阅者)状态,相当于OPC规范中组的参数
private Opc.IDiscovery m_discovery = new ServerEnumerator();//定义枚举基于COM服务器的接口,用来搜索所有的此类服务器。
public Form1()
{
InitializeComponent();
textBox1.Text = “192.168.1.5“;
button2.Enabled = false;
button3.Enabled = false;
}
private void button1_Click(object sender EventArgs e)
{
//查询服务器
try
{
Opc.Server[] servers = m_discovery.GetAvailableServers(Specification.COM_DA_20 textBox1.Text null);
if (servers != null)
{
foreach (Opc.Da.Server server in servers)
{
comboBox1.Items.Add(server.Name);
}
}
comboBox1.SelectedIndex = 0;
listBox1.Items.Add(“查询服务器成功.请选择OPC进行连接“);
button1.Enabled = false;
button2.Enabled = true;
}
catch (Exception ex)
{
listBox1.Items.Add(ex.Message);
}
}
private void button2_Click(object sender EventArgs e)
{
//连接
if (button2.Text==“释放“)
{
//结束:释放各资源
button2.Text = “连接“;
listBox1.Items.Add(“释放成功.不能进行读取数据请重新连接“);
button3.Enabled = false;
try
{
subscription.Dispose();//强制.NET资源回收站回收该subscription的所有资源。
m_server.Disconnect();//断开服务器连接
}
catch (Exception ex)
{
listBox1.Items.Add(ex.Message);
}
}
else
{
try
{
Opc.Server[] servers = m_discovery.GetAvailableServers(Specification.COM_DA_20 textBox1.Text null);
if (servers != null)
{
foreach (Opc.Da.Server server in servers)
{
if (String.Compare(server.Name comboBox1.Text true) == 0)//为true忽略大小写
{
m_server = server;//建立连接。
break;
}
}
}
}
catch (Exception ex)
{
listBox1.Items.Add(ex.Message);
return;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6294 2013-05-10 12:13 bank_pepoleBackupOPC_ClientForm1.cs
文件 10059 2013-05-10 12:13 bank_pepoleBackupOPC_ClientForm1.Designer.cs
文件 5814 2013-05-10 12:13 bank_pepoleBackupOPC_ClientForm1.resx
文件 5975 2013-05-10 13:33 bank_pepoleBackupOPC_ClientOPC_Client.csproj
文件 564 2013-05-10 13:33 bank_pepoleBackupOPC_ClientOPC_Client.csproj.user
文件 468 2012-12-12 14:43 bank_pepoleBackupOPC_ClientProgram.cs
文件 1383 2013-05-10 12:09 bank_pepoleBackupOPC_ClientPropertiesAssemblyInfo.cs
文件 2864 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesResources.Designer.cs
文件 5612 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesResources.resx
文件 1092 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesSettings.Designer.cs
文件 249 2012-12-12 14:43 bank_pepoleBackupOPC_ClientPropertiesSettings.settings
文件 920 2013-05-10 12:14 bank_pepoleBackupOPC_Client.sln
..A..H. 13824 2013-05-14 15:27 bank_pepoleBackupOPC_Client.v11.suo
文件 50449456 2014-11-10 15:29 bank_pepoledocumentdotNetFx40_Full_x86_x64.exe
文件 899584 2015-11-19 22:40 bank_pepoledocumentOPC Core Components 2.00 SDK 2.30.msi
文件 1278001 2015-11-05 15:19 bank_pepoledocumentWin7系统下的OPC运行配置.pdf
文件 4608 2016-01-05 16:32 bank_pepoleOpcEnumLib.dll
文件 200704 2005-11-25 17:07 bank_pepoleOpcNetApi.Com.dll
文件 225280 2005-11-25 17:07 bank_pepoleOpcNetApi.dll
文件 9216 2008-07-09 16:50 bank_pepoleOpcRcw.Cmd.dll
文件 6656 2008-07-09 16:50 bank_pepoleOpcRcw.Comn.dll
文件 20992 2008-07-09 16:50 bank_pepoleOpcRcw.Da.dll
文件 15872 2008-07-09 16:50 bank_pepoleOpcRcw.Dx.dll
文件 12800 2008-07-09 16:50 bank_pepoleOpcRcw.Hda.dll
文件 474 2016-06-23 14:56 bank_pepoleOPC_Clientapp.config
文件 474 2016-06-23 14:56 bank_pepoleOPC_ClientinDebugapp.config
文件 0 2015-11-29 08:56 bank_pepoleOPC_ClientinDebugloglog.txt
文件 26773 2015-12-04 09:47 bank_pepoleOPC_ClientinDebugloglog_2015-12-04.txt
文件 12006 2015-12-08 16:25 bank_pepoleOPC_ClientinDebugloglog_2015-12-08.txt
文件 4624 2015-12-09 12:36 bank_pepoleOPC_ClientinDebugloglog_2015-12-09.txt
............此处省略106个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)