Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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);
        }