Elevator dispatching of Software engineering operation

Source: Internet
Author: User

Problem Description:

A total of 20 floors of a building, now installed 4 elevator parameters are as follows:

1th elevator full floor maximum load 800kg

No. 2nd elevator singular layer maximum load 800kg

3rd Elevator Double-layer maximum load 1600kg

4th Elevator full Floor maximum load 2000kg

Analysis:

4 Elevators are independent of each other's work, then divided into 4 independent of the scheduling module. Elevators 1th and 4th are all serviced on the full floor with a maximum load difference, while the 2nd and 3rd elevator service modes are similar. Then the 1, 4th elevator Dispatch module can be combined into one. Similarly, Modules 2 and 3rd can also be combined. The core function of elevator dispatching is to accept the request of different floor users and corresponding, while the same elevator can only move up or down in a certain time, then we should design a decision algorithm to complete the selection of the elevator to different users ' requests.

Here I use a more simple decision-making method, first to priority, after the different ignore.

First define several concepts:

1. Legal request: To the target floor legal request;

2. Request queue: Elevators need to execute the queue of user requests sequentially, from the first team to take out, from the end of the team to join;

3. Idle state: Elevator The current request queue is empty;

4. Upstream status: Elevator The current request queue has at least one request to run to the upper layer;

5. Downstream status: Elevator current request queue has at least one down layer running request;

6. Wait timeout: When the lift request queue is empty and the current floor is above the first level, the idle time exceeds a certain value and is called a wait timeout;

7. Initial floor: full-or singular-level service is the first tier, and the two-tier service is the second tier.

First to priority, after the different ignore: suppose that at some point the elevator request queue is empty, at this time a legitimate request is detected in its target floor to determine whether the current state of the elevator is upstream or downstream, and then obtain the request if it is consistent with the running state is added to the queue, otherwise ignore the request.

Of course, when the elevator is idle for a long time and is not on the initial floor, the efficiency of the elevator operation should be automatically moved to the initial layer and allowed to accept the run request during this period.

Once you have identified the task requirements, you need to design the program structure. For different I/O Way program structure is also different, said that because 4 elevators are independent of each other, then can be in the main program to adopt the mode of switching I/O, and after switching can not lose the data before scheduling simulation, so you can consider scheduling into a class, both easy to design and easy to invoke.

Design:

The elevator operates on 1~20 floors and loads as a limiting parameter. No matter where the passengers take the elevator from that floor and down the elevator, when the elevator arrives at a certain level, it is only necessary for the passengers of that layer to go down and subtract the mass from the current load, which means the elevator is free when the current load is 0 o'clock. Before defining the operating state of the elevator, by the current state of operation to determine the elevator to perform an upstream or downstream action, before the first check whether the current load is 0, not 0 means that there is an uplink or downlink request passengers in the elevator, then perform an action, otherwise enter the idle state, and wait for a timeout after the reset action can be performed.

Realize:

Using a C + + console to achieve, using multilevel program structure: Switching program---Scheduling simulation program->I/O program.

The program design two classes, respectively, for storing the request data tuple's queue (RQ) and elevator basic function Class (elevator).

Details are detailed in the coding project.

Test:

The main program, enter the corresponding key to enter the sub-program.

Select Elevator 1, on the first floor input Request 5 100, 8 100, respectively, on behalf of the 5 floor passengers heavy 100kg, to 8 floor passengers heavy 100kg.

Every move layer needs to detect if there is a request to join.

When the queue is empty, the elevator is idle.

The reset state after the timeout, and each layer is moved to detect if there is a request.

This returns the main program, and the input non-n characters are valid.

The above is the description of the completion of this assignment.

Elevator dispatching of Software engineering operation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.