#include <elevator.h>
Inheritance diagram for ElevatorBank::

Public Methods | |
| ElevatorBank (int numElvtrs, int numFlrs, CallBackObj *riders, CallBackObj *controllers) | |
| Initialize the elevator hardware, use "riders" and "controllers" to notify the rider/controller threads that an event occurred they should be interested in (such as, elevator arrives, doors open, etc). More... | |
| ~ElevatorBank () | |
| deallocate the elevator hardware. More... | |
| void | OpenDoors (int elevator) |
| Open the elevator doors; elevator must not be in motion! More... | |
| void | CloseDoors (int elevator) |
| Close the elevator doors. More... | |
| void | MoveTo (int goingToFloor, int elevator) |
| Set the elevator into motion. Elevator doors must be closed. If elevator is already in motion, this causes the elevator to stop at a new floor (eg, if a rider presses a new floor while the elevator is moving). More... | |
| int | WhereIsElevator (int elevator) |
| return the current position of the elevator (which floor its on). More... | |
| void | MarkDirection (int elevator, Direction dir) |
| change the display to show riders where this elevator is headed. More... | |
| ElevatorEvent | getNextControllerEvent (int *floor, int *elevator) |
| when the elevator device calls back, this will tell you what event(s) (relevant to controller threads) triggered the callback. More... | |
| void | PressButton (int onFloor, Direction goingTo) |
| Press button outside elevator to indicate where rider wants to go. More... | |
| Direction | getDirection (int elevator) |
| return the indicated direction (set by MarkDirection()) of this elevator. More... | |
| bool | EnterElevator (int onFloor, int elevator) |
| Step onto the elevator; elevator must have MaxRiders people on it currently Returns false if doors have closed (might have happened between when riders got OpenDoors event and when they decided to step onto the elevator). More... | |
| void | PressFloor (int goingToFloor, int onElevator) |
| Press button inside elevator to indicate where rider wants to go; thread must be on the elevator. More... | |
| bool | ExitElevator (int onFloor, int elevator) |
| Step off the elevator. Returns false if doors have closed. More... | |
| ElevatorEvent | getNextRiderEvent (int *floor, int *elevator) |
| when the elevator device calls back, this will tell you what event(s) (relevant to rider threads) triggered the callback. More... | |
Private Methods | |
| void | CallBack () |
| called internally when the elevator hardware generates an interrupt. More... | |
| void | PostEvent (ListOfEvents *list, ElevatorEvent event, int floor, int elevator, bool inHandler) |
| an event occurred that requires a callback. More... | |
| ElevatorEvent | getNextEvent (ListOfEvents *list, int *floor, int *elevator) |
| pull next event off the pending list of events, return NoEvent if list is empty. More... | |
Private Attributes | |
| int | numElevators |
| how many elevators in this bank? More... | |
| int | numFloors |
| how many floors in this building? More... | |
| CallBackObj* | callRiders |
| call when an event occurs that riders would be interested in. More... | |
| CallBackObj* | callControllers |
| call when an event occurs that elevator controller threads would be interested in. More... | |
| ListOfEvents* | riderEvents |
| pending events relevant to riders. More... | |
| ListOfEvents* | controllerEvents |
| pending events relevant to controllers. More... | |
| ElevatorInfo** | elevators |
| array of per-elevator state. More... | |
Definition at line 43 of file elevator.h.
|
|
Initialize the elevator hardware, use "riders" and "controllers" to notify the rider/controller threads that an event occurred they should be interested in (such as, elevator arrives, doors open, etc). ElevatorBank::ElevatorBank Initialize the elevator hardware, calling "riders" and "controllers" to notify the rider/controller threads that an event has occurred that they should be interested in (such as, elevator arrives, doors open, etc) Definition at line 111 of file elevator.cc. |
|
|
deallocate the elevator hardware. ElevatorBank::~ElevatorBank Deallocate the elevator hardware. Definition at line 131 of file elevator.cc. |
|
|
called internally when the elevator hardware generates an interrupt. ElevatorBank::CallBack An event has occurred; check if someone needs to wakeup. Reimplemented from CallBackObj. Definition at line 290 of file elevator.cc. |
|
|
Close the elevator doors. ElevatorBank::CloseDoors Close an elevator's doors. Definition at line 160 of file elevator.cc. Referenced by ElevatorInspector::ControllerTest().
|
|
|
Step onto the elevator; elevator must have MaxRiders people on it currently Returns false if doors have closed (might have happened between when riders got OpenDoors event and when they decided to step onto the elevator). ElevatorBank::EnterElevator Rider steps onto elevator. Elevator must be at "onFloor", and there must be space on the elevator. Returns FALSE if doors have closed and/or elevator is on a different floor. Definition at line 247 of file elevator.cc. Referenced by ElevatorInspector::RiderTest().
|
|
|
Step off the elevator. Returns false if doors have closed. ElevatorBank::ExitElevator Rider steps off elevator. Rider must be on elevator. Return FALSE if doors have closed. Definition at line 277 of file elevator.cc. Referenced by ElevatorInspector::RiderTest().
|
|
|
change the display to show riders where this elevator is headed. ElevatorBank::MarkDirection Change the display showing where this elevator is headed. Definition at line 204 of file elevator.cc. Referenced by ElevatorInspector::ControllerTest().
|
|
|
Set the elevator into motion. Elevator doors must be closed. If elevator is already in motion, this causes the elevator to stop at a new floor (eg, if a rider presses a new floor while the elevator is moving). ElevatorBank::MoveTo Set the elevator into motion to "goingToFloor". Elevator doors must be closed. If elevator is already in motion, then if the new destination is ahead, keep going but stop at the new spot. If the new destination is behind us, wait until we get to the next even floor boundary, then change direction. Definition at line 176 of file elevator.cc. Referenced by ElevatorInspector::ControllerTest().
|
|
|
Open the elevator doors; elevator must not be in motion! ElevatorBank::OpenDoors Open an elevator's doors; the elevator must not be in motion! Definition at line 147 of file elevator.cc. Referenced by ElevatorInspector::ControllerTest().
|
|
|
an event occurred that requires a callback.
Definition at line 343 of file elevator.cc. Referenced by CallBack(), OpenDoors(), PressButton(), and PressFloor().
|
|
|
Press button outside elevator to indicate where rider wants to go. ElevatorBank::PressButton Rider has pressed button to indicate where he/she wants to go Definition at line 217 of file elevator.cc. Referenced by ElevatorInspector::RiderTest().
|
|
|
Press button inside elevator to indicate where rider wants to go; thread must be on the elevator. ElevatorBank::PressFloor Rider presses button inside elevator to say which floor he/she wants to go to. Rider must be on elevator! Definition at line 261 of file elevator.cc. Referenced by ElevatorInspector::RiderTest().
|
|
|
return the current position of the elevator (which floor its on). ElevatorBank::WhereIsElevator Return the current position of the elevator (which floor its on). If elevator is in motion, return the last floor we've gone by. Definition at line 192 of file elevator.cc. Referenced by ElevatorInspector::ControllerTest().
|
|
|
return the indicated direction (set by MarkDirection()) of this elevator. ElevatorBank::getDirection Return direction set by MarkDirection Definition at line 231 of file elevator.cc. Referenced by ElevatorInspector::RiderTest().
|
|
|
when the elevator device calls back, this will tell you what event(s) (relevant to controller threads) triggered the callback.
Definition at line 78 of file elevator.h. Referenced by ElevatorInspector::WaitForNextControllerEvent().
|
|
|
pull next event off the pending list of events, return NoEvent if list is empty. ElevatorBank::getNextEvent Retrieve an event posted by the elevator device. Definition at line 325 of file elevator.cc. Referenced by getNextControllerEvent(), and getNextRiderEvent().
|
|
|
when the elevator device calls back, this will tell you what event(s) (relevant to rider threads) triggered the callback.
Definition at line 114 of file elevator.h. Referenced by ElevatorInspector::WaitForNextRiderEvent().
|
|
|
call when an event occurs that elevator controller threads would be interested in.
Definition at line 126 of file elevator.h. |
|
|
call when an event occurs that riders would be interested in.
Definition at line 124 of file elevator.h. |
|
|
pending events relevant to controllers.
Definition at line 130 of file elevator.h. |
|
|
array of per-elevator state.
Definition at line 131 of file elevator.h. |
|
|
how many elevators in this bank?
Definition at line 122 of file elevator.h. |
|
|
how many floors in this building?
Definition at line 123 of file elevator.h. |
|
|
pending events relevant to riders.
Definition at line 129 of file elevator.h. |
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001