eeml
Class DataIn

java.lang.Object
  extended byjava.lang.Thread
      extended byeeml.DataIn
All Implemented Interfaces:
java.lang.Runnable

public class DataIn
extends java.lang.Thread

This is the class to use for receiving data from remote environments/applications. It is asynchronous which means that once a DataIn object is constructed it invokes an onReceiveEEML() method every time it receives data. You therefore must have a method void onReceiveEEML(DataIn d) in your application, and you would normally use the getValue() method to extract relevant data.

 DataIn myDataIn = new DataIn(this,"http://remote_url/001.xml",5000);
 
 void onReceiveEEML(DataIn d){ 
 
    float myVariable = d.getValue(0); 
    float myVariable2 = d.getValue("tagName");
 
 }
 


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DataIn(processing.core.PApplet parent_, java.lang.String url, int period)
          This object is asynchronous which means that it is set up to make requests at a particular interval (say once every five seconds, meaning period would be '5000').
DataIn(processing.core.PApplet parent_, java.lang.String url, java.lang.String key, int period)
          Just like DataIn(PApplet parent_, String url, int period) but enables the setting of a header to authenticate access to Pachube
 
Method Summary
 int countDatastreams()
          Returns the number of data elements in the remote EEML.
 int[] getId(java.lang.String tag)
          Returns an array of all the data stream ID's that are tagged with String tag.
 float getMaximum(int id)
          Used to determine the maximum value of a numeric data stream.
 float getMinimum(int id)
          Used to determine the minimum value of a numeric data stream.
 java.lang.String getStatus()
          Used to determine the status of an EEML feed ("live", "frozen" or "no status")/
 java.lang.String getStringValue(int id)
          Returns the string value of the remote data feed identified through its id number (useful when a stream's value is a string).
 java.lang.String getStringValue(java.lang.String tag)
          Returns the string value of the remote data feed identified through its tag (useful when a stream's value is a string).
 java.lang.String getTag(int id)
          Returns the tags for a specific data stream id.
 java.lang.String[] getUnits(int id)
          Used to determine the units of a data stream.
 java.lang.String getURL()
          Returns the URL requested by this object (useful in the onReceiveEEML method to determine which particular DataIn object's request has been received).
 float getValue(int id)
          Returns the value of the remote data feed identified through its id number.
 float getValue(java.lang.String tag)
          Returns the value of a remote data feed identified through its tag -- if there are several streams with the same tag, then only the first identified is returned.
 void printXML()
          Useful for debugging; returns the entire EEML document received.
 void quit()
          Ignore.
 void run()
          Ignore -- this is where the threads are created.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataIn

public DataIn(processing.core.PApplet parent_,
              java.lang.String url,
              int period)
This object is asynchronous which means that it is set up to make requests at a particular interval (say once every five seconds, meaning period would be '5000'). When the object receives a response from the remote server, it invokes the onReceiveEEML() method in your application where you can read the data for particular variables by using the getValue() method.
DataIn d = new DataIn(this,"http://remoteurl/001.xml",5000);

Parameters:
url - the URL to connect to
period - the number of milliseconds between requests to the remote feed.
See Also:
getValue(String tag), getValue(int id), DataIn(PApplet parent_, String url, String key, int period)

DataIn

public DataIn(processing.core.PApplet parent_,
              java.lang.String url,
              java.lang.String key,
              int period)
Just like DataIn(PApplet parent_, String url, int period) but enables the setting of a header to authenticate access to Pachube
DataIn d = new DataIn(this,"http://pachube.com/api/001.xml", "YourKeyGoesHere", 5000);

Parameters:
url - the URL to connect to
key - the Pachube API key used to access Pachube feeds (requires registration at pachube.com)
period - the number of milliseconds between requests to the remote feed.
See Also:
getValue(String tag), getValue(int id)
Method Detail

getValue

public float getValue(int id)
Returns the value of the remote data feed identified through its id number.
d.getValue(2);

Parameters:
id -
Returns:
value

getValue

public float getValue(java.lang.String tag)
Returns the value of a remote data feed identified through its tag -- if there are several streams with the same tag, then only the first identified is returned. (Use "getId" to retrieve an array containing the IDs of all the streams that contain a particular tag).
d.getValue("usefulTag");

Parameters:
tag -
Returns:
See Also:
getId(String tag)

getStringValue

public java.lang.String getStringValue(int id)
Returns the string value of the remote data feed identified through its id number (useful when a stream's value is a string).
String avatarName = d.getStringValue(4);

Parameters:
id -
Returns:
See Also:
getValue(int id), getStringValue(String tag)

getStringValue

public java.lang.String getStringValue(java.lang.String tag)
Returns the string value of the remote data feed identified through its tag (useful when a stream's value is a string).
String avatarName = d.getStringValue("avatarName");

Parameters:
tag -
Returns:
See Also:
getValue(int id), getStringValue(String tag)

getTag

public java.lang.String getTag(int id)
Returns the tags for a specific data stream id.

Returns:

getId

public int[] getId(java.lang.String tag)
Returns an array of all the data stream ID's that are tagged with String tag.

Parameters:
tag -
Returns:

countDatastreams

public int countDatastreams()
Returns the number of data elements in the remote EEML.

Returns:

printXML

public void printXML()
Useful for debugging; returns the entire EEML document received.


getURL

public java.lang.String getURL()
Returns the URL requested by this object (useful in the onReceiveEEML method to determine which particular DataIn object's request has been received).
if (thisD.getURL().equals(thatD.getURL()){
    doSomething(); // we know which feed's EEML we have just received
 }
 
@return


run

public void run()
Ignore -- this is where the threads are created.


getStatus

public java.lang.String getStatus()
Used to determine the status of an EEML feed ("live", "frozen" or "no status")/

Returns:

getMaximum

public float getMaximum(int id)
Used to determine the maximum value of a numeric data stream.

Returns:

getMinimum

public float getMinimum(int id)
Used to determine the minimum value of a numeric data stream.

Returns:

getUnits

public java.lang.String[] getUnits(int id)
Used to determine the units of a data stream. Returns an array, e.g.
 { "Celsius","C","basicSI" }
 

Returns:

quit

public void quit()
Ignore.