1 Design II : Plant Care System Sushant Jain Jong Hee Kang Daniel Lloyd.

28
1 Design II : Plant Care System Sushant Jain Jong Hee Kang Daniel Lloyd
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of 1 Design II : Plant Care System Sushant Jain Jong Hee Kang Daniel Lloyd.

1

Design II :Plant Care System

Sushant JainJong Hee KangDaniel Lloyd

2

Scenario Buy a plant Buy some sensors/actuators Attach sensors/actuators to the

plant Subscribe to a plant care service

3

Picture

Network

Data Store

Service

Sensors/Actuators

ID tag

Gateway

Dashed Line : Short-rage wireless communication(e.g. RF)

4

We’ll talk about Communication Data Store Service

5

Communication How to transfer data from sensor

to data store?

Packet format

URL : pointer to semantics of DATA

URL DATA

6

From Sensor to Data Store Sensors broadcast data to nearest

node Intermediate nodes add data to

the incoming data packetURL1DATA1

URL1DATA1URL2DATA2

Intermediate Node

Next

7

From Sensor to Data Store

temp.com63

temp.com63plant.comID:45236

temp.com63plant.comID:45236myhome.netroom23

Sensor

ID tag(plant)

Gateway(in a room)

8

Pros & Cons + Do not need to configure sensors

We can attach additional sensors without configuration

- How to associate sensor data with a specific object correctly? Plant A may catch Plant B’s data Recursion

9

Alternative Ideas Configure sensors

So that they can send the object ID with data

Use 3-D location sensing technology for associating data with object

10

Semantics of data Problem:

how do you interpret “raw data” from the devices

only device manufacturer knows about the data format

standard is needed so that services can be built on top of raw data

11

Self describing data Data contains information which can be

used to interpret it. Sending code along with data pointer to code(URL) data itself can be a java object(serializable)

which implements some standard interface data with a pointer to a service which

converts raw data to meaningful object. (rmi)

12

Reflection Create an instance of a class whose name is not

known until runtime. Determine the class of an object. Get information about a class's modifiers, fields,

methods, constructors, and superclasses. Find out what constants and method declarations

belong to an interface. Get and set the value of an object's field, even if the

field name is unknown to your program until runtime. Invoke a method on an object, even if the method is

not known until runtime.

13

Design choice Data packets with Pointer to code and data

URL#rawdata processing data packet

locally: reflection based approach remotely: RMI based

URL has the information about the path of the class file, name of the class www.temperature-1.com/temperature-

1.class/

14

How it happens !!

From datapacket::From datapacket::String classname, String rawdataString classname, String rawdata

// may require downloading the class classnameClass ctemp = Class.forName(classname)// cache this object ctemp to handle subsequent//packets from that particular sensor

Object otemp = ctemp.newInstance(rawdata)

Now one can query this object to see what all interfaces it implements, what all functions are available etc….for example otemp may implement interface Temperature

15

Sensors sending Objects Data packets with a java object

URL#JavaObject object should be serializable

processing data packet use(Object Output Stream, Object Input

Stream) readObject, writeObject functions

can determine the class of object, (using reflection)

16

pros/cons + Leverages off java reflection

capabilities - Locks everything in Java, all data is

basically Java objects + devices are dumb, only assumption

is the format of data that they send, which is extremely simple

- run untrusted code on your machine

17

Standardization/Extensibility

Every manufacturer of a particular device implements a standard interface

It can extend the interface to provide more functionality

Services query the class of an object and can provide enhanced functionality if additional functions are available

This allows devices with similar but different capabilities to be

used for same service depending upon availability

18

What’s realisitc? We’ve been operating under the

assumption that the DataStore knows everything.

A Good assumption for thinking about applications.

But not a realistic assumption. Typically in a database, you only care about

the current value (current model of the world), not how it changes over time.

19

Kinds of single source data Current value Average value

Average over what? Last millisecond? Last year?

History Sampled how often?

Rate of change First derivative? Second derivative?

20

What should the “Data Store” store? Instead of storing everything, store

nothing. Data Store serves as a gateway to

the data: A DataPort. A DataPort serves as a locus of

data, a place where data is channeled to and from.

21

DataPort

Sensors Actuators

DataPort

RF/Network connection

22

What does the DataPort know? The DataPort only knows atomic

pieces of information: what the sensors tell it.

There is no correlation of information in the DataPort.

There are no views supported in the DataPort.

23

ViewPort A ViewPort runs on top of

potentially several DataPorts. A ViewPort supports additional

Interfaces which build off of the data contained in one or more DataPorts or ViewPorts. Average temperature. Location History

24

ViewPort

DataPort

ViewPort ViewPort

25

Interface of DataPort and ViewPort DataPort and ViewPort have the

same interface: <<Interfaces> [<Interfaces> selection

method]> Every ViewPort and DataPort contains a

list of Interfaces of the objects that they contain or can indirectly retrieve.<<Interface>> returns the set of all

interfaces supported by that DataPort or ViewPort.

26

Example <<interface>> {Plant, Temp, Room, etc.} <<Plant, Temp> <Plant, Room, Temp>

{ … return room.contains(plant.getLocation()) && room.contains(temp.getLocation()); }>

{<plant1, temp1>, <plant2, temp1>, ...}Based on these tuples, a ViewPort can create

and offer the PlantRoomtemp class.

27

Advantages Flexible

Arbitrary selection method. ViewPort can be implemented to

support any kind of combination of the data, in anyway.

If a DataPort or ViewPort contains a collection that implements a more specific interface, these objects can be used.

Can dynamically add ViewPort.

28

Disadvantages Inflexible

Locks in Java. Locks in SQL like query language. Difficult to dynamically create

ViewPort.