speech.think
Class LoudMouthAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--speech.think.LoudMouthAgent

public class LoudMouthAgent
extends AgentAgent
implements LoudMouth

Allows agents to control the room the same way people do by talking. I put this into an agent, rather than just having agents call GrammarCenter.processString() themselves so we can divert or track this if we ever want to. The agent has two methods, "thinkOutloud" and "thinkQuietly". These cause the room to respond to the given text as if it were spoken outloud. (The Outloud method also causes the room to say the given text prefaced by "I am thinking.") They return the name of the rule that parsed the text or null if no rule did. You can see speech.speechin.LoudMouthTestAgent for an example of the LoudMouth in use. Note the following. Suppose your code looks like:

LampManagerSpeech lms = (LampManagerSpeech) 
reliesOn("agentland.device.speechin.LampManagerSpeech");
LoudMouth lm = (LoudMouth) reliesOn("speech.LoudMouth");
lm.thinkOutloud("turn on the light by the door");
Nothing will happen! Because the agents are started asynchronously, the LoudMouth agent will think "turn on the ..." before the grammars for the LampManagerSpeech have had time to load. Therefore, you must add explicit synchronization, such as:
LampManagerSpeech lms = (LampManagerSpeech) 
reliesOn("agentland.device.speechin.LampManagerSpeech");
lms.alive();
LoudMouth lm = (LoudMouth) reliesOn("speech.LoudMouth");
lm.thinkOutloud("turn on the light by the door");
The alive() call will block until the LampManagerSpeechAgent has emerged from its constructor, where presumably its grammars are all loaded.

See Also:
Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Constructor Summary
LoudMouthAgent()
           
 
Method Summary
 String thinkOutloud(String text)
           
 String thinkQuietly(String text)
           
 
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, log, obtainMetaglueAgent, obtainMetaglueAgent, obtainMetaglueAgentByName, reliesOn, reliesOn, 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
 

Constructor Detail

LoudMouthAgent

public LoudMouthAgent()
               throws RemoteException
Method Detail

thinkOutloud

public String thinkOutloud(String text)
                    throws RemoteException
Specified by:
thinkOutloud in interface LoudMouth

thinkQuietly

public String thinkQuietly(String text)
                    throws RemoteException
Specified by:
thinkQuietly in interface LoudMouth