Lecture 6 continued Alternate Homework problem 6 and 7 There is only one submittal, when HW7 is due, but this is a project and thus counts as three homework assignments. The goal is the same as the target-plane-missile homework problem. You are to use tasking to get some dynamics on the CRT screen. Elevator Problem ( a design analysis case study ) You are to simulate an elevator system for a nine story building having three elevators, assume real world conditions. e.g. the floors are numbered 1 through 9. If all elevators are on the first floor and someone pushes the down button on the ninth floor, only one elevator takes off for the ninth floor. Elevators with no where to go sit patiently with their doors closed. This is a real time simulation. Consider and elevator on the way from the first floor to the ninth floor. It has passed the fourth floor and the up button is pressed on the fifth floor. The determination of whether or not it will stop at the fifth floor depends on its position at the time the button is depressed. If this elevator does not stop then the closest free elevator will start for the fifth floor (or, the "Dynamically Closest", e.g. if another elevator is on the way up and is below the fifth floor). When all elevators are on first floor an the up button is pushed, only one door opens, it is desirable to get approximately uniform wear on the elevators thus the elevator at rest the longest responds. Your task is to first write the technical specification. If you had infinite foresight this would be the end of the problem specification, but... Considering real world students, below is some help. The help is in one possible order you might actually develop the information. Then there is an outline for the presentations of the developed information (quite a different order). First, write the physical specification, be terse yet state the obvious in order to record the information. 1. Environment. There is a building with 9 floors and three doors. Each door is either open, opening, closed or closing. Each door has a sensor that is effective only during closing and changes the state to opening. On each floor there are two buttons labeled up and down, the ninth floor has no up. The first floor has no down. Any buttons may be pressed at anytime. 2. Simulated environment. 16 keys are to be chosen to represent 8 up buttons and 8 down buttons. A portion of the screen is to show nine floors, 27 doors, 3 on each floor open or closed) and 16 buttons (lit or unlit). An indication of where each elevator will be shown in this view. Another portion of the screen is to show the inside control panel of the three elevators, (more detail later). 3. The object, one elevator, physical specification: Inside the cab a person sees a control panel. Buttons labeled 1 through 9 that are lit or unlit. There is an up arrow and a down arrow of which none or one can be lit. There is a door-open and a door-close button. They are only effective 3 seconds after being depressed, while still depressed and if the other button was not depressed first and still depressed. The door-close button is not effective when the door sensor indicates something jamming the door. There is and emergency stop button that is off or pulled-on. Editorial note. Did you notice that it was natural to write some functional specification in with the physical specification during the thinking process. This later gets strictly separated in formal MIL SPEC documentation. 4. The object, an elevator, performance specification: 1/4 floor is traveled to accelerate to constant speed, this takes 2 seconds deceleration to a stop also takes 2 seconds and covers a distance of 1/4 floor At constant speed the elevator travels 1/4 floor per second must sense 1/2 floor before if it is to stop doors take 2 seconds opening and 2 seconds closing allow 10 seconds door open to let a person on or off 5. The environment, functional specification The elevator that responds is the closest either statically or dynamically The elevators are to get about equal usage. Anticipated Load - All floors push down - the breakfast rush. (Assume, on average, an elevator can handle 3 floors worth of people) Stop if there is a " Target of Opportunity" A goal driven algorithm may be used. Possible goals are to minimize the average wait time for people pushing a button on a floor, or to minimize the maximum wait time for people pushing a button on a floor. Note, a goal driven, or rule driven, algorithm is akin to the use of AI. Each case is not analyzed, rather a strategy is used that gives a reasonable solution for all cases. 6. A scenario that might help finish the design and may be useful for testing ( get double duty out of your work ) All elevators on first floor The second floor down is pushed One elevator starts up The third floor down is pushed in time, elevator passes second floor. The fourth floor down is pushed in time, elevator passes third floor The fifth floor down is pushed in time but >3 floors allocated to this elevator so ignore (reject request?) Next elevator starts for the fifth floor The ninth floor down button is pushed. OH OH Don't let it go crazy, the rule being do not go more than 2 floors out of your way The third elevator starts for the ninth floor. The up button is pushed on the third floor The up button is pushed on the first floor ( as each elevator answer's the floor button call, just before the door closes, push the down button in the elevator for floor minus 2, or floor plus 2, whichever is appropriate.) The system should be symmetric with respect to up and down, and symmetric with respect to starting and stopping Try and lay out a complete test. ( Just lay it out, it could take a month to do any where near a complete test. ) This is the "Test data first" approach to software design. It helps flush out the loose ends in the specification. Implementation: It seems reasonable to have a task that is the elevator control system ( it tells each elevator its assignments i.e. floor(s) to go to) It handles power failure and system reset. There is an elevator task type and three elevator objects of this type. (See Grady's Book if you want to do an OOD type design. Use Pamela if you want to do a George Cherry process design. Expand the tests if you want to do a "Test data first" design.) There is one or more display tasks. You may want a keyboard input task. Elevator problem: A possible screen lay out Cab A Cab B Cab C --------- --------- --------- d 9 || || || | | | | | | | ^ v N | | ^ v N | | ^ v N | U d 8 || |<>| || | | | | | | | | | | | | u d 7 || || || | 1 2 3 | | 1 2 3 | | 1 2 3 | | | | | | | u D 6 || || |----| | 4 5 6 | | 4 5 6 | | 4 5 6 | | | | | | | u d 5 || || || | 7 8 9 | | 7 8 9 | | 7 8 9 | | | | | | | u d 4 || || || | O C S | | O C S | | O C S | | | | | | | u D 3 || || || --------- --------- --------- u d 2 || || || j J j U 1 |><| || || A possible display. Bold or upper case letters could indicate on Elevator A's door is closing, B's is opening, C's is open If door is closed, a < points to where the elevator is to half floor ^ is lit if the elevator is committed to go up v is lit if the elevator is committed to go down N is the single digit floor number that the cage is on or about to be on. O is the open button, lit for 5 seconds after being pushed C is the close button, lit until door is closed. S is the stop button, lit while pulled. Use key to toggle it in and out. J is the door jammed indicator, Use a key to toggle it. A possible key mapping is: Un for pushing the Up button on the n'th floor Dn for pushing the Down button on the n'th floor An for pushing the n'th floor button in elevator cab A AO, AC, AS, AJ for toggling the Open, Close, Stop, Jam conditions Bx same as Ax for elevator cab B Cx same as Ax for elevator cab C