The best way to use the KRL documentation is to search since you may not always appreciate how it's organized (or isn't).
In thislabyou will implement another ruleset for your pico that complements or adds functionality to the ruleset you built for Lab 3: Rules, Events, and Intermediaries. Note that this second ruleset depends on explicit events that the rules in the first ruleset raise. This is an important property of picos.
Do the following:
Write a new ruleset calledtemperature_store to serve as a temperature module. This ruleset should have three rules:
A rule namedcollect_temperaturesthat looks forwovyn:new_temperature_reading events and stores the temperature andtimestamp event attributes in an entity variable. The entity variable should contain all the temperatures that have been processed. Hint: look at the resources above for persistent variable help.
A rule namedcollect_threshold_violations that looks forwovyn:threshold_violation events and stores the violation temperature and a timestamp in a different entity variable that collects threshold violations.
A rule namedclear_temeratures that looks for asensor:reading_resetevent and resets both of the entity variables from the rules in (1) and (2).
Add three functions to the global block of thetemperature_storeruleset. These functions should return an array of temperatures where each temperature is a timestamp and a temperature in degrees.
A function calledtemperaturesthat returns the contents of the temperature entity variable.
A function calledthreshold_violationsthat returns the contents of the threshold violation entity variable.
A function calledinrange_temperatures that returns all the temperatures in the temperature entity variable that aren't in the threshold violation entity variable. (Note: I expect you to solve this without adding a rule that collects in-range temperatures)
Add aprovidespragma to the meta blockof thetemperature_storeruleset that lists the three functions. Also add ashares pragma to the meta block with the same list of functions.
Install yourtemperature_store ruleset in the same pico as your modifiedwovyn_base ruleset. Test your setup to ensure you are storing temperatures from the wovyn device. You can use curl, a program you write, or a browser app like theAdvanced REST Clientto make calls to the functions.
Turn in the following:
URLs for your ruleset(s)
Short screencast (< 3 min with sound) showing your new functions and rules with a short deminstartion of the labs functionality.
Answers to the questions, including any posed in the preceding "do this" section.
Explain how the rulecollect_temperatures and thetemperatures function work as an event-query API.
Explain your strategy for finding temperatures that are in range.
What happens ifprovidesdoesn't list the name of thetemperaturesfunction?
What happens ifshares doesn't list it?
Can't change a rubric once you've started using it.