Prelude

KRL uses the "event condition action" pattern. Since there is only space for a single Boolean expression in the condition, KRL adds a prelude section in which preparatory computations can be done. It fits in between the event and condition, setting things up for the conditional action. The prelude begins in line 3 in the rule template shown below. 

rule test {
  select when sensor heartbeat
  pre {
    ...
  }
  if condition_is_true then {
    send_directive("Heartbeat")
  }
  fired {
    ...
  } else {
    ...
  } 
}

The prelude comprises a series of declarations. The values bound to names in the declaration are within scope in the condition, action, and postlude of the rule. 

See the child pages of this page for details.

Copyright Picolabs | Licensed under Creative Commons.