Lab 1: SensorMap.

Introduction:    

                The goal of this lab is to assess feasibility of doing ¡®participatory sensing¡¯ application for traffic, and utilization and demonstration of the ease of use with the Cascades framework is the ultimate goal. By doing this, it gives us a Cascades API library for publishing data to any web services entity, and brings us scalability and other issues for the StreetWise application

Let¡¯s get started.

1.       Initial Work. 

a.
Create SensorMap Account
   
http://atom.re
   
http://research.microsoft.com/nec/msrsense/search.microsoft.com/sensormap/

    (C
reate a login account with user name and password)
b.
Get copy of Cascades
    d
ownloadable tarball from Phillip Sitbon available at http://cascades.cs.pdx.edu/
c.
Download MSRSense Toolkit(0.2 Alpha)

2.       SensorMap DataHub API

¡¤         DataHub is a web service

¡¤         Deployed by the SenseWeb project at Microsoft Research using the SensorMap website.

¡¤         DataHub exists at http://atom.research.microsoft.com/sensordatahub/service.asmx

¡¤         11 API functions available through these web services (currently, they support only 8 functions.)

a. Register Sensor

RegisterSensor (string publisherName, string password, string sensorInfoXML)

Inputs:

¡¤         publisherName: publisher account login name

¡¤         Password: publisher account password

¡¤         sensorInfoXML: sensor metadata in XML

 

Output:

¡¤           String with prefix ¡°OK¡± or ¡°ERROR¡± followed by outcome of call

b. Metadata SensorInfoXML

A sensorInfo object looks like (C# code):
SWLib.SensorInfo sensorInfo = new SWLib.SensorInfo (
                string publisherName,
  string sensorName,
  string SensorType,
  string DataType,
  double latitude,
  double longitude,
  double altitude,
  string sensorUrl,
  string keywords,
  string description,
  string unit,
  double samplingperiod,
  double reportperiod)

c. Python Code: Creating a Sensor

from DataHub_services import DataHubLocator, RegisterSensorSoapIn
locator = DataHubLocator()
server = locator.getDataHubSoap()
sdml = """<?xml version="1.0" encoding="utf-8"?><Sensorxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><publisherName>jfisch@cs.pdx.edu</publisherName><sensorName>PSU Camera</sensorName><longitude>-122.6812791824341</longitude><latitude>45.509174009003232</latitude><altitude>0</altitude><unit>jpeg</unit><sensorType>http://research.microsoft.com/nec/sensor/type/SensorType.owl#VideoCamera</sensorType><url></url><keywords>traffic, street</keywords><description>4th ave video camera</description><dataType>jpg</dataType><samplingPeriod>1</samplingPeriod><reportPeriod>1</reportPeriod><entryTime>2007-05-22T01:03:54.827</entryTime></Sensor>"""

 

params = RegisterSensorSoapIn()
params._publisherName = jfisch@cs.pdx.edu
params._password = "L111111"
params._sensorDescription = sdml

server.RegisterSensor( params)

d. C# code: Creating a sensor

SensorInfo sensor;
sensorName = "PSU Camera #1";
                    sensorKeywords = "PSU 4th Avenue";
                    sensorDescription = "Portland State University 4th Avenue Camera";
                    sensorType = SM_SensorTypes.VIDEOCAMERA;
                    sensorDataType = SM_DataTypes.JPG;
                    sensorUrl = "http://131.252.220.160";
                    sensorLatitude = 45.42497670435363;
                    sensorLongitude = -122.83549547195440;
                    sensorUnit = "bunchapixels";
                    sensor.publisherName = sensorPublisherName;
                    sensor.sensorName = sensorName;
                    sensor.latitude = sensorLatitude;
                    sensor.longitude = sensorLongitude;
                    sensor.sensorType = sensorType;
                    sensor.dataType = sensorDataType;
                    sensor.url = sensorUrl;
                    sensor.keywords = sensorKeywords;
                    sensor.description = sensorDescription;
                    sensor.unit = sensorUnit;
                    sensor.reportPeriod = 1;
                    sensor.samplingPeriod = 1;
                    sensor.entryTime = DateTime.Now;

CameraDriver camera = new WebCamDriver("http://131.252.220.160/");
Bitmap img = camera.getImage();                  

string mydocs = Environment.CurrentDirectory.ToString();
img.Save(mydocs + "\\tmp.jpg");
Console.WriteLine("Saved Image to" + mydocs);

byte[] imgByte = camera.ConvertBitmapToByteArray(img);
// generic remove sensor try-catch block

try
{
    
string removeSensorResult = mySensorMap.RemoveSensor(sensor.publisherName,
                                      
mySenseWebPassword, sensor.sensorName);
    
Console.WriteLine("remove sensor result: " + removeSensorResult);
}  catch (Exception e)
{    Console.WriteLine("Problem with web service: " + e.Message); }

     // generic register try-catch block
     xmlDesc = ObjectSerializer.SerializeObject(sensor);
     try
     {
          wsResponse = mySensorMap.RegisterSensor(sensor.publisherName,
                                                 
mySenseWebPassword, xmlDesc);
          Console.WriteLine("Register " + sensor.sensorName + " response: " + wsResponse);
          wsResponse = mySensorMap.SendBinaryData(sensorPublisherName,
                        
 mySenseWebPassword, sensorName, DateTime.Now, imgByte);
          Console.WriteLine("SendBinaryData " + sensor.sensorName + " response: " +
                         
 wsResponse);
          //System.Threading.Thread.Sleep(3000);
     } catch (Exception e) {
        
Console.WriteLine("Problem connecting to web service: " + e.Message);
    
}

}

