Applet: Weather Service

In this tutorial, we construct a useful applet, or receptor "system", with the ability to display textually or speak the our current weather conditions.  We will also explore two approaches for managing signal messaging: membranes vs. receptor signal I/O.

To begin with, let's select the receptors we want to use:

Here we have selected the following receptors:

  • Text Display - for displaying the weather textually
  • Text To Speech - for speaking the current weather conditions
  • Weather Service - queries NOAA for today's weather conditions
  • Zipcode Service - queries the USPS for the zipcode's city and state
  • Weather Info - collates the responses from the weather service and zipcode service into English sentences.


When we place those receptors onto the HOPE surface and rearrange them, we notice that all the receptors are send Text signals to both the Text Display and Text To Speech receptors. 

Why is this?  Because the Text semantic type is a component of the US Location and Weather Info signals, so they are emitted as well.  However, this is not the desired behavior. 

Using Membranes

To correct this problem, we can isolate the Weather and Zipcode service with a membrane:

We note a couple things:

  1. The Zip5 signal is being sent between the Zip Code Service and the Weather Service.  This is again because the both receptors emit signals that include the Zip5 semantic type, and both receptors receive Zip5 semantic signals.
  2. The WeatherInfo semantic type is not getting to the Weather Info receptor.

We correct the first problem by isolating the Zip Code Service receptor in its own membrane.  We configure this inner membrane to receive the Zip5 semantic element and to emit the US Location semantic type:

Next, we configure the outer membrane to emit the US Location and and Weather Info semantic types:

We now have the desired behavior:

Now we can specify our zip code by double-clicking on the Weather Service receptor and entering where we live.  When we click on save, the receptors begin processing the signals by querying the web services and then emitting the results, which are then displayed and also spoken to us with speech synthesis:

Sometimes the NOAA or the USPS web services are down or report malformed data, we'll add one final touch: an exception dialog that will show us if there are any problems:

Here is a question to test your comprehension:

  1. How did we get the ExceptionMessage semantic type to pass through the membrane surrounding the Zip Code Service receptor?

Configuring Receptor Signal I/O

Let's look at how to configure the system without using membranes.  We'll dissolve the membranes we created above, resulting in this morass of communication between receptors:

By right-clicking on each receptor, we get a protocol configuration dialog, which allows us to enable/disable both receive and emitted signals of a particular protocol.  For example:

We configure the following receptors by disabling specific emit protocols:

  • Zip Code Service
    • Text
    • Zip5
  • Weather Service
    • Text
  • Carrier List Viewer (ExceptionMessage)
    • Text

The result is an applet with the specific communication pathways that we want, without using membranes: