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

Link to this function

backup_state(state)

Request the state being backed up

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete_active_order(order)

Delete an executed order in OrderHandler and StateMachine

Link to this function

handle_call(msg, from, state)

Update the direction state

Link to this function

handle_cast(msg, state)

Update the direction state

Link to this function

init(direction)

Drive downwards to closest floor and initialize the state

Link to this function

initialize_to_floor()

Loops and drives downwards until it hits a floor

Link to this function

reset_motor_timer()

Reset the timer

Link to this function

start_link(init_args)

Link to this function

start_motor_timer()

Start a timer for the motor

Link to this function

stop_motor_timer()

Stop the timer

Link to this function

sync_order_lights(order, light_state)

Synchronize non-cab lights with other nodes through NetworkHandler

Link to this function

update_state_direction(direction)

Update the direction state