} // end SetupSimulation #region Generate Arrival and Departure Events /// <summary> /// Generates the arrival events for registrants and adds them to event Priority Queue /// </summary> private void GenerateArrivalEvents( ) { TimeSpan start; TimeSpan timeOpen = EndTime - StartTime; for (int registrant = 1; registrant <= NumRegistrants; registrant++) { // Generate random amount of time between 0 and registration open period start = new TimeSpan(0, 0, R.Next((int)timeOpen.TotalSeconds)); // Create arrival event Event newEvent = new Event(EventType.ARRIVAL, (StartTime + start)); // Create registrant Registrant newRegistrant = new Registrant(registrant, newEvent); // Associate registrant with event newEvent.Registrant = newRegistrant; newRegistrant.Arrival = newEvent; // Add arrival event to Priority Queue of events EventPQ.Enqueue(newEvent); } } // end GenerateArrivalEvents
} // end Event /// <summary> /// Parameterized constructor /// </summary> /// <param name="type">The type of event, either an arrival and a departure</param> /// <param name="time">The time of the event</param> public Event(EventType type, DateTime time) { Type = type; Time = time; Registrant = null; } // end Event
/// <summary> /// Default constructor /// </summary> public Event( ) { Type = EventType.ARRIVAL; Time = DateTime.Now; Registrant = null; } // end Event