資源簡介
西門子PLC OPC網絡通信示例代碼,建立了group,追加了item,自定義讀寫地址,可以批量讀寫多個字節數據。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?Project208Home;?
namespace?OPCWorker
{
????public?partial?class?Form1?:?Form
????{
????????int?readLen?=?0;?
????????public?Form1()
????????{
????????????InitializeComponent();
????????????textBox_readAddr.Text?=?“2000“;?
????????????textBox_readLen.Text?=?“0“;?
????????????textBox_writeAddr.Text?=?“2000“;?
????????????initPLC();?
????????}
????????private?OPCConnection?con?=?new?OPCConnection();?
????????private?void?initPLC()
????????{
????????????if?(!con.initPLC(“192.168.2.1“?“0201“))
????????????{
????????????????MessageBox.Show(“OPC?connection?error“);?
????????????}
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????byte?[]?data_for_recv?=?new?byte?[250];
????????????int?recv_len?=?con.getRemotePlcData(ref?data_for_recv?re
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????157??2014-11-14?14:43??OPCWorker_1118\OPCWorker\App.config
?????文件??????17408??2014-11-18?11:26??OPCWorker_1118\OPCWorker\bin\Debug\OPCWorker.exe
?????文件????????157??2014-11-14?14:43??OPCWorker_1118\OPCWorker\bin\Debug\OPCWorker.exe.config
?????文件??????42496??2014-11-18?11:26??OPCWorker_1118\OPCWorker\bin\Debug\OPCWorker.pdb
?????文件??????11608??2014-11-18?11:27??OPCWorker_1118\OPCWorker\bin\Debug\OPCWorker.vshost.exe
?????文件????????157??2014-11-14?14:43??OPCWorker_1118\OPCWorker\bin\Debug\OPCWorker.vshost.exe.config
?????文件????????490??2009-08-31?00:40??OPCWorker_1118\OPCWorker\bin\Debug\OPCWorker.vshost.exe.manifest
?????文件??????38400??2014-04-28?16:07??OPCWorker_1118\OPCWorker\bin\Debug\SiemensSMARTOPCdotNETLib.dll
?????文件??????16384??2014-11-18?11:28??OPCWorker_1118\OPCWorker\bin\Release\OPCWorker.exe
?????文件????????157??2014-11-14?14:43??OPCWorker_1118\OPCWorker\bin\Release\OPCWorker.exe.config
?????文件??????34304??2014-11-18?11:28??OPCWorker_1118\OPCWorker\bin\Release\OPCWorker.pdb
?????文件??????11608??2014-11-18?11:28??OPCWorker_1118\OPCWorker\bin\Release\OPCWorker.vshost.exe
?????文件????????157??2014-11-14?14:43??OPCWorker_1118\OPCWorker\bin\Release\OPCWorker.vshost.exe.config
?????文件????????490??2009-08-31?00:40??OPCWorker_1118\OPCWorker\bin\Release\OPCWorker.vshost.exe.manifest
?????文件??????38400??2014-04-28?16:07??OPCWorker_1118\OPCWorker\bin\Release\SiemensSMARTOPCdotNETLib.dll
?????文件???????3934??2014-11-18?11:26??OPCWorker_1118\OPCWorker\Form1.cs
?????文件??????11824??2014-11-18?11:26??OPCWorker_1118\OPCWorker\Form1.Designer.cs
?????文件???????5817??2014-11-18?11:26??OPCWorker_1118\OPCWorker\Form1.resx
?????文件????????789??2014-11-18?10:54??OPCWorker_1118\OPCWorker\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????5513??2014-11-18?11:26??OPCWorker_1118\OPCWorker\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????771??2014-11-18?11:27??OPCWorker_1118\OPCWorker\obj\Debug\OPCWorker.csproj.FileListAbsolute.txt
?????文件????????975??2014-11-18?11:26??OPCWorker_1118\OPCWorker\obj\Debug\OPCWorker.csproj.GenerateResource.Cache
?????文件??????17408??2014-11-18?11:26??OPCWorker_1118\OPCWorker\obj\Debug\OPCWorker.exe
?????文件????????180??2014-11-18?11:26??OPCWorker_1118\OPCWorker\obj\Debug\OPCWorker.Form1.resources
?????文件??????42496??2014-11-18?11:26??OPCWorker_1118\OPCWorker\obj\Debug\OPCWorker.pdb
?????文件????????180??2014-11-18?11:25??OPCWorker_1118\OPCWorker\obj\Debug\OPCWorker.Properties.Resources.resources
?????文件???????4608??2014-11-18?10:54??OPCWorker_1118\OPCWorker\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件???????5517??2014-11-18?11:28??OPCWorker_1118\OPCWorker\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????696??2014-11-18?11:28??OPCWorker_1118\OPCWorker\obj\Release\OPCWorker.csproj.FileListAbsolute.txt
?????文件????????975??2014-11-18?11:28??OPCWorker_1118\OPCWorker\obj\Release\OPCWorker.csproj.GenerateResource.Cache
............此處省略29個文件信息
評論
共有 條評論