Beispiel #1
0
        public void CreateWorkorder(Workorder.PoType type, DayTime due, int initialOp = 0)
        {
            Workorder wo = new Workorder(GetNextWoId(), type, initialOp);

            AddWorkorder("none", wo);
            DueDates[wo.Id] = due;
            NewToSend.Add(wo);
        }
        public void Work_SendsWorkordersToPlant()
        {
            Workorder.PoType productType = Workorder.PoType.p1;
            DayTime          due         = new DayTime().CreateTimestamp(50);

            _plant1.CanWorkOnType(Arg.Any <Op.OpTypes>()).Returns(false);
            _plant2.CanWorkOnType(Arg.Any <Op.OpTypes>()).Returns(true);

            _subject.CreateWorkorder(productType, due);
            _subject.Work(new DayTime());

            _plant1.DidNotReceive().Add(Arg.Any <IWork>());
            _plant2.Received().Add(Arg.Any <IWork>());
        }
        static private float RunTest(Test test)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            DayTime dt = new DayTime();

            Console.WriteLine("Updating Configuration for {0}", test.Name);
            Configuration.Initialize(test);

            //Console.WriteLine("{0}: Creating Customer and Enterprise", test.Name);
            Customer   customer = new Customer();
            Enterprise ent      = new Enterprise(customer);
            BigData    bigData  = new BigData();

            //Console.WriteLine("{0}: Generating Plants", test.Name);
            List <Plant> plants = SimulationSetup.GeneratePlants();

            foreach (Plant plant in plants)
            {
                ent.Add(plant);
                foreach (var wc in plant.Workcenters)
                {
                    if (wc.Name == "Shipping Dock" || wc.Name == "Stage")
                    {
                        continue;
                    }
                    bigData.AddWorkcenter(wc.Name);
                    ((Core.Workcenters.Workcenter)wc).AddBigData(bigData);
                }
            }
            ent.Add(bigData);

            //Console.WriteLine("{0}: Generating Transport Routes", test.Name);
            var       routes    = SimulationSetup.GenerateRoutes(plants);
            Transport transport = new Transport(ent, routes);

            ent.Add(transport);

            //Console.WriteLine("{0}: Generating Simulation Node", test.Name);
            SimulationNode sn = new SimulationNode(dt, ent);

            //Console.WriteLine("{0}: Loading Workorders", test.Name);
            int woCounter = 0;

            while (woCounter < Configuration.InitialNumberOfWorkorders)
            {
                Workorder.PoType type = SimulationSetup.SelectWoPoType(woCounter);
                DayTime          due  = SimulationSetup.SelectWoDueDate(dt, woCounter);
                int initialOp         = SimulationSetup.SelectWoInitialOp(woCounter, Workorder.GetMaxOps(type) - 1);
                customer.CreateOrder(type, due, initialOp);
                woCounter++;
            }
            customer.Work(dt); // Load Workorders into Enterprise

            //SaveToFile(Configuration.Instance.TestFilename, 0, sn);

            Console.WriteLine("{0}: Starting Simulation", test.Name);
            for (int i = 1; i < Configuration.MinutesForProgramToTest; i++)
            {
                dt.Next();
                ent.Work(dt);
                customer.Work(dt);

                var next = bigData.GetNextOrder(i);
                if (next.HasValue)
                {
                    customer.CreateOrder(next.Value.Item1, new DayTime((int)next.Value.Item2, 800));
                }

                if (i % 500 == 0)
                {
                    Console.Write(".");
                }

                //SaveToFile(Configuration.Instance.TestFilename, i, sn);
            }
            Console.WriteLine(".");
            //Console.WriteLine("Finished with Test {0}", test.Name);
            sw.Stop();
            Console.WriteLine("Time to Complete: {0}", sw.Elapsed);
            sw.Reset();

            var result = customer.Result();

            Console.WriteLine("Result: {0}", result.ToString());
            return(result);
        }