/// <summary> /// 点-点运动 等待停止 /// </summary> /// <param name="timeout"></param> /// <param name="pos"></param> /// <param name="speed"></param> /// <returns></returns> public short GoPosTillStop(int timeout, double pos, HostarSpeed speed) { if (double.IsNaN(pos) || double.IsInfinity(pos)) { return(-1); } Stopwatch a = new Stopwatch(); short rtn = 0; var sd = speed.GetActSpeed(this.AxisRatio); this.AxisMoveTrap_Abs(pos * this.AxisRatio, sd.StartSpeed, sd.MaxSpeed, sd.AccTime, sd.DecTime); a.Start(); while (!this.AxisReach(pos)) { Thread.Sleep(1); if (a.ElapsedMilliseconds > timeout || MotionHelper.Instance.Emg) { this.StopAxis(); this.ClearAxisSts(); return(-1); } } return(rtn); }
private short GoHomeWithInput(int timeout, HomeMode homeMode, bool direction, HostarSpeed goLimit, HostarSpeed goHome, IOInput limit) { short rtn = 0; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.StopAxis(); this.GetAxisSts(); #region 到轴的极限位置 if (!limit.GetIO()) { rtn = this.Jog(goLimit, !direction); // 到极限 while (!limit.GetIO()) { Thread.Sleep(1); this.GetAxisSts(); if (stopwatch.ElapsedMilliseconds > timeout || MotionHelper.Instance.Emg) { stopwatch.Stop(); this.StopAxis(); this.ClearAxisSts(); return(-1); } } } this.StopAxis(); #endregion Thread.Sleep(200); #region 开始回原点 stopwatch.Reset(); stopwatch.Start(); var homeSpeed = goHome.GetActSpeed(this.AxisRatio); rtn += this.AxisGoHome(homeMode, direction, homeSpeed.StartSpeed, homeSpeed.MaxSpeed, homeSpeed.AccTime, homeSpeed.DecTime); Thread.Sleep(200); this.GetAxisSts(); while (this.bAxisIsHoming || this.bAxisIsRunning) { Thread.Sleep(1); this.GetAxisSts(); if (stopwatch.ElapsedMilliseconds > timeout || MotionHelper.Instance.Emg) { stopwatch.Stop(); this.StopAxis(); this.ClearAxisSts(); return(-1); } } this.StopAxis(); this.ClearAxisSts(); this.ZeroAxis(); stopwatch.Stop(); return(rtn); #endregion }
/// <summary> /// 点-点运动 /// </summary> /// <param name="pos">位置</param> /// <param name="speed">速度</param> /// <returns></returns> public short GoPos(double pos, HostarSpeed speed) { if (double.IsNaN(pos) || double.IsInfinity(pos)) { return(-1); } var sd = speed.GetActSpeed(this.AxisRatio); return(this.AxisMoveTrap_Abs(pos * this.AxisRatio, sd.StartSpeed, sd.MaxSpeed, sd.AccTime, sd.DecTime)); }
/// <summary> /// 使用极限回原点的方式 /// </summary> /// <param name="homeMode"></param> /// <param name="direction"></param> /// <param name="speed"></param> /// <returns></returns> public short GoHome(int timeout, HostarSpeed goLimit, HostarSpeed goHome, bool limit = true) { if (limit) { return(this.GoHomeWithLimit(timeout, this.HomeMode, this.HomeDirection, goLimit, goHome)); } else { #region 开始回原点 Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var homeSpeed = goHome.GetActSpeed(this.AxisRatio); short rtn = this.AxisGoHome(this.HomeMode, this.HomeDirection, homeSpeed.StartSpeed, homeSpeed.MaxSpeed, homeSpeed.AccTime, homeSpeed.DecTime); Thread.Sleep(200); this.GetAxisSts(); while (this.bAxisIsHoming || this.bAxisIsRunning) { Thread.Sleep(1); this.GetAxisSts(); if (stopwatch.ElapsedMilliseconds > timeout || MotionHelper.Instance.Emg) { stopwatch.Stop(); this.StopAxis(); this.ClearAxisSts(); return(-1); } } this.StopAxis(); this.ClearAxisSts(); this.ZeroAxis(); stopwatch.Stop(); return(rtn); #endregion } }
/// <summary> /// Jog 运动 /// </summary> /// <param name="speed">速度</param> /// <param name="dirct">方向</param> /// <returns></returns> public short Jog(HostarSpeed speed, bool dirct) { var newSpeed = speed.GetActSpeed(this.AxisRatio); return(this.AxisMoveJog(newSpeed.StartSpeed, newSpeed.MaxSpeed, newSpeed.AccTime, newSpeed.DecTime, dirct)); }