OrderDistributor (ElevatorProject v0.1.0)
Distributes assigned and completed orders to all elevators in the node cluster.
Can also request backup from other elevators in the node cluster, and update
Orders
accordingly. Upon reception of assigned orders the orders are added to Orders
,
ElevatorOperator
is singalled to take the orders if it is the assigned elevator,
watchdog timers are started for hall calls, and order button lights are set.
Upon reception of completed orders the orders are removed from Orders
,
watchdog timers are stopped for hall calls, and order button lights are cleared.
Uses the following modules:
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Signals to all elevators in the node cluster that the given order has been completed. Spawning a multi_call effectively becomes a multi_cast with acknowledge and a given timeout.
Distributes a given order to all elevators in the node cluster. Spawning a multi_call effectively becomes a multi_cast with an acknowledgement and a given timeout.
Requests backups for all other elevators in the node cluster, and merges these
backups together with its own. All orders for which the elevator is assigned are
signalled to ElevatorOperator
, watchdog timers are started for hall calls,
and order button lights are set for all orders in the merged backup.
Link to this section Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
distribute_completed(order)
Signals to all elevators in the node cluster that the given order has been completed. Spawning a multi_call effectively becomes a multi_cast with acknowledge and a given timeout.
Parameters
- order: Order to be distributed as completed :: %Order{}
Return
- :ok :: atom()
distribute_new(order)
Distributes a given order to all elevators in the node cluster. Spawning a multi_call effectively becomes a multi_cast with an acknowledgement and a given timeout.
Parameters
- order: Order to be distributed as new :: %Order{}
- best_elevator: Elevator to serve the order :: atom()
Return
- :ok :: atom()
request_backup()
Requests backups for all other elevators in the node cluster, and merges these
backups together with its own. All orders for which the elevator is assigned are
signalled to ElevatorOperator
, watchdog timers are started for hall calls,
and order button lights are set for all orders in the merged backup.
Return
- :ok :: atom()