(Classic) Event Network Exercise: Semantic Translation

Objective

Process events to provide semantic translation for later processing

Setup

Exercise

  1. Create an event channel and label it "current location"
  2. Use the event channel ID to create an ESL that raises a location:current event with lat-long attributes
  3. Modify the location rule in the Personal Data Storage exercise to also store lat-long attributes from a Foursquare checkin
  4. Create and register a ruleset:
    1. Write a rule called nearby that listens for the current:location event. 
    2. Use the great circle functions in the math library to calculate the distance between the lat-long coordinates from the PDS module and those reported with the location:new_current event. 
    3. If the distance is less than a threshold (say 5 miles), then raise a explicit:location_nearby event otherwise raise a explicit:location_far event. Both events should contain the distance as an attribute. 
  5. Install the ruleset you created in the preceding step
  6. Create and register a second ruleset that has a rule that listens for the location:nearby event that sends a text message (see the Twilio module documentation) with the distance to your phone. Make sure you install this ruleset as well. 
  7. Test by raising the location:new_current event using the ESL you designed. Be sure you've checked in with Foursquare since modifying the ruleset to store lat-long data. 

This exercise previously named the location:new_current event location:current. The problem is that current is a reserved word and the current parser doesn't allow reserved words as event names. Feel free to name it whatever makes sense, just document what it is.

Copyright Picolabs | Licensed under Creative Commons.