The Bus component is a process local Bus, which supports publishers and subscribers on named topics. It does this by providing a topic-based publish/subscribe mechanism that is used to decouple data publishers from subscribers.
The Bus component is the core component of the XRT framework and most other components communicate using the Bus component.
The Bus component supports named topics with semantics based on MQTT topic naming and matching conventions.
Topics can be associated with a thread pool, which manages all asynchronous publications and/or subscriptions for the associated topic. This indirectly supports thread priority and processor affinity on a topic for asynchronous data handling.
Topics can be set to keep the last published data, by setting the Retain configuration parameter to true. For further information, see Topic Parameter Configuration Variables below.
The Bus component allows a subscriber to subscribe to multiple topics by using subscribers based on a topic pattern match. Subscribers can do the following:
- Poll for data publication. This is a synchronous operation
- Register a callback function, which is called when data is published on a matching topic. This can be either a synchronous or an asynchronous operation
- Set a maximum queue length, which limits the number of pending async events are cached before data is discarded
You can enable or disable publishers and subscribers, which allows for the temporary disabling of a publisher push or a subscriber pull.
The following table describes the configuration variables that can be used with the Bus component:
|Logger||String||The name of the Logger component to use||The name of an existing Logger component||N|
|Scheduler||String||The Scheduler component to use||The name of an existing Scheduler component||
N - if used in sync mode
Y - if used in async mode
|Topics||Array||An array of topic parameters, which are created on initialization||See Topic Parameter Configuration Variables below||N|
Topic Parameter Configuration Variables
The following table describes the configuration variables that can be used with the Bus topics parameter:
|Topic||String||The name of the topic||Y|
|Priority||Integer||The priority of the topic||
Valid values are system-dependent
For example, on Linux, it is usually between 1 and 100 with 1 being the lowest priority and 100 being the highest priority
Default is IOT_THREAD_NO_PRIORITY
Specifies whether to retain the last topic value
Specify true to retain the last topic value
Specify false to drop the last topic value
Valid values are as follows:
|ThreadPool||String||The name of the Threadpool component to use||The name of an existing Threadpool component||N|