PDA

View Full Version : 1, 2, 3, 4 take the elevator



iain
10-13-2002, 07:31 PM
an interesting problem to try and model:

a 20 storey building with two elevators, each can move independantly and at the same time in different directions, all features must be present (doors open close etc) and each elevator must be able to be called or sent to different floor at the same time.

i tried to solve this while bored one day and after several weeks i gave up , i dont think real time systems prgramming is for me.
have a try

RoD
10-13-2002, 09:10 PM
*cough* spam posts *cough*

DavidP
10-13-2002, 09:59 PM
hmm.....think i could do it...

supposed to do it graphically i am guessing?

yeah you just have booleans saying whether each elevator is moving, then call the movement functions...you also gotta have a couple vars to keep track of their floor numbers

I am guessing they are in different elevator shafts also, b/c you dont want them to crash against each other...

seems possible..

vasanth
10-14-2002, 01:52 AM
well i had this problem is my ASM(TASM) class....... It is quite easy.....

adrianxw
10-14-2002, 02:57 AM
>>> each can move independantly and at the same time in different directions,

Semantics I'm sure, but to me, that implies that an individual elevator can be moving up and down at the same time. That adds some interest to the model.

vasanth
10-14-2002, 08:36 AM
well this can be easily be implementd in JAVA by giving both the elevators thread equal priority..(Multi threading...) this can also be implemented in pure C by having a timer and changing between the two really fast.. or using multi threading.. Believe me it isnt tuff... these kinds of problems are normally given in assembly language classes..

salvelinus
10-14-2002, 09:15 AM
This problem is used in Deitel's C++ book, primarily as an example of UML modeling but it walks through all the code.

DavidP
10-14-2002, 10:29 AM
you dont even need multithreading for this, so why even mention it.

it is pretty simple:



bool elevator1switch;
bool elevator2switch;
int floorcur1, floorcur2, floor1, floor2;

while(1)
{
MoveElevator ( Elevator1, floorcur1, floor1, elevator1switch );
MoveElevator ( Elevator2, floorcur2, floor2, elevator2switch );

switch ( command )
{
case whatever:
floor1 = whatever;
floor2 = whatever;
break;
}

}

vasanth
10-14-2002, 10:45 AM
well u r talkin in terms of program.. In terms of writing code for circuits to be embeded in the real elevator... you cannot always execpt the first input to be for the 1st elevator... and it needs to work in real time...

-KEN-
10-14-2002, 01:33 PM
Originally posted by DavidP
you dont even need multithreading for this, so why even mention it.

it is pretty simple:



bool elevator1switch;
bool elevator2switch;
int floorcur1, floorcur2, floor1, floor2;

while(1)
{
MoveElevator ( Elevator1, floorcur1, floor1, elevator1switch );
MoveElevator ( Elevator2, floorcur2, floor2, elevator2switch );

switch ( command )
{
case whatever:
floor1 = whatever;
floor2 = whatever;
break;
}

}


Without multithreading, how can they be moving at the same time? In your model, the first one would move, then the second, then the first, then the second...etc.

Brian
10-14-2002, 01:47 PM
Originally posted by -KEN-
Without multithreading, how can they be moving at the same time? In your model, the first one would move, then the second, then the first, then the second...etc.

You need two CPUs are they still won't be able to move at the same time. Anyway a system like this would undoubtably have one program for each elevator (they could still be run on one CPU due to the wonders of multitasking)

-KEN-
10-14-2002, 02:03 PM
umm...put each elevator into its own thread, and do it that way...

Fountain
10-14-2002, 02:31 PM
I take it you lot dont design elevators(now reffered to as lifts). Lots of lifts at UNI. Just concerned thats all. Heh...

Oh yes there are lots of lifts, each independant......help me here, this is soooooooooo boring.

vasanth
10-14-2002, 09:51 PM
Well not every where they are independent... the controll unit for these lifts are expensive.. So many companys request for one single unit which can controll all the lifts...