View Source Rclex.Subscriber (Rclex v0.9.0)

Defines control, start/stop, Rclex.SubLoop functions.

Subscriber itself can be created on Node by calling below,

There are 4 GenServers including this module itself under the Node. They work together as shown below.

+-------------+
| Rclex.Node  |
+-----+-------+
      |
      |
      |
      |                            +-------------------+                            +-------------------+
      +------Supervisor------------+ Rclex.Subscriber  |------Supervisor------------+ Rclex.SubLoop     |
      |                            +--------^----------+                            +--------+----------+
      |                                     |                                                |
      |                                     |                                                |
      |                                     | GenServer.cast to Rclex.Subscriber             |
      |                                     |                                                |
      |                            +--------+----------+                                     |
      |                    +-------+ Rclex.JobExecutor |          GenServer.cast to JobQueue |
      |                    |       +--------^----------+                                     |
      |                    |                |                                                |
      +------Supervisor----+                | GenServer.cast to JobExecutor                  |
                           |                |                                                |
                           |       +--------+----------+                                     |
                           +-------+ Rclex.JobQueue    <-------------------------------------+
                                   +-------------------+                                      
  • This module stored call_back to be executed.
  • Rclex.SubLoop triggers the call_back execution according to pushing message to Rclex.JobQueue.

Summary

Functions

Returns a specification to start this module under a supervisor.

subscriberを状態として持つ。start_subscribingをした際にcontextとcall_backを追加で状態として持つ。

Types

@type id_tuple() :: {node_identifier :: charlist(), topic_name :: charlist(), :sub}

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec init({sub :: Rclex.Nifs.rcl_subscription(), msg_type :: charlist()}) ::
  {:ok, state :: map()}

subscriberを状態として持つ。start_subscribingをした際にcontextとcall_backを追加で状態として持つ。

Link to this function

start_subscribing(sub_list, context, call_back)

View Source
@spec start_subscribing(id_tuple(), Rclex.Nifs.rcl_context(), call_back :: function()) ::
  :ok
@spec start_subscribing(
  [id_tuple()],
  Rclex.Nifs.rcl_context(),
  call_back :: function()
) :: list()
Link to this function

stop_subscribing(sub_list)

View Source
@spec stop_subscribing(id_tuple()) :: :ok | :error
@spec stop_subscribing([id_tuple()]) :: list()