hmi.faceanimation.util
Class XfaceInterface

java.lang.Object
  extended by java.lang.Thread
      extended by hmi.faceanimation.util.XfaceInterface
All Implemented Interfaces:
Runnable

public class XfaceInterface
extends Thread

Provides an interface to Xface via TCP/IP. Xface accepts FAP uploads that usually contain more frames at once. In this interface, we upload one frame at a time. This works, but Xface stops working when these uploads come too fast after each other. We therefore create a seperate thread so the sleep does not get in the way of the GUI or whatever uses this interface.

We use a small state machine to keep track of our state and stops us from connecting when connected, sending when in error, etc.

Author:
R.C. Paul

Nested Class Summary
private static class XfaceInterface.State
           
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.UncaughtExceptionHandler
 
Field Summary
private  MPEG4Configuration configuration
           
private  InputStream in
           
private  org.slf4j.Logger logger
           
private  PrintWriter out
           
private  int ownerId
           
private  Socket socket
           
private  XfaceInterface.State state
           
private  boolean stopThread
           
private  int taskId
           
private  Integer[] values
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
XfaceInterface()
           
 
Method Summary
private  void communicate()
           
private  boolean communicationNeeded()
           
 void connect()
           
 void disconnect()
           
private  void displayConfiguration()
           
 boolean isStandby()
           
 void run()
           
private  void sendConfiguration()
           
private  void sendTask(int taskId, String task, String xml)
           
 void setConfiguration(MPEG4Configuration configuration)
          Sets values via a MPEG4Configuration object.
 void setRawValues(Integer[] values)
          Sets raw values.
private  void setState(XfaceInterface.State state)
           
static void sleep(long time)
           
private  void timedPrint(String message)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

configuration

private MPEG4Configuration configuration

values

private Integer[] values

logger

private org.slf4j.Logger logger

state

private XfaceInterface.State state

socket

private Socket socket

out

private PrintWriter out

in

private InputStream in

taskId

private int taskId

ownerId

private int ownerId

stopThread

private boolean stopThread
Constructor Detail

XfaceInterface

public XfaceInterface()
Method Detail

connect

public void connect()

disconnect

public void disconnect()

isStandby

public boolean isStandby()

setConfiguration

public void setConfiguration(MPEG4Configuration configuration)

Sets values via a MPEG4Configuration object. This usually contains values from 0.0-1.0 for unidirectional FAPs or -1.0-1.0 for bidirectional FAPs.

Parameters:
configuration -
See Also:
setRawValues

setRawValues

public void setRawValues(Integer[] values)

Sets raw values. These are directly used in the FAP uploads.

Parameters:
values -
See Also:
setConfiguration

sendConfiguration

private void sendConfiguration()

displayConfiguration

private void displayConfiguration()

sendTask

private void sendTask(int taskId,
                      String task,
                      String xml)

setState

private void setState(XfaceInterface.State state)

timedPrint

private void timedPrint(String message)

sleep

public static void sleep(long time)

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

communicationNeeded

private boolean communicationNeeded()

communicate

private void communicate()