User:Opensource Obscure/Pachube

From Second Life Wiki
< User:Opensource Obscure
Revision as of 03:13, 22 April 2011 by Opensource Obscure (talk | contribs) (templatizationingsx)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Go back to Opensource Obscure's userpage



Info about Pachube

According its website, Pachube is a service that enables people to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world. The key aim is to facilitate interaction between remote environments, both physical and virtual.

Some links about using Pachube and Second Life:


My feeds

Both Event Sensor and Display for this feed can be seen and used in-world at http://slurl.com/secondlife/Vulcano/99/152/39 :


Scripts

Example 1: Send Data from SL

Example 1 uses two prims, one script in each prim. Touch the first prim to send '0' value to your feed; when you touch it again, the value gets incremented by 1 and your feed gets updated; when you reset the script, the counter starts from 0 again. Touch the second prim to get the current value of your feed and display it via llSetText. <lsl> string baseurl = "http://www.pachube.com/api/YOUR FEED NUMBER.csv?key="; string pachube_key = "YOUR PACHUBE KEY"; string requestid; string my_key = "YOUR SL KEY"; integer i = 0;

default {

   state_entry()
   {
       llSay(0, "Hello, Avatar!");
   }
   touch_start(integer total_number)
   {
       i++;
       requestid = llHTTPRequest(baseurl+pachube_key, [ HTTP_METHOD, "PUT"], (string)i);
   }
   
   
   http_response(key request_id, integer status, list metadata, string body)
   {
       {
          llInstantMessage(my_key, body);
       }
   }     

}

</lsl>

Example 2: Import Data into SL

<lsl> string my_key = "YOUR PACHUBE KEY";

default {

   state_entry()
   {
       llSay(0, "Hello, Avatar!");
   }
   touch_start(integer total_number)
   {
       llHTTPRequest ("http://www.pachube.com/api/YOUR FEED NUMBER.csv?key=" + my_key, [], "");        
   }
   http_response (key keyReceivedRequest, integer intStatus, list lstMeta, string strBody)
   {        
       llSetText(strBody, <1,1,1>, 1);
   }

}

</lsl>


Notes