BB.Robot.ParamResolver (bb v0.15.2)

Copy Markdown View Source

Resolves parameter references in robot structs.

When a robot's DSL uses param([:path, :to, :param]) instead of literal unit values, the Builder stores nil for those fields and records subscriptions in param_subscriptions. This module handles:

  1. Initial resolution - At startup, resolve all param refs using current parameter values
  2. Dynamic updates - When a parameter changes, update all affected fields in the robot struct

Summary

Functions

Resolve all parameter references in a robot struct.

Update all fields that reference a specific parameter.

Functions

resolve_all(robot, robot_state)

@spec resolve_all(BB.Robot.t(), BB.Robot.State.t()) :: BB.Robot.t()

Resolve all parameter references in a robot struct.

Iterates through robot.param_subscriptions and resolves each parameter reference using the current value from robot_state.

Returns the updated robot struct with all param refs resolved to values.

update_for_param(robot, param_path, new_value, state)

@spec update_for_param(BB.Robot.t(), [atom()], term(), BB.Robot.State.t()) ::
  BB.Robot.t()

Update all fields that reference a specific parameter.

When a parameter changes, this function updates all robot struct fields that reference that parameter path.

Returns the updated robot struct.