Global Constant
Steve Nay's ramblings

Implementing the driver's personal event network with Kynetx

Lab 3 in CS 462 involves creating a personal event network for drivers in the classic flower delivery system. I have recommended that KRL is a good language to use to implement this personal event network, rather than writing everything in a traditional language. However, there are some pieces of the system that don’t quite make sense since KRL doesn’t exactly have a front-end.

Here’s a diagram of the driver registration process:

The orange arrows indicate that some important data is being exchanged; the data itself is shown in bold type.

In short, the driver’s personal event network needs at least the following information in it’s data store from this interaction:

  • Driver's name
  • Driver's phone number
  • Information about each flower shop:
    • Flower shop ESL
    • Flower shop latitude and longitude

If you write this all as a traditional website, the UI for this is obvious. But KRL doesn’t provide as obvious a way to create front-ends. Here’s how I would do it.

We first presume that the driver has created his personal event network with Kynetx and has installed the driver app. It’s then a simple matter to create another KRL app that the driver can install to interact with the data store. This app will have display its UI when the user has installed the app and navigates to Here are the various pieces of that app:

Driver registration

We implement an interface that lets the driver submit his name and phone number. It could look like this:

When the driver clicks Submit, the data is sent back to the Kynetx servers and stored in entity variables. (The code for this and all other examples will be given later.)

Flower shop information

The driver needs to maintain information about the flower shops for whom he delivers. We provide an interface like this for submitting that information:

Again, when the driver clicks Submit, the information is sent back to the Kynetx servers, where it can be stored in an array of flower shops. We’ll use entity variables and JSON-encode the information.

The driver may also want to list all the flower shops. To do that, we simply loop over the array containing the flower shops and display the details:

The code

The code for this is relatively straightforward. I display a series of notify() boxes and use watch actions to raise events when the user clicks buttons. Here’s what it looks like:

Installing the app

The “driver” can install the app into his personal event network at this link: Driver Registration Helper. To use the app, go to once the app is installed.

Using the data from this app You will need to import my ruleset as a module in order to get the data out. Put this line in your meta block:

use module a163x154 alias driver_data

You may choose the alias, but make sure you prefix all function calls with that alias.

The modules provides a few functions to give you access to the data collected from the driver:


The first two of those functions return strings. The second returns an array of string-encoded JSON objects (called “hashes” in KRL parlance) that look like this:

  "name": "The Flower Shoppe",
  "esl": "",
  "lat": "-41.1",
  "lng": "111.1"

Use decode() and pick() to get the information out of those hashes.

A function call could look like this:

pre {
  driver_name = driver_data:get_driver_name();