102 lines
3.0 KiB
C#
102 lines
3.0 KiB
C#
|
|
using Aurora;
|
|
|
|
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using Aurora.Api.Manager;
|
|
using AuroraLaserScanner;
|
|
|
|
using Hermes;
|
|
|
|
using VisionCommon;
|
|
|
|
namespace WeldingCommon.Vision.Adapter
|
|
{
|
|
internal class TeachingMotionManager : MotionManager<FovInfo>
|
|
{
|
|
private readonly IDeviceManager _deviceManger;
|
|
private readonly Scanner _scanner;
|
|
|
|
public TeachingMotionManager()
|
|
{
|
|
_deviceManger = VisionEnv.AuroraEnv.DeviceManager;
|
|
_scanner = _deviceManger[CommonDeviceIds.Scanner] as Scanner;
|
|
|
|
SetMotions();
|
|
}
|
|
|
|
private void SetMotions()
|
|
{
|
|
var fovInfos = VisionRecipeManager.GetFovInfos();
|
|
if (fovInfos == null || fovInfos.Count == 0) return;
|
|
SetMotion(fovInfos[0], new ScannerMotion(_scanner));
|
|
}
|
|
|
|
public class ScannerMotion : IMotion
|
|
{
|
|
private static readonly Logger _Logger = new Logger(typeof(ScannerMotion).Name);
|
|
private Scanner _scanner;
|
|
|
|
public ScannerMotion(Scanner scanner)
|
|
{
|
|
this._scanner = scanner;
|
|
}
|
|
|
|
public int RelMove(Position delta)
|
|
{
|
|
if (_scanner.IsActivated == false) {
|
|
_Logger.FuncE($"Not Activated");
|
|
return E.C(E1.GENERIC, E2.NOT_READY);
|
|
}
|
|
|
|
// delta 만큼 상대위치 이동 한다.
|
|
//_Scanner.JumpRel(delta.X, delta.Y);
|
|
_scanner.JumpRel(delta.X, delta.Y);
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
public int AbsMove(Position position)
|
|
{
|
|
if (_scanner.IsActivated == false) {
|
|
_Logger.FuncE($"Not Activated");
|
|
return E.C(E1.GENERIC, E2.NOT_READY);
|
|
}
|
|
|
|
// 요청한 위치로 이동한다.
|
|
//_Scanner.JumpAbs(position.X, position.Y);
|
|
_scanner.JumpAbs(position.X, position.Y);
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
public int MovePosition(ePositionType positionType)
|
|
{
|
|
if (_scanner.IsActivated == false) {
|
|
_Logger.FuncE($"Not Activated");
|
|
return E.C(E1.GENERIC, E2.NOT_READY);
|
|
}
|
|
|
|
// 1. 레시피 또는 모델에서 ePositionType에 맞는 포지션을 가져온다.
|
|
// 예) 비전 얼라인 측정을 위한 티칭 포지션
|
|
// 2. 포지션으로 AbsMove 절대 위치 이동한다.
|
|
return E1.OK;
|
|
}
|
|
|
|
public Position GetPosition()
|
|
{
|
|
if (_scanner.IsActivated == false) {
|
|
_Logger.FuncE($"Not Activated");
|
|
return new Position();
|
|
}
|
|
|
|
// 현재 모터 위치를 가져온다.
|
|
//_Scanner.GetXYPos(out var x, out var y);
|
|
_scanner.GetXYPos(out var x, out var y);
|
|
|
|
return new Position { X = x, Y = y };
|
|
}
|
|
}
|
|
}
|
|
}
|