Skip to content

Commit

Permalink
Merge pull request #20 from arnebp/master
Browse files Browse the repository at this point in the history
release 0.9.77.1
  • Loading branch information
arnebp authored Nov 23, 2016
2 parents 6d21278 + 3bd6f47 commit 55f031f
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log #
---

Version 0.9.77.1 (2016-11-23)
---
- Default states for all GazeManager enum types
- Fixed default network state
- Update Gradle version & dependencies

Version 0.9.77 (2016-05-17)
---
- Moving all data types from 64-bit to 32-bit floating point precision
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ allprojects {
}

task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
gradleVersion = '3.1'
}
4 changes: 2 additions & 2 deletions eyetribe.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
currentVersion=0.9.77
releaseDate=2016-05-17
currentVersion=0.9.77.1
releaseDate=2016-11-23
5 changes: 3 additions & 2 deletions javafx-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ apply from: 'javafx.plugin'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.guava:guava:19.0'
compile 'org.controlsfx:controlsfx:8.40.10'
compile 'com.theeyetribe:eyetribe-java:0.9.77'
compile 'org.controlsfx:controlsfx:8.40.12'
compile 'com.google.code.findbugs:jsr305:3.0.1'
compile 'com.theeyetribe:eyetribe-java:0.9.77+'
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*/
public class FrameRateGazeDataDeque extends GazeDataDeque
{
private static final long BUFFER_SIZE_MILLIS = 5000;

public FrameRateGazeDataDeque()
{
super(BUFFER_SIZE_MILLIS);
}

public FrameRateGazeDataDeque(long timeLimit)
{
super(timeLimit);
Expand All @@ -24,7 +31,7 @@ public float getAvgFramesPerSecond()
{
float avgMillis;
if((avgMillis = getAvgMillisFrame()) > 0 )
return (float)1000/avgMillis;
return 1000f / avgMillis;

return -1;
}
Expand All @@ -37,7 +44,10 @@ public float getAvgMillisFrame()
if(null != first && null != last)
{
float delta = first.timeStamp - last.timeStamp;
return delta / size();

// only return value when buffer populated
if (delta > (timeLimit >> 1))
return delta / size();
}

return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class GazeDataDeque extends LinkedBlockingDeque<GazeData>
{
private static final long serialVersionUID = -7224237939138791310L;
private long timeLimit;
protected long timeLimit;

public GazeDataDeque(long timeLimit)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
class GazeApiManager
{
static String DEFAULT_SERVER_HOST = "localhost";
static String DEFAULT_SERVER_HOST = "127.0.0.1";
static int DEFAULT_SERVER_PORT = 6555;

private Socket mSocket;
Expand Down Expand Up @@ -250,6 +250,7 @@ public synchronized boolean connect(String host, int port, long timeOut)
// connect to socket, with timeout
mSocket = new Socket();
mSocket.connect(new InetSocketAddress(host, port), (int) timeOut);
mSocket.setKeepAlive(true);
mSocket.setSoTimeout((int) timeOut);

// notify connection change
Expand Down Expand Up @@ -605,7 +606,7 @@ public void run()
}

/**
* Callback interface responsible for handling messages returned from the GazeApiManager
* Callback interface responsible for handling responses returned from the GazeApiManager
*/
protected interface IGazeApiResponseListener
{
Expand Down
65 changes: 55 additions & 10 deletions sdk/src/main/java/com/theeyetribe/clientsdk/GazeManagerCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package com.theeyetribe.clientsdk;

import com.theeyetribe.clientsdk.GazeApiManager.IGazeApiConnectionListener;
import com.theeyetribe.clientsdk.GazeApiManager.IGazeApiResponseListener;
import com.theeyetribe.clientsdk.data.CalibrationResult;
import com.theeyetribe.clientsdk.data.CalibrationResult.CalibrationPoint;
import com.theeyetribe.clientsdk.data.GazeData;
Expand All @@ -18,6 +16,8 @@
import com.theeyetribe.clientsdk.response.Response;
import com.theeyetribe.clientsdk.response.ResponseFailed;
import com.theeyetribe.clientsdk.response.TrackerGetResponse;
import com.theeyetribe.clientsdk.GazeApiManager.IGazeApiResponseListener;
import com.theeyetribe.clientsdk.GazeApiManager.IGazeApiConnectionListener;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -77,6 +77,7 @@ abstract class GazeManagerCore implements IGazeApiResponseListener, IGazeApiConn
mTrackerStateListeners = Collections.synchronizedList(new ArrayList<>());
mScreenStateListeners = Collections.synchronizedList(new ArrayList<>());
mConnectionStateListeners = Collections.synchronizedList(new ArrayList<>());
resetEnums();
}

/**
Expand Down Expand Up @@ -650,6 +651,8 @@ public void deactivate()

shutDownThreadpool();

resetEnums();

isInitialized = false;
isActive = false;
}
Expand Down Expand Up @@ -1753,7 +1756,7 @@ public void onGazeApiConnectionStateChanged(final boolean isConnected)


/**
* Mode in witch the EyeTribe server delivers gaze data stream to the Java SDK SDK
* Mode in witch the EyeTribe server delivers gaze data stream
*/
public enum ClientMode
{
Expand All @@ -1771,11 +1774,16 @@ private ClientMode(int clientMode)
}

/**
* Version of the EyeTribe API to be compliant to
* The EyeTribe API compliance levels
*/
public enum ApiVersion
{
VERSION_1_0(1);
/**
* ApiVersion is undefined. GazeManager not activated
*/
VERSION_UNDEFINED(0),
VERSION_1_0(1),
;

private int version;

Expand Down Expand Up @@ -1807,8 +1815,31 @@ public static int toInt(ApiVersion v)
*/
public enum TrackerState
{
TRACKER_CONNECTED(0), TRACKER_NOT_CONNECTED(1), TRACKER_CONNECTED_BADFW(2), TRACKER_CONNECTED_NOUSB3(3), TRACKER_CONNECTED_NOSTREAM(
4);
/**
* Tracker device is detected and working
*/
TRACKER_CONNECTED(0),
/**
* Tracker device is not detected
*/
TRACKER_NOT_CONNECTED(1),
/**
* Tracker device is detected but not working due to wrong/unsupported firmware
*/
TRACKER_CONNECTED_BADFW(2),
/**
* Tracker device is detected but not working due to unsupported USB host
*/
TRACKER_CONNECTED_NOUSB3(3),
/**
* Tracker device is detected but not working due to no stream could be received
*/
TRACKER_CONNECTED_NOSTREAM(4),
/**
* Tracker state is undefined. GazeManager not activated
*/
TRACKER_UNDEFINED(-1),
;

private int trackerState;

Expand Down Expand Up @@ -1839,10 +1870,17 @@ public static int toInt(TrackerState ts)
}

/**
* The current state of the connected TrackerDevice.
* The possible frame rates of the EyeTribe Server
*/
public enum FrameRate {
FPS_30(30), FPS_60(60);
public enum FrameRate
{
/**
* FrameRate is undefined. GazeManager not activated
*/
FPS_UNDEFINED(0),
FPS_30(30),
FPS_60(60),
;

private int frameRate;

Expand Down Expand Up @@ -1870,6 +1908,13 @@ public static int toInt(FrameRate fr) {
}
}

private void resetEnums()
{
trackerState = TrackerState.TRACKER_UNDEFINED;
frameRate = FrameRate.FPS_UNDEFINED;
version = ApiVersion.VERSION_UNDEFINED;
}

abstract protected GazeApiManager createApiManager(IGazeApiResponseListener responseListener, IGazeApiConnectionListener connectionListener);

abstract protected boolean parseApiResponse(final Response response, final Request request);
Expand Down
8 changes: 5 additions & 3 deletions sdk/src/test/java/com/theeyetribe/test/TestApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testActivateAsync() throws Exception

deactivateServer();
}

@Test
public void testActivateAsyncRetry() throws Exception
{
Expand Down Expand Up @@ -257,13 +257,15 @@ public void testAsyncLocks() throws Exception

lock.await(1, TimeUnit.SECONDS);

GazeManager.getInstance().calibrationStartAsync(9, null).get(5, TimeUnit.SECONDS);
GazeManager.getInstance().calibrationAbortAsync().get(5, TimeUnit.SECONDS);
Assert.assertTrue(GazeManager.getInstance().calibrationStartAsync(9, null).get(5, TimeUnit.SECONDS));
Assert.assertTrue(GazeManager.getInstance().calibrationAbortAsync().get(5, TimeUnit.SECONDS));

lock.await(1, TimeUnit.SECONDS);

GazeManager.getInstance().deactivate();

lock.await(1, TimeUnit.SECONDS);

Assert.assertFalse(GazeManager.getInstance().isActivated());
}

Expand Down

0 comments on commit 55f031f

Please sign in to comment.