private async void button1_Click(object sender, EventArgs e) { if (!int.TryParse(textBox2.Text, out int port)) { MessageBox.Show(DemoUtils.PortInputWrong); return; } siemensPPI?.ConnectClose( ); siemensPPI = new SiemensPPIOverTcp(textBox1.Text, port); try { siemensPPI.Station = byte.Parse(textBox15.Text); OperateResult connect = await siemensPPI.ConnectServerAsync( ); if (connect.IsSuccess) { MessageBox.Show(HslCommunication.StringResources.Language.ConnectedSuccess); button2.Enabled = true; button1.Enabled = false; panel2.Enabled = true; userControlReadWriteOp1.SetReadWriteNet(siemensPPI, "V100", true); } else { MessageBox.Show(HslCommunication.StringResources.Language.ConnectedFailed); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override void DeviceDiscnn() { siemensPPI?.ConnectClose(); }