cat.sig
Class SigManager

java.lang.Object
  extended bycat.sig.SigManager

public class SigManager
extends java.lang.Object

This class is the SigManager. SIGs are created, joined, and destroyed in here. The manager uses a SensorMonitor to get all sensor data, the sensor data is then distributed to the appropriate sig by means of nodes. Each node contains a sensor and all the sigs that share that sensor.


Field Summary
(package private) static int ESTABLISHED
           
private  SensorMonitor monitor
          Used to get sensor data from CAT to be shared in sigs.
(package private) static int REFUSED
           
private  java.util.Vector senList
          List of listeners to this manager.
private  java.util.Vector sensorNodes
          List of all nodes, used to match each CAT sensor with sigs for it.
private  java.util.Vector sigGroup
          All sigs.
 
Constructor Summary
SigManager()
          This constructor initializes the SigManager by starting new empty sig lists, and initializing the SensorMonitor.
 
Method Summary
 void addAgent(java.lang.String sig_name, Agent a)
          This method adds an agent to a Sig, so that the agent gets shared sensor data from this CAT.
 int addAgentToSig(java.lang.String name, Agent a, java.util.Vector want_sensors)
          This method is used to add an agent to a sig that already has been created.
 void addSensorSig(java.lang.String sig_name, Sensor s)
          This method adds a sensor to a Sig, so that it is shared to that sig.
 Sig addSig(java.lang.String name, java.util.Vector se, java.util.Vector a, int encrypt, int auth)
          This method is used internally to create/add a new sig into this SigManager and CAT.
 void addSigListener(SigListener s)
          This method adds a listener to this Manager.
 int createSig(java.lang.String name, Agent a, java.util.Vector want_sensors, java.util.Vector my_sensors)
          This method is used to create a new sig and try to get one other agent to join the sig.
 void deleteSigListener(SigListener s)
          This method removes a listener to this Manager.
private  java.util.Vector findInterestedSig(java.lang.String id)
          This method find Sig's that are interested in a particular sensor's data.
 Sig findSig(java.lang.String sig_name)
          This method finds Sig that has a particular name or returns null if no sig exists with the given name.
 SensorMonitor getMonitor()
          This method returns the SensorMonitor which is used to listen to all CAT sensors, so that some/none of the sensor data can be shared with SIGs.
 java.util.Vector getSigs()
          This method returns all the sigs in CAT.
 void joinSig(java.lang.String name, java.util.Vector se, java.util.Vector all, java.util.Vector a, int encrypt, int auth)
          This method is used to join a sig that someone else has already created The CAT app should call this method, when the user decides to join a sig.
 void notifySigListeners(SigEvent event)
          This method notifies all listeners of a sig data event.
 void removeAgent(java.lang.String sig_name, Agent a)
          This method removes an agent from a Sig, so that the agent no longer gets shared sensor data from this CAT.
 void removeSensor(Sensor s)
          This method removes a sensor from all Sigs, so that it is no longer shared to any sigs.
 void removeSensorSig(java.lang.String sig_name, Sensor s)
          This method removes a sensor from a Sig, so that it is no longer shared to that sig.
 void removeSig(java.lang.String name)
          This method is for removing a sig from the SigManager and from CAT.
 void send(SensorEvent event)
          This method sends SensorEvent to interested Sig.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ESTABLISHED

static final int ESTABLISHED
See Also:
Constant Field Values

REFUSED

static final int REFUSED
See Also:
Constant Field Values

sigGroup

private java.util.Vector sigGroup
All sigs.


monitor

private SensorMonitor monitor
Used to get sensor data from CAT to be shared in sigs.


senList

private java.util.Vector senList
List of listeners to this manager.


sensorNodes

private java.util.Vector sensorNodes
List of all nodes, used to match each CAT sensor with sigs for it.

Constructor Detail

SigManager

public SigManager()
This constructor initializes the SigManager by starting new empty sig lists, and initializing the SensorMonitor.

Method Detail

getMonitor

public SensorMonitor getMonitor()
This method returns the SensorMonitor which is used to listen to all CAT sensors, so that some/none of the sensor data can be shared with SIGs.

Returns:
SensorMonitor The sensor monitor used by this manager

createSig

