org.micropsi.comp.console
Interface ConsoleFacadeIF

All Known Implementing Classes:
ConsoleComponent

public interface ConsoleFacadeIF


Field Summary
static int DEFAULT_LIFETIME
           
static int DEFAULT_TIMEOUT
           
static int TOTAL_TOLERANCE
           
static int ZERO_TOLERANCE
           
 
Method Summary
 AnswerIF askBlockingQuestion(MQuestion q)
          Method askBlockingQuestion.
 AnswerIF askBlockingQuestion(MQuestion q, int timeout)
          Method askBlockingQuestion.
 ExceptionProcessor getExproc()
          Returns the exception processor for this console.
 void getInformation(int tolerance, int lifetime, java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback, java.lang.Object additionalData, boolean ignoreWaitingQuestions)
          Method getInformation.
 void getInformation(int tolerance, java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback)
           
 void getInformation(int tolerance, java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback, java.lang.Object additionalData)
          Method getInformation.
 Logger getLogger()
          Returns the logger for this component
 void sendCommand(int tolerance, int lifetime, java.lang.String componentID, java.lang.String command, java.lang.String parameters, java.lang.Object additionalData, boolean blocking)
          Sends a command to a component.
 void sendCommand(int tolerance, java.lang.String componentID, java.lang.String command, java.lang.String parameters, boolean blocking)
          Method sendCommand.
 void sendCommand(int tolerance, java.lang.String componentID, java.lang.String command, java.lang.String parameters, java.lang.Object additionalData, boolean blocking)
          Method sendCommand.
 void subscribe(int frequency, java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback)
           
 void subscribe(int frequency, java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback, java.lang.Object additionalData)
          Subscribes to frequent answers to a question.
 void unsubscribe(MQuestion q, AnswerQueueIF callback)
          Unsubscribes the callback from the given question.
 void unsubscribe(java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback)
          Method unsubscribe.
 void unsubscribe(java.lang.String componentID, java.lang.String question, java.lang.String parameters, AnswerQueueIF callback, java.lang.Object additionalData)
          Method unsubscribe.
 void unsubscribeAll()
          Unsubscribes all callbacks from all questions.
 void unsubscribeAll(AnswerQueueIF callback)
          Unsubscribes the callback from all question it is registered to.
 

Field Detail

ZERO_TOLERANCE

public static final int ZERO_TOLERANCE
See Also:
Constant Field Values

TOTAL_TOLERANCE

public static final int TOTAL_TOLERANCE
See Also:
Constant Field Values

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

DEFAULT_LIFETIME

public static final int DEFAULT_LIFETIME
See Also:
Constant Field Values
Method Detail

sendCommand

public void sendCommand(int tolerance,
                        int lifetime,
                        java.lang.String componentID,
                        java.lang.String command,
                        java.lang.String parameters,
                        java.lang.Object additionalData,
                        boolean blocking)
Sends a command to a component.

Parameters:
tolerance - - How old (in steps) might a cached answer be? The values
lifetime - - How long to wait for an answer.
componentID - - The component to be asked
command -
parameters -
additionalData -
blocking -
See Also:
and #ZERO_TOLERANCE are predefined.

sendCommand

public void sendCommand(int tolerance,
                        java.lang.String componentID,
                        java.lang.String command,
                        java.lang.String parameters,
                        java.lang.Object additionalData,
                        boolean blocking)
Method sendCommand.

Parameters:
tolerance - Maximal number of steps for cached commands.
componentID -
command -
parameters -
additionalData -
See Also:
lifetime = @see #DEFAULT_LIFETIME.

sendCommand

public void sendCommand(int tolerance,
                        java.lang.String componentID,
                        java.lang.String command,
                        java.lang.String parameters,
                        boolean blocking)
Method sendCommand.

Parameters:
tolerance - Maximal number of steps for cached commands.
componentID -
command -
parameters -
See Also:
No additionalData, lifetime = @see #DEFAULT_LIFETIME.

getInformation

public void getInformation(int tolerance,
                           int lifetime,
                           java.lang.String componentID,
                           java.lang.String question,
                           java.lang.String parameters,
                           AnswerQueueIF callback,
                           java.lang.Object additionalData,
                           boolean ignoreWaitingQuestions)
Method getInformation. Receive an information once. This method looks in the cache, if the question already exists and the answer is not older than tolerance steps. If there is no answer in the cache, we ask the component.

Parameters:
tolerance - - The allowed age of the answer in ticks. If @see #ZERO_TOLERANCE, the cache is not considered. If greater than zero, we look first, if a similar question is cached. If @see #TOTAL_TOLERANCE, a cached question, if exists, is taken, regardless of its age.
lifetime - - How long should be waited for an answer.
componentID - - The component to be asked.
question - - The question.
parameters - - The parameter string.
callback - - The callback for non blocking questions.
additionalData - - Additional Data.
ignoreWaitingQuestions - - Normally queations are registered. If a a question is already waiting for an answer, the same question is not sent once more. In certain cases it might be desired to send the same question twice (e.g. for saving documents). In this case choose true, normally you would take false here.

