This repository has been archived on 2023-03-29. You can view files and clone it, but cannot push or open issues or pull requests.
Sic02/Modules/Mainframe/TMs/TMRobotExtendRoutine.cs

121 lines
3.5 KiB
C#
Raw Normal View History

2022-08-05 14:47:02 +08:00
using System;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Event;
using Aitex.Core.RT.Routine;
using Aitex.Core.RT.SCCore;
using Aitex.Sorter.Common;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.Schedulers;
using MECF.Framework.Common.SubstrateTrackings;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadLocks;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
namespace Mainframe.TMs
{
public class TMRobotExtendRoutine : TMBaseRoutine
{
enum RoutineStep
{
WaitOpenSlitValveInterlock,
OpenSlitValve,
CheckBeforeExtend,
Extend,
}
private ModuleName _source;
private int _sourceSlot;
private Hand _hand;
private int _timeout;
private TMSlitValveRoutine _openSlitValveRoutine = new TMSlitValveRoutine();
public TMRobotExtendRoutine()
{
Module = "TMRobot";
Name = "Extend";
}
public void Init(ModuleName source, int sourceSlot, Hand blade)
{
_source = source;
_sourceSlot = sourceSlot;
_hand = blade;
_openSlitValveRoutine.Init(source.ToString(), true);
}
public void Init(ModuleName source, int sourceSlot, int blade)
{
Init(source, sourceSlot, (Hand)blade);
}
public override Result Start(params object[] objs)
{
Reset();
_timeout = SC.GetValue<int>("TMRobot.ExtendTimeout");
if (ModuleHelper.IsLoadLock(_source))
{
LoadLock ll = DEVICE.GetDevice<LoadLock>($"{_source.ToString()}.{_source.ToString()}");
if (!ll.CheckEnableTransfer(EnumTransferType.Extend))
{
EV.PostWarningLog(Module, $"can not extend, {_source} not ready for transfer");
return Result.FAIL;
}
}
if (ModuleHelper.IsPm(_source))
{
PM pm = DEVICE.GetDevice<PM>(_source.ToString());
if (!pm.CheckEnableTransfer(EnumTransferType.Extend, out string reason))
{
EV.PostWarningLog(Module, $"can not extend, {_source} reason");
return Result.FAIL;
}
}
Notify($"Start, extend to {_source} slot {_sourceSlot+1} with {_hand}");
return Result.RUN;
}
public override void Abort()
{
Notify("Abort");
}
public override Result Monitor()
{
try
{
WaitSlitValveOpenInterlock((int)RoutineStep.WaitOpenSlitValveInterlock, TMDevice.GetSlitValve(_source), _timeout);
ExecuteRoutine((int)RoutineStep.OpenSlitValve, _openSlitValveRoutine);
//CheckBeforeExtend((int)RoutineStep.CheckBeforeExtend, _source, _sourceSlot, _hand);
//Extend((int)RoutineStep.Extend, RobotDevice, _source, _sourceSlot, _hand, _timeout);
}
catch (RoutineBreakException)
{
return Result.RUN;
}
catch (RoutineFaildException)
{
return Result.FAIL;
}
Notify($"Finish, extend to {_source} slot {_sourceSlot + 1} with {_hand}");
return Result.DONE;
}
}
}