eu.semaine.components.dialogue.interpreters
Class UserPresenceInterpreter

java.lang.Object
  extended by java.lang.Thread
      extended by eu.semaine.components.Component
          extended by eu.semaine.components.dialogue.interpreters.UserPresenceInterpreter
All Implemented Interfaces:
SEMAINEMessageAvailableListener, java.lang.Runnable

public class UserPresenceInterpreter
extends Component

Author:
marc

Nested Class Summary
 
Nested classes/interfaces inherited from class eu.semaine.components.Component
Component.State
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String PROPERTY_EXTERNAL_USERPRESENCE_THRESHOLD
           
static java.lang.String PROPERTY_FACE_END_THRESHOLD
           
static java.lang.String PROPERTY_FACE_START_THRESHOLD
           
static java.lang.String PROPERTY_SYSTEM_END_THRESHOLD
           
static java.lang.String PROPERTY_VOICE_END_THRESHOLD
           
static java.lang.String PROPERTY_VOICE_START_THRESHOLD
           
 
Fields inherited from class eu.semaine.components.Component
inputWaiting, isInput, isOutput, log, meta, receivers, senders, state, waitingTime
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
UserPresenceInterpreter()
           
 
Method Summary
protected  void act()
          Proactive actions.
protected  long getFaceChangeTime(SEMAINEEmmaMessage m)
          If the given message indicates the fact that a face status change has been detected, provide the time of that change, if possible.
protected  java.lang.String getFaceStatusChange(SEMAINEEmmaMessage m)
          If the given message indicates the fact that a face status change has been detected, provide the type of that change.
protected  long getSystemSpeakingEventTime(SEMAINEXMLMessage callbackMessage)
           
 long getThresholdFaceAppeared()
           
 long getThresholdFaceDisappeared()
           
 long getThresholdSystemStoppedSpeaking()
           
 long getThresholdVoiceAppeared()
           
 long getThresholdVoiceDisappeared()
           
protected  long getVoiceChangeTime(SEMAINEEmmaMessage m)
          If the given message indicates the fact that a face status change has been detected, provide the time of that change, if possible.
protected  java.lang.String getVoiceStatusChange(SEMAINEEmmaMessage m)
          If the given message indicates the fact that a voice status change has been detected, provide the type of that change.
protected  boolean isExternalUserPresenceInForce()
          Whether there is an externally specified user presence which has been set less than threshold time ago.
protected  boolean isFaceDetected(SEMAINEEmmaMessage m)
          Determine whether the given message indicates the fact that a face has been detected.
protected  boolean isFaceDisappeared(SEMAINEEmmaMessage m)
          Determine whether the given message indicates the fact that a face has just disappeared.
protected  boolean isFacePresent()
          Determine whether the face is currently present, or presence is so recent that we still consider the face to be present.
protected  boolean isSystemSpeaking()
          Determine whether the system is currently speaking, or stopped speaking so recently that we still consider the system to be speaking.
protected  boolean isSystemStartsSpeaking(SEMAINEXMLMessage callbackMessage)
           
protected  boolean isSystemStopsSpeaking(SEMAINEXMLMessage callbackMessage)
           
protected  boolean isUserPresent()
          Determine based on the observed evidence (face, voice) whether the user is currently present, or presence is so recent that we still consider the user to be present.
protected  boolean isVoiceDetected(SEMAINEEmmaMessage m)
          Determine whether the given message indicates the fact that a voice has been detected.
protected  boolean isVoiceDisappeared(SEMAINEEmmaMessage m)
          Determine whether the given message indicates the fact that a voice has just disappeared.
protected  boolean isVoicePresent()
          Determine whether the voice is currently present, or presence is so recent that we still consider the voice to be present.
protected  void react(SEMAINEMessage m)
          Reactions to messages.
protected  void sendUserPresenceChange()
           
protected  boolean updateUserPresence()
          Update the internal state of the component reflecting the user presence, which can be obtained from isUserPresent().
 
Methods inherited from class eu.semaine.components.Component
customStartIO, exitRequested, getMeta, hasSystemJustBecomeReady, messageAvailableFrom, requestExit, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_VOICE_START_THRESHOLD

public static final java.lang.String PROPERTY_VOICE_START_THRESHOLD
See Also:
Constant Field Values

PROPERTY_VOICE_END_THRESHOLD

public static final java.lang.String PROPERTY_VOICE_END_THRESHOLD
See Also:
Constant Field Values

PROPERTY_FACE_START_THRESHOLD

public static final java.lang.String PROPERTY_FACE_START_THRESHOLD
See Also:
Constant Field Values

PROPERTY_FACE_END_THRESHOLD

public static final java.lang.String PROPERTY_FACE_END_THRESHOLD
See Also:
Constant Field Values

PROPERTY_SYSTEM_END_THRESHOLD

public static final java.lang.String PROPERTY_SYSTEM_END_THRESHOLD
See Also:
Constant Field Values

PROPERTY_EXTERNAL_USERPRESENCE_THRESHOLD

public static final java.lang.String PROPERTY_EXTERNAL_USERPRESENCE_THRESHOLD
See Also:
Constant Field Values
Constructor Detail

UserPresenceInterpreter

public UserPresenceInterpreter()
                        throws JMSException
Parameters:
componentName -
Throws:
JMSException
Method Detail

