Exemple #1
0
        private bool ConnectPLC()
        {
            OperateResult connect = siemensTcpNetNew.ConnectServer();

            if (connect.IsSuccess)
            {
                //longConnection = true;
                //LogNet.WriteDebug("PLC连接成功!");
                //this.toolStripStatusLabel2.Text = "PLC连接成功!";
                //btnTongDian.Enabled = true;
                //btnDuanDian.Enabled = true;
                //btnFuWei.Enabled = true;
                //btnJiTing.Enabled = true;
                return(true);
            }
            else
            {
                DisconnectPLC();
                //btnTongDian.Enabled = false;
                //btnDuanDian.Enabled = false;
                //btnFuWei.Enabled = false;
                //btnJiTing.Enabled = false;
                //longConnection = false;

                //LogNet.WriteDebug("PLC连接失败!");
                //this.toolStripStatusLabel2.Text = "PLC连接失败!";
                //ConnectPLC();
                return(false);
            }
        }
Exemple #2
0
        private static bool ConnectPLC()
        {
            OperateResult connect = siemensTcpNet.ConnectServer();

            if (connect.IsSuccess)
            {
                longConnection = true;

                return(true);
            }
            else
            {
                DisconnectPLC();

                longConnection = false;


                return(false);
            }
        }