KickAss Rules and Programs
Rules, Programs and Scripts
Rules have much more flexible triggers than macros, but those triggers do not overlap. Rules are not triggered by VR events or DTMF tones, and may not be called from Macros or other Rules. Rules also have conditional execution, meaning that the trigger alone does not cause the events to be executed. The Trigger Event (TE) instead causes zero or more Secondary Conditions (SC) to be evaluated. Only if all SC (if any) are true are the Actions executed.
Rules may not be called directly from other Rules or Macros, and may not be triggered by DTMF or VR events. However, Rules may be triggered by external events, by Flags becoming true or false, by time of day, and so on. Rules have many possible triggers.
The action portion of both Rules and Marcos are essentially identical, being simply a list of individual steps to be executed, and once invoked, no additional decision-making may occur. This might at first seem to be a serious limitation, but we will show how to work within HAL’s capabilities to build complex logic.
HAL Program Elements
HAL Program elements consist of Macros and Rules. These in turn are composed of statements that use flags, counters, timers, sensors and devices and so on. These are stored in HAL’s internal database structure. Currently, this internal database cannot be easily accessed (more about this later) but as this is written we are awaiting the release of HALi ActiveX controls, a new feature which promises more flexibility.
Individual Rules and Macros can implement logic for many purposes. But even more power can be demonstrated by using groups of these objects together in a HAL Program.
HAL Flags are boolean logic elements that have two possible states, TRUE and FALSE. Flags in HAL programs are of two distinct types, as defined by their usage.
Trigger Flags are flags that are used as trigger elements for Rules. Their value at any moment has no effect on the program, but instead the Action of setting the Flag to TRUE (even if it was ALREADY TRUE) triggers evaluation of one or more Rules.
Status Flags are flags used to hold the status of a device or other element. Status Flags are used as Secondary Conditions (SC) in Rules, but not as Triggers.
While it is certainly possible to use a single flag both ways, in practice it’s clearly a good idea and less confusing if you cleanly define and separate the types of flags.
HAL Timers are numeric variables that count down in one-second intervals until they reach zero. Upon reaching zero, timers are said to “expire” and they stop counting.
HAL Timers can trigger rules when they expire. Timers can also be used as SC in a rule, whereby if it’s running it returns TRUE and if stopped it returns FALSE.
|