Next: , Previous: , Up: The Rules File: Where the Magic Happens   [Contents]


2.3.3 Connecting the Dots: Events in Action

In the previous section, we defined Events, Inputs, and Outputs. Let’s see how they dance together in our alarm clock example:

The Event: "The current time has changed."
The Inputs: time:hour and time:minute.
The Output: The computer’s beep (On or Off).

For STARTER, the logic is straightforward: every time one of the inputs (time:hour or time:minute) changes, the entire block is re-evaluated. The system checks the rules from top to bottom and sets the target (beep:status) based on the first rule that evaluates to TRUE.

Simple, right? But now, let’s go back to our mantra: Abstraction.

What else could beep:status represent? And what other data could we feed in as an input? Let’s push the boundaries. Open your rules file again and swap the code for this:

beep:status {
    SET TRUE WHEN oil:price < 100;
    SET FALSE WHEN TRUE;
}

Now, launch starter-core, beep-example, and oil-example. If you suddenly hear your computer beeping, it means the price of oil has just dropped below 100 a barrel!

Think about the implications: What if, instead of a simple beep, that output was a service that sent a push notification to your phone? Or a service that executed a buy order on an exchange? In STARTER, there is no difference between a temperature sensor and a stock market index—data is data.