Package: elevators
Elevator LibraryThis library provides developers with anElevatorclass, that allows a physical elevator to
receive orders and fulfill them. It has to:Receive orders to pick up passengers (floor orders) and drop them off
(internal orders). Orders can come also from the administrator of the elevators that could be
received through a web serverInternally create and adapt a strategy to execute these ordersCommunicate with the machinery to implement this strategy through motion
(go up, go down, open the doors...)It has to contend with those constraints:Acceleration and deceleration will be instant time to go from one floor to the next will take 3
seconds. In future versions these problems will be handled more accurately.Doors stay open for 5 seconds and take 1 second to closeContextsThis class is meant to be used in two contexts:Concrete elevator:The embarked program that actually runs the physical elevator. The
program'smain()function will:Construct an Elevator instance based on configuration specifying the number of floors, the
space between each floor, maximum acceptable acceleration forceStart the instance's internal runtime by calling it'sstart()method in a background
process or threadTransform signals observed from the different sensors buttons, elevator vertical position etc
into requests sent to theElevatorinstance.frommultiprocessingimportProcessimportmultiprocessingasmpimporttimeimportrandomdefpress_button(q,floors):"""Simulates floor buttons being randomly pressed for illustration purposes"""whileTrue:time.sleep(random.randint(1,20))q.put(random.randint(0,floors-1))defmain():# Elevator that serves 5 floors, labelled from 0 to 4 — often 0 is referred# to as 'Ground Floor'floors=5elevator=Elevator(floors)call_queue=mp.Queue()elevator_runtime=Process(target=elevator.start)exterior_control=Process(target=press_button,args=(call_queue,floors))whileTrue:elevator.pick_up(call_queue.get())if__name__==main():main()Simulated elevators:To run a large scale simulations that scales up to many elevators, many
buildings, passengers, machinery events. Many instances can be created and launched where these
exterior elements will interact with them concurrently.Elevator stateThe elevator has several states:Moving/StationaryVertical position:1for floor 11.5when it is between floors 1 and 2Doors opened or closedCargo weightAPIsPassenger APIspick_up(floor_number)the passenger calls this method (method call is interfaced by the floor
elevator button) to ask the elevator to pick him or her up. Future versions will allow waiting
passengers to select 'up' or 'down'.drop_off(floor_number)once the passenger is inside the elevator he selects uses this method (
through the internal control panel) to tell the elevator to take him to floorfloor_numberpanic()when this method is called the elevator goes to the nearest floor below, sends a message
to security and or police forces and opens the doorsAdministrator APIsfire_alarm()the administrator uses this method to engage the fire safety protocolgo_to_floor()the administrator calls this method to tell the elevator to go to a certain floor
if it isn't busy. This can be useful for trying to optimize the elevator's waiting position
through heuristics or machine learning for instanceemergency_breaks()the administrator calls this method to protect passengers from a catastrophic
free fall it calls gets called when the elevator is moving, and the weight cargo weight sensor
reads zero indicating that the elevator isn't supporting its' own weight anymoreParametersFloorsThe elevator has a number of floors. If the number of floors is 5, then the elevator goes from floor
0 (or ground floor) all the way to floor number 4Maximum WeightThis has to be a required argument in the constructor: having a default could be tremendously
dangerous if it was implemented carelesslyMinimum WeightWeight of the elevator when empty, if the scale/weight sensor reads below this number, the elevator
might be in free fallSafetyMaximum Weight CheckBefore closing the doors, the elevator has to check that the weight of it's cargo does not exceed
it's safety limit. Specified during the instance's construction.Fire SafetyIf the fire alarm goes off:Stationary elevators should open their doors and no longer take instructionsMoving elevators should go to the closest floor below, stop and open their doorsPanic ButtonMeant to be hit by one of the passengers if he is being assaulted by another passenger, or is in
danger for any other reason inside the elevator. It will:Go to the nearest floor belowOpen the doors and send a message to building security or police forcesThese steps will be carried out silently so that the assailant isn't alertedBreaksStationary StateWhen the elevator is stationary the breaks should be on. Especially when the doors are open: if
passengers are getting in and out, and the cable snaps the result would be catastrophicFree FallIf the weight sensor goes below the minimum weight the elevator could be in free fall emergency
breaks have to be onDoor ObstructionThe elevator has an obstruction sensor, if this sensor is activated doors have to openMetricsElevators will produce logs reporting on their activity. These messages can then be sent to a
monitoring service allowing for analytics and machine learning lower downstream