7.8. feed — The Wubby Cloud feed module

The feed module provides functions for feeding the Wubby Cloud with the selected datastreams.

The feed() function returns a feed object with the name and datastream given as parameters. Datastream can be any object whose activity will be captured, for example a temperature sensor. An application may have multiple feeds and a feed may have multiple datastreams.

All the feeds are presented in the Wubby Client (see “Log File” section).

feed.feed(feed_name, datastream_name)

Create a new feed with the specific datastream.

7.8.1. Class feed

feed.update(value)

Send the current measured value of the datastream to the Wubby Cloud live feed.

7.8.2. Example

In the following example we create a new feed with “testFeed” name for the “testDatastream” datastream, which will be used to capture the activity of the ADC object and present it to the Wubby Cloud live feed.

# main.py -- put your code here!

import time
from hardware import adc
import feed

## Create an new feed with name "testFeed" for the "testDatastream" datastream
testFeed = feed.feed("testFeed","testDatastream")

## Create a new adc object
analog = adc(1)

## Initialize the new object
analog.init(1000)

val = 0

while True:
    ## Read Value
    val = analog.read()
    print ("value : " + str(val))

    ## Update the "testFeed" feed with the measured value
    testFeed.update(val)

    time.sleep(4000)

Note

Currently the Live Feed of the Wubby Client presents only the “testFeed” feed, for the “testDatastream” datastream. The ability to show other feeds and datastreams will be available soon.