speech.think
Class LoudMouthAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--agentland.util.GoodAgent
                                |
                                +--agentland.resource.ManagedAgent
                                      |
                                      +--speech.think.LoudMouthAgent
All Implemented Interfaces:
Agent, Good, LoudMouth, Managed, MetagluePrimitives, Remote, Serializable, Spy

public class LoudMouthAgent
extends ManagedAgent
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:
ManagedAgent, LoudMouth, Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
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
LoudMouthAgent()
          Creates a new LoudMouthAgent instance.
 
Method Summary
 String thinkOutloud(String text)
          Returns null if no rule parses the string
 String thinkOutloud(String sText, String sPretext)
          Says the text in sPretext, and thinks the text in sText
 String thinkQuietly(String text)
          Returns null if no rule parses the string
 
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, buildEHAFor, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getOldLogs, getProperties, getProxyHandlerClass, getSociety, installAPH, log, log, lookupClass, reliesOn, reliesOnSynch, removeAPHFromCatalog, removeFrozen, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, toString, 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, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface metaglue.Agent
addMonitor, alive, getAgentID, getMetaglueAgentID, getOldLogs, shutdown, startup, whereAreYou
 
Methods inherited from interface agentland.util.Good
getHistory, getHistoryElement, resetHistory
 
Methods inherited from interface agentland.util.Spy
tell
 

Constructor Detail

LoudMouthAgent

public LoudMouthAgent()
               throws RemoteException
Creates a new LoudMouthAgent instance.
Throws:
RemoteException - if an error occurs
Method Detail

thinkOutloud

public String thinkOutloud(String text)
                    throws RemoteException
Returns null if no rule parses the string
Specified by:
thinkOutloud in interface LoudMouth
Parameters:
text - a String value
Returns:
a String value
Throws:
RemoteException - if an error occurs

thinkOutloud

public String thinkOutloud(String sText,
                           String sPretext)
                    throws RemoteException
Says the text in sPretext, and thinks the text in sText
Specified by:
thinkOutloud in interface LoudMouth
Parameters:
sText - a String value
sPretext - a String value
Returns:
a String value
Throws:
RemoteException - if an error occurs

thinkQuietly

public String thinkQuietly(String text)
                    throws RemoteException
Returns null if no rule parses the string
Specified by:
thinkQuietly in interface LoudMouth
Parameters:
text - a String value
Returns:
a String value
Throws:
RemoteException - if an error occurs