We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › environmentXML library
Page Index Toggle Pages: 1
environmentXML library (Read 977 times)
environmentXML library
Nov 24th, 2006, 3:38pm
 
hi all

i've made an environmentXML processing library to make it easy to get environmental data from remote feeds from the environmentXML website [ http://www.haque.co.uk/environmentxml/live/ ]. right now there are feeds from buildings and environments in london, washington dc and plymouth, with a couple more hopefully to come soon from tokyo and geneva.

with this library and the enclosed example, you should be able, out of the box, to get data feeds from my office in london; and by changing the DataIn url you can quickly change to get feeds from the other locations.

likewise you'll be able to share your own data feeds by registering them at the website so others can construct things that respond to your environment (contact me for details; not difficult, but it's just not public yet).

you can download the library, example and reference here: [ http://www.haque.co.uk/environmentxml/live/library.php ].

this is my first library so i'd be grateful for any feedback on making it (or the system as whole) better...

usman

p.s. it also requires tex's proXML library [ http://www.texone.org/proxml/ ] for which i'm very grateful since it made a lot of this much easier...
Re: environmentXML library
Reply #1 - Nov 25th, 2006, 4:13pm
 
Thanks Usman. This is an interesting idea. I'm interested to see what happens with it. I hope to see some additional feeds added, maybe one at UCLA.  Smiley

Casey
Re: environmentXML library
Reply #2 - Nov 28th, 2006, 9:36am
 
thanks casey! it would be good to have a UCLA feed so i might hold you to that one... Wink
i'm looking forward soon to start making the-things-that-make-use-of-all-these-feeds which is of course the whole point of it!
btw, a friend has (playfully?) suggested he might hook up a muon detector to his feed, this would certainly up the ante!
Re: environmentXML library
Reply #3 - Jul 8th, 2007, 8:11pm
 
hello,

i'm trying to use environmentxml with processing 124, and i have some troubles.

i try to render the example's script :

import proxml.*;
import processing.net.*;
import environmentxml.*;

DataIn dataIn;

void setup(){

  dataIn = new DataIn("http://www.haque.co.uk/environmentxml/live/xml/79.xml");

}

void draw(){

dataIn.update();
println("value: " + dataIn.getTagValue("temperature"));

}


but this message error appears :

/tmp/build62212.tmp/Temporary_1686_1192.java:9:13:9:79: Semantic Error: No applicable overload was found for a constructor with signature "DataIn(java.lang.String)" in type "environmentxml.DataIn". Perhaps you wanted the overloaded version "DataIn(processing.core.PApplet $1, java.lang.String $2, int $3);" instead?

/tmp/build62212.tmp/Temporary_1686_1192.java:15:9:15:23: Semantic Error: No accessible method with signature "update()" was found in type "environmentxml.DataIn".

what could i do ?
Re: environmentXML library
Reply #4 - Jul 8th, 2007, 8:36pm
 
hi germond

you have the newest version of the library, which works with threads (i.e. it's asynchronous, so you don't have to explicitly use 'update()'), and i haven't had time to update the documentation.

there is an example program which _is_ up-to-date at the very bottom of this page:

http://haque.co.uk/environmentxml/live/library.php

but basically as a result of the latest version (back from the beginning of june)

1. you don't need import proxml and processing.net, you only need import environmentxml.*

2. you initiate by using something like

Code:

dataIn = new DataIn(this, "http://www.haque.co.uk/environmentxml/live/xml/79.xml", 5000);


where 5000 is the number of milliseconds between each attempt to grab the remote data -- basically happens in the background automatically, so you can do whatever else you want in the draw() loop without being slowed down;

and when the data actually comes in...

3. you would need this function below, which automatically gets called when the new data is ready

Code:

void onReturnEnvironmentXML(DataIn d){

// this method is called whenever updated remote environmentXML is available from your dataIn remote URL

println("found: " + d.getTagValue("temperature"));
println("found: " + d.getIdValue(1));
println("found: " + d.getAge());

}


let me know how it goes (and feel free to email me if there's any difficulty..)

like i said the example at the bottom of that page is fully up-to-date, so if you copy paste it into a new file it should work out of the box...
Re: environmentXML library
Reply #5 - Jul 8th, 2007, 11:38pm
 
hi usman and thank you for your help.

i made corrections and all is working fine.

another question : is it possible to get PCdata (as proXML library does) with the environmentXML library ?

By example, in the following XML data :


<FOO attr1="fred" attr2="barney">
   <BAR a1="flintstone" a2="rubble">
       Some data.
   </BAR>
</FOO>

Is it possible to get the string "Some data." ?
I hope this question isn't too dummy (i'm a newbie).
Re: environmentXML library
Reply #6 - Jul 9th, 2007, 8:50am
 
not exactly possible; environmentXML makes use of a small subset of proXML's capabilities.

the thing is that environment xml is basically a very particular 'dialect' of xml, which we're basically using to connect remote machines, devices, environments.
so the most important item in our case is the "value" attribute (of a <datastream>) -- the assumption is that either you know the datastream id already, or you know one of the tags of that datastream, (the tag is formed using PCDATA between <tag>'s) so that you're just trying to find the value for that datastream.

if you have more general xml requirements, then proXML is definitely the way to go.
Page Index Toggle Pages: 1