Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program
Elevator Simulation Program Elevator Simulation Program
Elevator Simulation Program
Go Back  Xtreme Visual Basic Talk > > > Elevator Simulation Program


Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2015, 06:33 AM
aasi99 aasi99 is offline
Newcomer
 
Join Date: Jun 2015
Posts: 2
Lightbulb Elevator Simulation Program


hi all,
ok i make an elevator simulation program, i already made it to go up and down, and go to the called floors. but my problem is that for example, if the elevator on the way up to the 5' floor, and someone in the third floor call the elevator, how can i make it stop, and pick the passenger in third floor, and then continue the fifth floor. my program now first go to the fifth floor then go back to the third please if you have any idee....
many thanks in advance.

Last edited by Flyguy; 06-29-2015 at 02:19 AM.
Reply With Quote
  #2  
Old 06-29-2015, 06:14 AM
passel's Avatar
passelElevator Simulation Program passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Since we don't have your code we can't tell how you are moving from floor to floor.
Hopefully you should be using a timer to step time, and with each time step, move the elevator towards its current destination.
Before each step, if the user pressed a button and selected a floor between time steps, you can add it to a list of floors needing to be visited, and check if it is currently between where you are and where you are going.
If it is, you can change the current destination to that floor.
Whenever you reach the current destination, and drop/pickup, you then check to see if there is a another floor selected in the current direction, set it as the current destination and continue.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 06-29-2015, 06:16 PM
hDC_0Elevator Simulation Program hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 559
Default Linked list?

Hi passel,
I know this is very open-ended question (since the original poster didn't offer any code),
but if you got multiple floors (and an object passing between them)
the thing that popped up in my mind was "linked list".

Oh course I could be wrong (maybe it's not particularly applicable to aasi99 is trying to do),
but that's just the first thought that popped into my head..


I know you have been one of the proponents of using LLs over the years.

There was this thread were Terabyte went past your linked list code and attached an double linked list OO (object oriented) version to this post.

There was also this thread where you talk about linked lists, and where Optikal's post had a bunch of related linked list hyperlinks as well as this thread which used linked lists for collision detection.



If it's not relevant then nevermind...but at least it proved an excuse to combine the bookmarks "folder"
(that I have for xvbt "linked lists" related thread/posts) into a single bookmark.

It's part of a larger effort to try to cut down on the thousands of xvbt-related Firefox bookmarks I've accumulated over the years
(that I usually don't get to use because people don't ask the same variety of wide-ranging VB questions that interest me).

Hopefully get it down to 1% of the over active 1/2 million bookmarks I keep in Firefox (yes..I know..I need to "get a life" )

Last edited by hDC_0; 06-29-2015 at 06:31 PM.
Reply With Quote
  #4  
Old 06-30-2015, 12:36 PM
passel's Avatar
passelElevator Simulation Program passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Quote:
Originally Posted by hDC_0 View Post
...
but if you got multiple floors (and an object passing between them)
the thing that popped up in my mind was "linked list".
...
The first thing that occurred to me, in regards to just the question itself, was a stack.
You're headed to floor X, but floor T makes a request and it is between you and X, so you push T on the stack and head for it, and when you get there, pop it off, and continue on to X next.

But you are right in that since the floor requests can happen at any time and in any order, before you or behind you, you would want to keep the list sorted, so a stack wouldn't work except for the singular case of floors being selected between where you are and where you're headed.

I made the assumption the OP has some setup, and my guess would be an array or arrays of information based on using the floor as an index into the arrays, and I was referring to whatever that mechanism is with the general term "list", as in updating the list with floors selected, etc...

Linked lists might be ahead of where they are in terms of approaches to solve the problem.

At first, when responding to your post, I was thinking that linked lists could be a good solution, but the more I thought about the implementation I can see that it is harder to comprehend and the logic more involved then using a straight forward array could be.

One would use a double linked list, of course, so you would be moving up and down the list as the elevator went up and down, but having to traverse the list to insert floors whenever a call was initiated is definitely more work than just setting a boolean at the floor index in an array.
And there is the matter of the removing items from the linked lists at every destination, which again would be less work with an array.

The main advantage of the linked lists, is you always know if you have any calls pending, and it what direction, without having to scan the list looking for them (you've done the scanning of the list when you inserted the items).
Also, since you only need to scan the active list when inserting a floor call, the number of items you have to scan should be much less than the number of floors in the building.

But, with the array you have the advantage of not having to scan the array when you do a floor call, you just set the values directly in the array based on floor index.
With a little planning when using the array, you also don't have to scan the array to see if there is a floor set above or below you. You just keep track of the highest floor call above you and lowest call below you as the calls comes in and you will know whether you need to continue moving in the current direction or not.

As you move up or down, you just check each floor as you reach it to see if it has its Elevator Call boolean set, stop, process it, can continue on it you haven't reached the highest or lowest floor call set.

After consideration, I think in this case an array is the better solution over a linked list implementation.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #5  
Old 07-02-2015, 05:00 PM
aasi99 aasi99 is offline
Newcomer
 
Join Date: Jun 2015
Posts: 2
Wink

Quote:
Quote:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Label1.Text = "1"
dest = 1
doorStatus("close")
goforit()
doorStatus("open")
End Sub
.............
.............
Private Sub goforit()

Select Case dest
Case 1

Do While PictureBox14.Top <> PictureBox9.Top
If dest< is1 Then
PictureBox14.Top = PictureBox14.Top + 1
Else
PictureBox14.Top = PictureBox14.Top - 1
End If
System.Threading.Thread.Sleep(10)
ETstatus()
Loop
PictureBox13.Top = PictureBox14.Top

Case 2................
.....

...............
................
End Sub
thanks alot guys i'm new to visual basic , my code is just simple if you click a button, it goes to function called "goforit" and keep moving the elevator until reaching it, but i think that i have to change the whole code to make it work correctly. i really don't know what should it do when a button"destination" has been clicked, if i make all buttons threading so if for example i click the 2' floor it goes to the function "goforit" and start moving to the 2'floor, if i click at the same time the 2'floor and 3'floor, it will leave the first order and go to the 3'floor . i need tips or direction of how to do. it should work like a normal elevator in a building.

Last edited by aasi99; 07-03-2015 at 02:54 AM.
Reply With Quote
  #6  
Old 07-08-2015, 07:29 PM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default VB.Net elevator simulation

After aasi99's original post I was actually thinking a console application,
with some character based animation, might be what he wanted --
rather then something like this vb.net gui elevator simulation, from this off forum thread.

The elevator simulation assignment was also already tackled gui-style in this xvbt thread,
so I wanted to try it another way, but I guess I wasted some time throwing something together...oh well

Last edited by dotnetwrassler; 07-08-2015 at 08:06 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program Elevator Simulation Program
Elevator Simulation Program
Elevator Simulation Program
 
Elevator Simulation Program
Elevator Simulation Program
 
-->