XMAVLink.Util.CacheManager (xmavlink v0.14.3)

Copy Markdown View Source

Populate and keep updated a set of protected ETS tables representing:

  • the visible MAV systems
  • the most recently received messages for each MAV and message type
  • the most recently received set of parameters for each MAV

Using ETS tables allows read-heavy utility queries without turning this GenServer into a bottleneck. Prefer this module's query functions over direct ETS access; table contents are internal cache structs.

Use XMAVLink.Util.Context when utility state should be scoped to a specific router, dialect, or ETS table namespace.

Summary

Functions

Returns a specification to start this module under a supervisor.

Return one cached MAVLink parameter by name.

Return the latest cached message for a MAVLink system/component pair.

Return visible MAVLink systems from the utility cache.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_param(system_id, component_id, param_id, opts \\ [])

@spec get_param(non_neg_integer(), non_neg_integer(), atom() | String.t(), keyword()) ::
  {:ok, non_neg_integer(), XMAVLink.Message.t()}
  | {:error, :not_started | :no_such_param}

Return one cached MAVLink parameter by name.

Parameter names are normalized to uppercase before lookup, matching XMAVLink.Util.ParamSet behavior.

latest_message(system_id, component_id, msg_type, opts \\ [])

@spec latest_message(non_neg_integer(), non_neg_integer(), module(), keyword()) ::
  {:ok, non_neg_integer(), XMAVLink.Message.t()}
  | {:error, :not_started | :no_such_message}

Return the latest cached message for a MAVLink system/component pair.

The result is {:ok, age_ms, message} where age_ms is the monotonic age of the cached message at read time.

list_systems(opts \\ [])

@spec list_systems(keyword()) ::
  {:ok, [{XMAVLink.Types.mavlink_address(), XMAVLink.Util.Cache.System.t()}]}
  | {:error, :not_started}

Return visible MAVLink systems from the utility cache.

This is the public query API for the utility systems table. Each entry is returned as {system_component_id, cached_system} where system_component_id is {system_id, component_id}.

mavs(opts \\ [])

msg()

msg(opts)

msg(name, opts)

msg(arg, msg_type, opts)

params()

params(opts)

params(match, opts)

params(arg, match, opts)

router(opts \\ [])

start_link(state, opts \\ [])