private void button1_Click(object sender, EventArgs e) { if (!int.TryParse(textBox2.Text, out int port)) { MessageBox.Show(DemoUtils.PortInputWrong); return; } try { lSisServer = new HslCommunication.Profinet.LSIS.LSisServer( ); // 实例化对象 //lSisServer.LogNet = new HslCommunication.LogNet.LogNetSingle( "logs.txt" ); // 配置日志信息 //lSisServer.LogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile; lSisServer.OnDataReceived += BusTcpServer_OnDataReceived; lSisServer.ServerStart(port); button1.Enabled = false; panel2.Enabled = true; button4.Enabled = true; button11.Enabled = true; timerSecond?.Dispose( ); timerSecond = new System.Windows.Forms.Timer( ); timerSecond.Interval = 1000; timerSecond.Tick += TimerSecond_Tick; timerSecond.Start( ); } catch (Exception ex) { MessageBox.Show(ex.Message); } }