How Would You Design An Elevator
In the following we are going to discuss an important topic that is “How would you design an elevator?” and will discuss it thoroughly within the article from the application developer perspective, we must always be telling the classes and its relation, class diagrams & Sequence flow. We all know the time scarcity during a technical discussion and sometimes its difficult what other guy is expecting from us.
A Snapshot Of The Elevator Control System
Our elevator has the essential function that all elevator systems have, like moving up and down, open and close doors, and in fact, picks up passengers. The elevator is meant to be used in a building having floors numbered from 1 to Max-Floor, where the first floor is actually the lobby. There are car(Lift) call buttons within the car corresponding to each floor. For every floor apart from the highest floor and also the lobby, there are two hall call buttons for the passengers to call for going up and down.
There is only 1 down hall call button at the highest floor and one up hall call button within the lobby. When the car stops at a floor, the doors are opened as well as the car lantern indicating the current or present direction the car is going is illuminated so that the passengers can know what the current moving direction of the car is. The car actually moves quite fast between floors, but it should be able to slow down early enough to stop at a desired/wanted floor. In order to certificate system safety, emergency brake will be triggered and therefore the car will be forced to stop under any unsafe conditions.
Use Case Diagram
All systems interact with either human or automated actors that use the system for a few purposes, and both human as well as actors expect the system to behave in predictable ways. There are a total of 7 use cases based on the current requirement of the elevator system:
- Process Car Or Lift Calls: This use case includes several scenarios, which will be described in detail in later sections of this paper. These scenarios includes that the elevator/lift receives car calls from the passengers, updates the record of car calls stored in system controlling parts, turns on or turns off the light of car call buttons, etc.
- Process E//Hall Calls: These are quite similar to lift Call processing, this use case includes that the elevator/lift receives hall calls from the passengers, actually updates the record of hall calls in system controlling parts, turns on or turns off the light of hall call buttons, etc.
- Move/Stop The Car: The main or primary function of an elevator will include the changing of driving speed, how to make the decision of stop, as well as driving directions of the car.
- Indicating Moving Direction: The elevator or lift should have this mechanism to let the passengers know what the current moving direction of the car is such that the passenger can decide whether to enter the car or not.
- Indicating Car Position: Similarly, the lift or elevator should let the passengers know whether his/her destination floor is reached so that the passenger can decide to weather to leave the car or not.
- Open/Close the Doors: The lift or elevator should be able to open as well as close the doors for the passengers to get in as well as out of the car. The functional areas of this use case should also enable the passengers to make door reversals when the doors are closing and therefore the passenger wants to get in the car.
- Trigger Emergency Brake: There is actually a safety mechanism within the car to make sure that an unsafe state is not transiently generated.
With this much of understanding of elevator system, we will start identifying the classes required it to design a system.
Identifying Classes/Objects:
Control objects
- Elevator Control: The central controlling object in the elevator system. Elevator Control communicates and controls all other objects within the system.
- Door: There are two doors in the system, the “god” object — the Elevator Control — commands the doors to open and close.
- Car/Lift: The car is being controlled to move up and down (in different speeds), to make stops at floors when necessary.
- Button: Furthermore, the Elevator Control class also controls the button class that further generalizes 2 sub-classes Car Call Button as well as Hall Call Button. The control object communicates with the Button objects, get the knowledge whether a button is pressed and in turn controls the illumination of Button lights.
- Indicator: There are two kinds of indicators in the system, the Car Position Indicator and the Car Direction Indicator (i.e. the Car Lantern). The indicators are controlled to show the information about the present position and moving direction of the car.
- Safety: Whenever an emergency happens, the Elevator Control commands the Safety
Controller classes:
- Door Control controls the action of Door Motor. Door Motor may be commanded to open, close, or make a door reversal.
- Drive Control controls the elevator Drive, which acts as the main motor moving the car up and down, and stopping at floors when necessary.
- Lantern Control is in the number of two, Car Position Indicator and the Car Direction Indicator.
- Hall Button Control exists in pair on each floor, where one controls the Up Hall Call Button and the other down. The Hall Button Control actually accepts hall call button presses controls as well as at the same time gives feedback to hall call lights.
- Car Button Control is one for each floor and all locate in the lift/car. The Car Button Control accepts Car Call Button calls and is in charge of turning on/off the corresponding lift/car call lights.
- Car Position Indicator gives value to the Car Position Indicator so that the passengers might know the current position of the lift/car.
- Dispatcher does not really control actual elevator or lift components, however it is important in the software system. There is one Dispatcher for every lift/car, whose main function is to calculate the target moving direction and destination for the lift/car, as well as to maintain the opening time for the doors. The Dispatcher interacts with almost all the control objects in the system except for Lantern Control.
Hope everything is going well till now; let’s understand everything with some of sequence diagrams.
Sequence Flow
It may be hard to explain verbally but if you clearly understand how it’s going to work, you can draw some sequence diagrams and try to explain the flow with some examples in parallel.
- Process hall calls : There are about 2 scenarios for this use case:
- The elevator is moving towards the same direction as the passenger’s destination.
- The elevator is moving towards the opposite direction as the passenger’s destination.
- Move/Stop the car
- Indicate moving direction
- Trigger emergency brake: There are about 5 scenarios for this use case:
- If the car or lift is commanded to stop but it won’t stop at a desired or wanted floor, the emergency brake will be triggered.
- If the car or lift is commanded to move but it does not move, the emergency brake will be triggered.
- If the doors are commanded to open when the car or lift stops at a floor, however the doors won’t open; the emergency brake will be triggered.
- If the doors open when the car or lift is moving, the emergency brake will actually be triggered.
- If the car or lift keeps going when the hoist way limit is reached, the emergency brake will actually be triggered.