コード例 #1
0
        protected IEnumerator <DesTask> Breakdown(Process proc, object brd)
        {
            while (proc.Simulation.State == SimulationState.Running)
            {
                var d = breakdown.Nextulong();
                yield return(proc.Delay(d));

                _machine.OutOfService++;
                SetState("Breakdown", "Down");
                d = repair.Nextulong();

                var copy = currentstatus.Select(ti => new Pair <string, ulong>(ti.Key, ti.Value)).ToArray();
                currentstatus.Clear();
                foreach (var current in copy)
                {
                    current.Value += d;
                    currentstatus.Add(current.Key, current.Value);
                }

                yield return(proc.Delay(d));

                SetState("Breakdown", "Idle");
                _machine.OutOfService--;
            }
        }
コード例 #2
0
ファイル: ResourceTest.cs プロジェクト: anh123minh/DES
        private IEnumerator <Task> TransferAndInterrupt(Process p, object data)
        {
            Resource r    = (Resource)data;
            Task     task = (Task)p.ActivationData;

            yield return(r.Acquire(p));

            Assert.IsTrue(r.IsOwner(p));
            if (p.Interrupted)
            {
                yield return(p.Delay(1000L));

                yield return(r.Release(p));

                Assert.AreEqual(r.Count, r.Free);
            }
            else
            {
                yield return(p.Delay(1000L));

                yield return(r.Transfer(p, task));

                task.Interrupt(p);
            }
            Assert.IsFalse(r.IsOwner(p));
            yield break;
        }
コード例 #3
0
ファイル: ResourceTest.cs プロジェクト: anh123minh/DES
        private IEnumerator <Task> SetInService(Process p, object data)
        {
            Resource r = (Resource)data;

            yield return(p.Delay(10));

            Assert.AreEqual(r.Count, r.BlockCount);
            while (r.OutOfService > 0)
            {
                r.OutOfService--;
                yield return(p.Delay(10));
            }
            Assert.AreEqual(0, r.BlockCount);
            yield break;
        }
コード例 #4
0
 private IEnumerator <DesTask> Jobsiterator(Process process, object brd, Job job)
 {
     foreach (var sub in job.Subjobs)
     {
         yield return(process.Delay((long)sub.Distribution.NextDouble()));
     }
 }
コード例 #5
0
ファイル: ProcessTest.cs プロジェクト: anh123minh/DES
        private IEnumerator <Task> CountProcess(Process process, object data)
        {
            while (_count < 10)
            {
                _count++;
                yield return(process.Delay(10));
            }

            yield break;
        }
コード例 #6
0
ファイル: ConditionTest.cs プロジェクト: anh123minh/DES
        //====================================================================
        //====                   Private Implementation                   ====
        //====================================================================

        private IEnumerator <Task> SignalCondition(Process p, object data)
        {
            Condition c = (Condition)data;

            yield return(p.Delay(10));

            Assert.AreEqual(1, c.BlockCount);
            c.Signal();
            yield break;
        }
コード例 #7
0
        protected IEnumerator <DesTask> Breakdown(Process proc, object brd)
        {
            while (proc.Simulation.State == SimulationState.Running)
            {
                var d = (long)breakdown.NextDouble();
                var u = proc.Simulation.Now;
                yield return(proc.Delay(d));

                //yield return _machine.Acquire(proc);
                _machine.OutOfService++;
                var  p = proc.Simulation.Now - u;
                long t = proc.Simulation.Now;
                d = (long)repair.NextDouble();
                yield return(proc.Delay(d));

                long v = proc.Simulation.Now - t;
                _machine.OutOfService--;
                //yield return _machine.Release(proc);
            }
            yield break;
        }
コード例 #8
0
ファイル: ResourceTest.cs プロジェクト: anh123minh/DES
        private IEnumerator <Task> AcquireOneInterrupted(Process p, object data)
        {
            IResource r = (IResource)data;
            Task      t = new InterruptTask(p.Simulation);

            p.WaitOnTask(t, t.Priority + 10);
            Assert.AreEqual(1, t.BlockCount);

            yield return(r.Acquire(p));

            // The InterruptTask should interrupt us here.
            Assert.IsTrue(p.Interrupted);
            yield return(p.Delay(3));

            // After a delay, the interrupt flag should be cleared.
            Assert.IsTrue(!p.Interrupted);
            yield break;
        }
コード例 #9
0
        public IEnumerator <DesTask> GetProcessSteps(Process process, DESProduct product, Job job, DESMachine nextMachine)
        {
            DESMachine p = parentDES;

            while (p != null)
            {
                while (!p.Machine.IsOwner(process))
                {
                    yield return(p.Machine.Acquire(process));
                }
                p.RegisterAcquire(product);
                var t = p as DESTransport;
                if (t != null)
                {
                    yield return(t.FirstTransport(process));
                }
                p = p.parentDES;
            }

            if (!SetState(product.ProductID + "", product.ProductID + ""))
            {
                Debug.Assert(true, "Foulty");
            }
            ulong time = Simulation.Now;

            foreach (var subjob in job.Subjobs)
            {
                var d = subjob.Distribution.Nextulong();
                yield return(new Delay(Simulation, d));
            }
            var tp = parentDES as DESTransport;

            if (tp != null)
            {
                tp.TransportProduct(process, Name);
            }
            //HALT here if brokendown!!!
            var checkdowntime = time;

            while (currentstatus[product.ProductID + ""] > checkdowntime)
            {
                checkdowntime = currentstatus[product.ProductID + ""];
                yield return(process.Delay(checkdowntime - time));
            }


            (Simulation as SimulationModel).AddProductEvent(new ProductResult()
            {
                ProductType = product.Name,
                Start       = time,
                Productid   = product.ProductID,
                ModelNode   = Name,
                Total       = Simulation.Now - time
            });

            NrofProductsProcessed++;
            SetState(product.ProductID + "", "Idle");
            p = parentDES;
            DESMachine next = nextMachine;

            while (p != null && (next == null || !next.parents.Contains(p)))
            {
                while (p.Machine.IsOwner(process))
                {
                    yield return(p.Machine.Release(process));
                }
                p.RegistrerRelease(product);
                p = p.parentDES;
            }
            yield break;
        }