You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
using Rs.Framework;
|
|
using Rs.MotionPlat.Commom;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Rs.MotionPlat.Flow.Common
|
|
{
|
|
public static class AxisArrived
|
|
{
|
|
/// <summary>
|
|
/// 检测XY是否在目标位置上
|
|
/// </summary>
|
|
/// <param name="xTargetPos"></param>
|
|
/// <param name="yTargetPos"></param>
|
|
/// <returns></returns>
|
|
public static bool LoadXYIsArrived(double xTargetPos, double yTargetPos)
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
return true;
|
|
Stopwatch timer = new Stopwatch();
|
|
timer.Start();
|
|
while (timer.ElapsedMilliseconds < 3000)
|
|
{
|
|
double xCurPos = Ops.GetCurPosition(AxisControl.LoadX);
|
|
double yCurPos = Ops.GetCurPosition(AxisControl.LoadY);
|
|
if ((Math.Abs(xTargetPos - xCurPos) < AxisControl.LoadX.Config.Tolerance
|
|
&& Math.Abs(yTargetPos - yCurPos) < AxisControl.LoadY.Config.Tolerance) || GlobalVar.VirtualAxis)
|
|
{
|
|
timer.Stop();
|
|
return true;
|
|
}
|
|
}
|
|
timer.Stop();
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检测XY是否在目标位置上
|
|
/// </summary>
|
|
/// <param name="xTargetPos"></param>
|
|
/// <param name="yTargetPos"></param>
|
|
/// <returns></returns>
|
|
public static bool TurnoverYIsInTargetPos(double yTargetPos)
|
|
{
|
|
Stopwatch timer = new Stopwatch();
|
|
timer.Start();
|
|
while (timer.ElapsedMilliseconds < 3000)
|
|
{
|
|
double yCurPos = Ops.GetCurPosition(AxisControl.TurnoverY);
|
|
if ((Math.Abs(yTargetPos - yCurPos) < AxisControl.TurnoverY.Config.Tolerance) || GlobalVar.VirtualAxis)
|
|
{
|
|
timer.Stop();
|
|
return true;
|
|
}
|
|
}
|
|
timer.Stop();
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检测TurnoverZ是否在目标位置上
|
|
/// </summary>
|
|
/// <param name="xTargetPos"></param>
|
|
/// <param name="yTargetPos"></param>
|
|
/// <returns></returns>
|
|
public static bool TurnoverZIsInTargetPos(double zTargetPos)
|
|
{
|
|
Stopwatch timer = new Stopwatch();
|
|
timer.Start();
|
|
while (timer.ElapsedMilliseconds < 3000)
|
|
{
|
|
double zCurPos = Ops.GetCurPosition(AxisControl.TurnoverZ);
|
|
if ((Math.Abs(zTargetPos - zCurPos) < AxisControl.TurnoverZ.Config.Tolerance) || GlobalVar.VirtualAxis)
|
|
{
|
|
timer.Stop();
|
|
return true;
|
|
}
|
|
}
|
|
timer.Stop();
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检测TurnoverZ是否在目标位置上
|
|
/// </summary>
|
|
/// <param name="xTargetPos"></param>
|
|
/// <param name="yTargetPos"></param>
|
|
/// <returns></returns>
|
|
public static bool PressZIsInTargetPos(double zTargetPos)
|
|
{
|
|
Stopwatch timer = new Stopwatch();
|
|
timer.Start();
|
|
while (timer.ElapsedMilliseconds < 3000)
|
|
{
|
|
double zCurPos = Ops.GetCurPosition(AxisControl.PressZ);
|
|
if ((Math.Abs(zTargetPos - zCurPos) < AxisControl.PressZ.Config.Tolerance) || GlobalVar.VirtualAxis)
|
|
{
|
|
timer.Stop();
|
|
return true;
|
|
}
|
|
}
|
|
timer.Stop();
|
|
return false;
|
|
}
|
|
}
|
|
}
|