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(cboxModel.Text);                       // 实例化对象
                //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);
            }
        }
Exemple #2
0
        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(cboxModel.Text);                       // 实例化对象
                lSisServer.OnDataReceived += BusTcpServer_OnDataReceived;

                lSisServer.ServerStart(port);

                userControlReadWriteServer1.SetReadWriteServer(lSisServer, "MB100");
                button1.Enabled  = false;
                panel2.Enabled   = true;
                button11.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }