trooped Members: Li Baoquan & Huang Yifan
Job Results Display URL: 4-way Elevator scheduling algorithm display http://ele.libq.ren/
Pair programming Topic: Elevator Scheduling
Existing new office building, a total of 21 floors, a total of four elevators, all elevators basic parameters are shown in the following table:
Elevator number |
Service Floors available |
Maximum number of passengers |
Maximum Load weight |
1 |
All floors |
10 |
Approx. |
2 |
Single layer |
10 |
Approx. |
3 |
Double |
20 |
Approx. |
4 |
All floors |
20 |
Kg |
The terms of use are as follows:
1, the floor number is 0~20, of which No. 0 is the basement layer;
2. Elevators with floor restrictions are not docked in the response floor, such as a single double layer;
3, all elevators with unified button control
Please design and implement an elevator control program according to the above requirements, if there is a graphical display is better.
Demand analysis
- Four elevators are controlled using a unified external button.
- Elevator Internal Button press event priority is higher than the external button.
- Single-storey elevators are docked only on a single floor, not in double-decker. The double-decker elevators are only double-decker, including 0 floors (basement level).
- When the elevator is idle, the elevator stops at the last movement to the floor.
- Reasonable dispatch of the elevator on the downstream and internal and external message response.
- Use the graphical interface to display the program.
We describe the reasonable elevator scheduling behavior as follows:
- The elevator first responds to internal button events.
- For external events, only the external events that respond to the elevator motion direction are responded to at a time. When the elevator is on the line, in response to an external event on top of the elevator floor, the elevator down, in response to the external events under the elevator floor.
- In response to internal events, priority responds to internal events in the direction of elevator motion. When the elevator is on the line, in response to the elevator on the floor of the internal events, the elevator down, in response to the elevator in the internal events under the layer.
- The same external event can have multiple elevators responding at the same time, or it can be a single elevator to the corresponding. This is determined by the specific motion state of the current 4 elevators.
Algorithm design
- Each elevator runs independently and uses Message Queuing inreqlist to store the elevator's docking messages. Message queues for each elevator are independent of each other.
- When the elevator interior button is pressed, the message is placed in the Inreqlist queue queue for this elevator. Since the floor where the internal button is pressed is the floor where the elevator must dock, each time you find the most suitable floor from the inreqlist queue and dock.
- When the elevator external button is pressed, the incoming message is placed in each inreqlist queue. Since the floor of the external button press is not necessarily the floor where each elevator is to be docked, it is necessary to respond to this external event according to the specific inreqlist queue of this elevator to find the appropriate time.
First from the single elevator in the scheduling process to start the discussion, the initial state of the elevator is idle state, in response to the external button event wake elevator, elevator start movement, scheduling diagram as follows:
Figure 1 Single elevator scheduling diagram
When scheduling multiple elevators, because each elevator's internal events are independent of each other, only the response rules for external events need to be modified.
- When the external button is pressed, the message property of the 4 elevators is traversed, and if there is an internal message at this level, the write is discarded; otherwise, an external message is written at this level.
- When the elevator stops, clear the message on the floor of the elevator, then traverse the message properties of the other elevators, and if the other elevators are external properties, clear the message; otherwise, no processing is done.
Figure 2 More than the elevator scheduling diagram
The requirement analysis and algorithm design of the implementation and test of the elevator scheduling algorithm (not to be continued)