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
Nested ClassesModifier and TypeClassDescriptionprivate classRunnable thread to -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AsyncBuffer<AckXml>private Threadprivate final AsyncBuffer<RecXml>private Stringprivate BufferedReaderprivate Mediatorprivate PrintStreamprivate intprivate Socketprivate final com.fasterxml.jackson.dataformat.xml.XmlMapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()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)voidsetMediator(Mediator mediator) private voidstart()voidInitiates calibration on the tracker.voidInitiates 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.voidwriteSetCommand(SetCommand setCommand) private voidwriteToBuffer(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:
IOExceptionInterruptedException
-
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:
setMediatorin interfaceComponent
-