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
{
///
/// 检测XY是否在目标位置上
///
///
///
///
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;
}
///
/// 检测XY是否在目标位置上
///
///
///
///
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;
}
///
/// 检测TurnoverZ是否在目标位置上
///
///
///
///
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;
}
///
/// 检测TurnoverZ是否在目标位置上
///
///
///
///
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;
}
}
}