Package adaptlil.gazepoint.api
Class GazepointSocket
java.lang.Object
adaptlil.gazepoint.api.GazepointSocket
- All Implemented Interfaces:
Component
Connects to GP3 and reads data.
Utilizes a thread safe queue to write/read data recieved from the tracker. API specifies that data is sent in the form of XML
so we utilize XML Annotations to construct XML objects after receiving API data. This is to simplify the process of
interacting with the tracking data.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate class
Runnable thread to -
Field Summary
Modifier and TypeFieldDescriptionprivate AsyncBuffer<AckXml>
private Thread
private final AsyncBuffer<RecXml>
private String
private BufferedReader
private Mediator
private PrintStream
private int
private Socket
private final com.fasterxml.jackson.dataformat.xml.XmlMapper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Opens socket port to the gazepoint tracker and sets the input, output streamsGrabs the head of the gaze data xml object queue (Reference gazepoint API)void
setMediator
(Mediator mediator) private void
start()
void
Initiates calibration on the tracker.void
Initiates ENABLE_SEND_DATA with the tracker to begin gaze data stream.Pauses the data stream by sending the ENABLE_SEND_DATA command w/ false flag.void
writeSetCommand
(SetCommand setCommand) private void
writeToBuffer
(String msg) Writes the string to the appropriate buffer.void
-
Field Details
-
hostName
-
port
private int port -
socket
-
input
-
output
-
xmlMapper
private final com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper -
gazeDataBuffer
-
ackBuffer
-
gazeBufferThread
-
mediator
-
-
Constructor Details
-
GazepointSocket
-
-
Method Details
-
connect
Opens socket port to the gazepoint tracker and sets the input, output streams- Throws:
IOException
-
startCalibration
public void startCalibration() throws com.fasterxml.jackson.core.JsonProcessingExceptionInitiates calibration on the tracker.- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
startGazeDataStream
Initiates ENABLE_SEND_DATA with the tracker to begin gaze data stream. This method creates a new thread so be careful. The thread will write data into the gaze buffer.- Throws:
IOException
-
start
- Throws:
IOException
InterruptedException
-
writeToBuffer
Writes the string to the appropriate buffer. If ACK, ackBuffer, if REC, Gaze buffer.- Parameters:
msg
-
-
readFromGazepointSocket
- Throws:
IOException
-
readGazeDataFromBuffer
Grabs the head of the gaze data xml object queue (Reference gazepoint API)- Returns:
- Returns the XML Data Object that details whatever GazeData has been sent from the tracker
-
stopGazeDataStream
Pauses the data stream by sending the ENABLE_SEND_DATA command w/ false flag.- Returns:
- Returns the ACK Xml from the server.
- Throws:
IOException
- If this is thrown, it may be a logic issue where we are reading the wrong input line.
-
getGazeDataQueue
-
writeToGazepointSocket
-
writeSetCommand
public void writeSetCommand(SetCommand setCommand) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
setMediator
- Specified by:
setMediator
in interfaceComponent
-