agentland.device
Class AbstractDeviceManagerAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--agentland.util.GoodAgent
                                |
                                +--agentland.resource.ManagedAgent
                                      |
                                      +--agentland.device.DeviceAgent
                                            |
                                            +--agentland.device.MultiDeviceAgent
                                                  |
                                                  +--agentland.device.AbstractDeviceManagerAgent
All Implemented Interfaces:
AbstractDeviceManager, Agent, Device, DeviceManager, Good, Managed, MetagluePrimitives, MultiDevice, Remote, Serializable, Spy
Direct Known Subclasses:
DrapesManagerAgent, LightManagerAgent, ProjectorManagerAgent

public abstract class AbstractDeviceManagerAgent
extends MultiDeviceAgent
implements AbstractDeviceManager

This is a base class for writing device manager agents -- agents that control behavior of several independent agents controlling individual (or groups of) devices.

See Also:
MultiDeviceAgent, AbstractDeviceManager, Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
Field Summary
protected  Hashtable devices
          key: AgentID, value: object of Device type; this hashtable is for caching agent stubs so that we do not need to call reliesOn every time we need to make a call to an agent.
protected  Vector managedDevices
          A list of all devices we are supposed to manage.
 
Fields inherited from class agentland.device.MultiDeviceAgent
grammars, nameResolver, nameResolverID
 
Fields inherited from class agentland.device.DeviceAgent
defaultState, fName, names, states
 
Fields inherited from class agentland.resource.ManagedAgent
rm, society
 
Fields inherited from class agentland.util.GoodAgent
alert, notifier
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Constructor Summary
AbstractDeviceManagerAgent()
           
 
Method Summary
 boolean addDevice(AgentID aid)
          Add a specific device to the list of controlled devices
 void addSecretDevice(Secret s)
          This is what catalog is supposed to call when devices we are interested in are started -- not really used now.
protected  void addSpies()
          Contacts the catalog and registers for notifications about agents of watched occupations starting.
protected  boolean callMethod(String name, String method)
          Calls named method on all managed devices referenced by the name
protected  boolean callMethod(String name, String method, Object param)
           
protected  boolean callMethod(String name, String method, Object[] params)
           
protected  Enumeration devices()
          Returns an enumeration of actual stubs for devices
protected  Enumeration devices(String name)
          Returns an enumeration of actual device agents
protected  Collection getAllAgentIDs()
          Returns agent id's of all devices that this manager manages
protected  Collection getAllNames()
          Overrides a method in MultiDevice agent so that it includes the names of itself
 Collection getDeviceIDs(String name)
          Returns a vector of agentID's of all agents managed by this manager that can be referenced by the name
 Vector getDevices()
          Returns a vector of AgentIDs of all devices managed by this agent
protected  void getPresent()
           
protected abstract  String[] getWatchedOccupations()
          This isn't really used yet.
protected  void registerKnown()
          Set up everything for the devices that we manage.
 boolean removeDevice(AgentID aid)
          Remove the device from the list of controlled devices
protected  void setUpNaming()
          Called after name resolver is set in MultiDevice agent
 
Methods inherited from class agentland.device.MultiDeviceAgent
addManagedGrammar, getNameResolver, removeManagedGrammar, setNameResolver, updateGrammar, updateGrammars
 
Methods inherited from class agentland.device.DeviceAgent
addName, createStateChangeNotification, ensureState, getDefaultNames, getDefaultStateName, getName, getNames, getState, getState, getStateNames, hasName, quietException, resetAllStates, resetName, resetState, resetState, setDefaultStateName, setName, setState, throwException, updateState, updateState, updateState, updateState, updateState, updateState, updateState, updateState
 
Methods inherited from class agentland.resource.ManagedAgent
connect, getAlert, getNeed, isAvailable, isAvailable, reliesOn, reliesOn, replace, replace, request, request, request, requestAgent, requestAgent, resources, resourcesByAgentID, setNeed, tiedTo, yank, yank, yank
 
Methods inherited from class agentland.util.GoodAgent
addSpy, addSpy, alert, alertString, beep, error, getHistory, getHistoryElement, getPersistentMap, log, notify, removeSpy, removeSpy, resetHistory, safeRely, safeRely, safeRely, setNiceLogName, tell
 
