/// <summary> /// Set work next location from Kanban information /// かんばんの目的地をワークに付ける(付け替える) /// </summary> /// <param name="location">target location of this Process instance</param> /// <returns>Kanban that is attached to a work</returns> private JitKanban CheckAndAttachKanban(JitLocation location, DateTime now) { var queue = kanbanQueue.GetValueOrDefault(location.Stage, true, a => new Queue <EventQueueKanban>()); if (queue.Count == 0) { return(null); } var buf = from we in location.Stage.GetWorks(location.ToChangeProcess(this)) where we.Work?.Next?.Process == null // No Next work select new WorkEntery { Work = we.Work, Enter = we.EnterTime }; var work = ExitWorkSelector.Invoke(buf); if (work == null) { return(null); } var sk = queue.Dequeue(); work.Next = sk.Kanban.PullTo; work.Kanbans.Add(sk.Kanban); sk.Kanban.Work = work; if (work.ExitTime < now) { work.ExitTime = now; // Because the work should be waiting kanban to exit from this process. かんばんを待っていたので、現在時刻が進んだときは、現在時刻でExitしたいこととする。 } return(sk.Kanban); }
/// <summary> /// find filtered work order by exit time sequence /// 退出する順番に、指定する属性のワークを検索する /// </summary> /// <param name="proc"></param> /// <param name="etype"></param> /// <param name="workclass"></param> /// <returns></returns> /// <remarks></remarks> public virtual LinkedListNode <Item> Find(JitLocation proc, EventTypes etype, string workclass = JitVariable.Class.Object) { for (var node = _dat.First; node != null; node = node.Next) { var ei = node.Value; if (ei is DummyItem || ei.Work is JitWork == false) { continue; } var w = ei.Work; if (w.Current == proc && ei.Type == etype && w.Is(workclass)) { return(node); } } return(null); }
/// <summary> /// find the all filtered work order by exit time sequence /// 退出する順番に、指定する属性のワークを すべて 検索する /// </summary> /// <param name="proc"></param> /// <param name="etype"></param> /// <param name="workclass"></param> /// <returns></returns> /// <remarks></remarks> public virtual IEnumerable <LinkedListNode <Item> > FindAll(JitLocation location, EventTypes etype, string workclass = JitVariable.Class.Object) { for (var node = _dat.First; node != null; node = node.Next) { var ei = node.Value; if (ei is DummyItem) { continue; } var workloc = ei.Work.Current; if (workloc.Equals(location)) { if (ei.Type == etype && ei.Work.Is(workclass)) { yield return(node); } } } }
/// <summary> /// Exit a priority work from this process that have not next process /// Engineに溜まっているこの工程のワーク(Work.NextProcess==null)から Exit優先の高いものを一つ退出させる /// </summary> /// <returns> /// selected work. null=no work /// </returns> /// <remarks> /// ret.PrevProcess = THIS PROCESS (do not confuse prev is current) /// ret.NextProcess = null /// ret.CurrentProcess = null /// </remarks> public virtual JitWork ExitCollectedWork(JitLocation location, DateTime now) { var buf = from wt in location.GetWorks(this) where wt.Work?.Next?.Process == null // work that have not next process where wt.Work.ExitTime <= now // select work that exit time expired. select new WorkEntery { Work = wt.Work, Enter = wt.EnterTime }; var work = ExitWorkSelector.Invoke(buf); if (work != null) { Exit(work); work.Previous = work.Current.ToChangeProcess(this); work.Current = work.Current.ToEmptyProcess(); work.Next = work.Current.ToEmptyProcess(); } return(work); }