Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     server?.Close();
     server = new ModBusTcpServer("127.0.0.1", 502);
     server.Start();
     button1.Enabled = false;
     button2.Enabled = true;
     txt_content.AppendText($"[{DateTime.Now.ToLongTimeString()}]开启仿真模拟服务\r\n");
 }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (server == null)
     {
         server = new ModBusTcpServer("127.0.0.1", 502);
     }
     if (button1.Text == "模拟从机")
     {
         server.Start();
         button1.Text = "模拟服务已启动";
     }
     else
     {
         server.Close();
         button1.Text = "模拟从机";
     }
 }