Methods inherited from class metaglue.AgentAgent
addMonitor, alive, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getProperties, getSociety, log, log, lookupClass, obtainMetaglueAgent, obtainMetaglueAgent, obtainMetaglueAgentByName, reliesOn, reliesOnSynch, removeFrozen, replaceExceptionHandler, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, whereAreYou
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface agentland.device.MultiDevice
addManagedGrammar, getNameResolver, removeManagedGrammar
 
Methods inherited from interface agentland.device.Device
addName, getName, getNames, getState, getState, getStateNames, hasName, resetAllStates, resetName, resetState, resetState, setName, setState
 
Methods inherited from interface agentland.resource.Managed
getNeed, replace, replace, resources, yank, yank
 
Methods inherited from interface agentland.util.Good
getHistory, getHistoryElement, resetHistory
 
Methods inherited from interface metaglue.Agent
addMonitor, alive, getAgentID, getMetaglueAgentID, shutdown, startup, whereAreYou
 
Methods inherited from interface agentland.util.Spy
tell
 

Field Detail

devices

protected Hashtable devices
key: AgentID, value: object of Device type; this hashtable is for caching agent stubs so that we do not need to call reliesOn every time we need to make a call to an agent.

managedDevices

protected Vector managedDevices
A list of all devices we are supposed to manage. This list gets frozen every time it is changed.
Constructor Detail

AbstractDeviceManagerAgent

public AbstractDeviceManagerAgent()
                           throws RemoteException
Method Detail

setUpNaming

protected void setUpNaming()
                    throws RemoteException
Called after name resolver is set in MultiDevice agent
Overrides:
setUpNaming in class MultiDeviceAgent

registerKnown

protected void registerKnown()
                      throws RemoteException
Set up everything for the devices that we manage. Called automatically at startup to set up frozen device list.

getWatchedOccupations

protected abstract String[] getWatchedOccupations()
This isn't really used yet. In theory, you should override this method so that it returns an array of occupations that your manager manages. Than, if you want, all agents of this occupation would be automatically pulled in to your manager when they are started. But, as I said, this has not been implemented.

addSpies

protected void addSpies()
                 throws RemoteException
Contacts the catalog and registers for notifications about agents of watched occupations starting.

addSecretDevice

public void addSecretDevice(Secret s)
                     throws RemoteException
This is what catalog is supposed to call when devices we are interested in are started -- not really used now.
Specified by:
addSecretDevice in interface AbstractDeviceManager
Parameters:
s - the details must contain the agent id of the newly started agent

getPresent

protected void getPresent()
                   throws RemoteException

getAllNames

protected Collection getAllNames()
                          throws RemoteException
Overrides a method in MultiDevice agent so that it includes the names of itself

getAllAgentIDs

protected Collection getAllAgentIDs()
                             throws RemoteException
Returns agent id's of all devices that this manager manages

addDevice

public boolean addDevice(AgentID aid)
                  throws RemoteException
Add a specific device to the list of controlled devices
Specified by:
addDevice in interface DeviceManager
Parameters:
aid - the agent id of the device
Returns:
true if things went well (even if the device is already there); false if something went wrong (e.g. we could not find the device anywhere)

devices

protected Enumeration devices(String name)
                       throws RemoteException
Returns an enumeration of actual device agents

getDeviceIDs

public Collection getDeviceIDs(String name)
                        throws RemoteException
Returns a vector of agentID's of all agents managed by this manager that can be referenced by the name
Specified by:
getDeviceIDs in interface AbstractDeviceManager

removeDevice

public boolean removeDevice(AgentID aid)
                     throws RemoteException
Remove the device from the list of controlled devices
Specified by:
removeDevice in interface DeviceManager
Returns:
true if the device was there and things went well; false otherwise

getDevices

public Vector getDevices()
                  throws RemoteException
Returns a vector of AgentIDs of all devices managed by this agent
Specified by:
getDevices in interface DeviceManager

devices

protected Enumeration devices()
Returns an enumeration of actual stubs for devices

callMethod

protected boolean callMethod(String name,
                             String method)
                      throws RemoteException
Calls named method on all managed devices referenced by the name
Parameters:
name - name of the devices to be called
method - name of the method to be called
Returns:
true if things worked out, false otherwise

callMethod

protected boolean callMethod(String name,
                             String method,
                             Object param)
                      throws RemoteException

callMethod

protected boolean callMethod(String name,
                             String method,
                             Object[] params)
                      throws RemoteException