資源簡介
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
//引用Twincat.ads和Sustem.IO
using?TwinCAT.Ads;
using?System.IO;
using?System.Runtime.InteropServices;
namespace?writeread
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
???????
????????//定義所需變量
????????private?bool??writebool?=false;
????????private?bool??readbool=false?;
????????private?short??writeint?=?0;
????????private?short??readint?=?0;
????????private?int?writelong?=?0;
????????private?int?readlong?=?0;
????????private?float?writereal?=?0;
????????private?float?readreal?=?0;
????????private?double?writelreal?=?0;
????????private?double?readlreal?=?0;
????????
????????private?string?writestring?=?““;
????????private?string?readstring?=?““;
????????private?int??stringlen?=?0;
????????//定義結構體類型
????????public?struct?structtype
????????{
????????????public??bool?s1;
????????????public?bool?dummy1;
????????????public?bool?dummy2;
????????????public?bool?dummy3;
????????????public??short?s2?;
????????????public?short?dummy4;??
????????????????
????????????public??int?s3?;
?????????????public??float?s4;
????????????public??double?s5?;
????????}
????????//定義結構體類型
????????[StructLayout(LayoutKind.Sequential?Pack?=?1)]
????????public?struct?structtype1
????????{
????????????[MarshalAs(UnmanagedType.I1)]
????????????public?bool?s1;
???????????//?[MarshalAs(UnmanagedType.I2)]
????????????public?short?s2;
??????????//??[MarshalAs(UnmanagedType.I4)]
????????????public?int?s3;
??????????//??[MarshalAs(UnmanagedType.R4)]
????????????public?float?s4;
??????????//??[MarshalAs(UnmanagedType.R8)]
????????????public?double?s5;
????????}
????????//實例化結構體
????????private??structtype?structtest?=new?structtype?();
????????private?structtype1?structtest1?=?new?structtype1();
????????//定義數組,含有五個元素
????????private?short[]?arraytest?=?new?short[5];
????????//定義句柄變量
????????private?int?hvar?=?new?int();
????????//通訊數據定義
????????private?TcAdsClient?tcclient;//定義通訊協議
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????//通訊協議
????????????tcclient?=?new?TcAdsClient();
????????????tcclient.Connect(“192.168.1.107.1.1“851);
????????????int?i?=?0;
????????}
????????//writebool
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????if?(writebool?==?true)
????????????{
????????????????writebool?=?false;
????????????}
????????????else
????????????{
????????????????writebool?=?true;
????????????}
????????????
????????????try
????????????{
????????????????hvar?=?tcclient.CreateVariableHandle(“MAIN.BoolTest“);
????????????????tcclient.WriteAny(hvar?writebool?);
????????????????tcclient.DeleteVariableHandle(hvar);
????????????}
????????????catch?(Exception?er
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????57856??2021-01-06?15:20??c#程序\writeread\.vs\writeread\v14\.suo
????..A..H.?????57856??2020-12-30?17:19??c#程序\writeread\.vs\writeread\v15\.suo
?????文件??????????0??2020-12-30?17:19??c#程序\writeread\.vs\writeread\v15\Server\sqlite3\db.lock
?????文件???????4096??2020-12-30?17:19??c#程序\writeread\.vs\writeread\v15\Server\sqlite3\storage.ide
?????文件??????32768??2020-12-30?17:19??c#程序\writeread\.vs\writeread\v15\Server\sqlite3\storage.ide-shm
?????文件?????593312??2020-12-30?17:19??c#程序\writeread\.vs\writeread\v15\Server\sqlite3\storage.ide-wal
?????文件?????401408??2017-07-26?08:31??c#程序\writeread\writeread\bin\Debug\TwinCAT.Ads.dll
?????文件????1226008??2017-07-26?08:31??c#程序\writeread\writeread\bin\Debug\TwinCAT.Ads.xm
?????文件??????27136??2019-12-02?11:00??c#程序\writeread\writeread\bin\Debug\writeread.exe
?????文件??????36352??2019-12-02?11:00??c#程序\writeread\writeread\bin\Debug\writeread.pdb
?????文件??????21680??2021-01-06?15:18??c#程序\writeread\writeread\bin\Debug\writeread.vshost.exe
?????文件????????490??2019-03-19?12:46??c#程序\writeread\writeread\bin\Debug\writeread.vshost.exe.manifest
?????文件??????15074??2020-07-27?09:09??c#程序\writeread\writeread\Form1.cs
?????文件??????40119??2018-12-23?13:50??c#程序\writeread\writeread\Form1.Designer.cs
?????文件???????6181??2018-12-23?13:50??c#程序\writeread\writeread\Form1.resx
?????文件???????1209??2020-12-17?09:18??c#程序\writeread\writeread\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6222??2021-01-06?15:18??c#程序\writeread\writeread\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????32768??2011-07-10?21:41??c#程序\writeread\writeread\obj\Debug\Interop.TcAdsDll.dll
?????文件???????4608??2015-06-09?15:55??c#程序\writeread\writeread\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件?????????42??2020-12-30?17:18??c#程序\writeread\writeread\obj\Debug\writeread.csproj.CoreCompileInputs.cache
?????文件??????10430??2021-01-06?15:18??c#程序\writeread\writeread\obj\Debug\writeread.csproj.FileListAbsolute.txt
?????文件????????847??2018-12-23?13:50??c#程序\writeread\writeread\obj\Debug\writeread.csproj.GenerateResource.Cache
?????文件????????502??2011-07-10?21:41??c#程序\writeread\writeread\obj\Debug\writeread.csproj.ResolveComReference.cache
?????文件??????21081??2020-12-30?17:18??c#程序\writeread\writeread\obj\Debug\writeread.csprojAssemblyReference.cache
?????文件???????3771??2019-12-02?11:00??c#程序\writeread\writeread\obj\Debug\writeread.csprojResolveAssemblyReference.cache
?????文件??????27136??2019-12-02?11:00??c#程序\writeread\writeread\obj\Debug\writeread.exe
?????文件????????180??2019-12-02?11:00??c#程序\writeread\writeread\obj\Debug\writeread.Form1.resources
?????文件??????36352??2019-12-02?11:00??c#程序\writeread\writeread\obj\Debug\writeread.pdb
?????文件????????180??2019-12-02?11:00??c#程序\writeread\writeread\obj\Debug\writeread.Properties.Resources.resources
?????文件????????481??2011-07-10?20:59??c#程序\writeread\writeread\Program.cs
............此處省略28個文件信息
- 上一篇:Ymodem窗體應用程序
- 下一篇:EMS企業進銷存源碼(附數據庫)
評論
共有 條評論