public void ProcessRequest(int requestedFloor) { RequestedFloorQueue.Enqueue(requestedFloor); FloorsStopMap[requestedFloor] = true; ElevatorButtons.FirstOrDefault(btn => btn.ButtonID == requestedFloor); if (!Timer.Enabled) { Start(); } }
public void Start() { if (Timer.Enabled == false) { Timer.Interval = CrossTime * 1000; /* converting from seconds to milliseconds */ Timer.Elapsed += Timer_Elapsed; Timer.Enabled = true; Timer.Start(); System.Threading.Tasks.Task.Run(() => Console.WriteLine("The Elevator {0} starts from the floor number {1}", ElevatorID, CurrentFloorNo)); RequestedFloor = RequestedFloorQueue.Dequeue(); ElevatorDirection = Utility.GetElevatorDirection(CurrentFloorNo, RequestedFloor); int t = Utility.FindTimeTaken(this, Utility.RequestedFloorLobbies.Peek()); Utility.ElevatorReqFloorTimeMap.Add(this, t); } }