getInformation

public void getInformation(int tolerance,
                           java.lang.String componentID,
                           java.lang.String question,
                           java.lang.String parameters,
                           AnswerQueueIF callback,
                           java.lang.Object additionalData)
Method getInformation. Receive an information once. This method looks in the cache, if the question already exists and the answer is not older than tolerance steps. If there is no answer in the cache, we ask the component.

Parameters:
tolerance - - The allowed age of the answer in ticks. If @see #ZERO_TOLERANCE, the cache is not considered. If greater than zero, we look first, if a similar question is cached. If @see #TOTAL_TOLERANCE, a cached question, if exists, is taken, regardless of its age.
componentID - - The component to be asked.
question - - The question.
parameters - - The parameter string.
callback - - The callback for non blocking questions.
additionalData - - Additional Data.
See Also:
lifetime = @see #DEFAULT_LIFETIME, we are waiting for similar questions.

getInformation

public void getInformation(int tolerance,
                           java.lang.String componentID,
                           java.lang.String question,
                           java.lang.String parameters,
                           AnswerQueueIF callback)
Parameters:
tolerance -
componentID -
question -
parameters -
callback -
See Also:
The question is sent without additionalData, lifetime = @see #DEFAULT_LIFETIME and it will be registered.

subscribe

public void subscribe(int frequency,
                      java.lang.String componentID,
                      java.lang.String question,
                      java.lang.String parameters,
                      AnswerQueueIF callback,
                      java.lang.Object additionalData)
Subscribes to frequent answers to a question.

Parameters:
frequency - - Frequency of answers in steps. At the moment only 1, 5 10, 50, 100
componentID -
question -
parameters -

subscribe

public void subscribe(int frequency,
                      java.lang.String componentID,
                      java.lang.String question,
                      java.lang.String parameters,
                      AnswerQueueIF callback)
Parameters:
frequency -
componentID -
question -
parameters -
callback -

unsubscribe

public void unsubscribe(java.lang.String componentID,
                        java.lang.String question,
                        java.lang.String parameters,
                        AnswerQueueIF callback,
                        java.lang.Object additionalData)
Method unsubscribe. Unsubscribes from a subscribed question.

Parameters:
componentID - - The callers componentID
question - - The questions name.
parameters - - Parameters of the question.
callback - - The callback provided with the subscribe request
additionalData -

unsubscribe

public void unsubscribe(MQuestion q,
                        AnswerQueueIF callback)
Unsubscribes the callback from the given question.

Parameters:
q -
callback -

unsubscribeAll

public void unsubscribeAll(AnswerQueueIF callback)
Unsubscribes the callback from all question it is registered to.

Parameters:
callback -

unsubscribeAll

public void unsubscribeAll()
Unsubscribes all callbacks from all questions.


unsubscribe

public void unsubscribe(java.lang.String componentID,
                        java.lang.String question,
                        java.lang.String parameters,
                        AnswerQueueIF callback)
Method unsubscribe. Unsubscribes from a subscribed question.

Parameters:
componentID - - The callers componentID
question - - The questions name.
parameters - - Parameters of the question.
callback - - The callback provided with the subscribe request

askBlockingQuestion

public AnswerIF askBlockingQuestion(MQuestion q,
                                    int timeout)
                             throws MicropsiException
Method askBlockingQuestion. This method sends a Question and waits for its answer. answerMode must be

Parameters:
q - - The question to be asked.
timeout - - Timeout in seconds.
Returns:
AnswerIF - The answer or null, if the answerMode was wrong.
Throws:
MicropsiException - if there is no answer after a timeout of timeout seconds.
See Also:
org.micropsi.common.consoleservice.QuestionIF.AM_ANSWER_ONCE

askBlockingQuestion

public AnswerIF askBlockingQuestion(MQuestion q)
                             throws MicropsiException
Method askBlockingQuestion. This method sends a Question and waits for its answer. answerMode must be

Parameters:
q - - The question to be asked.
Returns:
AnswerIF - The answer or null, if the answerMode was wrong.
Throws:
MicropsiException - if there is no answer after a timeout of 30 seconds.
See Also:
org.micropsi.common.consoleservice.QuestionIF.AM_ANSWER_ONCE

getExproc

public ExceptionProcessor getExproc()
Returns the exception processor for this console.

Returns:
an exception processor, never null

getLogger

public Logger getLogger()
Returns the logger for this component

Returns:
a logger, never null

(c) by Micropsi Project: http://www.cognitive-agents.org

.