|
@@ -13,6 +13,7 @@ using System.Linq;
|
|
|
using Venus_RT.Modules.Schedulers;
|
|
|
using Venus_RT.Scheduler;
|
|
|
using System;
|
|
|
+using MECF.Framework.Common.Schedulers;
|
|
|
|
|
|
namespace Venus_RT.Modules
|
|
|
{
|
|
@@ -32,9 +33,16 @@ namespace Venus_RT.Modules
|
|
|
int cycleCount = 1;
|
|
|
ModuleName _sourceModule = ModuleName.LLA;
|
|
|
ModuleName _destinationModule = ModuleName.LLB;
|
|
|
+ int _sourceSlotNumber = 4;
|
|
|
+ int _destinationSlotNumber = 4;
|
|
|
SchedulerTMRobot _TMRobot = new SchedulerTMRobot();
|
|
|
+ private readonly int INVALID_SLOT = -1;
|
|
|
|
|
|
Dictionary<ModuleName, SchedulerModule> dictSchedulers = new Dictionary<ModuleName, SchedulerModule>();
|
|
|
+
|
|
|
+ Queue<MoveItem> _ReturnWafers = new Queue<MoveItem>();
|
|
|
+ Queue<MoveItem> _runningItems = new Queue<MoveItem>();
|
|
|
+ Queue<MoveItem> _CycleWafers = new Queue<MoveItem>();
|
|
|
public TMCycle() : base(ModuleName.System)
|
|
|
{
|
|
|
Name = "TM Cycle";
|
|
@@ -85,41 +93,209 @@ namespace Venus_RT.Modules
|
|
|
public RState Monitor()
|
|
|
{
|
|
|
Runner.Run((int)TMCycleStep.Start, NullFun)
|
|
|
- .LoopStart((int)TMCycleStep.ReturnBack, "Cycle", cycleCount, ReturnBack, IsReturnDone)
|
|
|
- .LoopEnd((int)TMCycleStep.Cycling, Cycling, IsCycleDone)
|
|
|
+ .LoopStart((int)TMCycleStep.ReturnBack, "Cycle", cycleCount, StartReturn, ReturnBack)
|
|
|
+ .LoopEnd((int)TMCycleStep.Cycling, StartCycle, Cycling)
|
|
|
.End((int)TMCycleStep.End, NullFun, _delay_50ms);
|
|
|
|
|
|
return Runner.Status;
|
|
|
}
|
|
|
|
|
|
- private bool ReturnBack()
|
|
|
+ private bool StartReturn()
|
|
|
+ {
|
|
|
+ _destinationModule = tmCycleRoutine.Last();
|
|
|
+ _destinationSlotNumber = SC.GetValue<int>($"{_destinationModule}.SlotNumber");
|
|
|
+ _sourceModule = tmCycleRoutine.First();
|
|
|
+ _sourceSlotNumber = SC.GetValue<int>($"{_sourceModule}.SlotNumber");
|
|
|
+ _ReturnWafers.Clear();
|
|
|
+ for(int i = 0; i < _destinationSlotNumber; i++)
|
|
|
+ {
|
|
|
+ if(WaferManager.Instance.CheckHasWafer(_destinationModule, i))
|
|
|
+ {
|
|
|
+ _ReturnWafers.Enqueue(new MoveItem(_destinationModule, i, _sourceModule, INVALID_SLOT, Hand.None));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<int> GetReadyInSlot(ModuleName module, int slotCount)
|
|
|
+ {
|
|
|
+ List<int> slots = new List<int>();
|
|
|
+ for (int i = 0; i < slotCount; i++)
|
|
|
+ {
|
|
|
+ if (WaferManager.Instance.CheckNoWafer(module, i))
|
|
|
+ slots.Add(i);
|
|
|
+
|
|
|
+ if (slots.Count >= 2)
|
|
|
+ return slots;
|
|
|
+ }
|
|
|
+
|
|
|
+ return slots;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ModuleName> GetReadyOutPMs()
|
|
|
+ {
|
|
|
+ List<ModuleName> outpm = new List<ModuleName>();
|
|
|
+ foreach(var module in tmCycleRoutine)
|
|
|
+ {
|
|
|
+ if(ModuleHelper.IsPm(module))
|
|
|
+ {
|
|
|
+ if(IsModuleAvailable(module) && WaferManager.Instance.CheckHasWafer(module, 0))
|
|
|
+ {
|
|
|
+ outpm.Add(module);
|
|
|
+ if (outpm.Count >= 2)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return outpm;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ModuleName> GetReadyInPMs()
|
|
|
{
|
|
|
- if(_TMRobot.IsAvailable)
|
|
|
+ List<ModuleName> inpm = new List<ModuleName>();
|
|
|
+ foreach (var module in tmCycleRoutine)
|
|
|
{
|
|
|
- for(int i = 0; i < tmCycleRoutine.Count - 1; i++)
|
|
|
+ if (ModuleHelper.IsPm(module))
|
|
|
{
|
|
|
- if(IsModuleAvailable(tmCycleRoutine[i]) && IsModuleAvailable(tmCycleRoutine[i+1]))
|
|
|
+ if (IsModuleAvailable(module) && WaferManager.Instance.CheckNoWafer(module, 0))
|
|
|
{
|
|
|
+ inpm.Add(module);
|
|
|
+ if (inpm.Count >= 2)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return inpm;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool ReturnBack()
|
|
|
+ {
|
|
|
+ if (IsModuleAvailable(_sourceModule) && IsModuleAvailable(_destinationModule))
|
|
|
+ {
|
|
|
+ if (_ReturnWafers.Count == 0)
|
|
|
+ return IsModuleAvailable(ModuleName.TM);
|
|
|
+
|
|
|
+
|
|
|
+ var InSlots = GetReadyInSlot(_sourceModule, _sourceSlotNumber);
|
|
|
+ foreach (var slot in InSlots)
|
|
|
+ {
|
|
|
+ if(_ReturnWafers.Count > 0)
|
|
|
+ {
|
|
|
+ var move = _ReturnWafers.Dequeue();
|
|
|
+ move.DestinationSlot = slot;
|
|
|
+ _runningItems.Enqueue(move);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return true;
|
|
|
+
|
|
|
+ if (_TMRobot.IsAvailable && _runningItems.Count > 0)
|
|
|
+ {
|
|
|
+ if(_TMRobot.PostMoveItems(_runningItems.ToArray()))
|
|
|
+ _runningItems.Clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- private bool IsReturnDone()
|
|
|
+ private bool ModuleHasWafer(ModuleName mod, int nSlots)
|
|
|
{
|
|
|
+ for(int i= 0; i< nSlots; i++)
|
|
|
+ {
|
|
|
+ if (WaferManager.Instance.CheckHasWafer(mod, i))
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool PMsHasWafers()
|
|
|
+ {
|
|
|
+ foreach (var module in tmCycleRoutine)
|
|
|
+ {
|
|
|
+ if (ModuleHelper.IsPm(module))
|
|
|
+ {
|
|
|
+ if (WaferManager.Instance.CheckHasWafer(module, 0))
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool IsPMsAvailabe()
|
|
|
+ {
|
|
|
+ foreach (var module in tmCycleRoutine)
|
|
|
+ {
|
|
|
+ if (ModuleHelper.IsPm(module))
|
|
|
+ {
|
|
|
+ if (!IsModuleAvailable(module))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private bool Cycling()
|
|
|
{
|
|
|
- return true;
|
|
|
+ if(IsPMsAvailabe() && IsModuleAvailable(_destinationModule) && IsModuleAvailable(_sourceModule) && _TMRobot.IsAvailable)
|
|
|
+ {
|
|
|
+ if (!PMsHasWafers() && IsModuleAvailable(ModuleName.TM) && _CycleWafers.Count == 0)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ if(PMsHasWafers())
|
|
|
+ {
|
|
|
+ var pmSlots = GetReadyOutPMs();
|
|
|
+ var inSlots = GetReadyInSlot(_destinationModule, _destinationSlotNumber);
|
|
|
+ for(int i = 0; i < Math.Min(pmSlots.Count, inSlots.Count); i++)
|
|
|
+ {
|
|
|
+ _runningItems.Enqueue(new MoveItem(pmSlots[i], 0, _destinationModule, inSlots[i], Hand.Both));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var InPMs = GetReadyInPMs();
|
|
|
+ if(_CycleWafers.Count > 0 && InPMs.Count >= 1)
|
|
|
+ {
|
|
|
+ var item = _CycleWafers.Dequeue();
|
|
|
+ _runningItems.Enqueue(new MoveItem(item.SourceModule, item.SourceSlot, InPMs[0], 0, Hand.Both));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(_CycleWafers.Count > 0 && InPMs.Count >= 2)
|
|
|
+ {
|
|
|
+ var item = _CycleWafers.Dequeue();
|
|
|
+ _runningItems.Enqueue(new MoveItem(item.SourceModule, item.SourceSlot, InPMs[1], 0, Hand.Both));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_runningItems.Count > 0)
|
|
|
+ {
|
|
|
+ if (_TMRobot.PostMoveItems(_runningItems.ToArray()))
|
|
|
+ _runningItems.Clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- private bool IsCycleDone()
|
|
|
+ private bool StartCycle()
|
|
|
{
|
|
|
+ _CycleWafers.Clear();
|
|
|
+ for(int i = 0; i< _sourceSlotNumber; i++)
|
|
|
+ {
|
|
|
+ if (WaferManager.Instance.CheckHasWafer(_sourceModule, i))
|
|
|
+ _CycleWafers.Enqueue(new MoveItem(_sourceModule, i, _destinationModule, INVALID_SLOT, Hand.None));
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|