getThresholdVoiceAppeared

public long getThresholdVoiceAppeared()

getThresholdVoiceDisappeared

public long getThresholdVoiceDisappeared()

getThresholdFaceAppeared

public long getThresholdFaceAppeared()

getThresholdFaceDisappeared

public long getThresholdFaceDisappeared()

getThresholdSystemStoppedSpeaking

public long getThresholdSystemStoppedSpeaking()

isFaceDetected

protected boolean isFaceDetected(SEMAINEEmmaMessage m)
Determine whether the given message indicates the fact that a face has been detected.

Parameters:
m - an emma message which may or may not indicate face presence.
Returns:

isFaceDisappeared

protected boolean isFaceDisappeared(SEMAINEEmmaMessage m)
Determine whether the given message indicates the fact that a face has just disappeared.

Parameters:
m - an emma message which may or may not indicate face presence.
Returns:

getFaceStatusChange

protected java.lang.String getFaceStatusChange(SEMAINEEmmaMessage m)
If the given message indicates the fact that a face status change has been detected, provide the type of that change.

Parameters:
m - an emma message which may or may not indicate face status change.
the - type of status change to verify
Returns:
the face status change as a string, if any, or the empty string

getFaceChangeTime

protected long getFaceChangeTime(SEMAINEEmmaMessage m)
If the given message indicates the fact that a face status change has been detected, provide the time of that change, if possible.

Parameters:
m - an emma message which may or may not indicate face status change.
Returns:
the time of the status change in milliseconds since program start, or -1 if the information is not available.

isVoiceDetected

protected boolean isVoiceDetected(SEMAINEEmmaMessage m)
Determine whether the given message indicates the fact that a voice has been detected.

Parameters:
m - an emma message which may or may not indicate voice presence.
Returns:

isVoiceDisappeared

protected boolean isVoiceDisappeared(SEMAINEEmmaMessage m)
Determine whether the given message indicates the fact that a voice has just disappeared.

Parameters:
m - an emma message which may or may not indicate voice presence.
Returns:

getVoiceStatusChange

protected java.lang.String getVoiceStatusChange(SEMAINEEmmaMessage m)
If the given message indicates the fact that a voice status change has been detected, provide the type of that change.

Parameters:
m - an emma message which may or may not indicate voice status change.
the - type of status change to verify
Returns:
the voice status change as a string, if any, or the empty string

getVoiceChangeTime

protected long getVoiceChangeTime(SEMAINEEmmaMessage m)
If the given message indicates the fact that a face status change has been detected, provide the time of that change, if possible.

Parameters:
m - an emma message which may or may not indicate face status change.
Returns:
the time of the status change in milliseconds since program start, or -1 if the information is not available.

isSystemStartsSpeaking

protected boolean isSystemStartsSpeaking(SEMAINEXMLMessage callbackMessage)
                                  throws MessageFormatException,
                                         java.lang.NullPointerException
Throws:
MessageFormatException
java.lang.NullPointerException

isSystemStopsSpeaking

protected boolean isSystemStopsSpeaking(SEMAINEXMLMessage callbackMessage)
                                 throws MessageFormatException,
                                        java.lang.NullPointerException
Throws:
MessageFormatException
java.lang.NullPointerException

getSystemSpeakingEventTime

protected long getSystemSpeakingEventTime(SEMAINEXMLMessage callbackMessage)
                                   throws MessageFormatException,
                                          java.lang.NullPointerException
Throws:
MessageFormatException
java.lang.NullPointerException

react

protected void react(SEMAINEMessage m)
              throws JMSException
Description copied from class: Component
Reactions to messages. This base implementation does nothing; subclasses should implement suitable behaviour here.

Overrides:
react in class Component
Throws:
JMSException - if communication with the JMS server goes wrong.

isVoicePresent

protected boolean isVoicePresent()
Determine whether the voice is currently present, or presence is so recent that we still consider the voice to be present.

Returns:
true if present, false otherwise.

isFacePresent

protected boolean isFacePresent()
Determine whether the face is currently present, or presence is so recent that we still consider the face to be present.

Returns:
true if present, false otherwise.

isSystemSpeaking

protected boolean isSystemSpeaking()
Determine whether the system is currently speaking, or stopped speaking so recently that we still consider the system to be speaking.

Returns:

isUserPresent

protected boolean isUserPresent()
Determine based on the observed evidence (face, voice) whether the user is currently present, or presence is so recent that we still consider the user to be present.

Returns:
true if present, false otherwise.

isExternalUserPresenceInForce

protected boolean isExternalUserPresenceInForce()
Whether there is an externally specified user presence which has been set less than threshold time ago.

Returns:

updateUserPresence

protected boolean updateUserPresence()
Update the internal state of the component reflecting the user presence, which can be obtained from isUserPresent().

Returns:
true if user presence has changed during the update, false otherwise

act

protected void act()
            throws JMSException
Description copied from class: Component
Proactive actions. This method is called every Component.waitingTime milliseconds if no messages arrive, and after every message processing. This base implementation does nothing; subclasses should implement suitable behaviour here.

Overrides:
act in class Component
Throws:
JMSException - if communication with the JMS server goes wrong.

sendUserPresenceChange

protected void sendUserPresenceChange()
                               throws JMSException
Throws:
JMSException