Elevator v1.0.0 StateMachine
Module for the state of an individual elevator, for controlling the execution of orders, ensures own backup and makes sure lights are correct
State:
- A struct consisting of a floor (the last floor), a direction (:up, :down, :stop)
and a list of active orders it has accepted:
%State{active_orders: [], direction: :stop, floor: 1}
Tasks:
- Controlling the elevator motor
- Executing orders
Communication:
- Sends to: DriverInterface, WatchDog, NetworkHandler
- Receives from: OrderHandler, Poller
Link to this section Summary
Functions
Request the state being backed up
Returns a specification to start this module under a supervisor
Delete an executed order in OrderHandler and StateMachine
Update the direction state
Update the direction state
Drive downwards to closest floor and initialize the state
Loops and drives downwards until it hits a floor
Reset the timer
Start a timer for the motor
Stop the timer
Synchronize non-cab lights with other nodes through NetworkHandler
Update the direction state
Link to this section Functions
backup_state(state)
Request the state being backed up
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
delete_active_order(order)
Delete an executed order in OrderHandler and StateMachine
handle_call(msg, from, state)
Update the direction state
handle_cast(msg, state)
Update the direction state
init(direction)
Drive downwards to closest floor and initialize the state
initialize_to_floor()
Loops and drives downwards until it hits a floor
reset_motor_timer()
Reset the timer
start_link(init_args)
start_motor_timer()
Start a timer for the motor
stop_motor_timer()
Stop the timer
sync_order_lights(order, light_state)
Synchronize non-cab lights with other nodes through NetworkHandler
update_state_direction(direction)
Update the direction state