当前位置:网站首页>Elevator dispatching (pairing project) ②
Elevator dispatching (pairing project) ②
2022-07-04 10:52:00 【Painting and living~】
One 、UML chart
Two 、Design by Contract, Code Contract
Design by contract (Design by Contract ,DbC) It's a way of designing computer software , It is to make an agreement on some data according to some regulations . If beyond the agreement , The program will no longer run . for example , The input parameters must meet certain conditions . Standing on the java From the perspective of language , The so-called contractual programming is when certain conditions are met , Only conditional execution method body , have access to AOP Realization Java Design by contract . stay java Of Junit We use assertions in our tests (assert) Look at our program structure .
3、 ... and 、 Realization Bus Scheduling algorithm
Bus The idea of scheduling algorithm is : Use the elevator as a bus , from -1 From the first floor to the highest floor , Stop at every floor , And open the door to let passengers in and out , Then close the door and walk up . Up to the top , Down again .
In the process of implementation , We use four threads to run four elevators . In each thread , First, judge whether the elevator serves on this floor . If you can provide services , Then the elevator opens , At the same time call EleController Class synchronized Method GetPsgIn(), Pick up the passengers who can enter the elevator on this floor , This ensures that when each elevator accesses the waiting passenger list , There will be no thread conflicts bug.
public void busDispatcher(){
Randomly generate passengers
The thread used to dispatch the elevator ( common 4 individual )
for (int i = 0; i < ELE_COUNT; i++)
{
new Thread(()->{
while (true){
Get the current status and floor
Determine whether to serve on this layer
Check whether there is getting on and off the elevator
The elevator runs
}
}
}).start();
}
}
Four 、 Making the main interface UI

The above figure shows the main interface of the elevator dispatcher made by our group , Passengers can be randomly generated on the left , You can also add passengers manually . We provide “Bus”“SSTF”“LOOK” Three buttons , For users to choose the appropriate scheduling algorithm . On the right is the simulation of elevator operation , Visually display the current floor of the elevator 、 manned 、 Load and passenger information .
“ Set elevator parameters ” Button to connect to a new interface , The service floor of the elevator can be adjusted according to the needs of users 、 Maximum manned capacity 、 Maximum load and other parameters . Enter the elevator number and fill in the new load 、 The number of , Check the service floor , You can update the parameters of the elevator .
边栏推荐
- OSPF comprehensive experiment
- Network connection (III) functions and similarities and differences of hubs, switches and routers, routing tables and tables in switches, why do you need address translation and packet filtering?
- Software sharing: the best PDF document conversion tool and PDF Suite Enterprise version sharing | with sharing
- Read a piece of text into the vector object, and each word is stored as an element in the vector. Convert each word in the vector object to uppercase letters. Output the converted elements in the vect
- Postman interface test
- /*The rewriter outputs the contents of the IA array. It is required that the type defined by typedef cannot be used in the outer loop*/
- If you don't know these four caching modes, dare you say you understand caching?
- Learning XML DOM -- a typical model for parsing XML documents
- Personal thoughts on the development of game automation protocol testing tool
- Jemeter plug-in technology
猜你喜欢

JMeter assembly point technology and logic controller

Article publishing experiment
![[Galaxy Kirin V10] [server] KVM create Bridge](/img/a4/a35a276d13e194cefc547607c59f00.jpg)
[Galaxy Kirin V10] [server] KVM create Bridge

Canoe - the second simulation project -xvihicle1 bus database design (operation)

TS type gymnastics: illustrating a complex advanced type

Learning XML DOM -- a typical model for parsing XML documents

DCL statement of MySQL Foundation

Occasional pit compiled by idea
![[Galaxy Kirin V10] [desktop] build NFS to realize disk sharing](/img/72/5e725a44a50f152b477a4b2907a2d0.jpg)
[Galaxy Kirin V10] [desktop] build NFS to realize disk sharing

Virtual machine configuration network
随机推荐
Article publishing experiment
Canoe the second simulation engineering xvehicle 3 CAPL programming (operation)
1. Circular nesting and understanding of lists
OSPF comprehensive experiment
Canoe - the third simulation project - bus simulation-1 overview
Ten key performance indicators of software applications
Two way process republication + routing policy
[Galaxy Kirin V10] [server] system partition expansion
How to quickly parse XML documents through C (in fact, other languages also have corresponding interfaces or libraries to call)
Using SA token to solve websocket handshake authentication
Rhcsa12
For and while loops
The bamboo shadow sweeps the steps, the dust does not move, and the moon passes through the marsh without trace -- in-depth understanding of the pointer
[Galaxy Kirin V10] [server] KVM create Bridge
Locust learning record I
[Galaxy Kirin V10] [server] grub default password
Sword finger offer 05 (implemented in C language)
2、 Operators and branches
[testing theory] thinking about testing profession
Jianzhi offer 04 (implemented in C language)