xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 68KB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-02
  • 語言: C#
  • 標簽: 菱PLC??

資源簡介

c#與三菱FX2N系列PLC進行COM口通訊進行配置,實現數據讀寫

資源截圖

代碼片段和文件信息

/*
?*?由SharpDevelop創建。
?*?用戶:?hp
?*?日期:?2015/6/4
?*?時間:?15:20
?*?
?*?要改變這種模板請點擊?工具|選項|代碼編寫|編輯標準頭文件
?*/
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.IO.Ports;


namespace?串口通信程序1
{
///?
///?Description?of?MainForm.
///?

public?partial?class?MainForm?:?Form
{
public?MainForm()
{

InitializeComponent();

}

public?void?ComboBox1SelectedIndexChanged(object?sender?EventArgs?e)
{

}


public??void?Button1Click(object?sender?EventArgs?e)//點擊按鈕獲取串口
{
try?{
{
serialPort1.DataBits=7;
serialPort1.BaudRate=Convert.ToInt16(?textBox1.Text.ToString());
if?(serialPort1.PortName==comboBox1.Text)//判斷計算機端口是否等于設定端口

{??serialPort1.Open();
this.button1.Text=“關閉端口“;

}

else
{serialPort1.Close();
this.button1.Text=“打開端口“;
}

}
}

catch
{
MessageBox.Show(“請設定波特率“);

}
}

/////以上是打開端口的程序
private?bool??timerIsActive=?false;//最好初始化

public?void?MainFormLoad(object?sender?EventArgs?e)//獲取計算機的端口與設定端口
{

string[]?ports?=?SerialPort.GetPortNames();//獲取計算的可用串口
foreach(string?port?in?ports)
{this.textBox4.Text=port.ToString();
this?.comboBox1.Text=port.ToString();
serialPort1.PortName=textBox4.Text;
}

for?(int?i=0;i<=20;i++)//for循環增加串口
{
comboBox1.Items.Add(“COM“+i.ToString());//下拉框中出現串口
comboBox1.SelectedItem=1;

}

for?(int?q=0;q<=20;q++)//for循環增加發送的數據

{???string?str=Convert.ToString(q16);
if?(str.Length==1)
{str=“0“+str;
str?=“0x“+str;
comboBox2.Items.Add(str);//下拉框中出現串口

}

}

}
public?static?int?Asc(string?character)//字符串轉為ASCII碼
{
if?(character.Length?==?1)
{
System.Text.ASCIIEncoding?asciiEncoding?=?new?System.Text.ASCIIEncoding();
int?intAsciiCode?=?(int)asciiEncoding.GetBytes(character)[0];
return?(intAsciiCode);
}
else
{
throw?new?Exception(“Character?is?not?valid.“);
}

}


public?void?Button3Click(object?sender?EventArgs?e)//發送數據的按鈕
{??byte[]date=new?byte[1];
string?rtu;
try?{
rtu=comboBox2.Text;//發送的數據在下拉框中顯示
rtu=rtu.Substring(22);
date[0]=Convert.ToByte(rtu16);}
catch
{
MessageBox.Show?(“請使用正確的字符串“);

}
date[0]=1;
if(serialPort1.IsOpen)
{
try?{
serialPort1.Write(date01);
this.textBox2.Text=date[0]+““;


}

catch
{
MessageBox.Show?(“端口沒有打開,請檢查端口“);


}
}

else
{
MessageBox.Show?(“端口沒有打開,請檢查端口“);
}
}



public?void?Button4Click(object?sender?EventArgs?e)//發送代碼
{
//02h30h30h30h38h30h39h32h03h35h44h
//STX00080

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-08-16?14:54??串口通信程序1\
?????目錄???????????0??2015-07-09?15:17??串口通信程序1\串口通信程序1\
?????文件???????25372??2015-06-22?17:52??串口通信程序1\串口通信程序1\MainForm.Designer.cs
?????文件???????12204??2015-06-22?19:21??串口通信程序1\串口通信程序1\MainForm.cs
?????文件????????6579??2015-06-22?17:52??串口通信程序1\串口通信程序1\MainForm.resx
?????文件?????????648??2015-06-04?15:20??串口通信程序1\串口通信程序1\Program.cs
?????目錄???????????0??2015-06-04?15:20??串口通信程序1\串口通信程序1\Properties\
?????文件????????1095??2015-06-04?15:20??串口通信程序1\串口通信程序1\Properties\AssemblyInfo.cs
?????目錄???????????0??2015-06-04?15:20??串口通信程序1\串口通信程序1\bin\
?????目錄???????????0??2015-08-16?14:53??串口通信程序1\串口通信程序1\bin\Debug\
?????文件???????21504??2015-08-16?14:53??串口通信程序1\串口通信程序1\bin\Debug\串口通信程序1.exe
?????文件???????34304??2015-08-16?14:53??串口通信程序1\串口通信程序1\bin\Debug\串口通信程序1.pdb
?????文件???????23168??2015-08-16?14:53??串口通信程序1\串口通信程序1\bin\Debug\串口通信程序1.vshost.exe
?????文件?????????490??2010-03-17?22:39??串口通信程序1\串口通信程序1\bin\Debug\串口通信程序1.vshost.exe.manifest
?????目錄???????????0??2015-06-04?15:20??串口通信程序1\串口通信程序1\obj\
?????目錄???????????0??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\
?????文件????????2861??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????6694??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????目錄???????????0??2015-08-16?14:54??串口通信程序1\串口通信程序1\obj\Debug\TempPE\
?????文件?????????180??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\串口通信程序1.MainForm.resources
?????文件?????????816??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\串口通信程序1.csproj.FileListAbsolute.txt
?????文件?????????907??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\串口通信程序1.csproj.GenerateResource.Cache
?????文件????????7562??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\串口通信程序1.csprojResolveAssemblyReference.cache
?????文件???????21504??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\串口通信程序1.exe
?????文件???????34304??2015-08-16?14:53??串口通信程序1\串口通信程序1\obj\Debug\串口通信程序1.pdb
?????文件????????2719??2015-08-16?14:53??串口通信程序1\串口通信程序1\串口通信程序1.csproj
?????文件?????????870??2015-06-04?15:20??串口通信程序1\串口通信程序1.sln
?????文件???????14848??2015-08-16?14:54??串口通信程序1\串口通信程序1.v12.suo

評論

共有 條評論