コード例 #1
0
        public void Next_FromInitial_Increments1Minute()
        {
            const int expectedDay  = 0;
            const int expectedTime = 1;

            _dayTime.Next();

            Assert.AreEqual(_dayTime.Day, expectedDay);
            Assert.AreEqual(_dayTime.Time, expectedTime);
        }
コード例 #2
0
        // PUBLIC METHODS //
        public DayTime CreateTimestamp(int increment)
        {
            DayTime timestamp = new DayTime(Day, Time);

            while (increment > 0)
            {
                timestamp.Next();
                increment--;
            }

            return(timestamp);
        }
コード例 #3
0
        public void LessThan_WhenLess_ReturnsTrue()
        {
            _dayTime = _dayTime.CreateTimestamp(1440);
            _dayTime.Next();
            DayTime lessDay  = new DayTime((int)DayTime.Days.Sun, 0);
            DayTime lessTime = new DayTime((int)DayTime.Days.Mon, 0);

            Assert.IsTrue(lessDay.LessThan(_dayTime));
            Assert.IsFalse(_dayTime.LessThan(lessDay));
            Assert.IsTrue(lessTime.LessThan(_dayTime));
            Assert.IsFalse(_dayTime.LessThan(lessTime));
            Assert.IsFalse(_dayTime.Equals(lessDay));
            Assert.IsFalse(_dayTime.Equals(lessTime));
        }
コード例 #4
0
        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);
        }