private void LeaveEvent(Customer customer) { // generates a random interval for how long the person takes, with a minimum of 1 minute // and 30 seconds TimeSpan waiting = new TimeSpan(0, 0, (int)(120 + Negex(AvgCheckoutTime.TotalSeconds - 120))); // Creates departure event based on the time interval plus the time we are currently // at in the Priority Queue Event e = new Event(EVENTTYPE.LEAVE, ((EventPriorityQueue.Peek().Time + waiting))); //Associates departure event with registrant e.CurrCustomer = customer; customer.Leave = e; // Adds departure event to the queue EventPriorityQueue.Enqueue(e); // Update wait times for statistic counters TotalTime += waiting; if (waiting > LongestTime) { LongestTime = waiting; } if (waiting < ShortestTime) { ShortestTime = waiting; } }
} // end RunSimulation #endregion #region Arrival and Leave Events private void ArrivalEvent() { TimeSpan Start; TimeSpan Open; Open = EndTime - StartTime; for (int customer = 1; customer <= NumOfCustomers; customer++) { Start = new TimeSpan(0, 0, rand.Next((int)Open.TotalMinutes)); Event e = new Event(EVENTTYPE.ARRIVAL, (StartTime + Start)); Customer c = new Customer(customer, e); e.CurrCustomer = c; c.ArrivalTime = e; EventPriorityQueue.Enqueue(e); } }