Lab 0: Events and Queries
- Due No Due Date
- Points 100
- Submitting a text entry box, a media recording, or a file upload
Objective
The objectives of this lab are to
- install and run the Pico Engine.
- gain an understanding of how picos communicate with each other and how they react to those communications.
Reading and Reference
Read the following:
- Intro to Picos and Actor-Model Programming
- Persistent Compute Objects
- Pico Engine Quickstart
- Events and Queries Links to an external site.
The following videos may be helpful:
Events and Queries Video
Links to an external site.
You may find the following resources useful:
Prerequisites
You will need the following:
- Node.js version 6 or greater with NPM
- Laptop, AWS account, or other system capable of running NodeJS
Implementation Notes
- The best way to use the KRL documentation is to search since you may not always appreciate how it's organized (or isn't).
- For labs, you will find that keeping your rulesets on your file system (instead of Github) will be easiest.
- People often can't get their ruleset to run because it doesn't parse. Make sure you always parse your ruleset before checking it into whatever system you're using to store it (probably GitHub).
- If your changes don't seem to take effect, the most common cause is likely that GitHub's internal caching is returning the old ruleset even though you've checked in changes. Try waiting 5 minutes, refreshing, and trying again. Alternatively, use a local file for development and check into Github for turning the assignment in or use GitLab (Links to an external site.).. (Note: raw urls in private repositories will need an account access token.)
- Note that if you have two rules in your installed rulesets that select on the same event, then they will both fire when the pico sees that event.
- You can do this entire lab in one pico. You can do it in your account's primary pico, or you can create a child pico and install the rulesets there.
Do This
Complete the following:
- Install the Pico Engine on the system of your choice. (As a reminder, the installation instructions are found in the Quickstart guide given above)
- Copy the
hello_world
ruleset from the Quickstart into a resource that is accessible from a URL (can be a local URL using the file: schema). - Using one of the methods in Parsing Rulesets
Links to an external site., validate your ruleset.
- Change the KRL in the
hello_world
ruleset so that it's not properly formatted. - Reparse it and note the error.
- Fix the problem.
- Change the KRL in the
- Install the ruleset at the URL you used in step (2) in your pico.
- Create a new channel (pick any name and type you like, leave the policy open (*/*).
- Send an event to the pico using the new channel and the original (default) channel.
- Do you get the same result on both? Why or why not?
- Delete the channel.
- Resend the event using the deleted channel.
- What happens? Why?
- Send the event
echo/hello
to your pico. What do you observe? Why? - Send the misspelled event
ecco/hello
to your pico. What do you observe? Why? - Add a new rule to the
hello_world
ruleset that selects onecho/monkey
and responds with "Hello Monkey" unless an event attribute namedname
is given, in which case it will respond with "Hello " followed by the given name. Hint: use the||
operator. Use the.klog()
operator to log the value that is used. - Repeat the previous step using the ternary conditional
Links to an external site. instead of the
||
operator.
Deliverables
Turn in the following:
- URLs for your ruleset(s)
- Short screencast (< 3 min with sound) showing the results from (4) and (5) above
- Answers to any questions posed in the preceding "do this" section.
Rubric
Criteria | Ratings | Pts | ||
---|---|---|---|---|
URLs
Host this code on github and provide the url to the rulesets.
threshold:
pts
|
|
pts
--
|
||
Screencast
threshold:
pts
|
|
pts
--
|
||
Answers to Questions
Please provide this separately from the screencast.
threshold:
pts
|
|
pts
--
|
||
Total Points:
100
out of 100
|