|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
eeml.DataOut
This is the class to use for making data available to remote environments/applications.
It creates a 'server' object (based on Processing's network library) that sends
data to remote clients that request your local EEML data. (See below for instructions
on manual updates, in case a 'server' is not possible or desirable -- this is tailored
specifically for use with Pachube).
Automatic updates on request
The normal way to use the DataOut object is asynchronous which means that once a DataOut
object is constructed it invokes an onReceiveRequest() method every time it receives a request for
data. You therefore must have a method void onReceiveRequest(DataOut d) in your application, and you
would at this point normally update the values of your individual streamed data with the update()
method. The onReceiveRequest method then automatically creates an EEML document with all relevant
data and serves it to the requesting client.
DataOut myDataOut = new DataOut(this, 5210);
myDataOut.addData(0,"tag1,tag2,tag3");
void onReceiveRequest(DataOut d){
d.update(0, myVariable); // updates stream 0 with the value of myVariable.
}
Manual updates only when required
DataOut myDataOut = new DataOut(this, "FEED_URL", "API_KEY");
myDataOut.addData(0,"tag1,tag2,tag3");
myDataOut.update(0, myVariable); // updates stream 0 with the value of myVariable.
if (myDataOut.updatePachube() == 200){
// data was updated successfully.
}
Using Pachube
DataOut myDataOut = new DataOut(this, 5210);
myDataOut.addData(0,"tag1,tag2,tag3");
void onReceiveRequest(DataOut d){
d.update(0, myVariable); // updates stream 0 with the value of myVariable.
}
addData(),
update(int id, float value)| Field Summary |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
DataOut(processing.core.PApplet parent,
int port)
When the object receives a request from a remote client it invokes the onReceiveRequest() method in your application where data streams can be updated prior to serving. |
|
DataOut(processing.core.PApplet parent,
java.lang.String updateURL,
java.lang.String key)
DataOut object that enables manual updating of EEML data |
|
| Method Summary | |
void |
addData(int id,
java.lang.String tags)
Set up a data stream with a particular id with comma-delimited tags. |
void |
addData(int id,
java.lang.String tags,
float min,
float max)
Set up a data stream with a particular id with comma-delimited tags and minimum and maximum values. |
void |
quit()
Ignore. |
void |
run()
Ignore. |
java.lang.String |
serverMessage()
Returns the last message received from the requesting client. |
void |
setLocation(float lat,
float lon,
float ele)
Set location data for this environment: ONLY latitude, longitude and elevation. |
void |
setLocation(java.lang.String exposure,
java.lang.String domain,
java.lang.String disposition)
Sets location data for this environment: ONLY exposure ("outdoor"/"indoor"), domain ("physical"/"virtual"), disposition ("fixed"/"mobile") (See EEML specs for more info). |
void |
setLocation(java.lang.String exposure,
java.lang.String domain,
java.lang.String disposition,
float lat,
float lon,
float ele)
Sets location data for this environment, including exposure ("outdoor"/"indoor"), domain ("physical"/"virtual"), disposition ("fixed"/"mobile") and latitude, longitude and elevation. |
void |
setMaximum(int id,
float maximum)
Sets the "maximum" attribute for a particular data stream's value |
void |
setMinimum(int id,
float minimum)
Sets the "minimum" attribute for a particular data stream's value |
void |
setUnits(int id,
java.lang.String unit_,
java.lang.String symbol_,
java.lang.String type_)
Sets the unit element for a particular data stream's value. |
void |
update(int id,
float value)
Updates a particular data stream with a float value. |
void |
update(int id,
java.lang.String value)
Updates a particular data stream with a String value. |
int |
updatePachube()
Used to PUT data to Pachube in order to update a feed (for example when your IP address is not externally accessible and/or you want to update your datastreams manually). |
| 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 |
public DataOut(processing.core.PApplet parent,
int port)
DataOut myDataOut = new DataOut(this, 5210);
parent - usually 'this'port - port to serve on
public DataOut(processing.core.PApplet parent,
java.lang.String updateURL,
java.lang.String key)
DataOut myDataOut = new DataOut(this, "URL_TO_UPDATE_TO", "YOUR_API_KEY");
parent - usually 'this'updateURL - URL that was provided when the feed was registeredkey - the Pachube API key used to access Pachube feeds (requires registration at pachube.com)DataOut(PApplet parent, int port)| Method Detail |
public void addData(int id,
java.lang.String tags)
myDataOut.addData(0,"tag1,tag2,tag3");
id - tags -
public void addData(int id,
java.lang.String tags,
float min,
float max)
myDataOut.addData(0,"tag1,tag2,tag3",23.0,100.0);
id - tags -
public void update(int id,
float value)
d.update(3, 4.2);
id - value -
public void update(int id,
java.lang.String value)
d.update(0, "myName");
id - value - public int updatePachube()
if (myDataOut.updatePachube() == 200){
- server response indicates that the feed was successfully updated
}
DataOut(PApplet parent, String updateURL, String key)
public void setLocation(java.lang.String exposure,
java.lang.String domain,
java.lang.String disposition,
float lat,
float lon,
float ele)
d.setLocation("indoor", "physical", "fixed", 51.566742, -0.099373, 22.4);
exposure - domain - disposition - lat - lon - ele -
public void setLocation(java.lang.String exposure,
java.lang.String domain,
java.lang.String disposition)
d.setLocation("indoor", "physical", "fixed");
exposure - domain - disposition -
public void setLocation(float lat,
float lon,
float ele)
lat - lon - ele -
public void setMinimum(int id,
float minimum)
id - minimum -
public void setMaximum(int id,
float maximum)
id - maximum -
public void setUnits(int id,
java.lang.String unit_,
java.lang.String symbol_,
java.lang.String type_)
d.setUnits(0, "Celsius","C","basicSI");
id - unit_ - symbol_ - type_ - public java.lang.String serverMessage()
public void run()
public void quit()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||