Note: When The Live Web was written, there was a bigger focus on web page interaction, so many of the examples are based on that. Nevertheless the information raising events and creating event networks is still applicable.
You'll be modifying the rulesets that you create for this lessons in subsequent lessons. Be sure that the ruleset URLs you turn in for this lesson are unique from the URLs you provide later since this rulesets may not have been graded yet. You could do this by providing links to specific versions.
To send events to your pico, you will need the IP address of the machine that the pico engine is running on (along with the port that the pico engine is listening on).
Write a ruleset namedwovyn_base that contains a rule calledprocess_heartbeat that responds to a wovyn:heartbeat event. This rule should send a directive as its action.
Using the Pico Engine UI, create a pico that represents a temperature sensor and install yourwovyn_base ruleset in it.
Using one of the techniques inRaising Events, test your ruleset. Try it with various values for the sensor data to ensure it's working.
Configure your Wovyn device to post awovyn:heartbeat event to your temperature sensor pico. You'll need to format the temperature sensor's webhook URL to correspond to theSky Event APIthat your pico engine is expecting. You will need to create a channel for the temperature sensor to communicate with the pico.
Modify theprocess_heartbeatrule so that it will not fire unless there is a "genericThing"attribute present. See the Wovyn documentation for information on the structure of this attribute.
Modify the process_heartbeat rule toraise an event in the postlude with domainwovyn and typenew_temperature_reading. The new event should include (pass along) attributes for the temperature reading (called "temperature" and based on the content of the "genericThing" attribute) and a timestamp (called "timestamp"). Hint:event:attrs is a map of all attributes in the current event.
In the same ruleset, write a new rule namedfind_high_temps that selects on thewovyn:new_temperature_reading event. It should read the temperature attribute and, if it contains a value greater than the numeric value of the global variable named temperature_threshold, raise another event with domainwovyn and typethreshold_violation, along with any attributes passed along. Note, there are multiple ways to accomplish this. You can pick any positive value for temperature_threshold that you like.
In the same ruleset, write another rule calledthreshold_notification that selects on the wovyn:threshold_violation event. The rule should use the SMS action you created in Lab 2: APIs and Picos to send a notification of the violation to a SMS number stored in a global variable in the ruleset. Note: you will need to install your Twilio module ruleset and your keys module in the temperature sensor pico.
Use ruleset logging and debugging tools to convince yourself that your rules work.
Turn in the following:
URLs for your ruleset(s)
Short screencast (< 3 min with sound) showing the operation of your rulesets
Answers to the following questions:
What parsing method did you choose?
Did you accomplish step 5 with an event expression or a rule conditional statement? What are the advantages and disadvantages of the method you used compared with the other?
What was the output of the testing your ruleset before thefind_high_temps rule was added? How many directives were returned? How many rules do you think ran?
What was the output of the test after the find_high_temps rule was added? How many directives were returned? How many rules do you think ran?
How do you account for the difference? Diagram the event flow within the pico (i.e. show the event flow from when the pico receives the first event to the directives being created) using aswimlane diagram.
Would you say that yourfind_high_temps rule is an event intermediary? If so, what kind? Justify your answer.
How do your logs show that thefind_high_temps rule works? Pick out specific lines and explain them.
Can't change a rubric once you've started using it.