1.Map 进度更新

This commit is contained in:
HCL 2023-12-05 16:47:04 +08:00
parent cec02459c6
commit b26310b608
3 changed files with 148 additions and 48 deletions

View File

@ -974,7 +974,6 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
{
if (param.Length >= 1)
{
lock (_locker)
{
_lstHandler.AddLast(new SunwayRobotMapHandler(this, param[0].ToString(), _scMotionTimeout.IntValue));

View File

@ -1,6 +1,8 @@
using MECF.Framework.Common.CommonData;
using Aitex.Core.RT.Device;
using MECF.Framework.Common.CommonData;
using MECF.Framework.Common.Communications;
using MECF.Framework.Common.Equipment;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.SiasunPhoenixB;
using System;
using System.Collections.Generic;
using System.Linq;
@ -160,6 +162,148 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
}
}
public class SunwayRobotGotoMapHandler : SunwayRobotHandler
{
//GOTO N station [MAP (EX|RE)] [[RX] R1|R2|R3]
public SunwayRobotGotoMapHandler(SunwayRobot device, ModuleName module, bool isRetract,int timeout = 60)
: base(device, "GOTO", $"N {device.ModuleAssociateStationDic[module.ToString()]} MAP {(isRetract ? "RE" : "EX")}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.Both,
BladeTarget = "ArmA.System",
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as SunwayRobotMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot Goto Map Timeout");
return true;
}
if (result.Data == "_RDY")
{
Device.IsBusy = false;
}
else if (result.Data.Contains("ERR"))
{
Device.NoteError("Robot Goto Map Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
_onHandlerEndTask?.Invoke();
Device.NoteActionCompleted();
return true;
}
}
public class RobotSiasunPhoenixBGotoHandler : RobotSiasunPhoenixBHandler
{
//GOTO N station [R (EX|RE)] [Z (UP|DN)] [SLOT num] [[ARM] arm]
public RobotSiasunPhoenixBGotoHandler(RobotSiasunPhoenixB device, ModuleName module, int slot, RobotArmEnum blade,
bool isRetract = true, bool isZaxisDown = true, int timeout = 60)
: base(device, "GOTO", $"N {device.ModuleAssociateStationDic[module.ToString()]} R {(isRetract ? "RE" : "EX")}" +
$" Z {(isZaxisDown ? "DN" : "UP")} SLOT {slot} ARM {(blade == RobotArmEnum.Blade1 ? "A" : "B")}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
_target = (blade == RobotArmEnum.Blade2 ? "ArmB" : "ArmA") + "." + module;
_blade = blade;
device.MoveInfo = new RobotMoveInfo()
{
Action = isRetract ? RobotAction.Moving : RobotAction.Picking,
ArmTarget = blade == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
BladeTarget = _target,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as RobotSiasunPhoenixBMessage;
if (result.IsError)
{
Device.NoteError(result.Data);
}
else
{
Device.NoteError(null);
}
ResponseMessage = msg;
handled = true;
Device.NoteActionCompleted();
return true;
}
}
public class SunwayRobotMapHandler : SunwayRobotHandler
{
//MAP [module]
public SunwayRobotMapHandler(SunwayRobot device, string module, int timeout = 60)
: base(device, $"MAP {device.ModuleAssociateStationDic[module]}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Picking,
ArmTarget = RobotArm.ArmA,
BladeTarget = module,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as SunwayRobotMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot MAP Timeout");
return true;
}
if (result.Data == "_RDY")
{
}
else if (result.Data.Contains("ERR"))
{
Device.NoteError("Robot MAP Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
return true;
}
}
public class SunwayRobotSTATHandler : SunwayRobotHandler
{
@ -945,52 +1089,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
}
}
public class SunwayRobotMapHandler : SunwayRobotHandler
{
//MAP [module]
public SunwayRobotMapHandler(SunwayRobot device, string module, int timeout = 60)
: base(device, $"MAP {device.ModuleAssociateStationDic[module]}")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Picking,
ArmTarget = RobotArm.ArmA,
BladeTarget = module,
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as SunwayRobotMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot MAP Timeout");
return true;
}
if (result.Data == "_RDY")
{
}
else if (result.Data.Contains("ERR"))
{
Device.NoteError("Robot MAP Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
return true;
}
}
public class SunwayRobotRSRHandler : SunwayRobotHandler
{

View File

@ -50,6 +50,7 @@ namespace MECF.Framework.Simulator.Core.Robots.Sunway
{
AddCommandHandler("HOME", HandleHome);
AddCommandHandler("RQ", HandleRQLoad);
AddCommandHandler("GOTO", HandleHome);
AddCommandHandler("MAP", HandleMap);
@ -99,6 +100,7 @@ namespace MECF.Framework.Simulator.Core.Robots.Sunway
OnWriteMessage("LOAD A OFF");
}
internal void HandleGetSp(string msg)
{
// GETSP B 11 1