Multi Chain Triggers

A chain in microblx is a list of blocks to be triggered. Some would call it schedule. So far, the standard trigger blocks ptrig and trig supported one chain. That's fine if a single, fixed schedule is sufficient, however many applications need to discretely switch their processing upon occurrence of an event. The classical example is switching a robot controller from free-space- to force control upon making contact with the environment. Enter multi-chain triggers: In the upcoming microblx v0.9, ptrig and trig have been extended to support a configurable numbers of chains as well as run-time support for switching between them:

$ ubx-modinfo show trig

module trig
 license: BSD-3-Clause
 blocks:
   std_triggers/trig (type: cblock, prototype: false, attrs: trigger)
     configs:
         num_chains [int]            // number of trigger chains. def: 1
         tstats_mode [int]           // 0: off (def), 1: global only, 2: per block
         tstats_profile_path [char]  // directory to write the timing stats file to
         tstats_output_rate [double] // throttle output on tstats port
         tstats_skip_first [int]     // skip N steps before acquiring stats
         loglevel [int]              // block loglevel
     ports:
         active_chain [in: int]      // switch the active trigger chain
         tstats [out: struct ubx_tstat] // timing statistics (if enabled)

Note the num_chains config and the active_chain port. The former defines how many chains the block shall support (default is 1). Upon initialization, the block will create that number of chains called chain0, chain1, ... . Each of these can be configured with a list of blocks to trigger while the respective chain is active. To switch the active chain at run-time, simply send the respective chain id to the active_chain port.