1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- 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.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Core.Utilities;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.Common.Utilities;
- using MECF.Framework.Common.WaferHolder;
- using CyberX8_Core;
- using CyberX8_RT.Devices.AXIS;
- using CyberX8_RT.Devices.Loader;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MECF.Framework.Common.Alarm;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.Routine;
- using System.Collections;
- using System.Windows.Markup;
- using MECF.Framework.Common.CommonData.Loader;
- using Aitex.Core.Common;
- using MECF.Framework.RT.Core.Equipments;
- using CyberX8_RT.Modules.Dryer;
- namespace CyberX8_RT.Modules.Loader
- {
- public class LoaderEntity : Entity, IEntity, IModuleEntity
- {
- public enum LotTrackDatasStatus
- {
- None,
- Half,
- Complete
- }
- #region 属性
- public ModuleName Module { get; private set; }
- public bool IsInit
- {
- get { return fsm.State == (int)LOADERSTATE.Init; }
- }
- public bool IsIdle
- {
- get
- {
- return fsm.State == (int)LOADERSTATE.Idle;
- }
- }
- public bool IsError
- {
- get { return fsm.State == (int)LOADERSTATE.Error; }
- }
- public bool IsBusy
- {
- get { return !IsInit && !IsError && !IsIdle; }
- }
- public bool IsAuto { get; } = true;
- /// <summary>
- /// 是否为工程模式
- /// </summary>
- public bool IsEngineering { get; } = false;
- /// <summary>
- /// 是否为产品模式
- /// </summary>
- public bool IsProduction { get; } = true;
- public bool IsHomed
- {
- get { return _isHomed; }
- }
- /// <summary>
- /// 当前状态机状态
- /// </summary>
- public int State { get { return fsm.State; } }
- /// <summary>
- /// 是否禁用
- /// </summary>
- public bool IsDisable { get; internal set; }
- /// <summary>
- /// Rotation是否SwitchOn
- /// </summary>
- public bool IsRotationSwitchOn
- {
- get { return _rotationAxis.IsSwitchOn; }
- }
- /// <summary>
- /// ShuttleA是否SwitchOn
- /// </summary>
- public bool IsShuttleASwitchOn
- {
- get { return _shuttleAAxis.IsSwitchOn; }
- }
- /// <summary>
- /// ShuttleB是否SwitchOn
- /// </summary>
- public bool IsShuttleBSwitchOn
- {
- get { return _shuttleBAxis.IsSwitchOn; }
- }
- /// <summary>
- /// TiltA是否SwitchOn
- /// </summary>
- public bool IsTiltASwitchOn
- {
- get { return _tiltAAxis.IsSwitchOn; }
- }
- /// <summary>
- /// TiltB是否SwitchOn
- /// </summary>
- public bool IsTiltBSwitchOn
- {
- get { return _tiltBAxis.IsSwitchOn; }
- }
- /// <summary>
- /// CrsA是否SwitchOn
- /// </summary>
- public bool IsCrsASwitchOn
- {
- get { return _crsAAxis.IsSwitchOn; }
- }
- /// <summary>
- /// CrsB是否SwitchOn
- /// </summary>
- public bool IsCrsBSwitchOn
- {
- get { return _crsBAxis.IsSwitchOn; }
- }
- /// <summary>
- /// WaferHolder信息
- /// </summary>
- public WaferHolderInfo WaferHolderInfo { get { return WaferHolderManager.Instance.GetWaferHolder("Loader"); } }
- #endregion
- #region 内部变量
- private bool _isHomed = false;
- private IRoutine _currentRoutine;
- /// <summary>
- /// Loader当前unload、load操作Slot
- /// </summary>
- private Dictionary<string, List<string>> _loaderOperatingWaferInfosList = new Dictionary<string, List<string>> { { "unload", new List<string>(new string[2]) }, { "load", new List<string>(new string[2]) } };
- #region Axis
- JetAxisBase _shuttleAAxis;
- JetAxisBase _shuttleBAxis;
- JetAxisBase _tiltAAxis;
- JetAxisBase _tiltBAxis;
- JetAxisBase _crsAAxis;
- JetAxisBase _crsBAxis;
- JetAxisBase _rotationAxis;
- LoaderSideDevice _sideA;
- LoaderSideDevice _sideB;
- LoaderCommonDevice _loaderCommon;
- #endregion
- #region routine
- private LoaderHomeAllRoutine _homeAllRoutine;
- private LoaderSwitchAllOnRoutine _switchAllOnRoutine;
- private LoaderSwitchAllOffRoutine _switchAllOffRoutine;
- private LoaderUnloadSideRoutine _unloadSideRoutine;
- private LoaderLoadSideRoutine _loadSideRoutine;
- #endregion
- #region LotTrackDatas
- /// <summary>
- /// Load LotTrackData
- /// </summary>
- private List<LoaderLotTrackData> _loadLotTrackDatas = new List<LoaderLotTrackData>();
- /// <summary>
- /// UnLoad LotTrackData
- /// </summary>
- private List<LoaderLotTrackData> _unloadLotTrackDatas = new List<LoaderLotTrackData>();
- /// <summary>
- /// UnLoad LotTrackDataBuffer
- /// </summary>
- private List<LoaderLotTrackData> _unloadLotTrackDatasBuffer = new List<LoaderLotTrackData>();
- /// <summary>
- /// LeakTest LotTrackData
- /// </summary>
- private List<LoaderFlowLotTrackData> _flowLotTrackdatas = new List<LoaderFlowLotTrackData>();
- /// <summary>
- /// LoadTime
- /// </summary>
- private List<DateTime> _loadTimeList = new List<DateTime>();
- /// <summary>
- /// LoadTime
- /// </summary>
- private List<DateTime> _unloadTimeList = new List<DateTime>();
- /// <summary>
- /// Unload Start Time
- /// </summary>
- private DateTime _unloadStartTime;
- /// <summary>
- /// LotTrackHead
- /// </summary>
- private LotTrackFileHeaderCommonData _headerdata;
- /// <summary>
- /// Load Datas Status
- private LotTrackDatasStatus _loadDatasStatus = LotTrackDatasStatus.None;
- /// <summary>
- /// Unload Datas Status
- /// </summary>
- private LotTrackDatasStatus _unloadDatasStatus = LotTrackDatasStatus.None;
- /// <summary>
- /// Unload Datas Buffer Status
- /// </summary>
- private LotTrackDatasStatus _unloadDatasBufferStatus = LotTrackDatasStatus.None;
- /// <summary>
- /// Flow Test Datas status
- /// </summary>
- private LotTrackDatasStatus _flowTestDatasStatus = LotTrackDatasStatus.None;
- #endregion
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public LoaderEntity(ModuleName module)
- {
- this.Module = module;
- _shuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.ShuttleA");
- _shuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.ShuttleB");
- _tiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.TiltA");
- _tiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.TiltB");
- _crsAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.LSA");
- _crsBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.LSB");
- _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.Rotation");
- _sideA = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
- _sideB = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
- _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{module}.Common");
- WaferManager.Instance.SubscribeLocation(Module, 2);
- InitialOperation();
- InitializeRoutine();
- InitialDATA();
- InitialFsm();
- }
- /// <summary>
- /// 初始化操作
- /// </summary>
- private void InitialOperation()
- {
- OP.Subscribe($"{Module}.Abort", (cmd, args) => { return CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.Abort); });
- OP.Subscribe($"{Module}.ClearError", (cmd, args) => { return CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.ClearError); });
- OP.Subscribe($"{Module}.Common.HomeAll", (cmd, args) => { PostMsg((int)LoaderMSG.HomeAll); return true; });
- OP.Subscribe($"{Module}.Common.SwitchOnAll", (cmd, args) => { PostMsg((int)LoaderMSG.SwitchOnAll); return true; });
- OP.Subscribe($"{Module}.Common.SwitchOffAll", (cmd, args) => { PostMsg((int)LoaderMSG.SwitchOffAll); return true; });
- }
- /// <summary>
- /// 初始化Routine
- /// </summary>
- private void InitializeRoutine()
- {
- _homeAllRoutine=new LoaderHomeAllRoutine(Module.ToString());
- _switchAllOnRoutine=new LoaderSwitchAllOnRoutine(Module.ToString());
- _switchAllOffRoutine=new LoaderSwitchAllOffRoutine(Module.ToString());
- _unloadSideRoutine = new LoaderUnloadSideRoutine(Module.ToString());
- _loadSideRoutine=new LoaderLoadSideRoutine(Module.ToString());
- }
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void InitialDATA()
- {
- InitializeSvid();
- DATA.Subscribe($"{Module}.FsmState", () => ((LOADERSTATE)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsHomed", () => _isHomed, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsError", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <summary>
- /// 初始化SVID
- /// </summary>
- private void InitializeSvid()
- {
- DATA.Subscribe($"{Module}.State", () => ((LOADERSTATE)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LotID", () => WaferHolderInfo?.LotId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WSID", () => WaferHolderInfo?.Id, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LSAID", () => WaferHolderInfo?.CrsAId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.LSBID", () => WaferHolderInfo?.CrsBId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.SequenceRecipe", () => WaferHolderInfo?.SequenceId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WaferAID", () => WaferHolderInfo?.WaferAId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.WaferBID", () => WaferHolderInfo?.WaferBId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.Task", () => WaferHolderInfo?.CurrentControlJobId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <summary>
- /// 初始化状态机
- /// </summary>
- private void InitialFsm()
- {
- fsm = new StateMachine<LoaderEntity>(Module.ToString(), (int)LOADERSTATE.Init, 100);
- fsm.EnableRepeatedMsg(true);
- AnyStateTransition(LoaderMSG.Error, EnterError, LOADERSTATE.Error);
- AnyStateTransition(LoaderMSG.ReturnInit, EnterInit, LOADERSTATE.Init);
- AnyStateTransition(LoaderMSG.ReturnIdle, NullFunc, LOADERSTATE.Idle);
- AnyStateTransition(LoaderMSG.Abort, Abort, LOADERSTATE.Init);
- //clear error
- Transition(LOADERSTATE.Error, LoaderMSG.ClearError, ResumeError, LOADERSTATE.Init);
- //HomeAll
- AnyStateTransition(LoaderMSG.HomeAll, HomeAll, LOADERSTATE.Homing);
- Transition(LOADERSTATE.Homing, FSM_MSG.TIMER, HomeAllMonitor, LOADERSTATE.Idle);
- //Switch On All
- Transition(LOADERSTATE.Error, LoaderMSG.SwitchOnAll, SwitchOnAll, LOADERSTATE.SwitchOning);
- Transition(LOADERSTATE.Init, LoaderMSG.SwitchOnAll, SwitchOnAll, LOADERSTATE.SwitchOning);
- Transition(LOADERSTATE.Idle, LoaderMSG.SwitchOnAll, SwitchOnAll, LOADERSTATE.SwitchOning);
- Transition(LOADERSTATE.SwitchOning, FSM_MSG.TIMER, SwitchOnAllMonitor, LOADERSTATE.Init);
- //Switch Off All
- Transition(LOADERSTATE.Error, LoaderMSG.SwitchOffAll, SwitchOffAll, LOADERSTATE.SwitchOffing);
- Transition(LOADERSTATE.Init, LoaderMSG.SwitchOffAll, SwitchOffAll, LOADERSTATE.SwitchOffing);
- Transition(LOADERSTATE.Idle, LoaderMSG.SwitchOffAll, SwitchOffAll, LOADERSTATE.SwitchOffing);
- Transition(LOADERSTATE.SwitchOffing, FSM_MSG.TIMER, SwitchOffAllMonitor, LOADERSTATE.Init);
- //Prepare for Place
- Transition(LOADERSTATE.Idle, LoaderMSG.PrepareForPlace, PrePareForPlace, LOADERSTATE.PrepreForPlacing);
- Transition(LOADERSTATE.PrepreForPlacing, FSM_MSG.TIMER, PrepareForPlaceMonitor, LOADERSTATE.WaitForUnload);
- Transition(LOADERSTATE.Idle, LoaderMSG.ReadyForPuf, NullFunc, LOADERSTATE.WaitForUnload);
- Transition(LOADERSTATE.WaitForUnload, LoaderMSG.UnloadSide, UnloadSide, LOADERSTATE.Unloading);
- Transition(LOADERSTATE.Unloading, FSM_MSG.TIMER, UnloadSideMonitor, LOADERSTATE.WaitForLoad);
- Transition(LOADERSTATE.WaitForLoad, LoaderMSG.LoadSide, LoadSide, LOADERSTATE.Loading);
- Transition(LOADERSTATE.Loading, FSM_MSG.TIMER, LoadSideMonitor, LOADERSTATE.Idle);
- //Flip
- Transition(LOADERSTATE.Idle, LoaderMSG.WaitFlip, NullFunc, LOADERSTATE.WaitForFlip);
- Transition(LOADERSTATE.WaitForFlip,LoaderMSG.PrepareForPlace, PrePareForPlace, LOADERSTATE.PrepreForPlacing);
- //Retry
- Transition(LOADERSTATE.Error, LoaderMSG.Retry, NullFunc, LOADERSTATE.Retrying);
- Transition(LOADERSTATE.Retrying,FSM_MSG.TIMER,LoaderRetry,LOADERSTATE.Retrying);
- Transition(LOADERSTATE.Retrying, LoaderMSG.UnloadSide, RetryUnloadSide, LOADERSTATE.Unloading);
- Transition(LOADERSTATE.Retrying, LoaderMSG.LoadSide, RetryLoadSide, LOADERSTATE.Loading);
- //ConfirmComplete
- Transition(LOADERSTATE.Init, LoaderMSG.ConfirmComplete, ClearModuleAlarm, LOADERSTATE.Init);
- Transition(LOADERSTATE.Idle, LoaderMSG.ConfirmComplete, ClearModuleAlarm, LOADERSTATE.Idle);
- Transition(LOADERSTATE.Error, LoaderMSG.ConfirmComplete, NullFunc, LOADERSTATE.ConfirmCompleting);
- Transition(LOADERSTATE.ConfirmCompleting,FSM_MSG.TIMER,ConfirmComplete, LOADERSTATE.ConfirmCompleting);
- Transition(LOADERSTATE.ConfirmCompleting, LoaderMSG.PrepareForPlace, NullFunc, LOADERSTATE.WaitForUnload);
- Transition(LOADERSTATE.ConfirmCompleting,LoaderMSG.UnloadSide,ConfirmUnloadSide, LOADERSTATE.WaitForLoad);
- Transition(LOADERSTATE.ConfirmCompleting, LoaderMSG.LoadSide, ConfirmLoadSide, LOADERSTATE.Idle);
- EnumLoop<LOADERSTATE>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
- EnumLoop<LoaderMSG>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
- }
- /// <summary>
- /// 恢复错误
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ResumeError(object[] param)
- {
- if (_isHomed)
- {
- PostMsg(LoaderMSG.ReturnIdle);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 检验Loader两边waferSize不一致
- /// </summary>
- /// <returns></returns>
- public bool CheckLoaderWaferSizeNotEqual()
- {
- int sideAWaferSize = SC.GetValue<int>($"Loader1.SideAWaferSize");
- int sideBWaferSize = SC.GetValue<int>($"Loader1.SideBWaferSize");
- return sideAWaferSize != sideBWaferSize;
- }
- #region Abort
- private bool Abort(object parameter)
- {
- bool preHomed = IsHomed;
- _shuttleAAxis.StopPositionOperation();
- _shuttleBAxis.StopPositionOperation();
- _tiltAAxis.StopPositionOperation();
- _tiltBAxis.StopPositionOperation();
- _crsAAxis.StopPositionOperation();
- _crsBAxis.StopPositionOperation();
- _rotationAxis.StopPositionOperation();
- if (_currentRoutine != null)
- {
- _currentRoutine.Abort();
- _currentRoutine = null;
- }
- if (preHomed)
- {
- PostMsg(LoaderMSG.ReturnIdle);
- return false;
- }
- //Header信息
- if (_headerdata != null)
- {
- WaferHolderInfo info = WaferHolderManager.Instance.GetWaferHolder(Module.ToString());
- _headerdata.SequenceRecipe = (info != null ? $"{info.SequenceRecipe.SequenceType}\\" + $"{info.SequenceRecipe.Ppid}.seq.rcp" : null);
- _headerdata.ProcessTransferList = (info != null ? info.SchedulerModules : null);
- LoaderLotTrackUtil.ExportLoaderLotTrack(Module.ToString(), _unloadLotTrackDatas, _loadLotTrackDatas, _flowLotTrackdatas, _headerdata, _loaderOperatingWaferInfosList,
- _loadTimeList, _unloadTimeList, _unloadStartTime, LotTrackDatasStatus.None, LotTrackDatasStatus.None, LotTrackDatasStatus.None, _unloadLotTrackDatasBuffer, LotTrackDatasStatus.None);
- }
- return true;
- }
- #endregion
- /// <summary>
- /// 进入错误状态
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool EnterError(object param)
- {
- return true;
- }
- /// <summary>
- /// 进入初始化状态
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool EnterInit(object param)
- {
- _isHomed = false;
- return true;
- }
- #region HomeAll
- /// <summary>
- /// Home All
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool HomeAll(object[] param)
- {
- _isHomed = false;
- bool result= _homeAllRoutine.Start(param) == RState.Running;
- if (result)
- {
- _currentRoutine = _homeAllRoutine;
- }
- return result;
- }
- /// <summary>
- /// Load All监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool HomeAllMonitor(object[] param)
- {
- RState state = _homeAllRoutine.Monitor();
- if (state==RState.Failed||state==RState.Timeout)
- {
- _currentRoutine = null;
- PostMsg(LoaderMSG.Error);
- return false;
- }
- bool result= state == RState.End;
- if(result)
- {
- _currentRoutine = null;
- _isHomed = true;
- }
- return result;
- }
- #endregion
- #region Switch On All
- private bool SwitchOnAll(object[] param)
- {
- return _switchAllOnRoutine.Start(param) == RState.Running;
- }
-
- private bool SwitchOnAllMonitor(object[] param)
- {
- RState state = _switchAllOnRoutine.Monitor();
- if (state == RState.Failed || state == RState.Timeout)
- {
- PostMsg(LoaderMSG.ReturnInit);
- return false;
- }
- bool result= state == RState.End;
- if(result)
- {
- _isHomed = false;
- }
- return result;
- }
- #endregion
- #region Switch Off All
- private bool SwitchOffAll(object[] param)
- {
- return _switchAllOffRoutine.Start(param) == RState.Running;
- }
- private bool SwitchOffAllMonitor(object[] param)
- {
- RState state = _switchAllOffRoutine.Monitor();
- if (state == RState.Failed || state == RState.Timeout)
- {
- PostMsg(LoaderMSG.ReturnInit);
- return false;
- }
- bool result = state == RState.End;
- if (result)
- {
- _isHomed = false;
- }
- return result;
- }
- #endregion
- #region Prepare for Place
- /// <summary>
- /// Prepare For Place
- /// </summary>
- /// <returns></returns>
- private bool PrePareForPlace(object[] param)
- {
- //默认"TRNPA"
- string str = (param==null||param.Length==0)? "TRNPA":param[0].ToString();
- return _rotationAxis.PositionStation(str);
- }
- /// <summary>
- /// Prepare For Place监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool PrepareForPlaceMonitor(object param)
- {
- RState ret = _rotationAxis.Status;
- if (ret == RState.End)
- {
- return true;
- }
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostMsg(LoaderMSG.Error);
- }
- return false;
- }
- #endregion
- #region Unload Side
- /// <summary>
- /// Unload Side
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool UnloadSide(object[] param)
- {
- bool result= _unloadSideRoutine.Start(param) == RState.Running;
- if(result)
- {
- LotTrackDataClear();
- _currentRoutine = _unloadSideRoutine;
- _unloadLotTrackDatas.Clear();
- _unloadLotTrackDatasBuffer.Clear();
- _unloadTimeList.Clear();
- _unloadTimeList.Add(DateTime.Now);
- _unloadStartTime = DateTime.Now;
- _loaderOperatingWaferInfosList["unload"] = GetWaferInfo();
- //Header信息
- _headerdata = new LotTrackFileHeaderCommonData();
- _headerdata.SoftWareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
- if (SC.ContainsItem("System.ToolID")) _headerdata.ToolID = SC.GetStringValue("System.ToolID");
- _loadDatasStatus = LotTrackDatasStatus.None;
- _unloadDatasStatus = LotTrackDatasStatus.None;
- _flowTestDatasStatus = LotTrackDatasStatus.None;
- _headerdata.ProcessTransferList = new List<string>();
- }
- return result;
- }
- /// <summary>
- /// Retry UloadSide
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool RetryUnloadSide(object[] param)
- {
- int stepIndex = (int)param[0];
- bool result = _unloadSideRoutine.Retry(stepIndex)==RState.Running;
- if (result)
- {
- _unloadDatasStatus = LotTrackDatasStatus.Half;
- _unloadLotTrackDatas.Clear();
- _currentRoutine = _unloadSideRoutine;
- }
- return result;
- }
- /// <summary>
- /// Unload Side监控
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool UnloadSideMonitor(object param)
- {
- RState ret = _unloadSideRoutine.Monitor();
- if (ret == RState.End)
- {
- AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), LOADERSTATE.Unloading.ToString());
- _unloadLotTrackDatas = _unloadSideRoutine.UnloadLotTrackDatas;
- _unloadLotTrackDatasBuffer.AddRange(_unloadSideRoutine.UnloadLotTrackDatas);
- _unloadTimeList.Add(DateTime.Now);
- //Header信息
- WaferHolderInfo info = WaferHolderManager.Instance.GetWaferHolder(Module.ToString());
- _headerdata.SequenceRecipe = ((info != null && info.SequenceRecipe != null) ? $"{info.SequenceRecipe.SequenceType}\\" + $"{info.SequenceRecipe.Ppid}.seq.rcp" : "");
- if (info != null) _headerdata.ProcessTransferList.AddRange(info.SchedulerModules);
- info.SchedulerModules.Clear();
- LoaderLotTrackUtil.ExportLoaderLotTrack(Module.ToString(), _unloadLotTrackDatas, _loadLotTrackDatas, _flowLotTrackdatas, _headerdata, _loaderOperatingWaferInfosList,
- _loadTimeList, _unloadTimeList, _unloadStartTime, _unloadDatasStatus, _loadDatasStatus, _flowTestDatasStatus, _unloadLotTrackDatasBuffer, _unloadDatasStatus, true);
- return true;
- }
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- if (Singleton<RouteManager>.Instance.IsAutoRunning)
- {
- AlarmList alarmList = new AlarmList(Module.ToString(), ((LOADERSTATE)fsm.State).ToString(), (int)LoaderMSG.UnloadSide,
- _unloadSideRoutine.ErrorMsg, _unloadSideRoutine.ErrorStep, (int)AlarmType.Error);
- AlarmListManager.Instance.AddAlarm(alarmList);
- }
- PostMsg(LoaderMSG.Error);
- _unloadLotTrackDatas = _unloadSideRoutine.UnloadLotTrackDatas;
- _unloadLotTrackDatasBuffer.AddRange(_unloadSideRoutine.UnloadLotTrackDatas);
- ////Header信息
- WaferHolderInfo info = WaferHolderManager.Instance.GetWaferHolder(Module.ToString());
- _headerdata.SequenceRecipe = ((info != null && info.SequenceRecipe != null) ? $"{info.SequenceRecipe.SequenceType}\\" + $"{info.SequenceRecipe.Ppid}.seq.rcp" : "");
- if (info != null) _headerdata.ProcessTransferList.AddRange(info.SchedulerModules);
- info.SchedulerModules.Clear();
- LoaderLotTrackUtil.ExportLoaderLotTrack(Module.ToString(), _unloadLotTrackDatas, _loadLotTrackDatas, _flowLotTrackdatas, _headerdata, _loaderOperatingWaferInfosList,
- _loadTimeList, _unloadTimeList, _unloadStartTime, _unloadDatasStatus, _loadDatasStatus, _flowTestDatasStatus, _unloadLotTrackDatasBuffer, _unloadDatasStatus, true);
- }
- return false;
- }
- /// <summary>
- /// 确认UnloadAll是否完成
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ConfirmUnloadSide(object[] param)
- {
- int stepIdex=(int)param[0];
- bool result = _unloadSideRoutine.CheckCompleteCondition(stepIdex);
- if(!result)
- {
- if (Singleton<RouteManager>.Instance.IsAutoRunning)
- {
- AlarmList alarmList = new AlarmList(Module.ToString(), ((LOADERSTATE)fsm.State).ToString(), (int)LoaderMSG.UnloadSide,
- _unloadSideRoutine.ErrorMsg, _unloadSideRoutine.ErrorStep, (int)AlarmType.Error);
- AlarmListManager.Instance.AddAlarm(alarmList);
- }
- PostMsg(LoaderMSG.Error);
- }
- else
- {
- if (Singleton<RouteManager>.Instance.IsAutoRunning)
- {
- AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), LOADERSTATE.Unloading.ToString());
- }
- }
- return result;
- }
- #endregion
- #region Load Side
- /// <summary>
- /// Load Side
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool LoadSide(object[] param)
- {
- bool result= _loadSideRoutine.Start(param) == RState.Running;
- if(result)
- {
- _currentRoutine = _loadSideRoutine;
- //_loadTimeList.Clear();
- _flowLotTrackdatas.Clear();
- _loadLotTrackDatas.Clear();
- _loadDatasStatus = LotTrackDatasStatus.None;
- _flowTestDatasStatus = LotTrackDatasStatus.None;
- _unloadDatasStatus = LotTrackDatasStatus.Complete;
- _unloadDatasBufferStatus = LotTrackDatasStatus.None;
- }
- return result;
- }
- /// <summary>
- /// Retry LoadSide
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool RetryLoadSide(object[] param)
- {
- int stepIndex = (int)param[0];
- bool result = _loadSideRoutine.Retry(stepIndex) == RState.Running;
- if (result)
- {
- _unloadDatasStatus = LotTrackDatasStatus.Complete;
- _unloadDatasBufferStatus = LotTrackDatasStatus.Complete;
- SetLotTrackDatasStatus(stepIndex);
- _currentRoutine = _loadSideRoutine;
- }
- return result;
- }
- /// <summary>
- /// 监控LoadSide
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool LoadSideMonitor(object param)
- {
- RState ret = _loadSideRoutine.Monitor();
- if (ret == RState.End)
- {
- AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), LOADERSTATE.Loading.ToString());
- _loadLotTrackDatas = _loadSideRoutine.LoadLotTrackDatas;
- _loadTimeList = _loadSideRoutine.LoadTimeList;
- _flowLotTrackdatas = _loadSideRoutine.FlowLotTrackDatas;
- bool clearFlag = _loadDatasStatus == LotTrackDatasStatus.None && _flowTestDatasStatus == LotTrackDatasStatus.None;
- _loaderOperatingWaferInfosList["load"] = GetWaferInfo(clearFlag);
- //Header信息
- WaferHolderInfo info = WaferHolderManager.Instance.GetWaferHolder(Module.ToString());
- _headerdata.SequenceRecipe = ((info != null && info.SequenceRecipe != null) ? $"{info.SequenceRecipe.SequenceType}\\" + $"{info.SequenceRecipe.Ppid}.seq.rcp" : "");
- if(info != null) _headerdata.ProcessTransferList.AddRange(info.SchedulerModules);
- info.SchedulerModules.Clear();
- LoaderLotTrackUtil.ExportLoaderLotTrack(Module.ToString(), _unloadLotTrackDatas, _loadLotTrackDatas, _flowLotTrackdatas, _headerdata, _loaderOperatingWaferInfosList,
- _loadTimeList, _unloadTimeList,_unloadStartTime, _unloadDatasStatus, _loadDatasStatus, _flowTestDatasStatus, _unloadLotTrackDatasBuffer, _unloadDatasBufferStatus);
- return true;
- }
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- if (Singleton<RouteManager>.Instance.IsAutoRunning)
- {
- AlarmList alarmList = new AlarmList(Module.ToString(), ((LOADERSTATE)fsm.State).ToString(), (int)LoaderMSG.LoadSide,
- _loadSideRoutine.ErrorMsg, _loadSideRoutine.ErrorStep, (int)AlarmType.Error);
- AlarmListManager.Instance.AddAlarm(alarmList);
- }
- PostMsg(LoaderMSG.Error);
- _loadLotTrackDatas = _loadSideRoutine.LoadLotTrackDatas;
- _loadTimeList = _loadSideRoutine.LoadTimeList;
- _flowLotTrackdatas = _loadSideRoutine.FlowLotTrackDatas;
- bool clearFlag = _loadDatasStatus == LotTrackDatasStatus.None && _flowTestDatasStatus == LotTrackDatasStatus.None;
- _loaderOperatingWaferInfosList["load"] = GetWaferInfo(clearFlag);
- //Header信息
- WaferHolderInfo info = WaferHolderManager.Instance.GetWaferHolder(Module.ToString());
- _headerdata.SequenceRecipe = ((info != null && info.SequenceRecipe != null) ? $"{info.SequenceRecipe.SequenceType}\\" + $"{info.SequenceRecipe.Ppid}.seq.rcp" : "");
- if (info != null) _headerdata.ProcessTransferList.AddRange(info.SchedulerModules);
- info.SchedulerModules.Clear();
- LoaderLotTrackUtil.ExportLoaderLotTrack(Module.ToString(), _unloadLotTrackDatas, _loadLotTrackDatas, _flowLotTrackdatas, _headerdata, _loaderOperatingWaferInfosList,
- _loadTimeList, _unloadTimeList, _unloadStartTime, _unloadDatasStatus, _loadDatasStatus, _flowTestDatasStatus, _unloadLotTrackDatasBuffer, _unloadDatasBufferStatus);
- }
- return false;
- }
- /// <summary>
- /// 确认UnloadSide是否完成
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ConfirmLoadSide(object[] param)
- {
- int stepIdex = (int)param[0];
- bool result = _loadSideRoutine.CheckCompleteCondition(stepIdex);
- if (!result)
- {
- if (Singleton<RouteManager>.Instance.IsAutoRunning)
- {
- AlarmList alarmList = new AlarmList(Module.ToString(), ((LOADERSTATE)fsm.State).ToString(), (int)LoaderMSG.LoadSide,
- _loadSideRoutine.ErrorMsg, _loadSideRoutine.ErrorStep, (int)AlarmType.Error);
- AlarmListManager.Instance.AddAlarm(alarmList);
- }
- PostMsg(LoaderMSG.Error);
- }
- else
- {
- if (Singleton<RouteManager>.Instance.IsAutoRunning)
- {
- AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(),LOADERSTATE.Loading.ToString());
- }
- }
- return result;
- }
- #endregion
- #region LotTrack
- /// <summary>
- /// 获取Wafer信息
- /// </summary>
- private List<string> GetWaferInfo(bool clearPath = false)
- {
- List<string> waferIDs = new List<string>(new string[2]);
- WaferHolderInfo whInfo = WaferHolderManager.Instance.GetWaferHolder(Module.ToString());
- if (whInfo == null) return null;
- waferIDs[0] = string.IsNullOrEmpty(whInfo.WaferAId) ? "" : whInfo.WaferAId;
- waferIDs[1] = string.IsNullOrEmpty(whInfo.WaferBId) ? "" : whInfo.WaferBId;
- if (clearPath && !string.IsNullOrEmpty(waferIDs[0])) WaferManager.Instance.ClearWaferLotTrackPath(ModuleName.Loader1, 0);
- if (clearPath && !string.IsNullOrEmpty(waferIDs[1])) WaferManager.Instance.ClearWaferLotTrackPath(ModuleName.Loader1, 1);
- return waferIDs;
- }
- /// <summary>
- /// 清除信息
- /// </summary>
- private void LotTrackDataClear()
- {
- _headerdata = null;
- _loadLotTrackDatas.Clear();
- _unloadLotTrackDatas.Clear();
- _flowLotTrackdatas.Clear();
- _loadTimeList.Clear();
- _unloadTimeList.Clear();
- _loaderOperatingWaferInfosList["load"].Clear();
- _loaderOperatingWaferInfosList["unload"].Clear();
- }
- /// <summary>
- /// 设置Load LotTrackDatas记录状态
- /// </summary>
- /// <param name="stepIndex"></param>
- private void SetLotTrackDatasStatus(int stepIndex)
- {
- if (stepIndex == 0 || stepIndex == -1)
- {
- _loadDatasStatus = LotTrackDatasStatus.Half;
- _flowTestDatasStatus = LotTrackDatasStatus.None;
- }
- else if (stepIndex == 1)
- {
- _loadDatasStatus = LotTrackDatasStatus.Complete;
- _flowTestDatasStatus = LotTrackDatasStatus.None;
- }
- else
- {
- _loadDatasStatus = LotTrackDatasStatus.Complete;
- _flowTestDatasStatus = LotTrackDatasStatus.Complete;
- }
- }
- #endregion
- #region LoaderRetry
- /// <summary>
- /// Retry
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool LoaderRetry(object[] param)
- {
- AlarmList alarmList = AlarmListManager.Instance.GetAlarmListByModule(Module.ToString());
- if (alarmList != null)
- {
- CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), alarmList.ModuleCmd,
- alarmList.ModuleStep);
- }
- return false;
- }
- #endregion
- #region ConfirmComplete
- /// <summary>
- /// 确认是否完成
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ConfirmComplete(object[] param)
- {
- AlarmList alarmList = AlarmListManager.Instance.GetAlarmListByModule(Module.ToString());
- if (alarmList != null)
- {
- if(alarmList.ModuleState==LOADERSTATE.Unloading.ToString())
- {
- CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(),(int)LoaderMSG.UnloadSide,alarmList.ModuleStep);
- }
- else if(alarmList.ModuleState==LOADERSTATE.Loading.ToString())
- {
- CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.LoadSide,alarmList.ModuleStep);
- }
- else if (alarmList.ModuleState == LOADERSTATE.PrepreForPlacing.ToString())
- {
- CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.PrepareForPlace, alarmList.ModuleStep);
- }
- else
- {
- PostMsg(LoaderMSG.Error);
- }
- }
- return false;
- }
- /// <summary>
- /// 清除报警
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ClearModuleAlarm(object[] param)
- {
- AlarmList alarmList = AlarmListManager.Instance.GetAlarmListByModule(Module.ToString());
- if (alarmList != null)
- {
- AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), "");
- }
- return true;
- }
- #endregion
- public bool Check(int msg, out string reason, params object[] args)
- {
- reason = "";
- return false;
- }
- public bool CheckAcked(int msg)
- {
- return false;
- }
- public int Invoke(string function, params object[] args)
- {
- switch (function)
- {
- case "HomeAll":
- if(IsIdle)
- {
- return (int)FSM_MSG.NONE;
- }
- if (CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.HomeAll))
- {
- return (int)FSM_MSG.NONE;
- }
- else
- {
- return (int)FSM_MSG.ALARM;
- }
- case "Abort":
- CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.Abort);
- return (int)FSM_MSG.NONE;
- case "PrepareForPlace":
- if (State == (int)LOADERSTATE.WaitForUnload||State==(int)LOADERSTATE.PrepreForPlacing)
- {
- return (int)LoaderMSG.PrepareForPlace;
- }
- if (CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.WARN_LOADER, Module.ToString(), (int)LoaderMSG.PrepareForPlace,args))
- {
- return (int)LoaderMSG.PrepareForPlace;
- }
- else
- {
- return (int)FSM_MSG.NONE;
- }
- case "Retry":
- if (CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.Retry,args))
- {
- return (int)LoaderMSG.Retry;
- }
- else
- {
- return (int)FSM_MSG.NONE;
- }
- case "ConfirmComplete":
- if (CheckToPostMessage<LOADERSTATE, LoaderMSG>(eEvent.ERR_LOADER, Module.ToString(), (int)LoaderMSG.ConfirmComplete, args))
- {
- return (int)LoaderMSG.ConfirmComplete;
- }
- else
- {
- return (int)FSM_MSG.NONE;
- }
- }
- return (int)FSM_MSG.NONE;
- }
- }
- public enum LoaderMSG
- {
- ReturnInit,
- ReturnIdle,
- Abort,
- HomeAll,
- GoToSavedPosition,
- StopFlow,
- SwitchOnAll,
- SwitchOffAll,
- Error,
- ClearError,
- PrepareForPlace,
- ReadyForPuf,
- UnloadSide,
- LoadSide,
- Retry,
- ConfirmComplete,
- WaitFlip,
- }
- }
|