Friday 16 April 2010

Processing Sketch - Getting The Data

Now that my balls were practically finished I thought I would get onto writing the code that would collect the data I was going to use.

First of all I setup the floats that I was going to use:

float outsidetemperature;
float windspeed;
float windvane;
float humidity;
float LT1_Hum;
float LT1_Temp;
float LT2_Hum;
float LT2_Temp;
float LT3_Hum;
float LT3_Temp;
float AtriumA3rd_Temp;
float AtriumA5th_Temp;


I will state later on why I chose these particular bits of data.

Then I wrote these lines of code to get the numbers that I wanted.

outsidetemperature = float(description[21].getContent());
windspeed = float(description[37].getContent());
windvane = float(description[36].getContent());
humidity = float(description[20].getContent());
LT1_Hum = float(description[14].getContent());
LT1_Temp = float(description[15].getContent());
LT2_Hum = float(description[16].getContent());
LT2_Temp = float(description[17].getContent());
LT3_Hum = float(description[18].getContent());
LT3_Temp = float(description[19].getContent());
AtriumA3rd_Temp = float(description[23].getContent());
AtriumA5th_Temp = float(description[24].getContent());


I worked out that the XML feed was sort of like an array and thus by entering a number between the square brackets I could select what data I wanted using getContent. Now these were stored into the variables all I would have to do is type the float name and that number would be used.

No comments:

Post a Comment