西门子 S7 200 Smart TCP 通讯控制
short re = 0;
string restr = "";
re = PLC.EntLink(txtLocalIP.Text.Trim(), Convert.ToUInt16(txtLocalPort.Text), txtRemoteIP.Text.Trim(), Convert.ToUInt16(txtRemotePort.Text), Convert.ToUInt16(0), Convert.ToUInt16(2), "DEMO", ref Handle1);
txtReLink.Text = re.ToString();
if (re == 0)
{
EntLink = true;
MessageBox.Show("PLC联接成功!");
}
else
{
EntLink = false;
MessageBox.Show("PLC联接失败: " + restr);
}
1