Example #1
0
        /// <summary>
        /// 停止M2X4裝置 (復歸流程中不停止homeTask)
        /// </summary>
        public void Stop(StopType type, bool isStopTask = true)
        {
            I16 rc = -1;

            if (axisPara.IsActive && axisPara.Enabled)
            {
                if (type == StopType.Emergency)
                {
                    rc = CCMNet.CS_mnet_m204_emg_stop(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo);
                }
                if (type == StopType.SlowDown)
                {
                    rc = CCMNet.CS_mnet_m204_sd_stop(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, axisPara.DecVelM);
                }
                if (type == StopType.CmdWait)
                {
                    //if (this.IsReached || nPos == 0)
                    if (!this.IsBusy || axisPara.StopCmdWaitSeconds == 0)
                    {
                        Stop(StopType.SlowDown, isStopTask);
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            //if (!SpinWait.SpinUntil(() => this.IsReached, 3000))
                            if (!SpinWait.SpinUntil(() => !this.IsBusy, (int)(axisPara.StopCmdWaitSeconds * 1000)))
                            {
                                NotifyLogger.Post("Motor {0} CmdWait Stop Timeout", this.DeviceName);
                            }
                            Stop(StopType.SlowDown, isStopTask);
                        });
                    }
                }
                if (isStopTask)
                {
                    l122M2X4HomeFlow.Stop();
                }
            }
        }