| | |
Elevator simulation, queue management suggestions
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2007
Posts: 16
Reputation:
Solved Threads: 0
Hi, I am currently working on an elevator simulation in MS Visual C# that will eventually involve at least 2, preferrably 3 elevators running across 5 floors.
There is currently one elevator that will service all floors when a call button is pressed, though adding a 2nd one brings up the problem of which to send.
My form currently includes call buttons for the ground floor and top floor, and up and down buttons for the 1st,2nd and 3rd floors. There are also two timers for the elevator, one to determine the next floor, which it does so by referring to the lift direction and checking a request array. The other timer moves the lift accordingly.
Now obviously, the two elevators can both be at any floor at any time, so handing out requests can depend on a number of variables (lift direction, position and requests).
Hoping someone can help or suggest what direction i can go with this program and if theres any questions just ask I'll provide all the information.
Thankyou in advance
There is currently one elevator that will service all floors when a call button is pressed, though adding a 2nd one brings up the problem of which to send.
My form currently includes call buttons for the ground floor and top floor, and up and down buttons for the 1st,2nd and 3rd floors. There are also two timers for the elevator, one to determine the next floor, which it does so by referring to the lift direction and checking a request array. The other timer moves the lift accordingly.
Now obviously, the two elevators can both be at any floor at any time, so handing out requests can depend on a number of variables (lift direction, position and requests).
Hoping someone can help or suggest what direction i can go with this program and if theres any questions just ask I'll provide all the information.
Thankyou in advance
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
Well.
Think about what you know about lifts.
Go with the theory of 2 lifts, one you have more than 1 lift the logic is the same you just have more options.
Lifts go 1 of 2 ways. up or down.
A lift at floor 1 told to go up, if someone rings the bell on 3 and the lift is going there or passing there on the way up and the person said "up" on 3.. then it will stop, otherwise if its not due to stop there and the person said down, it wont. The other lift will get the job, or if both are going up, then it will be the first available lift.
Your lift needs states waiting/up/down
Your logic shouldnt be that complex, so, write down in words what your logic choices are, senarios etc
Then you should be ready to code it
Think about what you know about lifts.
Go with the theory of 2 lifts, one you have more than 1 lift the logic is the same you just have more options.
Lifts go 1 of 2 ways. up or down.
A lift at floor 1 told to go up, if someone rings the bell on 3 and the lift is going there or passing there on the way up and the person said "up" on 3.. then it will stop, otherwise if its not due to stop there and the person said down, it wont. The other lift will get the job, or if both are going up, then it will be the first available lift.
Your lift needs states waiting/up/down
Your logic shouldnt be that complex, so, write down in words what your logic choices are, senarios etc
Then you should be ready to code it
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Dec 2007
Posts: 16
Reputation:
Solved Threads: 0
thanks for your reply. I have started to go through possible scenarios and can see that, with two lifts i'd have the following situations;
Up calls will need an elevator going up that is below the floor or a free elevator.
If both elevators are above the floor or are going down then the first elevator free will get the job, or if both are free, the nearest will get the job.
Down calls will need an elevator going down that is above the floor or a free elevator.
If both are below the floor or are going up then the first free elevator will get the request, or if both are free, the nearest again will get the job.
Ok hopefully that's what I need to cover and i'm not missing anything.
My problem now is handling all of this within the code, but at least i've got a better idea. If anyone has any suggestions of ways to handle this please let me know.
In the meantime thankyou! i'll report back if theres success
Up calls will need an elevator going up that is below the floor or a free elevator.
If both elevators are above the floor or are going down then the first elevator free will get the job, or if both are free, the nearest will get the job.
Down calls will need an elevator going down that is above the floor or a free elevator.
If both are below the floor or are going up then the first free elevator will get the request, or if both are free, the nearest again will get the job.
Ok hopefully that's what I need to cover and i'm not missing anything.
My problem now is handling all of this within the code, but at least i've got a better idea. If anyone has any suggestions of ways to handle this please let me know.
In the meantime thankyou! i'll report back if theres success
There is an excellent discussion on an elevator algorithm in D.E.Knuth "The Art of Computer Programming" Vol 1 Fundamental Algorithms.
You may also view a short note on http://en.wikiversity.org/wiki/TAoCP:Algorithms
You may also view a short note on http://en.wikiversity.org/wiki/TAoCP:Algorithms
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Other Threads in the C# Forum
- Previous Thread: mobile phones
- Next Thread: Endless loop while losing focus
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input java list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