public int createSig(java.lang.String name,
                     Agent a,
                     java.util.Vector want_sensors,
                     java.util.Vector my_sensors)
This method is used to create a new sig and try to get one other agent to join the sig. A SigRequest is sent to the other agent.

Parameters:
name - The name for the new sig.
a - The first agent to send a join request to.
want_sensors - The shared sensors want for joining the sig.
my_sensors - The sensors being shared.

addAgentToSig

public int addAgentToSig(java.lang.String name,
                         Agent a,
                         java.util.Vector want_sensors)
This method is used to add an agent to a sig that already has been created. A SigRequest is sent to the agent.

Parameters:
name - The name of the sig.
a - The agent to send a join request to.
want_sensors - The shared sensors want for joining the sig.

addSig

public Sig addSig(java.lang.String name,
                  java.util.Vector se,
                  java.util.Vector a,
                  int encrypt,
                  int auth)
This method is used internally to create/add a new sig into this SigManager and CAT.

Parameters:
name - The name for the new sig.
a - The agents in the sig.
se - The shared sensors in the sig.
encrypt - Used for encryption of the sig.
auth - Used for authorization of the sig.

removeSig

public void removeSig(java.lang.String name)
This method is for removing a sig from the SigManager and from CAT. In this way, we no longer share data with the sig, and we no longer get data.

Parameters:
name - The name of the sig to remove.

joinSig

public void joinSig(java.lang.String name,
                    java.util.Vector se,
                    java.util.Vector all,
                    java.util.Vector a,
                    int encrypt,
                    int auth)
This method is used to join a sig that someone else has already created The CAT app should call this method, when the user decides to join a sig.

Parameters:
name - The name of the sig.
se - Sensor's we will share.
all - All sensors in the sig.
a - All agents in the sig.
encrypt - Used for encryption of the sig.
auth - Used for authorization of the sig.

addAgent

public void addAgent(java.lang.String sig_name,
                     Agent a)
This method adds an agent to a Sig, so that the agent gets shared sensor data from this CAT.

Parameters:
sig_name - The name of sig to add the agent to.

removeAgent

public void removeAgent(java.lang.String sig_name,
                        Agent a)
This method removes an agent from a Sig, so that the agent no longer gets shared sensor data from this CAT.

Parameters:
sig_name - The name of sig to remove the agent from.

removeSensor

public void removeSensor(Sensor s)
This method removes a sensor from all Sigs, so that it is no longer shared to any sigs.

Parameters:
s - The sensor to remove.

addSensorSig

public void addSensorSig(java.lang.String sig_name,
                         Sensor s)
This method adds a sensor to a Sig, so that it is shared to that sig.

Parameters:
sig_name - The name of sig to add sensor to.
s - The sensor to add.

removeSensorSig

public void removeSensorSig(java.lang.String sig_name,
                            Sensor s)
This method removes a sensor from a Sig, so that it is no longer shared to that sig.

Parameters:
sig_name - The name of sig to remove sensor from.
s - The sensor to remove.

send

public void send(SensorEvent event)
This method sends SensorEvent to interested Sig. It takes in a sensor data event, then finds the sigs that care about this sensor, and then gives the sensor data to those sigs to be shared.

Parameters:
event - The sensor data event to give to sigs.

findInterestedSig

private java.util.Vector findInterestedSig(java.lang.String id)
This method find Sig's that are interested in a particular sensor's data. In otherwords, it finds a sig that is sharing the given sensor.

Parameters:
id - The id of the sensor to look for in sigs.
Returns:
Vector The sigs (may be emtpy vector).

findSig

public Sig findSig(java.lang.String sig_name)
This method finds Sig that has a particular name or returns null if no sig exists with the given name.

Parameters:
sig_name - The name of the sig to find
Returns:
Sig The sig or null if no such sig exists.

getSigs

public java.util.Vector getSigs()
This method returns all the sigs in CAT.

Returns:
Vector The list of sigs.

addSigListener

public void addSigListener(SigListener s)
This method adds a listener to this Manager.

Parameters:
s - listener.

deleteSigListener

public void deleteSigListener(SigListener s)
This method removes a listener to this Manager.

Parameters:
s - listener.

notifySigListeners

public void notifySigListeners(SigEvent event)
This method notifies all listeners of a sig data event.

Parameters:
event - Sesnor data event.