示例#1
0
        private void EnterLift(Person p)
        {
            if (p.Departure == 0)
            {
                p.EnteringLiftTimeGoingUp = Context.TimePeriod;
                p.TotalQueueTime          = Context.TimePeriod - p.BeginQueueTimeGoingUp;
                personsGenerator.Floors[p.Departure].AverageQueueSize += Context.TimePeriod - p.BeginQueueTimeGoingUp;

                if ((Context.TimePeriod - p.BeginQueueTimeGoingUp) > personsGenerator.Floors[p.Departure].MaximumWaitingTime)
                {
                    personsGenerator.Floors[p.Departure].MaximumWaitingTime = Context.TimePeriod - p.BeginQueueTimeGoingUp;
                }
            }
            else
            {
                p.EnteringLiftTimeGoingDown = Context.TimePeriod;
                p.TotalQueueTime           += Context.TimePeriod - p.BeginQueueTimeGoingDown;
                personsGenerator.Floors[p.Departure].AverageQueueSize += Context.TimePeriod - p.BeginQueueTimeGoingDown;
                if ((Context.TimePeriod - p.BeginQueueTimeGoingUp) > personsGenerator.Floors[p.Departure].MaximumWaitingTime)
                {
                    personsGenerator.Floors[p.Departure].MaximumWaitingTime = Context.TimePeriod - p.BeginQueueTimeGoingUp;
                }
            }


            PersonsInLift.Add(p);



            Console.WriteLine("Person {0} is entering the lift", p.Id);

            if (!RequestedFloors.Contains(p.Destination))
            {
                RequestedFloors.Add(p.Destination);
            }
            CurrentLoad++;
        }
示例#2
0
 public void GoTo(int destinationFloor)
 {
     RequestedFloors.Add(destinationFloor);
 }