1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048 |
- using System;
- using System.Diagnostics;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Collections;
- using Venus_Core;
- using Venus_RT.Modules;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using Aitex.Sorter.Common;
- using Aitex.Core.Common;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using Venus_RT.Devices.YASKAWA;
- using System.Collections.Concurrent;
- namespace Venus_RT.Devices.EFEM
- {
- class JetEfem : EfemBase
- {
- private RState _status;
- private bool _IsHomed;
- private string _waferPresence;
- private bool _bIsUnloadClamp;
- private RobotMoveInfo _robotMoveInfo = new RobotMoveInfo();
- private readonly Loadport[] _LPMs = new Loadport[3];
- private readonly SignalTower _signalT = new SignalTower();
- private readonly AsyncSocket _socket;
- private EfemMessage _currentMsg;
- private EfemMessage _backroundMsg;
- private EfemMessage _revMsg;
- private bool _LiftIsUp = false;
- private bool _LiftIsDown = false;
- private R_TRIG _busyTrig = new R_TRIG();
- private Stopwatch _busyWatch = new Stopwatch();
- public override RState Status
- {
- get
- {
- _busyTrig.CLK = _status == RState.Running;
- if(_busyTrig.Q)
- {
- _busyWatch.Restart();
- }
- else if(_busyTrig.M)
- {
- if(_busyWatch.ElapsedMilliseconds > 30000)
- {
- _busyWatch.Stop();
- _status = RState.Timeout;
- }
- }
- return _status;
- }
- }
- public override bool IsHomed { get { return _IsHomed; } }
- public override RobotMoveInfo TMRobotMoveInfo { get { return _robotMoveInfo; } }
-
- public override ILoadport this[ModuleName mod]
- {
- get
- {
- if (!ModuleHelper.IsLoadPort(mod))
- throw new ApplicationException($"{mod} is NOT Loadport");
- return _LPMs[mod - ModuleName.LP1];
- }
- }
- public override bool LiftIsUp { get { return _LiftIsUp; } }
- public override bool LiftIsDown { get { return _LiftIsDown; } }
- private BlockingCollection<RobotAnimationData> blockingCollection = new BlockingCollection<RobotAnimationData>();
- public JetEfem()
- {
- _socket = new AsyncSocket("");
- _socket.Connect(SC.GetStringValue($"EFEM.IPAddress"));
- _socket.OnDataChanged += OnReceiveMessage;
- _socket.OnErrorHappened += OnErrorHappen;
- _status = RState.Init;
- _IsHomed = false;
- _busyTrig.RST = true;
- _LPMs[0] = new Loadport(ModuleName.LP1, this);
- _LPMs[1] = new Loadport(ModuleName.LP2, this);
- _LPMs[2] = new Loadport(ModuleName.LP3, this);
- CarrierManager.Instance.SubscribeLocation(ModuleName.LP1.ToString(), 1);
- CarrierManager.Instance.SubscribeLocation(ModuleName.LP2.ToString(), 1);
- CarrierManager.Instance.SubscribeLocation(ModuleName.LP3.ToString(), 1);
- Action<ModuleName, int> _subscribeLoc = (ModuleName module, int waferCount) =>
- {
- if (ModuleHelper.IsInstalled(module))
- {
- WaferManager.Instance.SubscribeLocation(module, waferCount);
- }
- };
- WaferManager.Instance.SubscribeLocation(ModuleName.EfemRobot, 2);
- WaferManager.Instance.SubscribeLocation(ModuleName.Aligner1, 1);
- // _subscribeLoc(ModuleName.EfemRobot, 2);
- //_subscribeLoc(ModuleName.Aligner1, 1);
- _subscribeLoc(ModuleName.Aligner2, 1);
- _subscribeLoc(ModuleName.Cooling1, 1);
- _subscribeLoc(ModuleName.Cooling2, 1);
- _subscribeLoc(ModuleName.LP1, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
- _subscribeLoc(ModuleName.LP2, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
- _subscribeLoc(ModuleName.LP3, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
- Task.Run(() =>
- {
- foreach (var data in blockingCollection.GetConsumingEnumerable())
- {
- _robotMoveInfo.Action = data.Action;
- _robotMoveInfo.ArmTarget = data.Hand == Hand.Blade1 ? RobotArm.ArmA : (data.Hand == Hand.Both ? RobotArm.Both : RobotArm.ArmB);
- _robotMoveInfo.BladeTarget = $"{_robotMoveInfo.ArmTarget}.{data.Target}";
- System.Threading.Thread.Sleep(600);
- }
- });
- }
- public override void Monitor()
- {
- }
- public override void Terminate()
- {
- }
- public override void Reset()
- {
- _status = RState.End;
- }
- public override void SetOnline(bool online)
- {
- }
- public override void SetOnline(ModuleName mod, bool online)
- {
- }
- public override void SetBusy(ModuleName mod, bool online)
- {
- _status = RState.Running;
- }
- public override bool HomeAll()
- {
- if (_status == RState.Running)
- _backroundMsg = _currentMsg;
- _currentMsg = new EfemMessage
- {
- Port = ModuleName.EFEM,
- Operation = EfemOperation.Home,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[ModuleName.EFEM] }
- };
- _status = RState.Running;
- string data = _currentMsg.ToString();
- SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
- return _socket.Write(data);
- }
- public override bool Home(ModuleName mod)
- {
- if (_status == RState.Running)
- _backroundMsg = _currentMsg;
- if (ModuleHelper.IsLoadPort(mod))
- {
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Home,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- else
- {
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Home,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- }
- public override bool OriginalSearch(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = ModuleName.EFEM,
- Operation = EfemOperation.Orgsh,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- Constant.ModuleString[mod]
- }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool CheckWaferPresence()
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = ModuleName.EFEM,
- Operation = EfemOperation.StateTrack,
- Head = EfemMessage.MsgHead.GET,
- Parameters = new List<string> { "TRACK" }
- };
- _waferPresence = string.Empty;
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override string GetWaferPresence()
- {
- return _waferPresence;
- }
- public override bool Halt()
- {
- if (_status == RState.Running)
- _backroundMsg = _currentMsg;
- _currentMsg = new EfemMessage
- {
- Port = ModuleName.EFEM,
- Operation = EfemOperation.EmsStop,
- Head = EfemMessage.MsgHead.MOV,
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool ClearError()
- {
- _currentMsg = new EfemMessage
- {
- Port = ModuleName.EFEM,
- Operation = EfemOperation.ClearError,
- Head = EfemMessage.MsgHead.SET,
- Parameters = new List<string> { "CLEAR" }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool PickExtend(ModuleName chamber, int slot, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Extend,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- chamber.ToHWString(),
- ExtendPos.GB.ToString(),
- Constant.ArmString[hand],
- }
- };
- SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool PickRetract(ModuleName chamber, int slot, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Extend,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- chamber.ToHWString(),
- ExtendPos.G4.ToString(),
- Constant.ArmString[hand],
- }
- };
- _status = RState.Running;
- SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Extend,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- chamber.ToHWString(),
- ExtendPos.PB.ToString(),
- Constant.ArmString[hand],
- }
- };
- _status = RState.Running;
- SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Extend,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- chamber.ToHWString(),
- ExtendPos.P4.ToString(),
- Constant.ArmString[hand],
- }
- };
- _status = RState.Running;
- SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Pick(ModuleName station, int slot, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- Position SrcPos = new Position { Module = station, Slot = (byte)slot };
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Pick,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- SrcPos.ToHWString(),
- Constant.ArmString[hand],
- //WaferSize.WS12.ToString()
- }
- };
- _status = RState.Running;
- SetRobotMovingInfo(RobotAction.Picking, hand, station);
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Place(ModuleName station, int slot, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- Position DestPos = new Position { Module = station, Slot = (byte)slot };
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Place,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- DestPos.ToHWString(),
- Constant.ArmString[hand],
- //WaferSize.WS12.ToString()
- }
- };
- _status = RState.Running;
- SetRobotMovingInfo(RobotAction.Placing, hand, station);
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Goto(ModuleName station, Hand hand)
- {
- if (!CheckEfemStatus())
- return false;
- Position DestPos = new Position { Module = station, Slot = (byte)0 };
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Goto,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string>
- {
- DestPos.ToHWString(),
- Constant.ArmString[hand],
- WaferSize.WS12.ToString()
- }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Grip(Hand blade, bool isGrip)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Grip,
- Head = EfemMessage.MsgHead.SET,
- Parameters = new List<string>
- {
- isGrip ? "ON":"OFF",
- Constant.ArmString[blade]
- }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Map(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Map,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool SetPinUp(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Lift,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod], "UP" }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool SetPinDown(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Lift,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod], "DOWN" }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Align(ModuleName mod, double angle, float delayTime, WaferSize size)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Operation = EfemOperation.Align,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { $"A{angle.ToString("000.00")}" }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool SetLamp(LightType light, LightStatus status)
- {
- if (Status == RState.Running)
- {
- LOG.Write(eEvent.ERR_EFEM_ROBOT, ModuleName.EFEM, "EFEM is busy, please wait a minute");
- return false;
- }
- _currentMsg = new EfemMessage
- {
- Port = ModuleName.EFEM,
- Operation = EfemOperation.Light,
- Head = EfemMessage.MsgHead.SET,
- Parameters = new List<string> { Constant.STOWER, light.ToString(), status.ToString() }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Load(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Load,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Unload(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Unload,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool ReadCarrierId(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.CarrierId,
- Head = EfemMessage.MsgHead.GET,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool WriteCarrierId(ModuleName mod, string id)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.CarrierId,
- Head = EfemMessage.MsgHead.SET,
- Parameters = new List<string> { Constant.ModuleString[mod], id }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool ReadTagData(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.CarrierId,
- Head = EfemMessage.MsgHead.GET,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool WriteTagData(ModuleName mod, string tagData)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.CarrierId,
- Head = EfemMessage.MsgHead.SET,
- Parameters = new List<string> { Constant.ModuleString[mod], tagData }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Dock(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Dock,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Undock(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Undock,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Clamp(ModuleName mod, bool isUnloadClamp)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Clamp,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- _bIsUnloadClamp = isUnloadClamp;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool Unclamp(ModuleName mod)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.Unclamp,
- Head = EfemMessage.MsgHead.MOV,
- Parameters = new List<string> { Constant.ModuleString[mod] }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override bool SetThickness(ModuleName mod, string thickness)
- {
- if (!CheckEfemStatus())
- return false;
- _currentMsg = new EfemMessage
- {
- Port = mod,
- Operation = EfemOperation.SetThickness,
- Head = EfemMessage.MsgHead.SET,
- Parameters = new List<string> { Constant.ModuleString[mod], thickness.ToUpper() }
- };
- _status = RState.Running;
- return _socket.Write(_currentMsg.ToString());
- }
- public override void SetRobotMovingInfo(RobotAction action, Hand hand, ModuleName target)
- {
- blockingCollection.Add(new RobotAnimationData(action, hand, target));
- }
- private void OnReceiveMessage(string RevMsg)
- {
- string[] msgs = RevMsg.Split('\r');
- foreach (var msg in msgs)
- {
- if (string.IsNullOrWhiteSpace(msg)) continue;
- EfemMessage rec_msg = msg.ToMessage();
- switch (rec_msg.Head)
- {
- case EfemMessage.MsgHead.ACK:
- if (msg.Contains("ERROR"))
- {
- _revMsg = rec_msg;
- }
- break;
- case EfemMessage.MsgHead.INF:
- // 收到INF之后发送ACK确认
- string strACK = rec_msg.RawString.Replace("INF", "ACK");
- SendBack(strACK);
- EfemMessage ack_msg = strACK.ToMessage();
- ack_msg.Direct = MsgDirection.To;
- _revMsg = rec_msg;
- OnCommandUpdated(rec_msg);
- SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
- break;
- case EfemMessage.MsgHead.EVT:
- OnEventUpdated(new EfemEventArgs
- {
- EvtStr = rec_msg.ToParamString(),
- Module = rec_msg.Port,
- CommandType = rec_msg.Operation,
- DataList = rec_msg.Data
- });
- if (rec_msg.Operation == EfemOperation.Home)
- {
- SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
- }
- break;
- case EfemMessage.MsgHead.NAK:
- case EfemMessage.MsgHead.CAN:
- case EfemMessage.MsgHead.ABS:
- OnErrorOccurred(rec_msg);
- break;
- }
- }
- }
- private void OnErrorHappen(ErrorEventArgs args)
- {
- _status = RState.Failed;
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- private void OnErrorOccurred(EfemMessage message)
- {
- string description = string.Empty;
- switch (message.Head)
- {
- case EfemMessage.MsgHead.NAK:
- description = Constant.FactorString[message.Factor];
- break;
- case EfemMessage.MsgHead.CAN:
- description = Constant.FactorString.ContainsKey(message.Factor) ? Constant.FactorString[message.Factor] : message.Factor;
- break;
- case EfemMessage.MsgHead.ABS:
- description = $"{message.Data[0]}, {message.Data[1]}";
- break;
- }
- _status = RState.Failed;
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, $"{description}, [{message.Data[0]}], [{message.Factor}]");
- }
- private void OnEventUpdated(EfemEventArgs eArg)
- {
- switch (eArg.CommandType)
- {
- case EfemOperation.SigStatus:
- // EVT:SIGSTAT/Parameter/DATA1/DATA2;
- string sParam = eArg.DataList[0]; // "SYSTEM" or "Pn"
- // DATA1 & DATA2
- int nData1 = Convert.ToInt32(eArg.DataList[1], 16);
- int nData2 = Convert.ToInt32(eArg.DataList[2], 16);
- BitArray baData1 = new BitArray(new int[] { nData1 });
- BitArray baData2 = new BitArray(new int[] { nData2 });
- if (0 == string.Compare(sParam, Constant.SYS, true))
- {
- // EVT:SIGSTAT/System/00000000/00000004;
- // DATA1
- // Post warning and alarm
- if (!baData1[0]) // Bit[0] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMVacuumPressureError);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM System vacuum source pressure low");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[1]) // Bit[1] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMIonizerAlarm);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM Ionizer compressed air error");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[2]) // Bit[2] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMCDAError);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM System compressed air pressure low");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[4]) // Bit[4] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMFlowGaugeSensorError);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM Flow gauge sensor error");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[5]) // Bit[5] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMLeakageAlarm);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM Leakage alarm");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[10]) // Bit[10] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMIonizerAlarm);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM Ionizer alarm");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[11]) // Bit[11] ON=Normal, OFF=Abnormal
- {
- //EV.Notify(EFEMFFUAlarm);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "FFU alarm");
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
- }
- if (!baData1[13]) // Bit[13] ON=RUN, OFF=Maintain
- {
- //EV.Notify(EFEMOffline);
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "EFEM switch to Maintain mode, HomeAll to recover");
- }
- // DATA2
- _signalT.ChangeLightStatus(LightType.RED, baData2[0] ? LightStatus.ON : baData2[5] ? LightStatus.BLINK : LightStatus.OFF);
- _signalT.ChangeLightStatus(LightType.GREEN, baData2[1] ? LightStatus.ON : baData2[6] ? LightStatus.BLINK : LightStatus.OFF);
- _signalT.ChangeLightStatus(LightType.YELLOW, baData2[2] ? LightStatus.ON : baData2[7] ? LightStatus.BLINK : LightStatus.OFF);
- _signalT.ChangeLightStatus(LightType.BLUE, baData2[3] ? LightStatus.ON : baData2[8] ? LightStatus.BLINK : LightStatus.OFF);
- _signalT.ChangeLightStatus(LightType.WHITE, baData2[4] ? LightStatus.ON : baData2[9] ? LightStatus.BLINK : LightStatus.OFF);
- _signalT.ChangeLightStatus(LightType.BUZZER1, baData2[10] ? LightStatus.ON : LightStatus.OFF);
- /* EFEM 程序中目前没有实现
- _RobotErr.CLK = baData2[27]; // bit 27
- bool bArmNotExtendLLA = baData2[30]; // bit 30
- bool bArmNotExtendLLB = baData2[31]; // bit 31
- */
- } // system event
- else
- {
- _LPMs[eArg.Module - ModuleName.LP1].HandleEvent(eArg);
- } // FOUP EVENT
- break;
- case EfemOperation.GetWaferInfo:
- _LPMs[eArg.Module - ModuleName.LP1].HandleEvent(eArg);
- break;
- default:
- break;
- }
- }
- private void OnCommandUpdated(EfemMessage message)
- {
- if (message.Operation != EfemOperation.Ready)
- {
- if (_currentMsg.Operation != message.Operation && (_backroundMsg == null || _backroundMsg.Operation != message.Operation))
- {
- LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EfemRobot, $"OnCommandUpdated() unexpected return: {message.Operation}, expect: {_currentMsg.Operation}");
- return;
- }
- }
- switch (message.Operation)
- {
- case EfemOperation.ClearError:
- case EfemOperation.Align:
- case EfemOperation.Map:
- case EfemOperation.Pick:
- case EfemOperation.Place:
- case EfemOperation.Extend:
- case EfemOperation.Goto:
- case EfemOperation.Orgsh:
- case EfemOperation.EmsStop:
- case EfemOperation.Light:
- _status = RState.End;
- break;
- case EfemOperation.StateTrack:
- {
- _waferPresence = message.Data.Count >= 1 ? message.Data.First() : string.Empty;
- _IsHomed = true;
- _status = RState.End;
- }
- break;
- case EfemOperation.Home:
- {
- if (_currentMsg.Port == ModuleName.EFEM)
- {
- _LPMs[0].OnHomed();
- _LPMs[1].OnHomed();
- _LPMs[2].OnHomed();
- }
- else if (ModuleHelper.IsLoadPort(_currentMsg.Port))
- {
- _LPMs[_currentMsg.Port - ModuleName.LP1].OnHomed();
- }
- _status = RState.End;
- }
- break;
- case EfemOperation.Load:
- {
- _LPMs[message.Port - ModuleName.LP1].OnLoaded();
- _status = RState.End;
- }
- break;
- case EfemOperation.Unload:
- {
- _LPMs[message.Port - ModuleName.LP1].OnUnloaded();
- _status = RState.End;
- }
- break;
- case EfemOperation.CarrierId:
- {
- if (message.Head == EfemMessage.MsgHead.GET)
- {
- _LPMs[message.Port - ModuleName.LP1].OnCarrierIDRead(message.Data.First());
- }
- else
- {
- _LPMs[message.Port - ModuleName.LP1].OnCarrierIDWrite(message.Data.First());
- }
- _status = RState.End;
- }
- break;
- case EfemOperation.Clamp:
- {
- _LPMs[message.Port - ModuleName.LP1].OnClamped(_bIsUnloadClamp);
- _status = RState.End;
- }
- break;
- case EfemOperation.Unclamp:
- {
- _LPMs[message.Port - ModuleName.LP1].OnUnclamped();
- _status = RState.End;
- }
- break;
- case EfemOperation.Grip:
- {
- if (_currentMsg.Parameters[1] == "ARM2")
- {
- GripStateBlade1 = _currentMsg.Parameters[0];
- }
- else
- {
- GripStateBlade2 = _currentMsg.Parameters[0];
- }
- _status = RState.End;
- }
- break;
- case EfemOperation.Ready:
- {
- Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.CommReady);
- }
- break;
- case EfemOperation.Lift:
- {
- if (_currentMsg.Parameters[1] == "UP")
- {
- _LiftIsUp = true;
- _LiftIsDown = false;
- }
- else if (_currentMsg.Parameters[1] == "DOWN")
- {
- _LiftIsUp = false;
- _LiftIsDown = true;
- }
- _status = RState.End;
- }
- break;
- }
- }
- void SendBack(string data)
- {
- _socket.Write(data + '\r');
- }
- }
- }
|