CAT: Design and Architecture

[Overview] [Transport] [Sensor] [SIG] [History] [Context Manager] [CAT Application] [CAT Homepage]
 

Overview

 

 

The Context Aware Toolkit is a component oriented system built using the Java programming language.  The architecture was designed to make CAT easy to modify and easy to use for applications.  Many of the CAT components are dependent on each other, however, the architecture's true benefit is in building CAT applications.  The application has complete access to all of CAT's features and functions, while remaining oblivious to the actual inner workings.  The idea is that applications built on CAT can have access to as many resources as needed, so as to allow for the most flexible and extensible applications possible.  Applications can listen to sensors, create sensors, create SIGs, do p2p communication, and access a history of sensor data without having to know what is actually happening.

The following sections will describe the main components of CAT, how the components all fit together, and how an application uses CAT. 

 

Transport

 

 

The Transport component of CAT controls all incoming SIG and P2P communication.  Simply put, it uses a proxy to enable it to switch from using a simulator or the real world.  In simulation mode, Transport will send/receive everything through iSIM.  In real world mode, the Transport component will use actual IP addresses to communicate with other agents.  In addition, a security component is under development that will be able to plug into the transport component when ready.

                                        

 
 

Sensor

 

 

The Sensor component contains and manages all the sensors in CAT.  A Sensor Manager keeps a reference to all sensors, facilitates sensor creation and deletion, and initializes all available hardware sensors during the startup of CAT.  Soft Sensors, which are actually created by an application, are at the top of the sensor hierarchy (the sensor manager just has references to them).  Soft sensors get their data from either other soft sensors or from hardware sensors, as seen in the figure below.  Hardware sensors (or just sensors for short) get their data from actual sensors on the wearable device (or simulated device).  The sensor data is given to a sensor directly by a Sensor Proxy.  The Sensor Proxy, upon creation by the Sensor Manager, is setup to listen to data from either iSIM or a real hardware sensor on a Communication Port of the wearable device.

Lastly, all sensors and soft sensors propagate their sensor data by sending events.  If no application or soft sensor is interested in a sensor, then its data will simply be ignored.  Components that are interested in sensor data events include the history component for recording the data and the SIG component for sharing the data.  

 

SIG

 

 

SIGs are used so that agents can form groups with other agents, in which they share their sensor data.  For instance, agents or the application itself might want to form SIGs so that a person can see the various temperatures around town, the atmosphere in various restaurants, or the location of his/her friends.  A SIG Manager is used to both contain all SIGs, and to facilitate the creation and deletion of SIGs.  A special Sensor Monitor is a class that listens to all sensors and soft sensors in CAT.  When new sensor data is seen by the Sensor Monitor, it will notify the SIG Manager, which will in turn send the sensor data to any SIGs which are sharing that sensor.  The Transport component is used for sending out the shared sensor data, as well as sending and receiving SIG notifications.

 
 

History

 

 

A key feature of CAT is saving sensor data for one or more agents to use.  The History component contains a History Manager that listens to all sensors and soft sensors in CAT.  The History Manager will then send all the sensor data to a history database through the Client class.  Upon the startup of CAT, Client can be told to connect to a local database or remote database.  Sensor data that is written to the database includes agent id (unique), timestamp, and sensor id (unique) to ensure uniqueness of the sensor data.

The History Manager can also access stored sensor data.  The History Manager can access sensor data for any timestamp, even the future.  The History Manager will attempt to find sensor data which is nearest to the timestamp.  For future timestamps and certain sensor values, such as location, methods are used for predicting the sensor data value.  (Note: prediction methods are rather primitive in this early implementation of CAT)

 
 

Context Manager

 

 

In order to bring all the components of CAT together, there is a Context Manager.  This class is responsible for the initial creation of the other CAT components.  It also provides the means for applications to access the CAT components.  Once CAT and an application are running, the application may want to add a soft sensor, create a SIG, or lookup sensor data in the history.  The Context Manager can supply the necessary components that an application might need.  In addition, the Context Manager makes sure that when a change is made to one component, the other components are updated accordingly.  For example, when a new sensor is created, the Context Manager will make sure that the other components have their listeners updated.

 
 

CAT Application

 

 

The CAT application has several features and abilities, and an abstract application is provided to give a layout for what a CAT applications needs to do, and what it can do.  The following diagram shows 7 functions that an application can perform through CAT.  An application can do P2P Communication with use of the Transport component.  The application can receive data such as SIG Notifications, Sensor Data, and Agent Discovery through being a listener of the CAT Sensor and SIG components.  An application can also access the SIG, Sensor, and History components through the Context Manager in order to create SIGs, Soft Sensors, and access the History of sensor data.

To see how the functions are actually implemented in the above diagram you can view the code for Context Application here, or you can look at the following pieces of code:

Methods in Context Application

P2P Communication

/* ===================================================================== */<br> /** ContextApp.java * This method can be used to send p2p communication. Can send any * serializable object to the given peer/agent. * * @param agent The agent to send a message/object to. * @param obj The object to send to the agent. * */ public static void p2pSend( Agent agent, Object obj ){...}

SIG Notification

/* ===================================================================== */ /** ContextApp.java * This method gets called when app receives a SIG join request. * */ public abstract boolean joinSig(String name, Vector agents, Vector wanted_sensors, Vector sharing_sensors);

Agent Discovery

//Keep a queue of sensor events, for processing in a thread. //Prevents this app from being a bottleneck in event passing. private Vector eventsQueue = new Vector(); /* ===================================================================== */ /** ContextApp.java * This method is for handling sensor events. (agent discovery is a * sensor event) App should loop through the eventsQueue and check * the sensor type of the sensor data event to handle it. */ public abstract void run();

Incoming Sensor Data

//Keep a queue of sensor events, for processing in a thread. //Prevents this app from being a bottleneck in event passing. private Vector eventsQueue = new Vector(); /* ===================================================================== */ /** ContextApp.java * This method is for handling sensor events. (agent discovery is a * sensor event) App should loop through the eventsQueue and check * the sensor type of the sensor data event to handle it. */ public abstract void run();&nbsp;

Methods that Context Application can use

Create SIG

//Create SIG called friend with agent a. We want sensors //want, and we're giving sensors sharing to the SIG. getContextManager().getSigManager().createSig("friend", a, want, sharing );

Create Soft Sensor

//Get the sensor called sound. Sensor sensor = getContextManager().getSensorManager().getSensor("SOUND"); //Create a new soft sensor called oktocall. CallableSensor oktocall = new CallableSensor("OKTOCALL"); oktocall.setSensorType( SensorOntology.OKTOCALL ); //Oktocall will get input from sound sensor. sensor.addSensorListener(oktocall); //Add the new sensor to CAT. getContextManager().addSensor(oktocall);

Access History Database

//Get sensor data for OKTOCALL sensor at the calendar time. getContextManager().getHistoryManager().query( "OKTOCALL", SensorOntology.OKTOCALL, calendar );