private void btnDisConnect_Click(object sender, EventArgs e) { m_siemensTcpNet.ConnectClose(); btnConnect.Enabled = true; btnDisConnect.Enabled = false; panel3.Enabled = false; }
private void button2_Click(object sender, EventArgs e) { // 断开连接 siemensTcpNet.ConnectClose( ); button2.Enabled = false; button1.Enabled = true; panel2.Enabled = false; }
/// <summary> /// 断开连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_DisConnect_Click(object sender, EventArgs e) { //断开连接 siemensTcpNet.ConnectClose(); btn_Connect.Enabled = true; btn_DisConnect.Enabled = false; panel2.Enabled = false; }
private void TheadConnection() { SiemensS7Net siemensS7 = new SiemensS7Net(SiemensPLCS.S1200); siemensS7.ConnectTimeOut = 10000; siemensS7.ConnectServer( ); siemensS7.ConnectClose( ); }
public void Dispose() { OperateResult operate = SiemensTcpNet.ConnectClose(); if (!operate.IsSuccess) { throw new Exception("关闭失败!" + operate.Message); } }
public void ClosePLC() { if (_SiementsTcpNet != null) { _SiementsTcpNet.ConnectClose(); _SiementsTcpNet = null; PLCIsopen = false; } }
/// <summary> /// 停止 /// </summary> public override void DoStop() { try { this.isClose = true; foreach (LD.Config.PlcTypeItem item in this.config.PlcTypeItems) { if (!item.IsActive || !item.IsConnected) { continue; } switch (item.DevType) { case Common.DeviceType.S1200: case Common.DeviceType.S1500: case Common.DeviceType.S200: case Common.DeviceType.S200Smart: case Common.DeviceType.S300: case Common.DeviceType.S400: SiemensS7Net plc = (SiemensS7Net)item.Tag; plc.ConnectClose(); break; case Common.DeviceType.ModbusTcp: ModbusTcpNet mdTcp = (ModbusTcpNet)item.Tag; mdTcp.ConnectClose(); break; case Common.DeviceType.ModbusRtu: ModbusRtu mdRtu = (ModbusRtu)item.Tag; mdRtu.Close(); break; default: break; } item.IsConnected = false; } foreach (LD.Config.PlcDataItem plc in this.config.PlcDataItems) { plc.PropertyChanged -= new PropertyChangedEventHandler(plc_PropertyChanged); plc.PropertyChanged -= new PropertyChangedEventHandler(Ui.frmSiemens.Instance.plc_PropertyChanged); } this.PlcValueChanged -= new LD.Config.PlcValueChangeEventHandler(PlcClient_PlcValueChanged); } catch (Exception ex) { throw new StopException(this.ToString(), ex.ToString()); } }
private void button2_Click(object sender, EventArgs e) { // 断开连接 ,带有窗口确定 if (System.Windows.Forms.DialogResult.Yes != MessageBox.Show("是否确认断开PLC连接", "确认", MessageBoxButtons.YesNo)) { siemensTcpNet.ConnectClose(); } button2.Enabled = false; button1.Enabled = true; panel2.Enabled = false; timer.Stop(); }
public bool Stop() { try { melsecMc.ConnectClose(); melsecMc.Dispose(); if (processor != null) { processor.Abort(); //解决线程过多情况,因为线程执行Abort,状态是AbortRequested,还是会存在继续执行 while (processor.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
//SiemensPLC初始化 void DoInitS7Plc(LD.Config.PlcTypeItem item) { //if (item.Timer == null) item.Timer = new System.Timers.Timer(); //item.Timer.Enabled = false; //item.Timer.Interval = 1000; //item.Timer.Elapsed += TimerCheck_Tick; SiemensS7Net S7PLC = new SiemensS7Net((SiemensPLCS)item.DevType); S7PLC.ConnectTimeOut = item.ConnectOutTime; S7PLC.Rack = byte.Parse(item.Rack); S7PLC.Slot = byte.Parse(item.Slot); System.Net.IPAddress address; if (!System.Net.IPAddress.TryParse(item.IP, out address)) { System.Windows.Forms.MessageBox.Show(string.Format("{0} input wrong!", item.IP)); return; } int port; if (!int.TryParse(item.Port.ToString(), out port)) { System.Windows.Forms.MessageBox.Show(string.Format("port {0} input wrong!", item.Port)); return; } S7PLC.IpAddress = item.IP; S7PLC.Port = port; item.Tag = S7PLC; if (S7PLC != null) { S7PLC.ConnectClose(); } OperateResult connect = S7PLC.ConnectServer(); if (connect.IsSuccess) { item.IsConnected = true; //Plcs.Add(item.DevName, S7PLC); } else { item.IsConnected = false; //Plcs.Add(item, S7PLC); } }
//连接监控 public void TimerCheck_Tick(object sender, EventArgs e) { IDictionaryEnumerator enumerator = Plcs.GetEnumerator(); while (enumerator.MoveNext()) { SiemensS7Net plc = enumerator.Value as SiemensS7Net; if (plc != null) { if (!plc.ReadBool("M0").IsSuccess) { plc.ConnectClose(); } } } }
private void btnConnect_Click(object sender, EventArgs e) { try { string IP = txtIP.Text.Trim(); if (string.IsNullOrEmpty(IP)) { MessageBox.Show("请输入IP地址!"); return; } string Port = txtPort.Text.Trim(); if (string.IsNullOrEmpty(Port)) { MessageBox.Show("请输入端口号!"); return; } OperateResult connect; using (WaitDialogForm dialog = new WaitDialogForm("正在连接,请稍后...", "提示")) { int port = Convert.ToInt16(Port); melsecMc = new SiemensS7Net(SiemensPLCS.S1200) { IpAddress = IP, Port = port, ConnectTimeOut = 5000, ReceiveTimeOut = 5000 }; melsecMc.ConnectClose(); connect = melsecMc.ConnectServer(); } if (!connect.IsSuccess) { MessageBox.Show("连接失败:" + connect.Message); return; } else { MessageBox.Show("连接成功"); btnConnect.Enabled = false; btnRead.Enabled = true; btnOff.Enabled = true; return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDisconnect_Click(object sender, EventArgs e) { try { plc.ConnectClose(); } catch (Exception error) { MessageBox.Show(error.Message); } isConnected = false; btnConnect.Enabled = true; btnDisconnect.Enabled = false; edtIPAddress.Enabled = true; edtPort.Enabled = true; edtRack.Enabled = true; edtSlot.Enabled = true; }
public bool ConnClose() { if (SiemensTcpNet != null) { OperateResult connect = SiemensTcpNet.ConnectClose(); if (connect.IsSuccess) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// 断开连接 /// </summary> private void Disconnect() { try { OperateResult rlt = siemensTcpNet.ConnectClose(); if (!rlt.IsSuccess) { _log.Error($"ErrCode={rlt.ErrorCode}|ErrText={rlt.Message}"); } } catch (Exception error) { _log.Error(error.Message, error); } finally { isConnected = false; } }
public void ClassTest2( ) { #region Usage2 // 实例化对象,指定PLC的ip地址和端口号 SiemensS7Net siemens = new SiemensS7Net(SiemensPLCS.S1200, " 192.168.1.110"); // 连接对象 OperateResult connect = siemens.ConnectServer( ); if (!connect.IsSuccess) { Console.WriteLine("connect failed:" + connect.Message); return; } // 举例读取M100的值 short M100 = siemens.ReadInt16("M100").Content; siemens.ConnectClose( ); #endregion }
private void btnOff_Click(object sender, EventArgs e) { try { if (melsecMc != null) { OperateResult connect = melsecMc.ConnectClose(); if (!connect.IsSuccess) { MessageBox.Show("关闭连接失败:" + connect.Message); return; } else { MessageBox.Show("关闭连接成功!"); this.btnConnect.Enabled = true; this.btnOff.Enabled = false; this.btnRead.Enabled = false; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static async void SiemensUnitTest( ) { SiemensS7Net plc = new SiemensS7Net(SiemensPLCS.S1200, "192.168.8.12"); if (!plc.ConnectServer( ).IsSuccess) { Console.WriteLine("无法连接PLC,将跳过单元测试。等待网络正常时,再进行测试"); return; } Console.WriteLine("测试开始"); // 开始单元测试,从bool类型开始测试 string address = "M300"; // short类型 short[] shortTmp = new short[] { 123, 423, -124, 5313, 2361 }; byte[] byteTmp = new byte[] { 0x1A, 0x2B, 0x36, 0x18, 0x52, 0xD1 }; // 异步short类型 for (int j = 0; j < 100; j++) { if (!(await plc.WriteAsync(address, byteTmp)).IsSuccess) { Console.WriteLine("Error!"); return; } byte[] readBytes = (await plc.ReadAsync(address, (ushort)byteTmp.Length)).Content; for (int i = 0; i < readBytes.Length; i++) { if (byteTmp[i] != readBytes[i]) { Console.WriteLine("Error!"); return; } } if (!(await plc.WriteAsync(address, (short)12345)).IsSuccess) { Console.WriteLine("Error!"); return; } if ((await plc.ReadInt16Async(address)).Content != 12345) { Console.WriteLine("Error!"); return; } if (!(await plc.WriteAsync(address, shortTmp)).IsSuccess) { Console.WriteLine("Error!"); return; } short[] readShort = (await plc.ReadInt16Async(address, (ushort)shortTmp.Length)).Content; for (int i = 0; i < readShort.Length; i++) { if (readShort[i] != shortTmp[i]) { Console.WriteLine("Error!"); return; } } } plc.ConnectClose( ); Console.WriteLine("测试完成"); }
public async Task SiemensUnitTest( ) { SiemensS7Net plc = new SiemensS7Net(SiemensPLCS.S1200, "192.168.8.12"); // "192.168.8.12" if (!plc.ConnectServer( ).IsSuccess) { Console.WriteLine("无法连接PLC,将跳过单元测试。等待网络正常时,再进行测试"); return; } // 开始单元测试,从bool类型开始测试 string address = "M200.4"; Assert.IsTrue(plc.Write(address, true).IsSuccess); Assert.IsTrue(plc.ReadBool(address).Content == true); address = "M300"; // short类型 Assert.IsTrue(plc.Write(address, (short)12345).IsSuccess); Assert.IsTrue(plc.ReadInt16(address).Content == 12345); short[] shortTmp = new short[] { 123, 423, -124, 5313, 2361 }; Assert.IsTrue(plc.Write(address, shortTmp).IsSuccess); short[] readShort = plc.ReadInt16(address, (ushort)shortTmp.Length).Content; for (int i = 0; i < readShort.Length; i++) { Assert.IsTrue(readShort[i] == shortTmp[i]); } // 异步short类型 for (int j = 0; j < 100; j++) { Assert.IsTrue((await plc.WriteAsync(address, (short)12345)).IsSuccess); Assert.IsTrue((await plc.ReadInt16Async(address)).Content == 12345); Assert.IsTrue((await plc.WriteAsync(address, shortTmp)).IsSuccess); readShort = (await plc.ReadInt16Async(address, (ushort)shortTmp.Length)).Content; for (int i = 0; i < readShort.Length; i++) { Assert.IsTrue(readShort[i] == shortTmp[i]); } } // ushort类型 Assert.IsTrue(plc.Write(address, (ushort)51234).IsSuccess); Assert.IsTrue(plc.ReadUInt16(address).Content == 51234); ushort[] ushortTmp = new ushort[] { 5, 231, 12354, 5313, 12352 }; Assert.IsTrue(plc.Write(address, ushortTmp).IsSuccess); ushort[] readUShort = plc.ReadUInt16(address, (ushort)ushortTmp.Length).Content; for (int i = 0; i < ushortTmp.Length; i++) { Assert.IsTrue(readUShort[i] == ushortTmp[i]); } // int类型 Assert.IsTrue(plc.Write(address, 12342323).IsSuccess); Assert.IsTrue(plc.ReadInt32(address).Content == 12342323); int[] intTmp = new int[] { 123812512, 123534, 976124, -1286742 }; Assert.IsTrue(plc.Write(address, intTmp).IsSuccess); int[] readint = plc.ReadInt32(address, (ushort)intTmp.Length).Content; for (int i = 0; i < intTmp.Length; i++) { Assert.IsTrue(readint[i] == intTmp[i]); } // uint类型 Assert.IsTrue(plc.Write(address, (uint)416123237).IsSuccess); Assert.IsTrue(plc.ReadUInt32(address).Content == (uint)416123237); uint[] uintTmp = new uint[] { 81623123, 91712749, 91273123, 123, 21242, 5324 }; Assert.IsTrue(plc.Write(address, uintTmp).IsSuccess); uint[] readuint = plc.ReadUInt32(address, (ushort)uintTmp.Length).Content; for (int i = 0; i < uintTmp.Length; i++) { Assert.IsTrue(readuint[i] == uintTmp[i]); } // float类型 Assert.IsTrue(plc.Write(address, 123.45f).IsSuccess); Assert.IsTrue(plc.ReadFloat(address).Content == 123.45f); float[] floatTmp = new float[] { 123, 5343, 1.45f, 563.3f, 586.2f }; Assert.IsTrue(plc.Write(address, floatTmp).IsSuccess); float[] readFloat = plc.ReadFloat(address, (ushort)floatTmp.Length).Content; for (int i = 0; i < readFloat.Length; i++) { Assert.IsTrue(floatTmp[i] == readFloat[i]); } // double类型 Assert.IsTrue(plc.Write(address, 1234.5434d).IsSuccess); Assert.IsTrue(plc.ReadDouble(address).Content == 1234.5434d); double[] doubleTmp = new double[] { 1.4213d, 1223d, 452.5342d, 231.3443d }; Assert.IsTrue(plc.Write(address, doubleTmp).IsSuccess); double[] readDouble = plc.ReadDouble(address, (ushort)doubleTmp.Length).Content; for (int i = 0; i < doubleTmp.Length; i++) { Assert.IsTrue(readDouble[i] == doubleTmp[i]); } // long类型 Assert.IsTrue(plc.Write(address, 123617231235123L).IsSuccess); Assert.IsTrue(plc.ReadInt64(address).Content == 123617231235123L); long[] longTmp = new long[] { 12312313123L, 1234L, 412323812368L, 1237182361238123 }; Assert.IsTrue(plc.Write(address, longTmp).IsSuccess); long[] readLong = plc.ReadInt64(address, (ushort)longTmp.Length).Content; for (int i = 0; i < longTmp.Length; i++) { Assert.IsTrue(readLong[i] == longTmp[i]); } // ulong类型 Assert.IsTrue(plc.Write(address, 1283823681236123UL).IsSuccess); Assert.IsTrue(plc.ReadUInt64(address).Content == 1283823681236123UL); ulong[] ulongTmp = new ulong[] { 21316UL, 1231239127323UL, 1238612361283123UL }; Assert.IsTrue(plc.Write(address, ulongTmp).IsSuccess); ulong[] readULong = plc.ReadUInt64(address, (ushort)ulongTmp.Length).Content; for (int i = 0; i < readULong.Length; i++) { Assert.IsTrue(readULong[i] == ulongTmp[i]); } // string类型 Assert.IsTrue(plc.Write(address, "123123").IsSuccess); Assert.IsTrue(plc.ReadString(address).Content == "123123"); // 中文,编码可以自定义 Assert.IsTrue(plc.Write(address, "测试信息123", Encoding.Unicode).IsSuccess); Assert.IsTrue(plc.ReadString(address, 14, Encoding.Unicode).Content == "测试信息123"); // byte类型 byte[] byteTmp = new byte[] { 0x4F, 0x12, 0x72, 0xA7, 0x54, 0xB8 }; Assert.IsTrue(plc.Write(address, byteTmp).IsSuccess); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(plc.Read(address, 6).Content, byteTmp)); // 批量写入测试 short[] shortValues = new short[50]; for (int i = 0; i < 50; i++) { shortValues[i] = (short)(i * 5 - 3); } Assert.IsTrue(plc.Write("M300", shortValues).IsSuccess); string[] addresses = new string[50]; ushort[] lengths = new ushort[50]; for (int i = 0; i < 50; i++) { addresses[i] = "M" + (i * 2 + 300); lengths[i] = 2; } OperateResult <byte[]> readBytes = plc.Read(addresses, lengths); Assert.IsTrue(readBytes.IsSuccess); Assert.IsTrue(readBytes.Content.Length == 100); for (int i = 0; i < 50; i++) { short shortTmp1 = plc.ByteTransform.TransInt16(readBytes.Content, i * 2); Assert.IsTrue(shortValues[i] == shortTmp1); } // 自定义类的测试 DataTest test = new DataTest( ) { Data1 = 425, Data2 = 123.53f, Data3 = new byte[] { 2, 4, 6, 8, 100, 123 } }; Assert.IsTrue(plc.Write(test).IsSuccess); Assert.IsTrue(plc.ReadInt16("M100").Content == 425); Assert.IsTrue(plc.ReadFloat("M200").Content == 123.53f); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(plc.Read("M300", 6).Content, test.Data3)); DataTest test1 = plc.Read <DataTest>( ).Content; Assert.IsTrue(test1.Data1 == test.Data1); Assert.IsTrue(test1.Data2 == test.Data2); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(test1.Data3, test.Data3)); // 大数据写入测试 Assert.IsTrue(plc.Write("M100", (short)12345).IsSuccess); Assert.IsTrue(plc.Write("M500", (short)12345).IsSuccess); Assert.IsTrue(plc.Write("M800", (short)12345).IsSuccess); OperateResult <short[]> readBatchResult = plc.ReadInt16("M100", 351); Assert.IsTrue(readBatchResult.IsSuccess); Assert.IsTrue(readBatchResult.Content[0] == 12345); Assert.IsTrue(readBatchResult.Content[200] == 12345); Assert.IsTrue(readBatchResult.Content[350] == 12345); plc.ConnectClose( ); }
/// <summary> /// 关闭PLC /// </summary> /// <returns></returns> public bool HsServerCloseConnect() { OperateResult disconnect = sPLC.ConnectClose(); return(disconnect.IsSuccess); }
/// <summary> /// 断开连接,也就是关闭了长连接,如果再去请求数据,就变成了短连接 /// </summary> private void DisconnectPLC2_Write() { siemensTcpNet2_Write.ConnectClose(); }
public void ConnectClose() { siemensS7Net.ConnectClose(); }
public void MelsecUnitTest( ) { SiemensS7Net plc = new SiemensS7Net(SiemensPLCS.S1200, "192.168.8.12"); if (!plc.ConnectServer( ).IsSuccess) { Console.WriteLine("无法连接PLC,将跳过单元测试。等待网络正常时,再进行测试"); return; } // 开始单元测试,从bool类型开始测试 string address = "M200.4"; Assert.IsTrue(plc.Write(address, true).IsSuccess); Assert.IsTrue(plc.ReadBool(address).Content == true); address = "M300"; // short类型 Assert.IsTrue(plc.Write(address, (short)12345).IsSuccess); Assert.IsTrue(plc.ReadInt16(address).Content == 12345); short[] shortTmp = new short[] { 123, 423, -124, 5313, 2361 }; Assert.IsTrue(plc.Write(address, shortTmp).IsSuccess); short[] readShort = plc.ReadInt16(address, (ushort)shortTmp.Length).Content; for (int i = 0; i < readShort.Length; i++) { Assert.IsTrue(readShort[i] == shortTmp[i]); } // ushort类型 Assert.IsTrue(plc.Write(address, (ushort)51234).IsSuccess); Assert.IsTrue(plc.ReadUInt16(address).Content == 51234); ushort[] ushortTmp = new ushort[] { 5, 231, 12354, 5313, 12352 }; Assert.IsTrue(plc.Write(address, ushortTmp).IsSuccess); ushort[] readUShort = plc.ReadUInt16(address, (ushort)ushortTmp.Length).Content; for (int i = 0; i < ushortTmp.Length; i++) { Assert.IsTrue(readUShort[i] == ushortTmp[i]); } // int类型 Assert.IsTrue(plc.Write(address, 12342323).IsSuccess); Assert.IsTrue(plc.ReadInt32(address).Content == 12342323); int[] intTmp = new int[] { 123812512, 123534, 976124, -1286742 }; Assert.IsTrue(plc.Write(address, intTmp).IsSuccess); int[] readint = plc.ReadInt32(address, (ushort)intTmp.Length).Content; for (int i = 0; i < intTmp.Length; i++) { Assert.IsTrue(readint[i] == intTmp[i]); } // uint类型 Assert.IsTrue(plc.Write(address, (uint)416123237).IsSuccess); Assert.IsTrue(plc.ReadUInt32(address).Content == (uint)416123237); uint[] uintTmp = new uint[] { 81623123, 91712749, 91273123, 123, 21242, 5324 }; Assert.IsTrue(plc.Write(address, uintTmp).IsSuccess); uint[] readuint = plc.ReadUInt32(address, (ushort)uintTmp.Length).Content; for (int i = 0; i < uintTmp.Length; i++) { Assert.IsTrue(readuint[i] == uintTmp[i]); } // float类型 Assert.IsTrue(plc.Write(address, 123.45f).IsSuccess); Assert.IsTrue(plc.ReadFloat(address).Content == 123.45f); float[] floatTmp = new float[] { 123, 5343, 1.45f, 563.3f, 586.2f }; Assert.IsTrue(plc.Write(address, floatTmp).IsSuccess); float[] readFloat = plc.ReadFloat(address, (ushort)floatTmp.Length).Content; for (int i = 0; i < readFloat.Length; i++) { Assert.IsTrue(floatTmp[i] == readFloat[i]); } // double类型 Assert.IsTrue(plc.Write(address, 1234.5434d).IsSuccess); Assert.IsTrue(plc.ReadDouble(address).Content == 1234.5434d); double[] doubleTmp = new double[] { 1.4213d, 1223d, 452.5342d, 231.3443d }; Assert.IsTrue(plc.Write(address, doubleTmp).IsSuccess); double[] readDouble = plc.ReadDouble(address, (ushort)doubleTmp.Length).Content; for (int i = 0; i < doubleTmp.Length; i++) { Assert.IsTrue(readDouble[i] == doubleTmp[i]); } // long类型 Assert.IsTrue(plc.Write(address, 123617231235123L).IsSuccess); Assert.IsTrue(plc.ReadInt64(address).Content == 123617231235123L); long[] longTmp = new long[] { 12312313123L, 1234L, 412323812368L, 1237182361238123 }; Assert.IsTrue(plc.Write(address, longTmp).IsSuccess); long[] readLong = plc.ReadInt64(address, (ushort)longTmp.Length).Content; for (int i = 0; i < longTmp.Length; i++) { Assert.IsTrue(readLong[i] == longTmp[i]); } // ulong类型 Assert.IsTrue(plc.Write(address, 1283823681236123UL).IsSuccess); Assert.IsTrue(plc.ReadUInt64(address).Content == 1283823681236123UL); ulong[] ulongTmp = new ulong[] { 21316UL, 1231239127323UL, 1238612361283123UL }; Assert.IsTrue(plc.Write(address, ulongTmp).IsSuccess); ulong[] readULong = plc.ReadUInt64(address, (ushort)ulongTmp.Length).Content; for (int i = 0; i < readULong.Length; i++) { Assert.IsTrue(readULong[i] == ulongTmp[i]); } // string类型 Assert.IsTrue(plc.Write(address, "123123").IsSuccess); Assert.IsTrue(plc.ReadString(address, 6).Content == "123123"); // byte类型 byte[] byteTmp = new byte[] { 0x4F, 0x12, 0x72, 0xA7, 0x54, 0xB8 }; Assert.IsTrue(plc.Write(address, byteTmp).IsSuccess); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(plc.Read(address, 6).Content, byteTmp)); plc.ConnectClose( ); }
public override void Disconnect() { PLC?.ConnectClose(); }
public void Dispose() { siemensTcpNet.ConnectClose(); siemensTcpNet = null; }
public override void DeviceDiscnn() { siemensTcpNet.ConnectClose(); }
private void userButton26_Click(object sender, EventArgs e) { siemensTcpNet.ConnectClose( ); }
/// <summary> /// 断开连接,也就是关闭了长连接,如果再去请求数据,就变成了短连接 /// </summary> private static void DisconnectPLC1() { siemensTcpNet1.ConnectClose(); }
/// <summary> /// 断开连接,也就是关闭了长连接,如果再去请求数据,就变成了短连接 /// </summary> private void DisconnectPLC2() { siemensTcpNet2_Read.ConnectClose(); }
/// <summary> /// 断开连接,也就是关闭了长连接,如果再去请求数据,就变成了短连接 /// </summary> public static void DisconnectPLC() { siemensS7Net.ConnectClose(); }