public Elevator(int id, int bottomFloor, int topFloor, int startFloor, double maxWeight) { _id = id; _bottomFloor = bottomFloor; _topFloor = topFloor; _maxWeight = maxWeight; currentFloor = startFloor; operationStatus = ElevatorOperationStatus.AVAILABLE; }
public bool RunSafetyChecks() { if (!WeighElevator()) { operationStatus = ElevatorOperationStatus.OVERWEIGHT; Console.WriteLine($"Elevator {_id} status: {operationStatus}. Max weight limit: {_maxWeight}. People leave.."); return(false); } Console.WriteLine($"Elevator {_id} weigh in successful"); return(true); }
public void ReadyElevatorForJourney(Request request) { //If the doors are open close them after all safety checks complete if (doorStatus == DoorStatus.OPEN) { while (!RunSafetyChecks()) { //Wait 1 second before re-trying Thread.Sleep(1000); } CloseDoors(); } //Check if we are travelling up or down and change the staus from 'Available' to 'Moving...' operationStatus = request.Floor > currentFloor ? ElevatorOperationStatus.MOVING_UP : ElevatorOperationStatus.MOVING_DOWN; Console.WriteLine($"Elevator {_id} beginning journey from Floor: {currentFloor}"); }
public void SetToMaintenanceMode() { operationStatus = ElevatorOperationStatus.MAINTENANCE_MODE; }
public void SetElevatorAsAvailable() { operationStatus = ElevatorOperationStatus.AVAILABLE; Console.WriteLine($"[{DateTime.Now.ToLongTimeString()}] Elevator {_id} status: {operationStatus}"); }