e. A new publishing and retrieval library for Cascades

¡¤           Simpler for scientists to use; once their webserver is setup, can publish all sensor data using web-based interface

¡¤           In line with how scientists want to work with their data

¡¤           Same interface for all methods of publishing

¡¤           Scientists just need to specify where they want to publish (SenseMap, Google Earth, Mapquest)

¡¤           Library will support many different mapping venues. (SensorMap being only one of these)

¡¤           StreetWise position in Cascades.

¡¤           System Diagram of StreetWise.

3.       Accomplishments

¡¤           C# code written to publish video data from web cam from specific url

¡¤           C# code to interface with Cascades.

¡¤           Python code written to publish video data from web cam from specific url

¡¤           Preliminary Cascades Library Specifications Created.

¡¤           Bugs found in SensorMap published to SensorMap forum

¡¤           Current breakdown of SensorMap login is showstopper for running system (posted to forum)

 

4.       What we¡¯ve learned – A LOT!!!

¡¤           Difficult in dealing with privacy issues (need lots of permissions)

¡¤           Cutting edge work has lack of docs, bugs and frequent changes -- need to work on close working relationships with developers.

¡¤           Python, C#, SOAP, Web Services, WSDL

5.       What¡¯s left to do (Future Plan)?

¡¤           Run experiment, 2 PCs running win xp, 2 stargates, 2 webcams in ITS lab.

¡¤           Preliminary web site for StreetWise needs completion.

¡¤           Web-based interface for publishing sensor data.

¡¤           Set up web pages for new Cascades library with usage examples.

¡¤           Develop StreetWise to provide analysis features.

¡¤           Get second wireless working on Linux and run experiment from Linux PC.

¡¤           Write position paper on work we¡¯ve done, what was learned and ideas we can build on.

¡¤           StreetWise implementation

¡×         Native C# codes for getting data from Cascades

¡×         C# codes for calling Cascades

Conclusion:  The ultimate goal is to get you familiar with the basics and the easy use of Cascade framework, and many general users can deploy their sensor data using simple web interface or application through Google, SensorMap, etc. We expect many common users, who are not familiar with complicated manipulation of sensor data, publish the data into web service by using Cascades.