123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Fsm;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Core.Utilities;
- using MECF.Framework.Common.Device.LinMot;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.ToolLayout;
- using MECF.Framework.Common.WaferHolder;
- using CyberX8_Core;
- using CyberX8_RT.Devices.LinMot;
- using CyberX8_RT.Devices.Prewet;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xaml.Schema;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.Common.Persistent.Prewet;
- using MECF.Framework.Common.RecipeCenter;
- using Aitex.Core.RT.RecipeCenter;
- using System.Timers;
- using Aitex.Core.RT.Routine;
- using System.Windows.Markup;
- using CyberX8_RT.Dispatch;
- using MECF.Framework.Common.Jobs;
- namespace CyberX8_RT.Modules.Prewet
- {
- public class PrewetEntity : Entity, IEntity, IModuleEntity
- {
- #region 常量
- private const string AUTO = "Auto";
- private const string MANUAL = "Manual";
- private const string DISABLED = "Disabled";
- private const string ENGINEERING = "Engineering";
- private const string PRODUCTION = "Production";
- #endregion
- #region 内部变量
- /// <summary>
- /// LintMot Axis
- /// </summary>
- private LinMotAxis _linmotAxis;
- /// <summary>
- /// prepare to trans
- /// </summary>
- private PrepareToTransferRoutine _prepareToTransferRoutine;
- /// <summary>
- /// Initialize routine
- /// </summary>
- private PrewetInitializeRoutine _initializeRoutine;
- /// <summary>
- /// Linmot Wet Scan Routine
- /// </summary>
- private PrewetLinmotScanWetRoutine _linmotWetScanRoutine;
- /// <summary>
- /// Manual模式下Cycle run
- /// </summary>
- private CycleManualProcessRecipeRoutine _cycleManualProcessRoutine;
- /// <summary>
- /// delay keepwet routine
- /// </summary>
- private PrewetDelayKeepwetRoutine _delayKeepwetRoutine;
- /// <summary>
- /// prewet Keepwet routine
- /// </summary>
- private PrewetKeepWetRoutine _prewetKeepWetRoutine;
- /// <summary>
- /// 执行前的状态
- /// </summary>
- private string _preExecuteState;
- /// <summary>
- /// Cycle次数
- /// </summary>
- private int _cycle = 0;
- /// <summary>
- /// 已经完成的Cycle次数
- /// </summary>
- private int _achievedCycle = 0;
- /// <summary>
- /// linmot设备数据
- /// </summary>
- private LinMotDeviceData _linMotDeviveData = new LinMotDeviceData();
- /// <summary>
- /// LinmotName
- /// </summary>
- private string _linmotName;
- /// <summary>
- /// PrewetDevice
- /// </summary>
- private PrewetDevice _prewetDevice;
- /// <summary>
- /// 工艺当前执行小步骤
- /// </summary>
- private string _currentStateMachine = "Init";
- /// <summary>
- /// 工艺当前执行大步骤
- /// </summary>
- private string _currentStatus = "Init";
- /// <summary>
- /// 持久化对象
- /// </summary>
- private PrewetPersistentValue _persistentValue;
- /// <summary>
- /// 当前Recipe
- /// </summary>
- private PwtRecipe _currentRecipe;
- /// <summary>
- /// recipe时长
- /// </summary>
- private int _recipeTime;
- /// <summary>
- /// keepwet倒计时
- /// </summary>
- private int _keepwetCountDown;
- /// <summary>
- /// run recipe start time
- /// </summary>
- private DateTime _runRecipeStartTime;
- /// <summary>
- /// run recipe complete time
- /// </summary>
- private DateTime _runRecipeCompleteTime;
- /// <summary>
- /// 是否Retry
- /// </summary>
- private bool _isRetry = false;
- #endregion
- #region 属性
- /// <summary>
- /// 模块名称
- /// </summary>
- public ModuleName Module { get; private set; }
- /// <summary>
- /// 初始化状态
- /// </summary>
- public bool IsInit { get { return fsm.State == (int)PrewetState.Init; } }
- /// <summary>
- /// 空闲状态
- /// </summary>
- public bool IsIdle { get { return fsm.State == (int)PrewetState.Idle; } }
- /// <summary>
- /// 是否发生错误
- /// </summary>
- public bool IsError { get { return fsm.State == (int)PrewetState.Error; } }
- /// <summary>
- /// 是否正在作业
- /// </summary>
- public bool IsBusy { get { return fsm.State>(int)PrewetState.Idle; } }
- /// <summary>
- /// 是否初始化完成
- /// </summary>
- public bool IsInitialized { get { return fsm.State >= (int)PrewetState.Initialized; } }
- /// <summary>
- /// 是否禁用
- /// </summary>
- public bool IsDisable { get { return _persistentValue == null || _persistentValue.OperatingMode == DISABLED; } }
- /// <summary>
- /// 自动模式
- /// </summary>
- public bool IsAuto { get { return _persistentValue != null && _persistentValue.OperatingMode == AUTO; } }
- /// <summary>
- /// 自动模式
- /// </summary>
- public bool IsManual { get { return _persistentValue != null && _persistentValue.OperatingMode == MANUAL; } }
- /// <summary>
- /// 是否为工程模式
- /// </summary>
- public bool IsEngineering { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == ENGINEERING; } }
- /// <summary>
- /// 是否为产品模式
- /// </summary>
- public bool IsProduction { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == PRODUCTION; } }
- /// <summary>
- /// WaferHolder信息
- /// </summary>
- public WaferHolderInfo WaferHolderInfo { get { return WaferHolderManager.Instance.GetWaferHolder(Module.ToString()); } }
- /// <summary>
- /// 当前状态机状态
- /// </summary>
- public int State { get { return fsm.State; } }
- /// <summary>
- /// recipe时长
- /// </summary>
- public int RecipeTime { get { return _recipeTime; } }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- public PrewetEntity(ModuleName moduleName)
- {
- this.Module = moduleName;
- _prewetDevice = DEVICE.GetDevice<PrewetDevice>(Module.ToString());
- WaferManager.Instance.SubscribeLocation(Module, 2);
- InitialFsm();
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <returns></returns>
- protected override bool Init()
- {
- InitializeParameter();
- InitialDATA();
- InitializeRoutine();
- InitialOperation();
- //InitialStateMachine();
- return true;
- }
- /// <summary>
- /// 中止
- /// </summary>
- protected override void Term()
- {
- }
- /// 初始化状态机
- /// </summary>
- private void InitialFsm()
- {
- fsm = new StateMachine<PrewetEntity>(Module.ToString(), (int)PrewetState.Init, 20);
- fsm.EnableRepeatedMsg(true);
- AnyStateTransition(PrewetMsg.Error, ErrorSolution, PrewetState.Error);
- AnyStateTransition(PrewetMsg.ReturnInit, NullFunc, PrewetState.Init);
- AnyStateTransition(PrewetMsg.ReturnIdle, NullFunc, PrewetState.Idle);
-
- Transition(PrewetState.Error, PrewetMsg.ResumeError, (param) => { return true; }, PrewetState.Init);
- //Initialize
- AnyStateTransition(PrewetMsg.Initialize, InitializeAll, PrewetState.Initializing);
- Transition(PrewetState.Initializing, FSM_MSG.TIMER, InitializeAllTimeout, PrewetState.Idle);
-
- //LinmotWetScan
- Transition(PrewetState.Idle, PrewetMsg.LinmotScanWet, LinmotScanWet, PrewetState.Linmot_Scanning);
- Transition(PrewetState.Linmot_Scanning, FSM_MSG.TIMER, LinmotScanTimeout, PrewetState.Idle);
- //Kepwet
- Transition(PrewetState.Idle, PrewetMsg.KeepWet, KeepWet, PrewetState.KeepWeting);
- Transition(PrewetState.KeepWeting, FSM_MSG.TIMER, KeepWetMonitor, PrewetState.Idle);
- Transition(PrewetState.Idle, PrewetMsg.DelayKeepwet, DelayKeepwet, PrewetState.DelayKeepweting);
- Transition(PrewetState.DelayKeepwetComplete, PrewetMsg.DelayKeepwet, DelayKeepwet, PrewetState.DelayKeepweting);
- Transition(PrewetState.RunRecipeComplete, PrewetMsg.DelayKeepwet, DelayKeepwet, PrewetState.DelayKeepweting);
- Transition(PrewetState.DelayKeepweting, FSM_MSG.TIMER, DelayKeepwetMonitor, PrewetState.DelayKeepwetComplete);
- //PrepareToTransfer
- Transition(PrewetState.Idle, PrewetMsg.PrepareToTransfer, PrepareToTransfer, PrewetState.PrepareToTransfering);
- Transition(PrewetState.PrepareToTransfering, FSM_MSG.TIMER, PrepareToTransferTimeout, PrewetState.Idle);
- //PrepareToPlace
- Transition(PrewetState.Idle, PrewetMsg.PrepareToPlace, PrepareToTransfer, PrewetState.PreparingToPlace);
- Transition(PrewetState.PreparingToPlace, FSM_MSG.TIMER, PrepareToTransferTimeout, PrewetState.WaitForPlace);
- //PrepareToPick
- Transition(PrewetState.DelayKeepweting, PrewetMsg.PrepareToPick, PrepareToTransfer, PrewetState.PreparingToPick);
- Transition(PrewetState.RunRecipeComplete, PrewetMsg.PrepareToPick, PrepareToTransfer, PrewetState.PreparingToPick);
- Transition(PrewetState.DelayKeepwetComplete, PrewetMsg.PrepareToPick, PrepareToTransfer, PrewetState.PreparingToPick);
- Transition(PrewetState.Idle, PrewetMsg.PrepareToPick, PrepareToTransfer, PrewetState.PreparingToPick);
- Transition(PrewetState.PreparingToPick, FSM_MSG.TIMER, PrepareToTransferTimeout, PrewetState.WaitForPick);
- Transition(PrewetState.WaitForPick, PrewetMsg.PickComplete, NullFunc, PrewetState.Idle);
- //RunRecipe
- Transition(PrewetState.Idle, PrewetMsg.RunRecipe, CycleManualProcess, PrewetState.RunReciping);
- Transition(PrewetState.WaitForPlace, PrewetMsg.RunRecipe, CycleManualProcess, PrewetState.RunReciping);
- Transition(PrewetState.RunReciping, FSM_MSG.TIMER, CycleManualMonitor, PrewetState.RunRecipeComplete);
- //Cycle Manual Process
- Transition(PrewetState.Idle, PrewetMsg.CycleProcessRecipe, CycleManualProcess, PrewetState.CycleManualProcessing);
- Transition(PrewetState.CycleManualProcessing, FSM_MSG.TIMER, CycleManualMonitor, PrewetState.Idle);
-
- //Abort
- Transition(PrewetState.CycleManualProcessing, PrewetMsg.Abort, CycleManualAbort, PrewetState.Abort);
- //Enter Init
- Transition(PrewetState.Idle, PrewetMsg.Init, NullFunc, PrewetState.Init);
- EnumLoop<PrewetState>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
- EnumLoop<PrewetMsg>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
- }
- /// <summary>
- /// 初始化参数
- /// </summary>
- private void InitializeParameter()
- {
- _persistentValue = PrewetPersistentManager.Instance.GetPrewetPersistentValue(Module.ToString());
- if (_persistentValue == null)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "Persistent Value Object is not exist");
- }
- _keepwetCountDown = 0;
- }
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void InitialDATA()
- {
- PrewetItem prewetItem = PrewetItemManager.Instance.GetPrewetItem(Module.ToString());
- if (prewetItem!=null)
- {
- _linmotAxis = DEVICE.GetDevice<LinMotAxis>(prewetItem.LinmotID);
- string LinmotDeviceName = _linmotName = _linmotAxis.DeviceID;
- LinMotDevice linMotDevice = LinMotDeviceConfigManager.Instance.GetLinMotDevice(LinmotDeviceName);
- if (linMotDevice != null)
- {
- _linMotDeviveData = linMotDevice.LinMotDeviceData;
- }
- }
- InitializeSvid();
- DATA.Subscribe($"{Module}.FsmState", () => ((PrewetState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WaferHolder", () => WaferHolderInfo, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.AchievedCycle", () => _achievedCycle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.GetKeepWetLimit", () => fsm.State==(int)PrewetState.DelayKeepweting?Math.Max(_keepwetCountDown-_delayKeepwetRoutine.ElapsedMilliseconds/1000,0):0 , SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsInit", () => IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsIdle", () => IsIdle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsError", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsDisable", () => IsDisable, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LinmotDeviceData", () => _linMotDeviveData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LinmotName", () => _linmotName, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CurrentStateMachine", () => _currentStateMachine, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CurrentStatus", () => _currentStatus, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CurrentRecipe", () => _currentRecipe != null ? _currentRecipe.Ppid : "", SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.ID", () => _linmotAxis.Module, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.IsMotorOn", () => _linmotAxis.IsMotorOn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.IsError", () => _linmotAxis.IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.IsSwitchOn", () => _linmotAxis.IsSwitchOn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.ErrorCode", () => _linmotAxis.ErrorCode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.CurrentPosition", () => _linmotAxis.CurrentPosition, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Linmot.ScanCount", () => _linmotAxis.ScanCount, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <summary>
- /// 初始化SVID
- /// </summary>
- private void InitializeSvid()
- {
- DATA.Subscribe($"{Module}.State", () => ((PrewetState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LotID", () => (WaferHolderInfo != null ? WaferHolderInfo.LotId : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WSID", () => (WaferHolderInfo != null ? WaferHolderInfo.Id : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LSAID", () => (WaferHolderInfo != null ? WaferHolderInfo.CrsAId : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LSBID", () => (WaferHolderInfo != null ? WaferHolderInfo.CrsBId : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ModuleRecipe", () => (_currentRecipe != null ? _currentRecipe.Ppid : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.SequenceRecipe", () => (WaferHolderInfo != null ? WaferHolderInfo.SequenceId : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WaferAID", () => (WaferHolderInfo != null ? WaferHolderInfo.WaferAId : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WaferBID", () => (WaferHolderInfo != null ? WaferHolderInfo.WaferBId : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.TotalTime", () => _recipeTime, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.TimeRemain", () => _recipeTime != 0 ? (_recipeTime - Math.Round((double)_cycleManualProcessRoutine.ElapsedMilliseconds / 1000, 0)) : 0, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Task", () => WaferHolderInfo != null ? WaferHolderInfo.CurrentControlJobId : "", SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.OperatingMode", () => _persistentValue != null ? _persistentValue.OperatingMode : "None", SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <summary>
- /// 初始化操作
- /// </summary>
- protected void InitialOperation()
- {
- OP.Subscribe($"{Module}.InitializeAll", (cmd, args) => { return CheckToPostMessage<PrewetState,PrewetMsg>(eEvent.ERR_PREWET,Module.ToString(),(int)PrewetMsg.Initialize); });
- OP.Subscribe($"{Module}.Abort", (cmd, args) => { return CheckToPostMessage<PrewetState,PrewetMsg>(eEvent.ERR_PREWET,Module.ToString(),(int)PrewetMsg.Abort); });
- OP.Subscribe($"{Module}.LimotScanWet", (cmd, args) => { return CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.LinmotScanWet, args); });
- OP.Subscribe($"{Module}.KeepWet", (cmd, args) => { return CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.KeepWet, args); });
- OP.Subscribe($"{Module}.PrepareToTransfer", (cmd, args) => { return CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.PrepareToTransfer); });
- OP.Subscribe($"{Module}.ManualProcessRecipe", (cmd, args) => { return CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.ProcessRecipe,args); });
- OP.Subscribe($"{Module}.CycleManualProcessRecipe", (cmd, args) =>
- {
- PwtRecipe recipe = RecipeFileManager.Instance.LoadGenericityRecipe<PwtRecipe>(args[0].ToString());
- if (recipe == null)
- {
- LOG.WriteLog(eEvent.ERR_PREWET, Module.ToString(), $"{args[0]} recipe is null");
- return false;
- }
- object[] objects = new object[args.Length];
- objects[0] = recipe;
- for (int i = 1; i < args.Length; i++)
- {
- objects[i] = args[i];
- }
- return CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.CycleProcessRecipe,objects);
- });
-
- }
- /// <summary>
- /// EnterInit
- /// </summary>
- public void EnterInit()
- {
- if ((PrewetState)fsm.State != PrewetState.Idle) return;
- else
- {
- CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.Init);
- }
- }
- /// <summary>
- /// 初始化Routine
- /// </summary>
- private void InitializeRoutine()
- {
- _prepareToTransferRoutine = new PrepareToTransferRoutine(Module.ToString(), _linmotAxis);
- _initializeRoutine=new PrewetInitializeRoutine(Module.ToString(), _linmotAxis);
- _linmotWetScanRoutine=new PrewetLinmotScanWetRoutine(Module.ToString(), _linmotAxis);
- _cycleManualProcessRoutine = new CycleManualProcessRecipeRoutine(Module.ToString(), _linmotAxis);
- _delayKeepwetRoutine=new PrewetDelayKeepwetRoutine(Module.ToString(),_linmotAxis);
- _prewetKeepWetRoutine = new PrewetKeepWetRoutine(Module.ToString(), _linmotAxis);
- }
- /// <summary>
- /// 初始化状态机
- /// </summary>
- private void InitialStateMachine()
- {
- //_keepwetStateMachine = new PrewetKeepWetStateMachine(Module.ToString(),_linmotAxis);
- //_keepwetStateMachine.Initialize();
- }
- private bool ErrorSolution(object[] param)
- {
- bool result = _prewetDevice.PumpValveClose();
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_PREWET,Module.ToString(), "Close Pump Valve error");
- }
- return true;
- }
- #region Initialize
- /// <summary>
- /// Initialize
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool InitializeAll(object[] param)
- {
- if (fsm.State == (int)PrewetState.Initializing)
- {
- LOG.WriteLog(eEvent.WARN_PREWET, Module.ToString(), "state is Initializing,cannot do initialize");
- return false;
- }
- return _initializeRoutine.Start() == RState.Running;
- }
- /// <summary>
- /// Initialize 监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool InitializeAllTimeout(object[] param)
- {
- RState ret = _initializeRoutine.Monitor();
- _currentStateMachine = _initializeRoutine.CurrentStateMachine;
- _currentStatus = "initializing";
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostMsg(PrewetMsg.Error);
- _currentStateMachine = "Error";
- _currentStatus = "Error";
- return false;
- }
- bool result = ret == RState.End;
- if (result)
- {
- _currentStateMachine = "Idle";
- _currentStatus = "Idle";
- }
- return result;
- }
- #endregion
- #region Linmot scan wet
- /// <summary>
- /// Initialize
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool LinmotScanWet(object[] param)
- {
- _preExecuteState = ((PrewetState)fsm.State).ToString();
- return _linmotWetScanRoutine.Start(param) == RState.Running;
- }
- /// <summary>
- /// LinmotScan 监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool LinmotScanTimeout(object[] param)
- {
- RState ret = _linmotWetScanRoutine.Monitor();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostReturnPreState();
- _currentStateMachine = "Error";
- _currentStatus = "Error";
- return false;
- }
- return ret == RState.End;
- }
- #endregion
- #region Keep wet
- /// <summary>
- /// Keep Wet
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool KeepWet(object[] param)
- {
- _preExecuteState = ((PrewetState)fsm.State).ToString();
- return _prewetKeepWetRoutine.Start() == RState.Running;
- }
- /// <summary>
- /// Keep Wet Monitor
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool KeepWetMonitor(object[] param)
- {
- RState ret = _prewetKeepWetRoutine.Monitor();
- if(ret==RState.End)
- {
- return true;
- }
- else if(ret==RState.Failed||ret==RState.Timeout)
- {
- PostReturnPreState();
- return false;
- }
- return false;
- }
- /// <summary>
- /// Delay Keepwet
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool DelayKeepwet(object[] param)
- {
- _preExecuteState = ((PrewetState)fsm.State).ToString();
- _keepwetCountDown = SC.GetValue<int>("Prewet.IdleKeepwetPauseBetweenScanSeconds");
- return _delayKeepwetRoutine.Start() == RState.Running;
- }
- /// <summary>
- /// Delay Keepwet 监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool DelayKeepwetMonitor(object[] param)
- {
- RState ret = _delayKeepwetRoutine.Monitor();
- if(ret==RState.End)
- {
- return true;
- }
- else if(ret==RState.Failed||ret==RState.Timeout)
- {
- PostMsg(PrewetMsg.Error);
- return false;
- }
- return false;
- }
- #endregion
- #region PrepareToTransfer
- /// <summary>
- /// PrepareToTransfer
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool PrepareToTransfer(object[] param)
- {
- bool isNeedStopLinmot = true;
- if (fsm.State == (int)PrewetState.DelayKeepweting)
- {
- _delayKeepwetRoutine.Abort();
- isNeedStopLinmot = false;
- }
- _preExecuteState = ((PrewetState)fsm.State).ToString();
- return _prepareToTransferRoutine.Start(isNeedStopLinmot) == RState.Running;
- }
- /// <summary>
- /// PrepareToTransfer 监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool PrepareToTransferTimeout(object[] param)
- {
- RState ret = _prepareToTransferRoutine.Monitor();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostReturnPreState();
- _currentStateMachine = "Error";
- _currentStatus = "Error";
- return false;
- }
- return ret == RState.End;
- }
- #endregion
- #region Manual Process
- private bool CycleManualProcess(object[] param)
- {
- PwtRecipe recipe = param[0] as PwtRecipe;
- _cycle = (int)param[1];
-
- bool result = _cycleManualProcessRoutine.Start(param) == RState.Running;
- if(result)
- {
- _isRetry = false;
- if (CellItemRecipeTimeManager.Instance.ContainRecipe(recipe.Ppid))
- {
- _recipeTime = _cycle * CellItemRecipeTimeManager.Instance.GetRecipeTotalTime(recipe.Ppid);
- }
- else
- {
- _recipeTime = 0;
- }
- _currentRecipe = recipe;
- _runRecipeStartTime = DateTime.Now;
- if (WaferHolderInfo != null && _currentRecipe != null)
- {
- FaModuleNotifier.Instance.NotifyWaferShuttleRecipeStart(WaferHolderInfo, _currentRecipe.Ppid);
- }
- }
- return result;
- }
- private bool CycleManualMonitor(object[] param)
- {
- RState state = _cycleManualProcessRoutine.Monitor();
- _currentStatus = _cycleManualProcessRoutine.CurrentStatus;
- _currentStateMachine = _cycleManualProcessRoutine.CurrentStateMachine;
- if (state == RState.Failed || state == RState.Timeout)
- {
- PostMsg(PrewetMsg.Error);
- _currentStateMachine = "Error";
- _currentStatus = "Error";
- _runRecipeCompleteTime = DateTime.Now;
- _cycleManualProcessRoutine.PrewetLotTrackHeaderDatas.ProcessTime = (_runRecipeCompleteTime - _runRecipeStartTime).TotalSeconds.ToString("F2");
- //导出lotTrack数据
- PrewetLotTrackUtil.ExportPrewetLotTrack(Module.ToString(), _cycleManualProcessRoutine.PrewetLotTrackDatas,
- _cycleManualProcessRoutine.PrewetLotTrackHeaderDatas, IsAuto, _isRetry);
- if (WaferHolderInfo != null && _currentRecipe != null)
- {
- FaModuleNotifier.Instance.NotifyWaferShuttleRecipeFailed(WaferHolderInfo, _currentRecipe.Ppid);
- }
- return false;
- }
- _achievedCycle = _cycleManualProcessRoutine.GetAchievedCycle();
- bool result = state == RState.End;
- if (result)
- {
- double elapsedMilliseconds = _cycleManualProcessRoutine.ElapsedMilliseconds;
- int recipeTime = (int)Math.Floor(elapsedMilliseconds / _cycle/ 1000);
- CellItemRecipeTimeManager.Instance.UpdateRecipeTime(_currentRecipe.Ppid, recipeTime);
- _runRecipeCompleteTime = DateTime.Now;
- _cycleManualProcessRoutine.PrewetLotTrackHeaderDatas.ProcessTime = (_runRecipeCompleteTime - _runRecipeStartTime).TotalSeconds.ToString("F2");
- //导出lotTrack数据
- PrewetLotTrackUtil.ExportPrewetLotTrack(Module.ToString(), _cycleManualProcessRoutine.PrewetLotTrackDatas,
- _cycleManualProcessRoutine.PrewetLotTrackHeaderDatas, IsAuto, _isRetry);
- if (WaferHolderInfo != null && _currentRecipe != null)
- {
- FaModuleNotifier.Instance.NotifyWaferShuttleRecipeEnd(WaferHolderInfo, _currentRecipe.Ppid, recipeTime);
- }
- }
- return result;
- }
- private bool CycleManualAbort(object[] param)
- {
- _cycleManualProcessRoutine.Abort();
- _currentStateMachine = "Abort";
- _currentStatus = "Abort";
- _runRecipeCompleteTime = DateTime.Now;
- _cycleManualProcessRoutine.PrewetLotTrackHeaderDatas.ProcessTime = (_runRecipeCompleteTime - _runRecipeStartTime).TotalSeconds.ToString("F2");
- //导出lotTrack数据
- PrewetLotTrackUtil.ExportPrewetLotTrack(Module.ToString(), _cycleManualProcessRoutine.PrewetLotTrackDatas,
- _cycleManualProcessRoutine.PrewetLotTrackHeaderDatas, IsAuto, _isRetry);
- return true;
- }
- #endregion
- /// <summary>
- /// 返回上一状态
- /// </summary>
- private void PostReturnPreState()
- {
- if (_preExecuteState == PrewetState.Init.ToString())
- {
- PostMsg(PrewetMsg.ReturnInit);
- }
- else if (_preExecuteState != PrewetState.Init.ToString())
- {
- PostMsg(PrewetMsg.ReturnIdle);
- }
- }
- #region IEntity接口模块(unused)
- public bool Check(int msg, out string reason, params object[] args)
- {
- throw new NotImplementedException();
- }
- public bool CheckAcked(int msg)
- {
- throw new NotImplementedException();
- }
- public int Invoke(string function, params object[] args)
- {
- switch (function)
- {
- case "HomeAll":
- if (IsIdle)
- {
- return (int)FSM_MSG.NONE;
- }
- if (CheckToPostMessage<PrewetState, PrewetMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PrewetMsg.Initialize))
- {
- return (int)PrewetMsg.Initialize;
- }
- else
- {
- return (int)FSM_MSG.NONE;
- }
- }
- return (int)FSM_MSG.NONE;
- }
- #endregion
- }
- public enum PrewetMsg
- {
- Error,
- Abort,
- ResumeError,
- Initialize,
- LinmotScanWet,
- KeepWet,
- DelayKeepwet,
- PrepareToPlace,
- PrepareToPick,
- PrepareToTransfer,
- ReturnInit,
- ReturnIdle,
- ProcessRecipe,
- CycleProcessRecipe,
- RunRecipe,
- PickComplete,
- Init
- }
- }
|