diff --git a/CHANGELOG.md b/CHANGELOG.md index f61b589..2595000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build.gradle b/build.gradle index 7669292..573ebe7 100644 --- a/build.gradle +++ b/build.gradle @@ -27,5 +27,5 @@ allprojects { } task wrapper(type: Wrapper) { - gradleVersion = '2.14.1' + gradleVersion = '3.1' } \ No newline at end of file diff --git a/eyetribe.properties b/eyetribe.properties index 857ebcc..6c473a4 100644 --- a/eyetribe.properties +++ b/eyetribe.properties @@ -1,2 +1,2 @@ -currentVersion=0.9.77 -releaseDate=2016-05-17 \ No newline at end of file +currentVersion=0.9.77.1 +releaseDate=2016-11-23 \ No newline at end of file diff --git a/javafx-sample/build.gradle b/javafx-sample/build.gradle index ae34695..87f2fc3 100644 --- a/javafx-sample/build.gradle +++ b/javafx-sample/build.gradle @@ -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 { diff --git a/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/FrameRateGazeDataDeque.java b/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/FrameRateGazeDataDeque.java index 2ce6b9c..470532a 100644 --- a/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/FrameRateGazeDataDeque.java +++ b/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/FrameRateGazeDataDeque.java @@ -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); @@ -24,7 +31,7 @@ public float getAvgFramesPerSecond() { float avgMillis; if((avgMillis = getAvgMillisFrame()) > 0 ) - return (float)1000/avgMillis; + return 1000f / avgMillis; return -1; } @@ -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; diff --git a/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/GazeDataDeque.java b/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/GazeDataDeque.java index 097e403..d125afc 100644 --- a/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/GazeDataDeque.java +++ b/javafx-sample/src/main/java/com/theeyetribe/javafx/utils/GazeDataDeque.java @@ -25,7 +25,7 @@ public class GazeDataDeque extends LinkedBlockingDeque { private static final long serialVersionUID = -7224237939138791310L; - private long timeLimit; + protected long timeLimit; public GazeDataDeque(long timeLimit) { diff --git a/sdk/src/main/java/com/theeyetribe/clientsdk/GazeApiManager.java b/sdk/src/main/java/com/theeyetribe/clientsdk/GazeApiManager.java index 5d24ba9..473e759 100644 --- a/sdk/src/main/java/com/theeyetribe/clientsdk/GazeApiManager.java +++ b/sdk/src/main/java/com/theeyetribe/clientsdk/GazeApiManager.java @@ -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; @@ -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 @@ -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 { diff --git a/sdk/src/main/java/com/theeyetribe/clientsdk/GazeManagerCore.java b/sdk/src/main/java/com/theeyetribe/clientsdk/GazeManagerCore.java index b26178e..af59b02 100644 --- a/sdk/src/main/java/com/theeyetribe/clientsdk/GazeManagerCore.java +++ b/sdk/src/main/java/com/theeyetribe/clientsdk/GazeManagerCore.java @@ -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; @@ -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; @@ -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(); } /** @@ -650,6 +651,8 @@ public void deactivate() shutDownThreadpool(); + resetEnums(); + isInitialized = false; isActive = false; } @@ -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 { @@ -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; @@ -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; @@ -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; @@ -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); diff --git a/sdk/src/test/java/com/theeyetribe/test/TestApiClient.java b/sdk/src/test/java/com/theeyetribe/test/TestApiClient.java index a0a4375..659f256 100644 --- a/sdk/src/test/java/com/theeyetribe/test/TestApiClient.java +++ b/sdk/src/test/java/com/theeyetribe/test/TestApiClient.java @@ -135,7 +135,7 @@ public void testActivateAsync() throws Exception deactivateServer(); } - + @Test public void testActivateAsyncRetry() throws Exception { @@ -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()); }