91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

一、源碼特點
      1、C# 寫的歐姆龍PLC通訊程序源碼(DEMO)可按照自己的實際要求進行修改添加,網上找了一些列子,完善的
本源碼也可做通用的串口通信案例使用
二、菜單功能
      可實現功能:
      1、串口通信、通信測試、狀態讀取、數據的讀寫等基本操作
      2、PLC工作模式設定
      3、讀寫DM數據區
      4、置位和復位IR區,讀相應位的狀態
      5、校驗實現:HOST LINK校驗方式
三、注意事項
      1、開發環境為Visual Studio 2012使用.net 4.0開發

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.IO.Ports;
using?System.Linq;
using?System.Text;
using?System.Threading;
using?System.Threading.Tasks;
using?System.Windows.Forms;

namespace?OmronPLC_DEMO
{
????public?partial?class?Frm_Main?:?Form
????{
????????public?Frm_Main()
????????{
????????????InitializeComponent();
????????}
????????#region?聲明變量與定義
????????string?str_StationNo?=?““;
????????#endregion

????????///?
????????///?【按鈕】打開串口
????????///?

????????///?
????????///?
????????private?void?btn_Open_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????if?(sPort1.IsOpen?==?false)
????????????????{
????????????????????sPort1.Open();
????????????????????btn_ControlSport.Text?=?“關閉串口“;
????????????????????btn_ConnectTest.Enabled?=?true;
????????????????????btn_ReadState.Enabled?=?true;
????????????????}
????????????????else
????????????????{
????????????????????sPort1.Close();
????????????????????btn_ControlSport.Text?=?“打開串口“;
????????????????????btn_ConnectTest.Enabled?=?false;
????????????????????btn_ReadState.Enabled?=?false;
????????????????}
????????????}
????????????catch?(Exception)
????????????{
????????????????MessageBox.Show(“端口打開失敗,請檢查端口未被使用!!!“);
????????????}
????????}

????????private?void?btn_ConnectTest_Click(object?sender?EventArgs?e)
????????{
????????????string?str_SendStr?=?““;
????????????string?str_ReadStr?=?““;
????????????if?(sPort1.IsOpen?==?false)
????????????{
????????????????MessageBox.Show(“請打開串口!“);
????????????????return;
????????????}
????????????str_SendStr?=?“@“?+?str_StationNo?+?“TS“?+?“LSLLHD“;
????????????str_SendStr?=?str_SendStr?+?FCS(str_SendStr)?+?“*“?+?“\r“;
????????????str_ReadStr?=?CPM2A(str_ReadStr);
????????????if?(str_ReadStr?==?str_SendStr)
????????????{
????????????????MessageBox.Show(“與PLC通訊正常!“);
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“通訊異常!“?+?str_ReadStr);
????????????}
????????}

????????///?
????????///?數據返回查看
????????///?

????????///?
????????///?數據接收返回
????????private?string?CPM2A(string?inStr)
????????{
????????????char[]?SendBuffer;
????????????char[]?ReadBuffer;
????????????int?length?=?0;
????????????SendBuffer?=?inStr.ToCharArray();
????????????sPort1.Write(SendBuffer?0?SendBuffer.Length);
????????????do
????????????{
????????????????Thread.Sleep(5);
????????????}?while?(sPort1.BytesToRead?????????????Thread.Sleep(20);
????????????length?=?sPort1.BytesToRead;
????????????ReadBuffer?=?new?char[length];
????????????sPort1.Read(ReadBuffer?0?length);
????????????string?instring?=?new?string(ReadBuffer);
????????????return?instring;
????????}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3144??2016-08-16?10:16??51Aspx源碼必讀.txt
?????文件?????????187??2016-08-01?10:15??App.config
?????文件???????24687??2016-08-01?13:47??Frm_Main.Designer.cs
?????文件???????13410??2016-08-01?13:47??Frm_Main.cs
?????文件???????10243??2016-08-01?13:47??Frm_Main.resx
?????文件??????315955??2016-08-01?13:53??OMRON?PLC與上位機的通信協議.docx
?????文件????????3820??2016-08-01?10:46??OmronPLC_DEMO.csproj
?????文件?????????915??2016-08-16?09:47??OmronPLC_DEMO.sln
?????文件???????19968??2016-08-16?09:47??OmronPLC_DEMO.v11.suo
?????文件?????????528??2016-08-01?10:21??Program.cs
?????目錄???????????0??2016-08-16?09:39??Properties\
?????文件????????1358??2016-08-01?10:15??Properties\AssemblyInfo.cs
?????文件????????2878??2016-08-01?10:15??Properties\Resources.Designer.cs
?????文件????????5612??2016-08-01?10:15??Properties\Resources.resx
?????文件????????1100??2016-08-01?10:15??Properties\Settings.Designer.cs
?????文件?????????249??2016-08-01?10:15??Properties\Settings.settings
?????目錄???????????0??2016-08-16?09:39??bin\
?????目錄???????????0??2016-08-16?09:43??bin\Debug\
?????文件???????24576??2016-08-16?09:43??bin\Debug\OmronPLC_DEMO.exe
?????文件?????????187??2016-08-01?10:15??bin\Debug\OmronPLC_DEMO.exe.config
?????文件???????34304??2016-08-16?09:43??bin\Debug\OmronPLC_DEMO.pdb
?????文件???????22984??2016-08-16?09:41??bin\Debug\OmronPLC_DEMO.vshost.exe
?????文件?????????187??2016-08-01?10:15??bin\Debug\OmronPLC_DEMO.vshost.exe.config
?????文件?????????490??2012-06-02?22:34??bin\Debug\OmronPLC_DEMO.vshost.exe.manifest
?????目錄???????????0??2016-08-16?10:16??bin\Release\
?????文件????????4945??2014-04-30?09:10??from.gif
?????文件????????1818??2007-07-03?10:18??high.png
?????文件????????1889??2007-07-03?10:18??low.png
?????目錄???????????0??2016-08-16?09:39??obj\
?????目錄???????????0??2016-08-16?09:43??obj\Debug\
?????文件????????1278??2016-08-01?13:33??obj\Debug\DesignTimeResolveAssemblyReferences.cache
............此處省略14個文件信息

評論

共有 條評論