Exemplo n.º 1
0
        protected override IEnumerator <DesTask> GetProcessSteps()
        {
            DESMachine prev = null;

            for (int i = 0; i < jobsPairs.Count; i++)
            {
                var jobpair = jobsPairs[i];

                while (!jobpair.Key.Machine.IsOwner(this))
                {
                    yield return(jobpair.Key.Machine.Acquire(this));
                }


                if (prev != null && prev != jobpair.Key)
                {
                    yield return(prev.Machine.Release(this));
                }

                var n = jobsPairs.Count < i + 1 ? jobsPairs[i + 1].Key : null;
                //var job = jobpair.Key.GetProcessSteps(this, jobpair.Value, n);
                yield return(ProcessJob(jobpair.Key, this, jobpair.Value, n));

                prev = jobpair.Key;
            }

            yield return(prev.Machine.Release(this));

            yield break;
        }
Exemplo n.º 2
0
 public Process ProcessJob(DESMachine machine, DESProduct product, Job job, DESMachine nextDesMachine)
 {
     if (machine != null || job != null)
     {
         var p = new Process(Simulation, (process, o) => machine.GetProcessSteps(process, product, job, nextDesMachine));
         return(p);
     }
     return(null);
 }
Exemplo n.º 3
0
        public DESTransport(SimulationModel sim, Transport involvednode, DESMachine parentNode) : base(sim, involvednode, parentNode)
        {
            speed          = involvednode.ResourceModel.Speed;
            startdistances = involvednode.ResourceModel.DistansToNode;
            var list =
                involvednode.ResourceModel.DistanceBetweenChildrenNodesWithNodes.Select(
                    t => new KeyValuePair <string, decimal>(t.Key.Text, t.Value));

            foreach (var pair in list)
            {
                distances.Add(pair.Key, pair.Value);
            }
        }
Exemplo n.º 4
0
        private void CreateModel(IEnumerable <Product> productenumerable, ulong simulationTime)
        {
            var products = productenumerable.ToList();

            sims.Clear();
            //simprogress.Value = 0;

            var involvedproductsjobs = products.Select(t => t.Nodes).Distinct();

            for (int i = 0; i < _nrOfIterations; i++)
            {
                var machines = new List <DESMachine>();
                var sim      = new SimulationModel()
                {
                    ClosingTime = simulationTime
                };
                var enumerable = involvedproductsjobs as ObservableCollection <Pair <ModelNode, Job> >[] ?? involvedproductsjobs.ToArray();

                foreach (var involvedproductsjob in enumerable)
                {
                    foreach (var pair in involvedproductsjob)
                    {
                        var machine = machines.FirstOrDefault(t => t.Name == pair.Key.ResourceModel.ProcessName);
                        if (machine == null)
                        {
                            DESMachine parent = CreateParentMachines(pair.Key, machines, sim);
                            machine = new DESMachine(sim, pair.Key, parent);
                            machines.Add(machine);
                        }
                    }
                }
                sim.AddMachines(machines);

                foreach (var product in products)
                {
                    sim.AddProduct(product.ProductName,
                                   product.Nodes.Select(
                                       t =>
                                       new Pair <DESMachine, Job>(
                                           machines.FirstOrDefault(p => p.Name == t.Key.ResourceModel.ProcessName), t.Value))
                                   .ToList());
                }


                sim.PropertyChanged += sim_PropertyChanged;

                sims.Add(sim);
            }
        }
Exemplo n.º 5
0
        private static DESMachine CreateParentMachines(ModelNode node, List <DESMachine> machines, SimulationModel sim)
        {
            DESMachine DESNode = null;

            if (node.ParentNode != null)
            {
                DESMachine parent = CreateParentMachines(node.ParentNode, machines, sim);
                DESNode = machines.FirstOrDefault(t => t.Name == node.ParentNode.ResourceModel.ProcessName);
                if (DESNode == null)
                {
                    DESNode = new DESMachine(sim, node.ParentNode, parent);
                    machines.Add(DESNode);
                }
            }
            return(DESNode);
        }
Exemplo n.º 6
0
        public DESMachine(SimulationModel sim, ModelNode involvednode, DESMachine parentNode) : base(sim)
        {
            Name = involvednode.ResourceModel.ProcessName;
            if (involvednode.ResourceModel.HasBreakdown)
            {
                breakdown = involvednode.ResourceModel.MTBF.Distribution.DESRandom;
                repair    = involvednode.ResourceModel.MTTR.Distribution.DESRandom;
                GetBreakdown(sim).Activate(sim);
            }
            _machine  = DESResource.Create(involvednode.ResourceModel.Capacity);
            parentDES = parentNode;
            DESMachine p = parentNode;

            while (p != null)
            {
                parents.Add(p);
                p = p.parentDES;
            }
            Machine.AllowOwnMany = false;
            currentstatus.Add("Idle", 0);
        }
Exemplo n.º 7
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;
        }