public void AddNewEvent(FutureEvent newEvent) { EventList.Add(newEvent); EventList.BubbleSort(); }
public void StartSimulation() { _result = new SimulationResult(); var futureEvent = new FutureEvent(Events.Arrival, new DateTime()); //Dummy! while (futureEvent.Event != Events.EndOfSimulation) { futureEvent = _fel.GetImminentEvent(); switch (futureEvent.Event) { case Events.Arrival: OnArrival(futureEvent.Time); break; case Events.Departure: OnDeparture(); break; case Events.ServiceEndedOnStationA: OnServiceEndedAtStationA(futureEvent.Time); break; case Events.ServiceEndedOnStationB: OnServiceEndedAtStationB(futureEvent.Time); break; case Events.ServiceEndedOnStationC: OnServiceEndedAtStationC(futureEvent.Time); break; case Events.RobotJobFinished: OnRobotJobFinished(futureEvent.Time); break; case Events.ServiceStartedOnStationA: // BOX arrived to the Station A! OnServiceStartedAtStationA(futureEvent.Time); break; case Events.ServiceStartedOnStationB: // BOX arrived to the Station B! OnServiceStartedAtStationB(futureEvent.Time); break; case Events.ServiceStartedOnStationC: // BOX arrived to the Station C! OnServiceStartedAtStationC(futureEvent.Time); break; case Events.LoadingBoxStartedOnStationA: OnLoadingBoxStartedOnStationA(futureEvent.Time); break; case Events.LoadingBoxEndedOnStationA: OnLoadingBoxEndedOnStationA(futureEvent.Time); break; case Events.LoadingBoxStartedOnStationB: OnLoadingBoxStartedOnStationB(futureEvent.Time); break; case Events.LoadingBoxEndedOnStationB: OnLoadingBoxEndedOnStationB(futureEvent.Time); break; case Events.LoadingBoxStartedOnStationC: OnLoadingBoxStartedOnStationC(futureEvent.Time); break; case Events.LoadingBoxEndedOnStationC: OnLoadingBoxEndedOnStationC(futureEvent.Time); break; case Events.BoxArrivedToInspectorQ: OnBoxArrivedToInspector(futureEvent.Time); break; case Events.InspectorWorker1JobDone: OnInspector1JobFinished(futureEvent.Time); break; case Events.InspectorWorker2JobDone: OnInspector2JobFinished(futureEvent.Time); break; case Events.InspectorWorker1JobStarted: OnInspector1JobStarted(futureEvent.Time); break; case Events.InspectorWorker2JobStarted: OnInspector2JobStarted(futureEvent.Time); break; case Events.EndOfSimulation: break; } } _result.SimulationStartDate = StartTime; _result.SimulationEndDate = EndTime; _result.StationATotalService = _platformA.GetTotalServiceTime; _result.StationBTotalService = _platformB.GetTotalServiceTime; _result.StationCTotalService = _platformC.GetTotalServiceTime; _result.Inspector1TotalService = _inspectorStation.GetTotalServiceTimeInspector1; _result.Inspector2TotalService = _inspectorStation.GetTotalServiceTimeInspector2; }