hmi.sensors.eyebox2.directaccess
Class DirectXuukReader

java.lang.Object
  extended by java.lang.Thread
      extended by hmi.sensors.eyebox2.directaccess.DirectXuukReader
All Implemented Interfaces:
XuukReader, Runnable

public class DirectXuukReader
extends Thread
implements XuukReader


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  HashMap<Integer,EyePair> eyes
           
private  ArrayList<XuukListener> eyesAppearanceListeners
           
private  ArrayList<XuukListener> eyesPositionListeners
           
private  ArrayList<XuukListener> faceAppearanceListeners
           
private  ArrayList<XuukListener> facePositionListeners
           
private  HashMap<Integer,Face> faces
           
private  String host
           
private  BufferedReader in
           
private  boolean isLogging
           
private  boolean isReading
           
private  XuukXMLLogger logger
           
private  int port
           
private  Socket sock
           
private  boolean stopRunning
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DirectXuukReader(String host, int port)
          Creates a new instance of XuukReader, which will connect to the Xuuk-software with the given host and the given port.
 
Method Summary
 void addListener(XuukListener listener, boolean faceAppearances, boolean eyesAppearances, boolean facePositions, boolean eyesPositions)
          Used to add new interested Listeners.
private  void closeSocket()
           
static void main(String[] args)
           
private  boolean openSocket()
           
 void processLine(String line)
          Processes a line that is received from the Xuuk-reader.
 void run()
          Starts reading lines from the connection with the Xuuk-reader
 void setLogger(XuukXMLLogger xuukLogger)
          Set the logger of the reader to xuukLogger
 void startLogging()
          Starts logging the messages from the Xuuk-software Precondition 1: The reader has to reading messages Precondition 2: A logger has to be set for the reader
 void startReader()
          Starts the reading of the socket connected to the Xuuk-software
 void stopLogging()
          Stops logging the messages from the Xuuk-software
 void stopReader()
          Stops the reading of the socket connected to the Xuuk-software
 void stopRunning()
           
 
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, 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

stopRunning

private boolean stopRunning

isReading

private boolean isReading

isLogging

private boolean isLogging

host

private String host

port

private int port

sock

private Socket sock

in

private BufferedReader in

logger

private XuukXMLLogger logger

faces

private HashMap<Integer,Face> faces

eyes

private HashMap<Integer,EyePair> eyes

faceAppearanceListeners

private ArrayList<XuukListener> faceAppearanceListeners

eyesAppearanceListeners

private ArrayList<XuukListener> eyesAppearanceListeners

facePositionListeners

private ArrayList<XuukListener> facePositionListeners

eyesPositionListeners

private ArrayList<XuukListener> eyesPositionListeners
Constructor Detail

DirectXuukReader

public DirectXuukReader(String host,
                        int port)
Creates a new instance of XuukReader, which will connect to the Xuuk-software with the given host and the given port.

Parameters:
host - the host of the Xuuk-software
port - the port to contact the Xuuk-software
Method Detail

run

public void run()
Starts reading lines from the connection with the Xuuk-reader

Specified by:
run in interface Runnable
Overrides:
run in class Thread

processLine

public void processLine(String line)
Processes a line that is received from the Xuuk-reader. It will first look at the first element of that line, that element specifies what kind of data it is.

Parameters:
line -

addListener

public void addListener(XuukListener listener,
                        boolean faceAppearances,
                        boolean eyesAppearances,
                        boolean facePositions,
                        boolean eyesPositions)
Used to add new interested Listeners. The booleans are used to indicate what kind of events the listener wants to receive.

Specified by:
addListener in interface XuukReader
Parameters:
listener - the listener to add
faceAppearances - set this to 'true' to receive events about the appearances and disappearances of the face
eyesAppearances - set this to 'true' to receive events about the appearances and disappearances of the eyes
facePositions - set this to 'true' to receive events about positions of the detected faces
eyesPositions - set this to 'true' to receive events about positions of the detected eyes

stopRunning

public void stopRunning()

stopReader

public void stopReader()
Stops the reading of the socket connected to the Xuuk-software


startReader

public void startReader()
Starts the reading of the socket connected to the Xuuk-software


stopLogging

public void stopLogging()
Stops logging the messages from the Xuuk-software


startLogging

public void startLogging()
Starts logging the messages from the Xuuk-software Precondition 1: The reader has to reading messages Precondition 2: A logger has to be set for the reader


setLogger

public void setLogger(XuukXMLLogger xuukLogger)
Set the logger of the reader to xuukLogger

Parameters:
xuukLogger - XuukXMLLogger to the file you want to write the logs to

closeSocket

private void closeSocket()

openSocket

private boolean openSocket()

main

public static void main(String[] args)