| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading;
 
- using System.Threading.Tasks;
 
- using System.Xml;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Sorter.Common;
 
- using MECF.Framework.Common.Equipment;
 
- using VirgoRT.Device;
 
- using VirgoRT.Devices.YASKAWA;
 
- namespace VirgoRT.Devices.EFEM
 
- {
 
-     class EfemBase : BaseDevice, IDevice
 
-     {
 
-         // Fields
 
-         //
 
-         protected volatile LinkedList<ActionBase> _actions = new LinkedList<ActionBase>();
 
-         protected EfemCommunicationBase _comm;
 
-         protected IMessageHandler _msgHandler;
 
-         public BrooksEFEMProxy BrooksProxy;
 
-         public virtual ILoadport this[ModuleName mod]
 
-         {
 
-             get { throw new ApplicationException(); }
 
-         }
 
-         // Properties
 
-         //
 
-         public new ModuleName Module { get; set; }
 
-         public OnlineFlag OnlineFlag { get; set; }
 
-         public bool CommunicationConnected { get; protected set; }
 
-         public DeviceState Status { get; set; }
 
-         public bool HasActions
 
-         {
 
-             get
 
-             {
 
-                 lock (_lockerAction)
 
-                 {
 
-                     return _actions.Any(x => x.Status == ActionStatus.Pending);
 
-                 }
 
-             }
 
-         }
 
-         public bool HasUncompleteActions
 
-         {
 
-             get
 
-             {
 
-                 lock(_lockerAction)
 
-                 {
 
-                     return _actions.Any(x => x.IsBackground == false && x.Status == ActionStatus.SendCmd);
 
-                 }
 
-             }
 
-         }
 
-         public EfemCommunicationBase Comm => _comm;
 
-         public IMessageHandler MsgHandler => _msgHandler;
 
-         protected object _lockerAction = new object();
 
-         public string GripStateBlade1
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public string GripStateBlade2
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         protected EfemBase(XmlElement xmlNode = null)
 
-         {
 
-         }
 
-         public bool Initialize()
 
-         {
 
-             return true;
 
-         }
 
-         public void Monitor()
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         public void Terminate()
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         public void Reset()
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         // Methods
 
-         //
 
-         public void ExecuteAction()
 
-         {
 
-             lock (_lockerAction)
 
-             {
 
-                 if (!_actions.Any())
 
-                 {
 
-                     LOG.Write("No Action in the EFEM Queue");
 
-                     return;
 
-                 }
 
-                 if (_actions.All(x => x.Status != ActionStatus.Pending))
 
-                 {
 
-                     LOG.Write("NO pending Action in EFEM Queue");
 
-                     //System.Diagnostics.Trace.Assert(false);
 
-                     return;
 
-                 }
 
-                 var nextAction = _actions.First(a => a.Status == ActionStatus.Pending);
 
-                 if (nextAction != null)
 
-                 {
 
-                     LOG.Write($"found pending action : efem action [{nextAction.GetType().Name}] [{nextAction.ID}] 开始执行");
 
-                     nextAction.Execute();
 
-                 }
 
-             }
 
-         }
 
-         public void ClearActions()
 
-         {
 
-             lock (_lockerAction)
 
-             {
 
-                 _actions?.Clear();
 
-             }
 
-         }
 
-         public void AddAction(ActionBase cmd)
 
-         {
 
-             lock (_lockerAction)
 
-             {
 
-                 _actions.AddLast(cmd);
 
-                 LOG.Write($"efem action [{cmd.GetType().Name}] [{cmd.ID}] add to queue");
 
-                 if (cmd.IsBackground)
 
-                 {
 
-                     LOG.Write($"background, efem action [{cmd.GetType().Name}]  [{cmd.ID}] 开始执行");
 
-                     cmd.Execute();
 
-                 }
 
-                 if (cmd is LedAction)
 
-                 {
 
-                     Thread.Sleep(50);
 
-                 }
 
-                 if (cmd is LiftAction)
 
-                 {
 
-                     Thread.Sleep(50);
 
-                 }
 
-             }
 
-         }
 
-         public void UpdateStatus(ushort Id, ActionStatus st)
 
-         {
 
-             lock (_lockerAction)
 
-             {
 
-                 var cur = _actions.First(x => x.ID == Id);
 
-                 if (null == cur)
 
-                 {
 
-                     LOG.Write($"NO {Id} action in the queue");
 
-                     return;
 
-                 }
 
-                 cur.Status = st;
 
-                 if (st == ActionStatus.Completed)
 
-                 {
 
-                     cur.OnPostWork();
 
-                     _actions.Remove(cur);
 
-                     LOG.Write($"efem action [{cur.GetType().Name}] [{cur.ID}] removed from queue");
 
-                 }
 
-             }
 
-         }
 
-         public virtual void ReceiveMessage(string sRec) { throw new NotImplementedException(); }
 
-         public void SetOnline(bool online)
 
-         {
 
-             this.OnlineFlag = online ? OnlineFlag.Online : OnlineFlag.Offline;
 
-         }
 
-         public virtual void SetOnline(ModuleName mod, bool online) { }
 
-         public virtual void SetBusy(ModuleName mod, bool online) { }
 
-     }
 
- }
 
 
  |