Ejemplo n.º 1
0
        /// <summary>
        /// 停止扫描
        /// </summary>
        public void Stop()
        {
            IsRuning = false;
            Client.Close();

            if (this.StatusChangeHandler != null)
            {
                var arg = new StatusChangeEventArgs();
                arg.PlcID  = this.PlcId;
                arg.Status = Client.IsConnected;
                this.StatusChangeHandler(this, arg);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 连接PLC
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            if (!Client.IsConnected)
            {
                try
                {
                    Client.Open();
                }
                catch (Exception ex)
                {
                    return(false);
                }

                if (this.StatusChangeHandler != null)
                {
                    var arg = new StatusChangeEventArgs();
                    arg.PlcID  = this.PlcId;
                    arg.Status = Client.IsConnected;
                    this.StatusChangeHandler(this, arg);
                }
            }
            return(Client.IsConnected);
        }