From 03b00aa1e80e17361ae6037d32f0a74b3efe3900 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 27 Oct 2015 20:38:28 +0100 Subject: [PATCH 01/63] updates to dependecies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 67605c8..c4a1932 100644 --- a/pom.xml +++ b/pom.xml @@ -36,12 +36,12 @@ org.slf4j slf4j-api - 1.7.7 + 1.7.12 junit junit - 4.11 + 4.12 test From 2b931b52d5f9e32f89022d1242e3f4114440dc66 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 27 Oct 2015 20:39:54 +0100 Subject: [PATCH 02/63] add contributors --- pom.xml | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index c4a1932..dbd02c2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 de.taimos @@ -25,6 +26,12 @@ Andrew Evdokimov + + Frank Kusters + + + Michael Erskine + @@ -33,31 +40,31 @@ json 20090211 - - org.slf4j - slf4j-api - 1.7.12 - + + org.slf4j + slf4j-api + 1.7.12 + junit junit 4.12 test - - ch.qos.logback - logback-classic - 1.1.2 - test - + + ch.qos.logback + logback-classic + 1.1.2 + test + scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD - + HEAD + From b12331fd9653ce69a40797f63bb163591adea1cc Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 27 Oct 2015 20:58:05 +0100 Subject: [PATCH 03/63] fix formatting and javadoc error --- .../taimos/gpsd4java/backend/GPSdEndpoint.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 1efa1a2..e5a0738 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -122,14 +122,14 @@ public void start() { */ public void stop() { try { - socket.close(); + this.socket.close(); } catch (final IOException e1) { - GPSdEndpoint.LOG.debug("Close forced: "+ e1.getMessage()); + GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage()); } - + try { this.listeners.clear(); - if(listenThread != null) { + if (this.listenThread != null) { this.listenThread.halt(); } } catch (final Exception e) { @@ -304,12 +304,12 @@ void handle(final IGPSObject object) { } } } - + /** * Attempt to kick a failed device back into life on gpsd server. - * - * @see https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html - * + * + * see: https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html + * * @param path Path of device known to gpsd * @throws IOException * @throws JSONException @@ -318,6 +318,6 @@ public void kickDevice(String path) throws IOException, JSONException { final JSONObject d = new JSONObject(); d.put("class", "DEVICE"); d.put("path", path); - voidCommand("?DEVICE="+d); + this.voidCommand("?DEVICE=" + d); } } From 9caad8f21ee56a8207def8f13b032bae0e1ca8cd Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 27 Oct 2015 22:28:30 +0100 Subject: [PATCH 04/63] update OSS parent --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbd02c2..a4548c7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.taimos oss-parent - 2 + 5 gpsd4java 1.4-SNAPSHOT From 821894f30956c8e7091b396501052697affce099 Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Tue, 27 Oct 2015 21:35:45 +0000 Subject: [PATCH 05/63] [maven-release-plugin] prepare release v1.4 --- pom.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index a4548c7..6f7634f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 de.taimos @@ -8,7 +7,7 @@ 5 gpsd4java - 1.4-SNAPSHOT + 1.4 bundle GPSd4Java Java Client library for GPSd deamon @@ -63,7 +62,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD + v1.4 From 4ac54cc61205d694f0c57972bc9aff8e6fcdfe0d Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Tue, 27 Oct 2015 21:35:51 +0000 Subject: [PATCH 06/63] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6f7634f..1691a52 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.4 + 1.5-SNAPSHOT bundle GPSd4Java Java Client library for GPSd deamon @@ -62,7 +62,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - v1.4 + HEAD From a5237a9b31853b0dc91d4882929b910ed5b8f2fb Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 27 Oct 2015 22:48:51 +0100 Subject: [PATCH 07/63] fix versions in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61a4eb0..3399470 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ You can use GPSd4Java with a Maven project. Just add the following lines to your de.taimos gpsd4java - 1.3 + 1.4 @@ -31,6 +31,6 @@ To get the latest development snapshot add the following lines to your pom.xml. de.taimos gpsd4java - 1.4-SNAPSHOT + 1.5-SNAPSHOT From 429f5072c37e17b04e1a8b9144c8bb7a69e6dcea Mon Sep 17 00:00:00 2001 From: Henryk Konsek Date: Mon, 21 Dec 2015 12:51:00 +0100 Subject: [PATCH 08/63] Added null-check to toString(). --- src/main/java/de/taimos/gpsd4java/types/TPVObject.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/types/TPVObject.java b/src/main/java/de/taimos/gpsd4java/types/TPVObject.java index aab9d11..fc187ae 100644 --- a/src/main/java/de/taimos/gpsd4java/types/TPVObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/TPVObject.java @@ -539,8 +539,10 @@ public String toString() { sb.append(this.speedError); sb.append(", climbRateError="); sb.append(this.climbRateError); - sb.append(", mode="); - sb.append(this.mode.name()); + if (mode != null) { + sb.append(", mode="); + sb.append(this.mode.name()); + } sb.append("}"); return sb.toString(); } From 45caf3b821a91e9eaa36e94eeb4e36c332603925 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Mon, 21 Dec 2015 17:29:59 +0100 Subject: [PATCH 09/63] This fixes a race condition between the calling thread and the SocketThread. It was possible that once the request had been written, the response was coming back before the "this.asyncResult = null" (line 258) statement was being called. This was causing a valid response to be lost and "null" being returned. This fix first checks to ensure no response has been received yet, and only then to wait for a second at most for a response. --- .../gpsd4java/backend/GPSdEndpoint.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index e5a0738..60c301a 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -66,7 +66,7 @@ public class GPSdEndpoint { private final List listeners = new ArrayList(1); - private IGPSObject asnycResult = null; + private IGPSObject asyncResult = null; private final Object asyncMutex = new Object(); @@ -255,17 +255,17 @@ private void voidCommand(final String command) throws IOException { */ private IGPSObject waitForResult() { synchronized (this.asyncWaitMutex) { - this.asnycResult = null; - try { - this.asyncWaitMutex.wait(1000); - } catch (final InterruptedException e) { - GPSdEndpoint.LOG.info("Interrupted while waiting for result", e); - } - if (this.asnycResult != null) { - return this.asnycResult; + if (this.asyncResult == null) { + try { + this.asyncWaitMutex.wait(1000); + } catch (final InterruptedException e) { + GPSdEndpoint.LOG.info("Interrupted while waiting for result", e); + } } + final IGPSObject result = this.asyncResult; + this.asyncResult = null; + return result; } - return null; } /* @@ -299,7 +299,7 @@ void handle(final IGPSObject object) { } else { // object was requested, so put it in the response object synchronized (this.asyncWaitMutex) { - this.asnycResult = object; + this.asyncResult = object; this.asyncWaitMutex.notifyAll(); } } From fd4896ce056e6970019b82b61821b94d42d5a20f Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Thu, 31 Dec 2015 18:55:33 +0100 Subject: [PATCH 10/63] ignore IDEA files --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c41cc9e..8e99583 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -/target \ No newline at end of file +/target +gpsd4java.iml +.idea From f12630300bb86c56981d2dc3117cac905a45d3d6 Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Thu, 31 Dec 2015 17:59:46 +0000 Subject: [PATCH 11/63] [maven-release-plugin] prepare release v1.5 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1691a52..0fd23a8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.5-SNAPSHOT + 1.5 bundle GPSd4Java Java Client library for GPSd deamon @@ -62,7 +62,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD + v1.5 From d84f85de5844997d4373fdcfbef284386bda4645 Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Thu, 31 Dec 2015 17:59:51 +0000 Subject: [PATCH 12/63] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0fd23a8..c6dfa88 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.5 + 1.6-SNAPSHOT bundle GPSd4Java Java Client library for GPSd deamon @@ -62,7 +62,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - v1.5 + HEAD From 045ecd6232692fd139307e73c1e94f89d14e151e Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Thu, 31 Dec 2015 19:07:12 +0100 Subject: [PATCH 13/63] push version changes to README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3399470..42e98c3 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ You can use GPSd4Java with a Maven project. Just add the following lines to your de.taimos gpsd4java - 1.4 + 1.5 @@ -31,6 +31,6 @@ To get the latest development snapshot add the following lines to your pom.xml. de.taimos gpsd4java - 1.5-SNAPSHOT + 1.6-SNAPSHOT From b719dac42bca90739fd44373f7bfbd79dd14ef78 Mon Sep 17 00:00:00 2001 From: Tim Williscroft Date: Sat, 13 Aug 2016 09:54:53 +1000 Subject: [PATCH 14/63] Changed SocketThread and GPSEndpoint to reconnect if connectivity is lost to the GPSd TCP socket. --- .../gpsd4java/backend/GPSdEndpoint.java | 36 +++++++++++-- .../gpsd4java/backend/SocketThread.java | 52 +++++++++++++++++-- 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 60c301a..42cccf9 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -56,11 +56,11 @@ public class GPSdEndpoint { private static final Logger LOG = LoggerFactory.getLogger(GPSdEndpoint.class); - private final Socket socket; + private Socket socket; - private final BufferedReader in; + private BufferedReader in; - private final BufferedWriter out; + private BufferedWriter out; private SocketThread listenThread; @@ -73,6 +73,12 @@ public class GPSdEndpoint { private final Object asyncWaitMutex = new Object(); private final AbstractResultParser resultParser; + + private String server; + + private int port; + + private JSONObject watch; /** @@ -87,6 +93,8 @@ public class GPSdEndpoint { * @throws IOException */ public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser) throws UnknownHostException, IOException { + this.server = server; + this.port = port; if (server == null) { throw new IllegalArgumentException("server can not be null!"); } @@ -121,6 +129,7 @@ public void start() { * Stops the endpoint. */ public void stop() { + try { this.socket.close(); } catch (final IOException e1) { @@ -169,7 +178,7 @@ public WatchObject watch(final boolean enable, final boolean dumpData) throws IO * @throws JSONException */ public WatchObject watch(final boolean enable, final boolean dumpData, final String device) throws IOException, JSONException { - final JSONObject watch = new JSONObject(); + watch = new JSONObject(); watch.put("class", "WATCH"); watch.put("enable", enable); watch.put("json", dumpData); @@ -320,4 +329,23 @@ public void kickDevice(String path) throws IOException, JSONException { d.put("path", path); this.voidCommand("?DEVICE=" + d); } + + /** + * Our socket thread got disconnect and is exiting. + */ + void handleDisconnected() throws IOException{ + synchronized (this.asyncMutex) { + socket.close(); + this.socket = new Socket(server, port); + this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); + this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); + + this.listenThread = new SocketThread(this.in, this, this.resultParser); + this.listenThread.start(); + if( watch!=null){ + this.syncCommand("?WATCH=" + watch.toString(), WatchObject.class); + } + } + + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index c0bce6d..a3a94ac 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -23,7 +23,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.net.SocketException; -import java.util.concurrent.atomic.AtomicBoolean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +42,7 @@ public class SocketThread extends Thread { private final AbstractResultParser resultParser; - private final AtomicBoolean running = new AtomicBoolean(true); + private final WaitableBoolean running = new WaitableBoolean(true); /** @@ -86,11 +85,32 @@ public void run() { this.endpoint.handle(this.resultParser.parse(s)); } } catch (final SocketException e) { - // stop if socket fails - break; + break; // stop } catch (final Exception e) { // TODO handle this better SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line", e); + } + } + if( running.get() && !Thread.interrupted()){ + SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line, attempting restart"); + retry(); + } + } + + + protected void retry(){ + SocketThread.LOG.debug("Disconnected from GPS socket, retrying connection"); + + while(this.running.get()){ + try { + running.waitFor(1000); + this.endpoint.handleDisconnected(); + SocketThread.LOG.debug("Reconnected to GPS socket"); + running.set(false); + } catch (InterruptedException ix){ + break; + } catch (IOException e) { + SocketThread.LOG.debug("Still disconnected from GPS socket, retrying connection again"); } } } @@ -110,3 +130,27 @@ public void halt() throws InterruptedException { this.join(1000); } } +/** + * Not as efficient as AtomicBoolean but you can wait on it. + * @author TimW + * + */ +class WaitableBoolean { + private boolean val; + + public WaitableBoolean(boolean b) { + val=b; + } + + synchronized void set(boolean value){ + this.val=value; + notifyAll(); + } + + synchronized boolean get(){ + return val; + } + synchronized public void waitFor(long millis) throws InterruptedException{ + super.wait(millis); + } +} \ No newline at end of file From bc17addf48c5108b5ab607608155254dc9b7339a Mon Sep 17 00:00:00 2001 From: Tim Williscroft Date: Sat, 13 Aug 2016 10:11:49 +1000 Subject: [PATCH 15/63] Make the reconnect retry interval configurable. --- .../gpsd4java/backend/GPSdEndpoint.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 42cccf9..af61f0a 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -29,6 +29,7 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicLong; import org.json.JSONException; import org.json.JSONObject; @@ -78,8 +79,9 @@ public class GPSdEndpoint { private int port; - private JSONObject watch; + private String lastWatch; + private AtomicLong retryInterval = new AtomicLong(1000); /** * Instantiate this class to connect to a GPSd server @@ -178,7 +180,7 @@ public WatchObject watch(final boolean enable, final boolean dumpData) throws IO * @throws JSONException */ public WatchObject watch(final boolean enable, final boolean dumpData, final String device) throws IOException, JSONException { - watch = new JSONObject(); + JSONObject watch = new JSONObject(); watch.put("class", "WATCH"); watch.put("enable", enable); watch.put("json", dumpData); @@ -237,7 +239,9 @@ private T syncCommand(final String command, final Class Date: Sat, 15 Oct 2016 17:01:09 +0200 Subject: [PATCH 22/63] add contributor --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 6ffdee1..c8ab4da 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,9 @@ Tim Williscroft + + Martin Nordqvist + From 584bd313e54319a2797cc0b6d945e9cda0f70bf0 Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Sat, 15 Oct 2016 15:06:51 +0000 Subject: [PATCH 23/63] [maven-release-plugin] prepare release v1.7 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c8ab4da..00bfbb6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.7-SNAPSHOT + 1.7 bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD + v1.7 From 242773e33d0f0610e966cc1e3ebb1477ad7a926b Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Sat, 15 Oct 2016 15:07:07 +0000 Subject: [PATCH 24/63] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 00bfbb6..9d75881 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.7 + 1.8-SNAPSHOT bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - v1.7 + HEAD From d3d8de30afdad59f36e731ea490715f87b446d87 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Sat, 15 Oct 2016 17:12:10 +0200 Subject: [PATCH 25/63] bump version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc56018..3581463 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ You can use GPSd4Java with a Maven project. Just add the following lines to your de.taimos gpsd4java - 1.6 + 1.7 From 07aae6fc836c7f6e1f498865cd7552f5c87a51af Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Sat, 18 Feb 2017 14:47:03 +0100 Subject: [PATCH 26/63] fix reconnect error #24 --- src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index af61f0a..d94fd4e 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -346,8 +346,8 @@ void handleDisconnected() throws IOException{ this.listenThread = new SocketThread(this.in, this, this.resultParser); this.listenThread.start(); - if( lastWatch!=null){ // restore watch if we had one. - this.syncCommand("?WATCH=" + lastWatch, WatchObject.class); + if (lastWatch != null) { // restore watch if we had one. + this.syncCommand(lastWatch, WatchObject.class); } } From 976c1dbe1a112745794f3025132fd1106b9807fd Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Sat, 18 Feb 2017 14:48:47 +0100 Subject: [PATCH 27/63] fix code format --- .../gpsd4java/api/DistanceListener.java | 6 +- .../taimos/gpsd4java/api/IObjectListener.java | 20 +- .../taimos/gpsd4java/api/ObjectListener.java | 2 +- .../backend/AbstractResultParser.java | 10 +- .../de/taimos/gpsd4java/backend/GISTool.java | 25 +-- .../gpsd4java/backend/GPSdEndpoint.java | 77 ++++---- .../gpsd4java/backend/LegacyResultParser.java | 10 +- .../gpsd4java/backend/ResultParser.java | 10 +- .../gpsd4java/backend/SocketThread.java | 24 +-- .../de/taimos/gpsd4java/types/ATTObject.java | 177 ++++++++---------- .../taimos/gpsd4java/types/DeviceObject.java | 69 +++---- .../taimos/gpsd4java/types/DevicesObject.java | 13 +- .../de/taimos/gpsd4java/types/ENMEAMode.java | 5 +- .../de/taimos/gpsd4java/types/EParity.java | 10 +- .../de/taimos/gpsd4java/types/GSTObject.java | 77 ++++---- .../de/taimos/gpsd4java/types/IGPSObject.java | 2 +- .../gpsd4java/types/ParseException.java | 17 +- .../de/taimos/gpsd4java/types/PollObject.java | 37 ++-- .../de/taimos/gpsd4java/types/SATObject.java | 41 ++-- .../de/taimos/gpsd4java/types/SKYObject.java | 83 ++++---- .../de/taimos/gpsd4java/types/TPVObject.java | 126 ++++++------- .../taimos/gpsd4java/types/VersionObject.java | 18 +- .../taimos/gpsd4java/types/WatchObject.java | 20 +- .../types/subframes/ALMANACObject.java | 42 ++--- .../types/subframes/EPHEM1Object.java | 39 ++-- .../types/subframes/EPHEM2Object.java | 39 ++-- .../types/subframes/EPHEM3Object.java | 33 ++-- .../gpsd4java/types/subframes/ERDObject.java | 18 +- .../types/subframes/HEALTH2Object.java | 21 +-- .../types/subframes/HEALTHObject.java | 27 +-- .../gpsd4java/types/subframes/IONOObject.java | 54 ++---- .../types/subframes/SUBFRAMEObject.java | 111 +++++------ 32 files changed, 521 insertions(+), 742 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java b/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java index e1998d2..f05cb32 100644 --- a/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java +++ b/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java @@ -25,7 +25,7 @@ /** * Derive this class to implement a listener for location updates which reacts to changes greater a given threshold - * + * * @author thoeger */ public abstract class DistanceListener extends ObjectListener { @@ -34,10 +34,8 @@ public abstract class DistanceListener extends ObjectListener { private final double threshold; - /** - * @param threshold - * the threshold to fire in kilometers + * @param threshold the threshold to fire in kilometers */ public DistanceListener(final double threshold) { this.threshold = threshold; diff --git a/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java b/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java index 4b7b54d..f7aa4e0 100644 --- a/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java +++ b/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java @@ -29,44 +29,38 @@ /** * Listener to receive response objects - * + * * @author thoeger */ public interface IObjectListener { /** - * @param tpv - * the TPV object + * @param tpv the TPV object */ void handleTPV(TPVObject tpv); /** - * @param sky - * the SKY object + * @param sky the SKY object */ void handleSKY(SKYObject sky); /** - * @param att - * the ATT object + * @param att the ATT object */ void handleATT(ATTObject att); /** - * @param subframe - * the SUBFRAME object + * @param subframe the SUBFRAME object */ void handleSUBFRAME(SUBFRAMEObject subframe); /** - * @param devices - * the devices object + * @param devices the devices object */ void handleDevices(DevicesObject devices); /** - * @param device - * the device object + * @param device the device object */ void handleDevice(DeviceObject device); diff --git a/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java b/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java index 7b4e1ca..e769a16 100644 --- a/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java +++ b/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java @@ -29,7 +29,7 @@ /** * Adapter class for {@link IObjectListener} - * + * * @author thoeger */ public class ObjectListener implements IObjectListener { diff --git a/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java index 4a7107f..d294fca 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java @@ -37,7 +37,6 @@ import de.taimos.gpsd4java.types.ParseException; /** - * * @author irakli, thoeger */ public abstract class AbstractResultParser { @@ -46,7 +45,6 @@ public abstract class AbstractResultParser { protected final DateFormat dateFormat; // Don't make this static! - /** * Create new ResultParser */ @@ -57,12 +55,10 @@ public AbstractResultParser() { /** * Parse a received line into a {@link IGPSObject} - * - * @param line - * the line read from GPSd + * + * @param line the line read from GPSd * @return the parsed object - * @throws ParseException - * if parsing fails + * @throws ParseException if parsing fails */ public IGPSObject parse(final String line) throws ParseException { try { diff --git a/src/main/java/de/taimos/gpsd4java/backend/GISTool.java b/src/main/java/de/taimos/gpsd4java/backend/GISTool.java index 2aa53ea..2551a09 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GISTool.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GISTool.java @@ -24,14 +24,13 @@ /** * This class provides tools to measure the distance between two locations in WGS84 coordinates - * + * * @author thoeger */ public final class GISTool { private static final int EARTH_RADIUS_KILOMETERS = 6371; - private GISTool() { // } @@ -39,11 +38,9 @@ private GISTool() { /** * calculates the distance between two {@link TPVObject} in kilometers
* the method used is the great-circle-distance with hypersine formula - * - * @param tpv1 - * - position 1 - * @param tpv2 - * - position 2 + * + * @param tpv1 - position 1 + * @param tpv2 - position 2 * @return distance in kilometers */ public static double getDistance(final TPVObject tpv1, final TPVObject tpv2) { @@ -53,15 +50,11 @@ public static double getDistance(final TPVObject tpv1, final TPVObject tpv2) { /** * calculates the distance between two locations, which are given as coordinates, in kilometers
* the method used is the great-circle-distance with hypersine formula - * - * @param x1 - * - longitude of position 1 - * @param x2 - * - longitude of position 2 - * @param y1 - * - latitude of position 1 - * @param y2 - * - latitude of position 2 + * + * @param x1 - longitude of position 1 + * @param x2 - longitude of position 2 + * @param y1 - latitude of position 1 + * @param y2 - latitude of position 2 * @return distance in kilometers */ public static double getDistance(final double x1, final double x2, final double y1, final double y2) { diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index d94fd4e..0ac5e27 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -50,7 +50,7 @@ /** * GPSd client endpoint - * + * * @author thoeger */ public class GPSdEndpoint { @@ -74,22 +74,20 @@ public class GPSdEndpoint { private final Object asyncWaitMutex = new Object(); private final AbstractResultParser resultParser; - + private String server; - + private int port; - + private String lastWatch; private AtomicLong retryInterval = new AtomicLong(1000); /** * Instantiate this class to connect to a GPSd server - * - * @param server - * the server name or IP - * @param port - * the server port + * + * @param server the server name or IP + * @param port the server port * @param resultParser * @throws UnknownHostException * @throws IOException @@ -151,14 +149,11 @@ public void stop() { /** * send WATCH command - * - * @param enable - * enable/disable watch mode - * @param dumpData - * enable/disable dumping of data + * + * @param enable enable/disable watch mode + * @param dumpData enable/disable dumping of data * @return {@link WatchObject} - * @throws IOException - * on IO error in socket + * @throws IOException on IO error in socket * @throws JSONException */ public WatchObject watch(final boolean enable, final boolean dumpData) throws IOException, JSONException { @@ -167,16 +162,12 @@ public WatchObject watch(final boolean enable, final boolean dumpData) throws IO /** * send WATCH command - * - * @param enable - * enable/disable watch mode - * @param dumpData - * enable/disable dumping of data - * @param device - * If present, enable watching only of the specified device rather than all devices + * + * @param enable enable/disable watch mode + * @param dumpData enable/disable dumping of data + * @param device If present, enable watching only of the specified device rather than all devices * @return {@link WatchObject} - * @throws IOException - * on IO error in socket + * @throws IOException on IO error in socket * @throws JSONException */ public WatchObject watch(final boolean enable, final boolean dumpData, final String device) throws IOException, JSONException { @@ -192,10 +183,9 @@ public WatchObject watch(final boolean enable, final boolean dumpData, final Str /** * Poll GPSd for Message - * + * * @return {@link PollObject} - * @throws IOException - * on IO error in socket + * @throws IOException on IO error in socket */ public PollObject poll() throws IOException { return this.syncCommand("?POLL;", PollObject.class); @@ -203,10 +193,9 @@ public PollObject poll() throws IOException { /** * Poll GPSd version - * + * * @return {@link VersionObject} - * @throws IOException - * on IO error in socket + * @throws IOException on IO error in socket */ public VersionObject version() throws IOException { return this.syncCommand("?VERSION;", VersionObject.class); @@ -214,17 +203,16 @@ public VersionObject version() throws IOException { // TODO implement rest of commands // ######################################################## + /** - * @param listener - * the listener to add + * @param listener the listener to add */ public void addListener(final IObjectListener listener) { this.listeners.add(listener); } /** - * @param listener - * the listener to remove + * @param listener the listener to remove */ public void removeListener(final IObjectListener listener) { this.listeners.remove(listener); @@ -239,8 +227,8 @@ private T syncCommand(final String command, final Class * see: https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html - * + * * @param path Path of device known to gpsd * @throws IOException * @throws JSONException @@ -333,16 +321,16 @@ public void kickDevice(String path) throws IOException, JSONException { d.put("path", path); this.voidCommand("?DEVICE=" + d); } - + /** * Our socket thread got disconnect and is exiting. */ - void handleDisconnected() throws IOException{ + void handleDisconnected() throws IOException { synchronized (this.asyncMutex) { socket.close(); this.socket = new Socket(server, port); this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); - this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); + this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); this.listenThread = new SocketThread(this.in, this, this.resultParser); this.listenThread.start(); @@ -352,13 +340,14 @@ void handleDisconnected() throws IOException{ } } + /** * Set a retry interval for reconnecting to GPSD if the socket closes. * Default value is 1000ms. - * + * * @param millis how long to wait between each reconnection attempts. */ - public void setRetryInterval(long millis){ + public void setRetryInterval(long millis) { retryInterval.set(millis); } diff --git a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java index 9f45970..d3dadd6 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java @@ -48,19 +48,17 @@ /** * This class is used to parse responses from GPSd
- * + * * @author thoeger */ public class LegacyResultParser extends AbstractResultParser { /** * parse {@link JSONObject} into {@link IGPSObject} - * - * @param json - * the {@link JSONObject} to parse + * + * @param json the {@link JSONObject} to parse * @return the parsed object - * @throws ParseException - * if parsing fails + * @throws ParseException if parsing fails */ @Override public IGPSObject parse(final JSONObject json) throws ParseException { diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index e6eca3a..0c37e8d 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -48,19 +48,17 @@ /** * This class is used to parse responses from GPSd
- * + * * @author thoeger */ public class ResultParser extends AbstractResultParser { /** * parse {@link JSONObject} into {@link IGPSObject} - * - * @param json - * the {@link JSONObject} to parse + * + * @param json the {@link JSONObject} to parse * @return the parsed object - * @throws ParseException - * if parsing fails + * @throws ParseException if parsing fails */ @Override public IGPSObject parse(final JSONObject json) throws ParseException { diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index 41655ad..f09343d 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -29,7 +29,7 @@ /** * thread reading input from GPSd server - * + * * @author thoeger */ public class SocketThread extends Thread { @@ -44,12 +44,9 @@ public class SocketThread extends Thread { private final WaitableBoolean running = new WaitableBoolean(true); - /** - * @param reader - * the socket input - * @param endpoint - * the endpoint + * @param reader the socket input + * @param endpoint the endpoint * @param resultParser */ public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, final AbstractResultParser resultParser) { @@ -89,25 +86,24 @@ public void run() { } catch (final Exception e) { // TODO handle this better SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line", e); - } + } } - if( running.get() && !Thread.interrupted()){ + if (running.get() && !Thread.interrupted()) { SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line, attempting restart"); retry(); } } - - protected void retry(){ + protected void retry() { SocketThread.LOG.debug("Disconnected from GPS socket, retrying connection"); - - while(this.running.get()){ + + while (this.running.get()) { try { running.waitFor(1000); this.endpoint.handleDisconnected(); SocketThread.LOG.debug("Reconnected to GPS socket"); running.set(false); - } catch (InterruptedException ix){ + } catch (InterruptedException ix) { break; } catch (IOException e) { SocketThread.LOG.debug("Still disconnected from GPS socket, retrying connection again"); @@ -117,7 +113,7 @@ protected void retry(){ /** * Halts the socket thread. - * + * * @throws InterruptedException */ public void halt() throws InterruptedException { diff --git a/src/main/java/de/taimos/gpsd4java/types/ATTObject.java b/src/main/java/de/taimos/gpsd4java/types/ATTObject.java index 95d16e3..c6e9fdd 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ATTObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/ATTObject.java @@ -25,15 +25,17 @@ * heading, pitch, roll, yaw, gyroscope, and magnetic-field readings. Because such sensors are often bundled as part of marine-navigation * systems, the ATT response may also include water depth.
*
- * + *

* all getters for double values may return Double.NaN if value is not present
* other getters may return null - * + * * @author thoeger */ public class ATTObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "ATT"; private String tag = null; @@ -84,10 +86,9 @@ public class ATTObject implements IGPSObject { private String rollState = null; - /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * + * * @return the tag */ public String getTag() { @@ -96,9 +97,8 @@ public String getTag() { /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag - * the tag to set + * + * @param tag the tag to set */ public void setTag(final String tag) { this.tag = tag; @@ -106,7 +106,7 @@ public void setTag(final String tag) { /** * Name of originating device - * + * * @return the device */ public String getDevice() { @@ -115,9 +115,8 @@ public String getDevice() { /** * Name of originating device - * - * @param device - * the device to set + * + * @param device the device to set */ public void setDevice(final String device) { this.device = device; @@ -125,7 +124,7 @@ public void setDevice(final String device) { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * + * * @return the timestamp */ public double getTimestamp() { @@ -134,9 +133,8 @@ public double getTimestamp() { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @param timestamp - * the timestamp to set + * + * @param timestamp the timestamp to set */ public void setTimestamp(final double timestamp) { this.timestamp = timestamp; @@ -144,7 +142,7 @@ public void setTimestamp(final double timestamp) { /** * Heading, degrees from true north. - * + * * @return the heading */ public double getHeading() { @@ -153,9 +151,8 @@ public double getHeading() { /** * Heading, degrees from true north. - * - * @param heading - * the heading to set + * + * @param heading the heading to set */ public void setHeading(final double heading) { this.heading = heading; @@ -163,7 +160,7 @@ public void setHeading(final double heading) { /** * Pitch in degrees. - * + * * @return the pitch */ public double getPitch() { @@ -172,9 +169,8 @@ public double getPitch() { /** * Pitch in degrees. - * - * @param pitch - * the pitch to set + * + * @param pitch the pitch to set */ public void setPitch(final double pitch) { this.pitch = pitch; @@ -182,7 +178,7 @@ public void setPitch(final double pitch) { /** * Yaw in degrees - * + * * @return the yaw */ public double getYaw() { @@ -191,9 +187,8 @@ public double getYaw() { /** * Yaw in degrees - * - * @param yaw - * the yaw to set + * + * @param yaw the yaw to set */ public void setYaw(final double yaw) { this.yaw = yaw; @@ -201,7 +196,7 @@ public void setYaw(final double yaw) { /** * Roll in degrees. - * + * * @return the roll */ public double getRoll() { @@ -210,9 +205,8 @@ public double getRoll() { /** * Roll in degrees. - * - * @param roll - * the roll to set + * + * @param roll the roll to set */ public void setRoll(final double roll) { this.roll = roll; @@ -220,7 +214,7 @@ public void setRoll(final double roll) { /** * Roll in degrees. - * + * * @return the dip */ public double getDip() { @@ -229,9 +223,8 @@ public double getDip() { /** * Roll in degrees. - * - * @param dip - * the dip to set + * + * @param dip the dip to set */ public void setDip(final double dip) { this.dip = dip; @@ -239,7 +232,7 @@ public void setDip(final double dip) { /** * Scalar magnetic field strength. - * + * * @return the mag_len */ public double getMag_len() { @@ -248,9 +241,8 @@ public double getMag_len() { /** * Scalar magnetic field strength. - * - * @param mag_len - * the mag_len to set + * + * @param mag_len the mag_len to set */ public void setMag_len(final double mag_len) { this.mag_len = mag_len; @@ -258,7 +250,7 @@ public void setMag_len(final double mag_len) { /** * X component of magnetic field strength. - * + * * @return the mag_x */ public double getMag_x() { @@ -267,9 +259,8 @@ public double getMag_x() { /** * X component of magnetic field strength. - * - * @param mag_x - * the mag_x to set + * + * @param mag_x the mag_x to set */ public void setMag_x(final double mag_x) { this.mag_x = mag_x; @@ -277,7 +268,7 @@ public void setMag_x(final double mag_x) { /** * Y component of magnetic field strength. - * + * * @return the mag_y */ public double getMag_y() { @@ -286,9 +277,8 @@ public double getMag_y() { /** * Y component of magnetic field strength. - * - * @param mag_y - * the mag_y to set + * + * @param mag_y the mag_y to set */ public void setMag_y(final double mag_y) { this.mag_y = mag_y; @@ -296,7 +286,7 @@ public void setMag_y(final double mag_y) { /** * Z component of magnetic field strength. - * + * * @return the mag_z */ public double getMag_z() { @@ -305,9 +295,8 @@ public double getMag_z() { /** * Z component of magnetic field strength. - * - * @param mag_z - * the mag_z to set + * + * @param mag_z the mag_z to set */ public void setMag_z(final double mag_z) { this.mag_z = mag_z; @@ -315,7 +304,7 @@ public void setMag_z(final double mag_z) { /** * Scalar acceleration. - * + * * @return the acc_len */ public double getAcc_len() { @@ -324,9 +313,8 @@ public double getAcc_len() { /** * Scalar acceleration. - * - * @param acc_len - * the acc_len to set + * + * @param acc_len the acc_len to set */ public void setAcc_len(final double acc_len) { this.acc_len = acc_len; @@ -334,7 +322,7 @@ public void setAcc_len(final double acc_len) { /** * X component of acceleration. - * + * * @return the acc_x */ public double getAcc_x() { @@ -343,9 +331,8 @@ public double getAcc_x() { /** * X component of acceleration. - * - * @param acc_x - * the acc_x to set + * + * @param acc_x the acc_x to set */ public void setAcc_x(final double acc_x) { this.acc_x = acc_x; @@ -353,7 +340,7 @@ public void setAcc_x(final double acc_x) { /** * Y component of acceleration. - * + * * @return the acc_y */ public double getAcc_y() { @@ -362,9 +349,8 @@ public double getAcc_y() { /** * Y component of acceleration. - * - * @param acc_y - * the acc_y to set + * + * @param acc_y the acc_y to set */ public void setAcc_y(final double acc_y) { this.acc_y = acc_y; @@ -372,7 +358,7 @@ public void setAcc_y(final double acc_y) { /** * Z component of acceleration. - * + * * @return the acc_z */ public double getAcc_z() { @@ -381,9 +367,8 @@ public double getAcc_z() { /** * Z component of acceleration. - * - * @param acc_z - * the acc_z to set + * + * @param acc_z the acc_z to set */ public void setAcc_z(final double acc_z) { this.acc_z = acc_z; @@ -391,7 +376,7 @@ public void setAcc_z(final double acc_z) { /** * X component of acceleration. - * + * * @return the gyro_x */ public double getGyro_x() { @@ -400,9 +385,8 @@ public double getGyro_x() { /** * X component of acceleration. - * - * @param gyro_x - * the gyro_x to set + * + * @param gyro_x the gyro_x to set */ public void setGyro_x(final double gyro_x) { this.gyro_x = gyro_x; @@ -410,7 +394,7 @@ public void setGyro_x(final double gyro_x) { /** * Y component of acceleration. - * + * * @return the gyro_y */ public double getGyro_y() { @@ -419,9 +403,8 @@ public double getGyro_y() { /** * Y component of acceleration. - * - * @param gyro_y - * the gyro_y to set + * + * @param gyro_y the gyro_y to set */ public void setGyro_y(final double gyro_y) { this.gyro_y = gyro_y; @@ -429,7 +412,7 @@ public void setGyro_y(final double gyro_y) { /** * Water depth in meters. - * + * * @return the depth */ public double getDepth() { @@ -438,9 +421,8 @@ public double getDepth() { /** * Water depth in meters. - * - * @param depth - * the depth to set + * + * @param depth the depth to set */ public void setDepth(final double depth) { this.depth = depth; @@ -448,7 +430,7 @@ public void setDepth(final double depth) { /** * Temperature at sensor, degrees centigrade. - * + * * @return the temperature */ public double getTemperature() { @@ -457,9 +439,8 @@ public double getTemperature() { /** * Temperature at sensor, degrees centigrade. - * - * @param temperature - * the temperature to set + * + * @param temperature the temperature to set */ public void setTemperature(final double temperature) { this.temperature = temperature; @@ -467,7 +448,7 @@ public void setTemperature(final double temperature) { /** * Magnetometer status. - * + * * @return the magState */ public String getMagState() { @@ -476,9 +457,8 @@ public String getMagState() { /** * Magnetometer status. - * - * @param magState - * the magState to set + * + * @param magState the magState to set */ public void setMagState(final String magState) { this.magState = magState; @@ -486,7 +466,7 @@ public void setMagState(final String magState) { /** * Pitch sensor status. - * + * * @return the pitchState */ public String getPitchState() { @@ -495,9 +475,8 @@ public String getPitchState() { /** * Pitch sensor status. - * - * @param pitchState - * the pitchState to set + * + * @param pitchState the pitchState to set */ public void setPitchState(final String pitchState) { this.pitchState = pitchState; @@ -505,7 +484,7 @@ public void setPitchState(final String pitchState) { /** * Yaw sensor status. - * + * * @return the yawState */ public String getYawState() { @@ -514,9 +493,8 @@ public String getYawState() { /** * Yaw sensor status. - * - * @param yawState - * the yawState to set + * + * @param yawState the yawState to set */ public void setYawState(final String yawState) { this.yawState = yawState; @@ -524,7 +502,7 @@ public void setYawState(final String yawState) { /** * Roll sensor status. - * + * * @return the rollState */ public String getRollState() { @@ -533,9 +511,8 @@ public String getRollState() { /** * Roll sensor status. - * - * @param rollState - * the rollState to set + * + * @param rollState the rollState to set */ public void setRollState(final String rollState) { this.rollState = rollState; diff --git a/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java b/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java index b1f647f..39601bc 100644 --- a/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java @@ -21,12 +21,13 @@ */ /** - * * @author thoeger */ public class DeviceObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "DEVICE"; private String path; @@ -47,10 +48,9 @@ public class DeviceObject implements IGPSObject { private double mincycle; - /** * Name the device for which the control bits are being reported - * + * * @return the path */ public String getPath() { @@ -59,9 +59,8 @@ public String getPath() { /** * Name the device for which the control bits are being reported - * - * @param path - * the path to set + * + * @param path the path to set */ public void setPath(final String path) { this.path = path; @@ -69,7 +68,7 @@ public void setPath(final String path) { /** * Time the device was activated, or 0 if it is being closed. - * + * * @return the activated */ public double getActivated() { @@ -78,9 +77,8 @@ public double getActivated() { /** * Time the device was activated, or 0 if it is being closed. - * - * @param activated - * the activated to set + * + * @param activated the activated to set */ public void setActivated(final double activated) { this.activated = activated; @@ -88,7 +86,7 @@ public void setActivated(final double activated) { /** * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable packets from the device. - * + * * @return the driver */ public String getDriver() { @@ -97,9 +95,8 @@ public String getDriver() { /** * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable packets from the device. - * - * @param driver - * the driver to set + * + * @param driver the driver to set */ public void setDriver(final String driver) { this.driver = driver; @@ -107,7 +104,7 @@ public void setDriver(final String driver) { /** * Device speed in bits per second. - * + * * @return the bps */ public int getBps() { @@ -116,9 +113,8 @@ public int getBps() { /** * Device speed in bits per second. - * - * @param bps - * the bps to set + * + * @param bps the bps to set */ public void setBps(final int bps) { this.bps = bps; @@ -126,7 +122,7 @@ public void setBps(final int bps) { /** * Device parity - * + * * @return the parity */ public EParity getParity() { @@ -135,9 +131,8 @@ public EParity getParity() { /** * Device parity - * - * @param parity - * the parity to set + * + * @param parity the parity to set */ public void setParity(final EParity parity) { this.parity = parity; @@ -145,7 +140,7 @@ public void setParity(final EParity parity) { /** * Device Stopbits - * + * * @return the stopbit */ public int getStopbit() { @@ -154,9 +149,8 @@ public int getStopbit() { /** * Device Stopbits - * - * @param stopbit - * the stopbit to set + * + * @param stopbit the stopbit to set */ public void setStopbit(final int stopbit) { this.stopbit = stopbit; @@ -164,7 +158,7 @@ public void setStopbit(final int stopbit) { /** * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and Evermore chipsets in particular). - * + * * @return the nativeMode */ public boolean isNativeMode() { @@ -173,9 +167,8 @@ public boolean isNativeMode() { /** * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and Evermore chipsets in particular). - * - * @param nativeMode - * the nativeMode to set + * + * @param nativeMode the nativeMode to set */ public void setNativeMode(final boolean nativeMode) { this.nativeMode = nativeMode; @@ -183,7 +176,7 @@ public void setNativeMode(final boolean nativeMode) { /** * Device cycle time in seconds. - * + * * @return the cycle */ public double getCycle() { @@ -192,9 +185,8 @@ public double getCycle() { /** * Device cycle time in seconds. - * - * @param cycle - * the cycle to set + * + * @param cycle the cycle to set */ public void setCycle(final double cycle) { this.cycle = cycle; @@ -202,7 +194,7 @@ public void setCycle(final double cycle) { /** * Device minimum cycle time in seconds. - * + * * @return the mincycle */ public double getMincycle() { @@ -211,9 +203,8 @@ public double getMincycle() { /** * Device minimum cycle time in seconds. - * - * @param mincycle - * the mincycle to set + * + * @param mincycle the mincycle to set */ public void setMincycle(final double mincycle) { this.mincycle = mincycle; diff --git a/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java b/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java index 0fa9ddd..f35552d 100644 --- a/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java @@ -23,20 +23,20 @@ import java.util.List; /** - * * @author thoeger */ public class DevicesObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "DEVICES"; private List devices; - /** * list of devices - * + * * @return the devices */ public List getDevices() { @@ -45,9 +45,8 @@ public List getDevices() { /** * list of devices - * - * @param devices - * the devices to set + * + * @param devices the devices to set */ public void setDevices(final List devices) { this.devices = devices; diff --git a/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java b/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java index 4b6ebd1..10e453a 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java +++ b/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java @@ -22,7 +22,7 @@ /** * NMEA Mode of GPSd response - * + * * @author thoeger */ public enum ENMEAMode { @@ -45,8 +45,7 @@ public enum ENMEAMode { ThreeDimensional; /** - * @param mode - * - mode integer + * @param mode - mode integer * @return {@link ENMEAMode} */ public static ENMEAMode fromInt(final int mode) { diff --git a/src/main/java/de/taimos/gpsd4java/types/EParity.java b/src/main/java/de/taimos/gpsd4java/types/EParity.java index e94b245..3f0f2bc 100644 --- a/src/main/java/de/taimos/gpsd4java/types/EParity.java +++ b/src/main/java/de/taimos/gpsd4java/types/EParity.java @@ -21,27 +21,25 @@ */ /** - * * @author thoeger */ public enum EParity { /** - * + * */ NO, /** - * + * */ ODD, /** - * + * */ EVEN; /** - * @param parity - * the parity string + * @param parity the parity string * @return {@link EParity} */ public static EParity fromString(final String parity) { diff --git a/src/main/java/de/taimos/gpsd4java/types/GSTObject.java b/src/main/java/de/taimos/gpsd4java/types/GSTObject.java index ea619b4..d581b21 100644 --- a/src/main/java/de/taimos/gpsd4java/types/GSTObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/GSTObject.java @@ -24,12 +24,14 @@ * A GST object is a pseudorange noise report.
* all getters for double values may return Double.NaN if value is not present
* other getters may return null - * + * * @author thoeger */ public class GSTObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "GST"; private String tag = null; @@ -52,10 +54,9 @@ public class GSTObject implements IGPSObject { private double alt = Double.NaN; - /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * + * * @return the tag */ public String getTag() { @@ -64,9 +65,8 @@ public String getTag() { /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag - * the tag to set + * + * @param tag the tag to set */ public void setTag(final String tag) { this.tag = tag; @@ -74,7 +74,7 @@ public void setTag(final String tag) { /** * Name of originating device - * + * * @return the device */ public String getDevice() { @@ -83,9 +83,8 @@ public String getDevice() { /** * Name of originating device - * - * @param device - * the device to set + * + * @param device the device to set */ public void setDevice(final String device) { this.device = device; @@ -93,7 +92,7 @@ public void setDevice(final String device) { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * + * * @return the timestamp */ public double getTimestamp() { @@ -102,9 +101,8 @@ public double getTimestamp() { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @param timestamp - * the timestamp to set + * + * @param timestamp the timestamp to set */ public void setTimestamp(final double timestamp) { this.timestamp = timestamp; @@ -113,7 +111,7 @@ public void setTimestamp(final double timestamp) { /** * Value of the standard deviation of the range inputs to the navigation process (range inputs include pseudoranges and DGPS * corrections). - * + * * @return the rms */ public double getRms() { @@ -123,9 +121,8 @@ public double getRms() { /** * Value of the standard deviation of the range inputs to the navigation process (range inputs include pseudoranges and DGPS * corrections). - * - * @param rms - * the rms to set + * + * @param rms the rms to set */ public void setRms(final double rms) { this.rms = rms; @@ -133,7 +130,7 @@ public void setRms(final double rms) { /** * Standard deviation of semi-major axis of error ellipse, in meters. - * + * * @return the major */ public double getMajor() { @@ -142,9 +139,8 @@ public double getMajor() { /** * Standard deviation of semi-major axis of error ellipse, in meters. - * - * @param major - * the major to set + * + * @param major the major to set */ public void setMajor(final double major) { this.major = major; @@ -152,7 +148,7 @@ public void setMajor(final double major) { /** * Standard deviation of semi-minor axis of error ellipse, in meters. - * + * * @return the minor */ public double getMinor() { @@ -161,9 +157,8 @@ public double getMinor() { /** * Standard deviation of semi-minor axis of error ellipse, in meters. - * - * @param minor - * the minor to set + * + * @param minor the minor to set */ public void setMinor(final double minor) { this.minor = minor; @@ -171,7 +166,7 @@ public void setMinor(final double minor) { /** * Orientation of semi-major axis of error ellipse, in degrees from true north. - * + * * @return the orient */ public double getOrient() { @@ -180,9 +175,8 @@ public double getOrient() { /** * Orientation of semi-major axis of error ellipse, in degrees from true north. - * - * @param orient - * the orient to set + * + * @param orient the orient to set */ public void setOrient(final double orient) { this.orient = orient; @@ -190,7 +184,7 @@ public void setOrient(final double orient) { /** * Standard deviation of latitude error, in meters. - * + * * @return the lat */ public double getLat() { @@ -199,9 +193,8 @@ public double getLat() { /** * Standard deviation of latitude error, in meters. - * - * @param lat - * the lat to set + * + * @param lat the lat to set */ public void setLat(final double lat) { this.lat = lat; @@ -209,7 +202,7 @@ public void setLat(final double lat) { /** * Standard deviation of longitude error, in meters. - * + * * @return the lon */ public double getLon() { @@ -218,9 +211,8 @@ public double getLon() { /** * Standard deviation of longitude error, in meters. - * - * @param lon - * the lon to set + * + * @param lon the lon to set */ public void setLon(final double lon) { this.lon = lon; @@ -228,7 +220,7 @@ public void setLon(final double lon) { /** * Standard deviation of altitude error, in meters. - * + * * @return the alt */ public double getAlt() { @@ -237,9 +229,8 @@ public double getAlt() { /** * Standard deviation of altitude error, in meters. - * - * @param alt - * the alt to set + * + * @param alt the alt to set */ public void setAlt(final double alt) { this.alt = alt; diff --git a/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java b/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java index e034f9b..5851a18 100644 --- a/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java @@ -22,7 +22,7 @@ /** * Interface for generic GPSd object - * + * * @author thoeger */ public interface IGPSObject { diff --git a/src/main/java/de/taimos/gpsd4java/types/ParseException.java b/src/main/java/de/taimos/gpsd4java/types/ParseException.java index 047d509..9f4fce0 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ParseException.java +++ b/src/main/java/de/taimos/gpsd4java/types/ParseException.java @@ -22,42 +22,37 @@ /** * {@link Exception} indication an error while parsing the GPSd line - * + * * @author thoeger */ public class ParseException extends Exception { private static final long serialVersionUID = 7747422116792199432L; - /** - * + * */ public ParseException() { super(); } /** - * @param message - * the message + * @param message the message */ public ParseException(final String message) { super(message); } /** - * @param message - * the message - * @param cause - * the cause + * @param message the message + * @param cause the cause */ public ParseException(final String message, final Throwable cause) { super(message, cause); } /** - * @param cause - * the cause + * @param cause the cause */ public ParseException(final Throwable cause) { super(cause); diff --git a/src/main/java/de/taimos/gpsd4java/types/PollObject.java b/src/main/java/de/taimos/gpsd4java/types/PollObject.java index 767ff8e..3e4ae66 100644 --- a/src/main/java/de/taimos/gpsd4java/types/PollObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/PollObject.java @@ -23,12 +23,13 @@ import java.util.List; /** - * * @author thoeger */ public class PollObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "POLL"; private double timestamp; @@ -41,10 +42,9 @@ public class PollObject implements IGPSObject { private List gst; - /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * + * * @return the timestamp */ public double getTimestamp() { @@ -53,9 +53,8 @@ public double getTimestamp() { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @param timestamp - * the timestamp to set + * + * @param timestamp the timestamp to set */ public void setTimestamp(final double timestamp) { this.timestamp = timestamp; @@ -63,7 +62,7 @@ public void setTimestamp(final double timestamp) { /** * Count of active devices. - * + * * @return the active */ public int getActive() { @@ -72,9 +71,8 @@ public int getActive() { /** * Count of active devices. - * - * @param active - * the active to set + * + * @param active the active to set */ public void setActive(final int active) { this.active = active; @@ -82,7 +80,7 @@ public void setActive(final int active) { /** * list of TPV objects - * + * * @return the fixes */ public List getFixes() { @@ -91,9 +89,8 @@ public List getFixes() { /** * list of TPV objects - * - * @param fixes - * the fixes to set + * + * @param fixes the fixes to set */ public void setFixes(final List fixes) { this.fixes = fixes; @@ -101,7 +98,7 @@ public void setFixes(final List fixes) { /** * list of SKY objects - * + * * @return the skyviews */ public List getSkyviews() { @@ -110,9 +107,8 @@ public List getSkyviews() { /** * list of SKY objects - * - * @param skyviews - * the skyviews to set + * + * @param skyviews the skyviews to set */ public void setSkyviews(final List skyviews) { this.skyviews = skyviews; @@ -126,8 +122,7 @@ public List getGst() { } /** - * @param gst - * the gst to set + * @param gst the gst to set */ public void setGst(final List gst) { this.gst = gst; diff --git a/src/main/java/de/taimos/gpsd4java/types/SATObject.java b/src/main/java/de/taimos/gpsd4java/types/SATObject.java index 2e66a46..df109bd 100644 --- a/src/main/java/de/taimos/gpsd4java/types/SATObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/SATObject.java @@ -21,12 +21,13 @@ */ /** - * * @author aevdokimov */ public class SATObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "SAT"; private int PRN = -1; @@ -39,10 +40,9 @@ public class SATObject implements IGPSObject { private boolean used = false; - /** * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites - * + * * @return PRN */ public int getPRN() { @@ -51,9 +51,8 @@ public int getPRN() { /** * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites - * - * @param PRN - * the PRN to set + * + * @param PRN the PRN to set */ public void setPRN(final int PRN) { this.PRN = PRN; @@ -61,7 +60,7 @@ public void setPRN(final int PRN) { /** * Azimuth, degrees from true north. - * + * * @return azimuth */ public int getAzimuth() { @@ -70,9 +69,8 @@ public int getAzimuth() { /** * Azimuth, degrees from true north. - * - * @param azimuth - * the azimuth to set + * + * @param azimuth the azimuth to set */ public void setAzimuth(final int azimuth) { this.azimuth = azimuth; @@ -80,7 +78,7 @@ public void setAzimuth(final int azimuth) { /** * Elevation in degrees. - * + * * @return elevation */ public int getElevation() { @@ -89,9 +87,8 @@ public int getElevation() { /** * Elevation in degrees. - * - * @param elevation - * the elevation to set + * + * @param elevation the elevation to set */ public void setElevation(final int elevation) { this.elevation = elevation; @@ -99,7 +96,7 @@ public void setElevation(final int elevation) { /** * Signal strength in dB. - * + * * @return signal strength */ public int getSignalStrength() { @@ -108,9 +105,8 @@ public int getSignalStrength() { /** * Signal strength in dB. - * - * @param signalStrength - * the signal strength to set + * + * @param signalStrength the signal strength to set */ public void setSignalStrength(final int signalStrength) { this.signalStrength = signalStrength; @@ -119,7 +115,7 @@ public void setSignalStrength(final int signalStrength) { /** * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all * drivers make this information available.) - * + * * @return used */ public boolean getUsed() { @@ -129,9 +125,8 @@ public boolean getUsed() { /** * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all * drivers make this information available.) - * - * @param used - * the used flag to set + * + * @param used the used flag to set */ public void setUsed(final boolean used) { this.used = used; diff --git a/src/main/java/de/taimos/gpsd4java/types/SKYObject.java b/src/main/java/de/taimos/gpsd4java/types/SKYObject.java index 701d115..bff720c 100644 --- a/src/main/java/de/taimos/gpsd4java/types/SKYObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/SKYObject.java @@ -23,13 +23,14 @@ import java.util.List; /** - * * @author thoeger * @author aevdokimov */ public class SKYObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "SKY"; private String tag = null; @@ -54,10 +55,9 @@ public class SKYObject implements IGPSObject { private List satellites; - /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * + * * @return the tag */ public String getTag() { @@ -66,9 +66,8 @@ public String getTag() { /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag - * the tag to set + * + * @param tag the tag to set */ public void setTag(final String tag) { this.tag = tag; @@ -76,7 +75,7 @@ public void setTag(final String tag) { /** * Name of originating device - * + * * @return the device */ public String getDevice() { @@ -85,9 +84,8 @@ public String getDevice() { /** * Name of originating device - * - * @param device - * the device to set + * + * @param device the device to set */ public void setDevice(final String device) { this.device = device; @@ -95,7 +93,7 @@ public void setDevice(final String device) { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * + * * @return the timestamp */ public double getTimestamp() { @@ -104,9 +102,8 @@ public double getTimestamp() { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * - * @param timestamp - * the timestamp to set + * + * @param timestamp the timestamp to set */ public void setTimestamp(final double timestamp) { this.timestamp = timestamp; @@ -114,7 +111,7 @@ public void setTimestamp(final double timestamp) { /** * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * + * * @return the longitude DOP */ public double getLongitudeDOP() { @@ -123,9 +120,8 @@ public double getLongitudeDOP() { /** * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param longitudeDOP - * the longitude DOP to set + * + * @param longitudeDOP the longitude DOP to set */ public void setLongitudeDOP(final double longitudeDOP) { this.longitudeDOP = longitudeDOP; @@ -133,7 +129,7 @@ public void setLongitudeDOP(final double longitudeDOP) { /** * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * + * * @return the latitude DOP */ public double getLatitudeDOP() { @@ -142,9 +138,8 @@ public double getLatitudeDOP() { /** * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param latitudeDOP - * the latitude DOP to set + * + * @param latitudeDOP the latitude DOP to set */ public void setLatitudeDOP(final double latitudeDOP) { this.latitudeDOP = latitudeDOP; @@ -152,7 +147,7 @@ public void setLatitudeDOP(final double latitudeDOP) { /** * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * + * * @return the altitude DOP */ public double getAltitudeDOP() { @@ -161,9 +156,8 @@ public double getAltitudeDOP() { /** * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param altitudeDOP - * the altitude DOP to set + * + * @param altitudeDOP the altitude DOP to set */ public void setAltitudeDOP(final double altitudeDOP) { this.altitudeDOP = altitudeDOP; @@ -171,7 +165,7 @@ public void setAltitudeDOP(final double altitudeDOP) { /** * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * + * * @return the timestamp DOP */ public double getTimestampDOP() { @@ -180,9 +174,8 @@ public double getTimestampDOP() { /** * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param timestampDOP - * the timestamp DOP to set + * + * @param timestampDOP the timestamp DOP to set */ public void setTimestampDOP(final double timestampDOP) { this.timestampDOP = timestampDOP; @@ -190,7 +183,7 @@ public void setTimestampDOP(final double timestampDOP) { /** * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get a circular error estimate. - * + * * @return the horizontal DOP */ public double getHorizontalDOP() { @@ -199,9 +192,8 @@ public double getHorizontalDOP() { /** * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get a circular error estimate. - * - * @param horizontalDOP - * the horizontal DOP to set + * + * @param horizontalDOP the horizontal DOP to set */ public void setHorizontalDOP(final double horizontalDOP) { this.horizontalDOP = horizontalDOP; @@ -209,7 +201,7 @@ public void setHorizontalDOP(final double horizontalDOP) { /** * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * + * * @return the spherical DOP */ public double getSphericalDOP() { @@ -218,9 +210,8 @@ public double getSphericalDOP() { /** * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param sphericalDOP - * the spherical DOP to set + * + * @param sphericalDOP the spherical DOP to set */ public void setSphericalDOP(final double sphericalDOP) { this.sphericalDOP = sphericalDOP; @@ -228,7 +219,7 @@ public void setSphericalDOP(final double sphericalDOP) { /** * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * + * * @return the hyperspherical DOP */ public double getHypersphericalDOP() { @@ -237,9 +228,8 @@ public double getHypersphericalDOP() { /** * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param hypersphericalDOP - * the hyperspherical DOP to set + * + * @param hypersphericalDOP the hyperspherical DOP to set */ public void setHypersphericalDOP(final double hypersphericalDOP) { this.hypersphericalDOP = hypersphericalDOP; @@ -247,7 +237,7 @@ public void setHypersphericalDOP(final double hypersphericalDOP) { /** * list of Satellite objects - * + * * @return the satellites */ public List getSatellites() { @@ -256,9 +246,8 @@ public List getSatellites() { /** * list of Satellite objects - * - * @param satellites - * the satellites to set + * + * @param satellites the satellites to set */ public void setSatellites(final List satellites) { this.satellites = satellites; diff --git a/src/main/java/de/taimos/gpsd4java/types/TPVObject.java b/src/main/java/de/taimos/gpsd4java/types/TPVObject.java index fc187ae..e24f8ae 100644 --- a/src/main/java/de/taimos/gpsd4java/types/TPVObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/TPVObject.java @@ -25,12 +25,14 @@ *
* all getters for double values may return Double.NaN if value is not present
* other getters may return null - * + * * @author thoeger */ public class TPVObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "TPV"; private String tag = null; @@ -67,10 +69,9 @@ public class TPVObject implements IGPSObject { private ENMEAMode mode; - /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * + * * @return the tag */ public String getTag() { @@ -79,9 +80,8 @@ public String getTag() { /** * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag - * the tag to set + * + * @param tag the tag to set */ public void setTag(final String tag) { this.tag = tag; @@ -89,7 +89,7 @@ public void setTag(final String tag) { /** * Name of originating device - * + * * @return the device */ public String getDevice() { @@ -98,9 +98,8 @@ public String getDevice() { /** * Name of originating device - * - * @param device - * the device to set + * + * @param device the device to set */ public void setDevice(final String device) { this.device = device; @@ -108,7 +107,7 @@ public void setDevice(final String device) { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * + * * @return the timestamp */ public double getTimestamp() { @@ -117,9 +116,8 @@ public double getTimestamp() { /** * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * - * @param timestamp - * the timestamp to set + * + * @param timestamp the timestamp to set */ public void setTimestamp(final double timestamp) { this.timestamp = timestamp; @@ -127,7 +125,7 @@ public void setTimestamp(final double timestamp) { /** * Estimated timestamp error (%f, seconds, 95% confidence). - * + * * @return the timestampError */ public double getTimestampError() { @@ -136,9 +134,8 @@ public double getTimestampError() { /** * Estimated timestamp error (%f, seconds, 95% confidence). - * - * @param timestampError - * the timestampError to set + * + * @param timestampError the timestampError to set */ public void setTimestampError(final double timestampError) { this.timestampError = timestampError; @@ -146,7 +143,7 @@ public void setTimestampError(final double timestampError) { /** * Latitude in degrees: +/- signifies North/South - * + * * @return the latitude */ public double getLatitude() { @@ -155,9 +152,8 @@ public double getLatitude() { /** * Latitude in degrees: +/- signifies North/South - * - * @param latitude - * the latitude to set + * + * @param latitude the latitude to set */ public void setLatitude(final double latitude) { this.latitude = latitude; @@ -165,7 +161,7 @@ public void setLatitude(final double latitude) { /** * Longitude in degrees: +/- signifies East/West - * + * * @return the longitude */ public double getLongitude() { @@ -174,9 +170,8 @@ public double getLongitude() { /** * Longitude in degrees: +/- signifies East/West - * - * @param longitude - * the longitude to set + * + * @param longitude the longitude to set */ public void setLongitude(final double longitude) { this.longitude = longitude; @@ -184,7 +179,7 @@ public void setLongitude(final double longitude) { /** * Altitude in meters. - * + * * @return the altitude */ public double getAltitude() { @@ -193,9 +188,8 @@ public double getAltitude() { /** * Altitude in meters. - * - * @param altitude - * the altitude to set + * + * @param altitude the altitude to set */ public void setAltitude(final double altitude) { this.altitude = altitude; @@ -203,7 +197,7 @@ public void setAltitude(final double altitude) { /** * Latitude error estimate in meters, 95% confidence. - * + * * @return the latitudeError */ public double getLatitudeError() { @@ -212,9 +206,8 @@ public double getLatitudeError() { /** * Latitude error estimate in meters, 95% confidence. - * - * @param latitudeError - * the latitudeError to set + * + * @param latitudeError the latitudeError to set */ public void setLatitudeError(final double latitudeError) { this.latitudeError = latitudeError; @@ -222,7 +215,7 @@ public void setLatitudeError(final double latitudeError) { /** * Longitude error estimate in meters, 95% confidence. - * + * * @return the longitudeError */ public double getLongitudeError() { @@ -231,9 +224,8 @@ public double getLongitudeError() { /** * Longitude error estimate in meters, 95% confidence. - * - * @param longitudeError - * the longitudeError to set + * + * @param longitudeError the longitudeError to set */ public void setLongitudeError(final double longitudeError) { this.longitudeError = longitudeError; @@ -241,7 +233,7 @@ public void setLongitudeError(final double longitudeError) { /** * Estimated vertical error in meters, 95% confidence. - * + * * @return the altitudeError */ public double getAltitudeError() { @@ -250,9 +242,8 @@ public double getAltitudeError() { /** * Estimated vertical error in meters, 95% confidence. - * - * @param altitudeError - * the altitudeError to set + * + * @param altitudeError the altitudeError to set */ public void setAltitudeError(final double altitudeError) { this.altitudeError = altitudeError; @@ -260,7 +251,7 @@ public void setAltitudeError(final double altitudeError) { /** * Course over ground, degrees from true north. - * + * * @return the course */ public double getCourse() { @@ -269,9 +260,8 @@ public double getCourse() { /** * Course over ground, degrees from true north. - * - * @param course - * the course to set + * + * @param course the course to set */ public void setCourse(final double course) { this.course = course; @@ -279,7 +269,7 @@ public void setCourse(final double course) { /** * Speed over ground, meters per second. - * + * * @return the speed */ public double getSpeed() { @@ -288,9 +278,8 @@ public double getSpeed() { /** * Speed over ground, meters per second. - * - * @param speed - * the speed to set + * + * @param speed the speed to set */ public void setSpeed(final double speed) { this.speed = speed; @@ -298,7 +287,7 @@ public void setSpeed(final double speed) { /** * Climb (positive) or sink (negative) rate, meters per second. - * + * * @return the climbRate */ public double getClimbRate() { @@ -307,9 +296,8 @@ public double getClimbRate() { /** * Climb (positive) or sink (negative) rate, meters per second. - * - * @param climbRate - * the climbRate to set + * + * @param climbRate the climbRate to set */ public void setClimbRate(final double climbRate) { this.climbRate = climbRate; @@ -317,7 +305,7 @@ public void setClimbRate(final double climbRate) { /** * Direction error estimate in degrees, 95% confidence. - * + * * @return the courseError */ public double getCourseError() { @@ -326,9 +314,8 @@ public double getCourseError() { /** * Direction error estimate in degrees, 95% confidence. - * - * @param courseError - * the courseError to set + * + * @param courseError the courseError to set */ public void setCourseError(final double courseError) { this.courseError = courseError; @@ -336,7 +323,7 @@ public void setCourseError(final double courseError) { /** * Speed error estimate in meters/sec, 95% confidence. - * + * * @return the speedError */ public double getSpeedError() { @@ -345,9 +332,8 @@ public double getSpeedError() { /** * Speed error estimate in meters/sec, 95% confidence. - * - * @param speedError - * the speedError to set + * + * @param speedError the speedError to set */ public void setSpeedError(final double speedError) { this.speedError = speedError; @@ -355,7 +341,7 @@ public void setSpeedError(final double speedError) { /** * Climb/sink error estimate in meters/sec, 95% confidence. - * + * * @return the climbRateError */ public double getClimbRateError() { @@ -364,9 +350,8 @@ public double getClimbRateError() { /** * Climb/sink error estimate in meters/sec, 95% confidence. - * - * @param climbRateError - * the climbRateError to set + * + * @param climbRateError the climbRateError to set */ public void setClimbRateError(final double climbRateError) { this.climbRateError = climbRateError; @@ -374,7 +359,7 @@ public void setClimbRateError(final double climbRateError) { /** * NMEA mode - * + * * @return the mode */ public ENMEAMode getMode() { @@ -383,9 +368,8 @@ public ENMEAMode getMode() { /** * NMEA mode - * - * @param mode - * the mode to set + * + * @param mode the mode to set */ public void setMode(final ENMEAMode mode) { this.mode = mode; diff --git a/src/main/java/de/taimos/gpsd4java/types/VersionObject.java b/src/main/java/de/taimos/gpsd4java/types/VersionObject.java index 06da562..50d7a90 100644 --- a/src/main/java/de/taimos/gpsd4java/types/VersionObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/VersionObject.java @@ -21,12 +21,13 @@ */ /** - * * @author thoeger */ public class VersionObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "VERSION"; private String release; @@ -37,7 +38,6 @@ public class VersionObject implements IGPSObject { private double protocolMinor; - /** * @return the release */ @@ -46,8 +46,7 @@ public String getRelease() { } /** - * @param release - * the release to set + * @param release the release to set */ public void setRelease(final String release) { this.release = release; @@ -61,8 +60,7 @@ public String getRev() { } /** - * @param rev - * the rev to set + * @param rev the rev to set */ public void setRev(final String rev) { this.rev = rev; @@ -76,8 +74,7 @@ public double getProtocolMajor() { } /** - * @param protocolMajor - * the protocolMajor to set + * @param protocolMajor the protocolMajor to set */ public void setProtocolMajor(final double protocolMajor) { this.protocolMajor = protocolMajor; @@ -91,8 +88,7 @@ public double getProtocolMinor() { } /** - * @param protocolMinor - * the protocolMinor to set + * @param protocolMinor the protocolMinor to set */ public void setProtocolMinor(final double protocolMinor) { this.protocolMinor = protocolMinor; diff --git a/src/main/java/de/taimos/gpsd4java/types/WatchObject.java b/src/main/java/de/taimos/gpsd4java/types/WatchObject.java index 6a14659..445a209 100644 --- a/src/main/java/de/taimos/gpsd4java/types/WatchObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/WatchObject.java @@ -21,22 +21,22 @@ */ /** - * * @author thoeger */ public class WatchObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "WATCH"; private boolean enable = true; private boolean dump = false; - /** * Enable (true) or disable (false) watcher mode. Default is true. - * + * * @return the enable */ public boolean isEnable() { @@ -45,9 +45,8 @@ public boolean isEnable() { /** * Enable (true) or disable (false) watcher mode. Default is true. - * - * @param enable - * the enable to set + * + * @param enable the enable to set */ public void setEnable(final boolean enable) { this.enable = enable; @@ -55,7 +54,7 @@ public void setEnable(final boolean enable) { /** * Enable (true) or disable (false) dumping of JSON reports. Default is false. - * + * * @return the json */ public boolean isDump() { @@ -64,9 +63,8 @@ public boolean isDump() { /** * Enable (true) or disable (false) dumping of JSON reports. Default is false. - * - * @param dump - * the dump to set + * + * @param dump the dump to set */ public void setDump(final boolean dump) { this.dump = dump; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java index 10e8bc0..53de4e7 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java @@ -23,12 +23,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class ALMANACObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "ALMANAC"; private int ID = -1; @@ -55,7 +56,6 @@ public class ALMANACObject implements IGPSObject { private double af1 = Double.NaN; - /** * @return the iD */ @@ -64,8 +64,7 @@ public int getID() { } /** - * @param iD - * the iD to set + * @param iD the iD to set */ public void setID(final int iD) { this.ID = iD; @@ -79,8 +78,7 @@ public int getHealth() { } /** - * @param health - * the health to set + * @param health the health to set */ public void setHealth(final int health) { this.Health = health; @@ -94,8 +92,7 @@ public double getE() { } /** - * @param e - * the e to set + * @param e the e to set */ public void setE(final double e) { this.e = e; @@ -109,8 +106,7 @@ public int getToa() { } /** - * @param toa - * the toa to set + * @param toa the toa to set */ public void setToa(final int toa) { this.toa = toa; @@ -124,8 +120,7 @@ public double getDeltai() { } /** - * @param deltai - * the deltai to set + * @param deltai the deltai to set */ public void setDeltai(final double deltai) { this.deltai = deltai; @@ -139,8 +134,7 @@ public double getOmegad() { } /** - * @param omegad - * the omegad to set + * @param omegad the omegad to set */ public void setOmegad(final double omegad) { this.Omegad = omegad; @@ -154,8 +148,7 @@ public double getSqrtA() { } /** - * @param sqrtA - * the sqrtA to set + * @param sqrtA the sqrtA to set */ public void setSqrtA(final double sqrtA) { this.sqrtA = sqrtA; @@ -169,8 +162,7 @@ public double getOmega0() { } /** - * @param omega0 - * the omega0 to set + * @param omega0 the omega0 to set */ public void setOmega0(final double omega0) { this.Omega0 = omega0; @@ -184,8 +176,7 @@ public double getOmega() { } /** - * @param omega - * the omega to set + * @param omega the omega to set */ public void setOmega(final double omega) { this.omega = omega; @@ -199,8 +190,7 @@ public double getM0() { } /** - * @param m0 - * the m0 to set + * @param m0 the m0 to set */ public void setM0(final double m0) { this.M0 = m0; @@ -214,8 +204,7 @@ public double getAf0() { } /** - * @param af0 - * the af0 to set + * @param af0 the af0 to set */ public void setAf0(final double af0) { this.af0 = af0; @@ -229,8 +218,7 @@ public double getAf1() { } /** - * @param af1 - * the af1 to set + * @param af1 the af1 to set */ public void setAf1(final double af1) { this.af1 = af1; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java index 690399f..3f39147 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java @@ -23,12 +23,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class EPHEM1Object implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "EPHEM1"; private int WN = -1; @@ -53,7 +54,6 @@ public class EPHEM1Object implements IGPSObject { private double af0 = Double.NaN; - /** * @return the wN */ @@ -62,8 +62,7 @@ public int getWN() { } /** - * @param wN - * the wN to set + * @param wN the wN to set */ public void setWN(final int wN) { this.WN = wN; @@ -77,8 +76,7 @@ public int getIODC() { } /** - * @param iODC - * the iODC to set + * @param iODC the iODC to set */ public void setIODC(final int iODC) { this.IODC = iODC; @@ -92,8 +90,7 @@ public int getL2() { } /** - * @param l2 - * the l2 to set + * @param l2 the l2 to set */ public void setL2(final int l2) { this.L2 = l2; @@ -107,8 +104,7 @@ public double getUra() { } /** - * @param ura - * the ura to set + * @param ura the ura to set */ public void setUra(final double ura) { this.ura = ura; @@ -122,8 +118,7 @@ public double getHlth() { } /** - * @param hlth - * the hlth to set + * @param hlth the hlth to set */ public void setHlth(final double hlth) { this.hlth = hlth; @@ -137,8 +132,7 @@ public int getL2P() { } /** - * @param l2p - * the l2P to set + * @param l2p the l2P to set */ public void setL2P(final int l2p) { this.L2P = l2p; @@ -152,8 +146,7 @@ public double getTgd() { } /** - * @param tgd - * the tgd to set + * @param tgd the tgd to set */ public void setTgd(final double tgd) { this.Tgd = tgd; @@ -167,8 +160,7 @@ public int getToc() { } /** - * @param toc - * the toc to set + * @param toc the toc to set */ public void setToc(final int toc) { this.toc = toc; @@ -182,8 +174,7 @@ public double getAf2() { } /** - * @param af2 - * the af2 to set + * @param af2 the af2 to set */ public void setAf2(final double af2) { this.af2 = af2; @@ -197,8 +188,7 @@ public double getAf1() { } /** - * @param af1 - * the af1 to set + * @param af1 the af1 to set */ public void setAf1(final double af1) { this.af1 = af1; @@ -212,8 +202,7 @@ public double getAf0() { } /** - * @param af0 - * the af0 to set + * @param af0 the af0 to set */ public void setAf0(final double af0) { this.af0 = af0; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java index 87ec083..5a52a4c 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java @@ -23,12 +23,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class EPHEM2Object implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "EPHEM2"; private int IODE = -1; @@ -53,7 +54,6 @@ public class EPHEM2Object implements IGPSObject { private int AODO = -1; - /** * @return the iODE */ @@ -62,8 +62,7 @@ public int getIODE() { } /** - * @param iODE - * the iODE to set + * @param iODE the iODE to set */ public void setIODE(final int iODE) { this.IODE = iODE; @@ -77,8 +76,7 @@ public double getCrs() { } /** - * @param crs - * the crs to set + * @param crs the crs to set */ public void setCrs(final double crs) { this.Crs = crs; @@ -92,8 +90,7 @@ public double getDeltan() { } /** - * @param deltan - * the deltan to set + * @param deltan the deltan to set */ public void setDeltan(final double deltan) { this.deltan = deltan; @@ -107,8 +104,7 @@ public double getM0() { } /** - * @param m0 - * the m0 to set + * @param m0 the m0 to set */ public void setM0(final double m0) { this.M0 = m0; @@ -122,8 +118,7 @@ public double getCuc() { } /** - * @param cuc - * the cuc to set + * @param cuc the cuc to set */ public void setCuc(final double cuc) { this.Cuc = cuc; @@ -137,8 +132,7 @@ public double getE() { } /** - * @param e - * the e to set + * @param e the e to set */ public void setE(final double e) { this.e = e; @@ -152,8 +146,7 @@ public double getCus() { } /** - * @param cus - * the cus to set + * @param cus the cus to set */ public void setCus(final double cus) { this.Cus = cus; @@ -167,8 +160,7 @@ public double getSqrtA() { } /** - * @param sqrtA - * the sqrtA to set + * @param sqrtA the sqrtA to set */ public void setSqrtA(final double sqrtA) { this.sqrtA = sqrtA; @@ -182,8 +174,7 @@ public int getToe() { } /** - * @param toe - * the toe to set + * @param toe the toe to set */ public void setToe(final int toe) { this.toe = toe; @@ -197,8 +188,7 @@ public int getFIT() { } /** - * @param fIT - * the fIT to set + * @param fIT the fIT to set */ public void setFIT(final int fIT) { this.FIT = fIT; @@ -212,8 +202,7 @@ public int getAODO() { } /** - * @param aODO - * the aODO to set + * @param aODO the aODO to set */ public void setAODO(final int aODO) { this.AODO = aODO; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java index 305e757..0321d8e 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java @@ -23,12 +23,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class EPHEM3Object implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "EPHEM3"; private int IODE = -1; @@ -49,7 +50,6 @@ public class EPHEM3Object implements IGPSObject { private double Omegad = Double.NaN; - /** * @return the iODE */ @@ -58,8 +58,7 @@ public int getIODE() { } /** - * @param iODE - * the iODE to set + * @param iODE the iODE to set */ public void setIODE(final int iODE) { this.IODE = iODE; @@ -73,8 +72,7 @@ public double getIDOT() { } /** - * @param iDOT - * the iDOT to set + * @param iDOT the iDOT to set */ public void setIDOT(final double iDOT) { this.IDOT = iDOT; @@ -88,8 +86,7 @@ public double getCic() { } /** - * @param cic - * the cic to set + * @param cic the cic to set */ public void setCic(final double cic) { this.Cic = cic; @@ -103,8 +100,7 @@ public double getOmega0() { } /** - * @param omega0 - * the omega0 to set + * @param omega0 the omega0 to set */ public void setOmega0(final double omega0) { this.Omega0 = omega0; @@ -118,8 +114,7 @@ public double getCis() { } /** - * @param cis - * the cis to set + * @param cis the cis to set */ public void setCis(final double cis) { this.Cis = cis; @@ -133,8 +128,7 @@ public double getI0() { } /** - * @param i0 - * the i0 to set + * @param i0 the i0 to set */ public void setI0(final double i0) { this.i0 = i0; @@ -148,8 +142,7 @@ public double getCrc() { } /** - * @param crc - * the crc to set + * @param crc the crc to set */ public void setCrc(final double crc) { this.Crc = crc; @@ -163,8 +156,7 @@ public double getOmega() { } /** - * @param omega - * the omega to set + * @param omega the omega to set */ public void setOmega(final double omega) { this.omega = omega; @@ -178,8 +170,7 @@ public double getOmegad() { } /** - * @param omegad - * the omegad to set + * @param omegad the omegad to set */ public void setOmegad(final double omegad) { this.Omegad = omegad; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java index 6c2e9c8..8916c63 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java @@ -25,19 +25,19 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class ERDObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "ERD"; private int[] ERD = new int[30]; private int ai = -1; - /** * @return the eRD */ @@ -46,8 +46,7 @@ public int[] getERD() { } /** - * @param eRD - * the eRD to set + * @param eRD the eRD to set */ public void setERD(final int[] eRD) { this.ERD = eRD; @@ -61,8 +60,7 @@ public int getAi() { } /** - * @param ai - * the ai to set + * @param ai the ai to set */ public void setAi(final int ai) { this.ai = ai; @@ -77,10 +75,8 @@ public int getERDbyIndex(final int index) { } /** - * @param index - * the index - * @param ERDvalue - * the ERD + * @param index the index + * @param ERDvalue the ERD */ public void setERDbyIndex(final int index, final int ERDvalue) { this.ERD[index] = ERDvalue; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java index bc987c1..ef193ff 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java @@ -25,12 +25,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class HEALTH2Object implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "HEALTH2"; private final int[] SV = new int[24]; @@ -39,7 +40,6 @@ public class HEALTH2Object implements IGPSObject { private int WNa = -1; - /** * @return the toa */ @@ -48,8 +48,7 @@ public int getToa() { } /** - * @param toa - * the toa to set + * @param toa the toa to set */ public void setToa(final int toa) { this.toa = toa; @@ -63,16 +62,14 @@ public int getWNa() { } /** - * @param wNa - * the wNa to set + * @param wNa the wNa to set */ public void setWNa(final int wNa) { this.WNa = wNa; } /** - * @param index - * the index + * @param index the index * @return the SV */ public int getSVbyIndex(final int index) { @@ -80,10 +77,8 @@ public int getSVbyIndex(final int index) { } /** - * @param index - * the index - * @param SVvalue - * the SV + * @param index the index + * @param SVvalue the SV */ public void setSVbyIndex(final int index, final int SVvalue) { this.SV[index] = SVvalue; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java index 57cf5a5..51a8723 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java @@ -25,12 +25,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class HEALTHObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "HEALTH"; private final int[] SV = new int[32]; @@ -39,7 +40,6 @@ public class HEALTHObject implements IGPSObject { private int data_id = -1; - /** * @return the data_id */ @@ -48,16 +48,14 @@ public int getData_id() { } /** - * @param data_id - * the data_id to set + * @param data_id the data_id to set */ public void setData_id(final int data_id) { this.data_id = data_id; } /** - * @param index - * the index + * @param index the index * @return the SV */ public int getSVbyIndex(final int index) { @@ -65,18 +63,15 @@ public int getSVbyIndex(final int index) { } /** - * @param index - * the index - * @param SVvalue - * the SV + * @param index the index + * @param SVvalue the SV */ public void setSVbyIndex(final int index, final int SVvalue) { this.SV[index] = SVvalue; } /** - * @param index - * the index + * @param index the index * @return the SVH */ public int getSVHbyIndex(final int index) { @@ -84,10 +79,8 @@ public int getSVHbyIndex(final int index) { } /** - * @param index - * the index - * @param SVHvalue - * the SVH + * @param index the index + * @param SVHvalue the SVH */ public void setSVHbyIndex(final int index, final int SVHvalue) { this.SVH[index] = SVHvalue; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java index 487178e..7695643 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java @@ -23,12 +23,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class IONOObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "IONO"; private double alpha0 = Double.NaN; @@ -63,7 +64,6 @@ public class IONOObject implements IGPSObject { private int lsf = -1; - /** * @return the alpha0 */ @@ -72,8 +72,7 @@ public double getAlpha0() { } /** - * @param alpha0 - * the alpha0 to set + * @param alpha0 the alpha0 to set */ public void setAlpha0(final double alpha0) { this.alpha0 = alpha0; @@ -87,8 +86,7 @@ public double getAlpha1() { } /** - * @param alpha1 - * the alpha1 to set + * @param alpha1 the alpha1 to set */ public void setAlpha1(final double alpha1) { this.alpha1 = alpha1; @@ -102,8 +100,7 @@ public double getAlpha2() { } /** - * @param alpha2 - * the alpha2 to set + * @param alpha2 the alpha2 to set */ public void setAlpha2(final double alpha2) { this.alpha2 = alpha2; @@ -117,8 +114,7 @@ public double getAlpha3() { } /** - * @param alpha3 - * the alpha3 to set + * @param alpha3 the alpha3 to set */ public void setAlpha3(final double alpha3) { this.alpha3 = alpha3; @@ -132,8 +128,7 @@ public double getBeta0() { } /** - * @param beta0 - * the beta0 to set + * @param beta0 the beta0 to set */ public void setBeta0(final double beta0) { this.beta0 = beta0; @@ -147,8 +142,7 @@ public double getBeta1() { } /** - * @param beta1 - * the beta1 to set + * @param beta1 the beta1 to set */ public void setBeta1(final double beta1) { this.beta1 = beta1; @@ -162,8 +156,7 @@ public double getBeta2() { } /** - * @param beta2 - * the beta2 to set + * @param beta2 the beta2 to set */ public void setBeta2(final double beta2) { this.beta2 = beta2; @@ -177,8 +170,7 @@ public double getBeta3() { } /** - * @param beta3 - * the beta3 to set + * @param beta3 the beta3 to set */ public void setBeta3(final double beta3) { this.beta3 = beta3; @@ -192,8 +184,7 @@ public double getA0() { } /** - * @param a0 - * the a0 to set + * @param a0 the a0 to set */ public void setA0(final double a0) { this.A0 = a0; @@ -207,8 +198,7 @@ public double getA1() { } /** - * @param a1 - * the a1 to set + * @param a1 the a1 to set */ public void setA1(final double a1) { this.A1 = a1; @@ -222,8 +212,7 @@ public double getTot() { } /** - * @param tot - * the tot to set + * @param tot the tot to set */ public void setTot(final double tot) { this.tot = tot; @@ -237,8 +226,7 @@ public int getWNt() { } /** - * @param wNt - * the wNt to set + * @param wNt the wNt to set */ public void setWNt(final int wNt) { this.WNt = wNt; @@ -252,8 +240,7 @@ public int getLeap() { } /** - * @param leap - * the leap to set + * @param leap the leap to set */ public void setLeap(final int leap) { this.leap = leap; @@ -267,8 +254,7 @@ public int getWNlsf() { } /** - * @param wNlsf - * the wNlsf to set + * @param wNlsf the wNlsf to set */ public void setWNlsf(final int wNlsf) { this.WNlsf = wNlsf; @@ -282,8 +268,7 @@ public int getDN() { } /** - * @param dN - * the dN to set + * @param dN the dN to set */ public void setDN(final int dN) { this.DN = dN; @@ -297,8 +282,7 @@ public int getLsf() { } /** - * @param lsf - * the lsf to set + * @param lsf the lsf to set */ public void setLsf(final int lsf) { this.lsf = lsf; diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java index 4288154..13173a2 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java @@ -23,12 +23,13 @@ import de.taimos.gpsd4java.types.IGPSObject; /** - * * @author aevdokimov */ public class SUBFRAMEObject implements IGPSObject { - /** the GPSd internal name */ + /** + * the GPSd internal name + */ public static final String NAME = "SUBFRAME"; private String device = null; @@ -61,10 +62,9 @@ public class SUBFRAMEObject implements IGPSObject { private IONOObject iono; - /** * Name of originating device - * + * * @return the device */ public String getDevice() { @@ -73,9 +73,8 @@ public String getDevice() { /** * Name of originating device - * - * @param device - * the device to set + * + * @param device the device to set */ public void setDevice(final String device) { this.device = device; @@ -83,7 +82,7 @@ public void setDevice(final String device) { /** * Subframe number - * + * * @return the subframe number */ public int getSubFrameNumber() { @@ -92,9 +91,8 @@ public int getSubFrameNumber() { /** * Subframe number - * - * @param subframeNumber - * to set + * + * @param subframeNumber to set */ public void setSubframeNumber(final int subframeNumber) { this.subframeNumber = subframeNumber; @@ -102,7 +100,7 @@ public void setSubframeNumber(final int subframeNumber) { /** * Satellite number - * + * * @return the satellite number */ public int getSatelliteNumber() { @@ -111,9 +109,8 @@ public int getSatelliteNumber() { /** * Satellite number - * - * @param satelliteNumber - * satellite number to set + * + * @param satelliteNumber satellite number to set */ public void setSatelliteNumber(final int satelliteNumber) { this.satelliteNumber = satelliteNumber; @@ -121,7 +118,7 @@ public void setSatelliteNumber(final int satelliteNumber) { /** * TOW17 field containing the 17 MSBs of the start of the next 12-second message - * + * * @return TOW17 */ public int getMSBs() { @@ -130,9 +127,8 @@ public int getMSBs() { /** * TOW17 field containing the 17 MSBs of the start of the next 12-second message - * - * @param MSBs - * TOW17 to set + * + * @param MSBs TOW17 to set */ public void setMSBs(final int MSBs) { this.MSBs = MSBs; @@ -140,7 +136,7 @@ public void setMSBs(final int MSBs) { /** * field telling whether the remainder of the fields are dumped in scaled or unscaled form - * + * * @return scaled */ public boolean getScaled() { @@ -149,9 +145,8 @@ public boolean getScaled() { /** * field telling whether the remainder of the fields are dumped in scaled or unscaled form - * - * @param scaled - * scaled to set + * + * @param scaled scaled to set */ public void setScaled(final boolean scaled) { this.scaled = scaled; @@ -159,7 +154,7 @@ public void setScaled(final boolean scaled) { /** * optional pageid for ERD, IONO, HEALTH and system message - * + * * @return pageid */ public int getPageid() { @@ -168,9 +163,8 @@ public int getPageid() { /** * optional pageid for ERD, IONO, HEALTH and system message - * - * @param pageid - * page id to set + * + * @param pageid page id to set */ public void setPageid(final int pageid) { this.pageid = pageid; @@ -178,7 +172,7 @@ public void setPageid(final int pageid) { /** * optional system message - * + * * @return system message */ public String getSystemMessage() { @@ -187,9 +181,8 @@ public String getSystemMessage() { /** * optional system message - * - * @param systemMessage - * system message to set + * + * @param systemMessage system message to set */ public void setSystemMessage(final String systemMessage) { this.systemMessage = systemMessage; @@ -197,7 +190,7 @@ public void setSystemMessage(final String systemMessage) { /** * Optional ALMANAC object - * + * * @return ALMANAC */ public ALMANACObject getAlmanac() { @@ -206,9 +199,8 @@ public ALMANACObject getAlmanac() { /** * Optional ALMANAC object - * - * @param almanac - * ALMANAC to set + * + * @param almanac ALMANAC to set */ public void setAlmanac(final ALMANACObject almanac) { this.almanac = almanac; @@ -216,7 +208,7 @@ public void setAlmanac(final ALMANACObject almanac) { /** * Optional EPHEM1 object - * + * * @return EPHEM1 */ public EPHEM1Object getEphem1() { @@ -225,9 +217,8 @@ public EPHEM1Object getEphem1() { /** * Optional EPHEM1 object - * - * @param ephem1 - * EPHEM1 to set + * + * @param ephem1 EPHEM1 to set */ public void setEphem1(final EPHEM1Object ephem1) { this.ephem1 = ephem1; @@ -235,7 +226,7 @@ public void setEphem1(final EPHEM1Object ephem1) { /** * Optional EPHEM2 object - * + * * @return EPHEM2 */ public EPHEM2Object getEphem2() { @@ -244,9 +235,8 @@ public EPHEM2Object getEphem2() { /** * Optional EPHEM2 object - * - * @param ephem2 - * EPHEM2 to set + * + * @param ephem2 EPHEM2 to set */ public void setEphem2(final EPHEM2Object ephem2) { this.ephem2 = ephem2; @@ -254,7 +244,7 @@ public void setEphem2(final EPHEM2Object ephem2) { /** * Optional EPHEM3 object - * + * * @return EPHEM3 */ public EPHEM3Object getEphem3() { @@ -263,9 +253,8 @@ public EPHEM3Object getEphem3() { /** * Optional EPHEM3 object - * - * @param ephem3 - * EPHEM3 to set + * + * @param ephem3 EPHEM3 to set */ public void setEphem3(final EPHEM3Object ephem3) { this.ephem3 = ephem3; @@ -273,7 +262,7 @@ public void setEphem3(final EPHEM3Object ephem3) { /** * Optional ERD object - * + * * @return ERD */ public ERDObject getErd() { @@ -282,9 +271,8 @@ public ERDObject getErd() { /** * Optional ERD object - * - * @param erd - * ERD to set + * + * @param erd ERD to set */ public void setErd(final ERDObject erd) { this.erd = erd; @@ -292,7 +280,7 @@ public void setErd(final ERDObject erd) { /** * Optional HEALTH object - * + * * @return HEALTH */ public HEALTHObject getHealth() { @@ -301,9 +289,8 @@ public HEALTHObject getHealth() { /** * Optional HEALTH object - * - * @param health - * HEALTH to set + * + * @param health HEALTH to set */ public void setHealth(final HEALTHObject health) { this.health = health; @@ -311,7 +298,7 @@ public void setHealth(final HEALTHObject health) { /** * Optional HEALTH2 object - * + * * @return HEALTH2 */ public HEALTH2Object getHealth2() { @@ -320,9 +307,8 @@ public HEALTH2Object getHealth2() { /** * Optional HEALTH2 object - * - * @param health2 - * HEALTH2 to set + * + * @param health2 HEALTH2 to set */ public void setHealth2(final HEALTH2Object health2) { this.health2 = health2; @@ -330,7 +316,7 @@ public void setHealth2(final HEALTH2Object health2) { /** * Optional IONO object - * + * * @return IONO */ public IONOObject getIono() { @@ -339,9 +325,8 @@ public IONOObject getIono() { /** * Optional IONO object - * - * @param iono - * IONO to set + * + * @param iono IONO to set */ public void setIono(final IONOObject iono) { this.iono = iono; From cc188a8c23cbd729617e75c9704fec5f295e4762 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 21 Feb 2017 17:00:14 +0100 Subject: [PATCH 28/63] update thirdparty libs --- .buildpath | 3 --- .classpath | 8 ------- .project | 23 ------------------- ...org.ebayopensource.vjet.eclipse.core.prefs | 2 -- .settings/org.eclipse.core.resources.prefs | 7 ------ .settings/org.eclipse.jdt.core.prefs | 6 ----- .settings/org.eclipse.m2e.core.prefs | 5 ---- pom.xml | 12 +++++----- 8 files changed, 6 insertions(+), 60 deletions(-) delete mode 100644 .buildpath delete mode 100644 .classpath delete mode 100644 .project delete mode 100644 .settings/org.ebayopensource.vjet.eclipse.core.prefs delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.m2e.core.prefs diff --git a/.buildpath b/.buildpath deleted file mode 100644 index a187add..0000000 --- a/.buildpath +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/.classpath b/.classpath deleted file mode 100644 index 0e84149..0000000 --- a/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index 7a5c420..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - de.taimos.gpsd4java - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/.settings/org.ebayopensource.vjet.eclipse.core.prefs b/.settings/org.ebayopensource.vjet.eclipse.core.prefs deleted file mode 100644 index 6e8a644..0000000 --- a/.settings/org.ebayopensource.vjet.eclipse.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -initialized_project_from_v4classpath=true diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index d941a59..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun Oct 23 16:02:02 CEST 2011 -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 957a458..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Oct 23 16:12:15 CEST 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index 94ba964..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Thu Oct 13 20:29:50 CEST 2011 -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/pom.xml b/pom.xml index 9d75881..27c98f2 100644 --- a/pom.xml +++ b/pom.xml @@ -43,12 +43,12 @@ org.json json - 20090211 + 20160810 org.slf4j slf4j-api - 1.7.12 + 1.7.23 junit @@ -59,7 +59,7 @@ ch.qos.logback logback-classic - 1.1.2 + 1.2.1 test @@ -76,7 +76,7 @@ maven-compiler-plugin - 3.0 + 3.6.0 @@ -93,7 +93,7 @@ maven-jar-plugin - 2.4 + 3.0.2 @@ -107,7 +107,7 @@ org.apache.felix maven-bundle-plugin - 2.5.3 + 2.5.4 true From 5bede05a20f76527f145bf806332a84d97dba3cd Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 21 Feb 2017 17:02:45 +0100 Subject: [PATCH 29/63] [maven-release-plugin] prepare release v1.8 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 27c98f2..c2249a8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.8-SNAPSHOT + 1.8 bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD + v1.8 From 8ca2e8e6e5ba418451a116ac235b6407669d0844 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 21 Feb 2017 17:02:55 +0100 Subject: [PATCH 30/63] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c2249a8..e77a154 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.8 + 1.9-SNAPSHOT bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - v1.8 + HEAD From a2045a7c421958fc99fd36857c6393344074c77c Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 21 Feb 2017 17:12:38 +0100 Subject: [PATCH 31/63] bump readme version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3581463..2fe308f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ You can use GPSd4Java with a Maven project. Just add the following lines to your de.taimos gpsd4java - 1.7 + 1.8 From 31d631a46e30e720a5be5d91188ab079c693805e Mon Sep 17 00:00:00 2001 From: Ivaylo Stoyanov Date: Fri, 30 Jun 2017 17:44:51 +0300 Subject: [PATCH 32/63] Use GPSdEndpoint's retryInterval when retrying connection --- .../java/de/taimos/gpsd4java/backend/GPSdEndpoint.java | 10 ++++++++++ .../java/de/taimos/gpsd4java/backend/SocketThread.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 0ac5e27..44e0d77 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -351,4 +351,14 @@ public void setRetryInterval(long millis) { retryInterval.set(millis); } + /** + * Returns the retry interval for reconnecting to GPSD if the socket closes. + * Default value is 1000ms. + * + * @return retry interval + */ + public long getRetryInterval() { + return retryInterval.get(); + } + } diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index f09343d..4ddbdea 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -99,7 +99,7 @@ protected void retry() { while (this.running.get()) { try { - running.waitFor(1000); + running.waitFor(this.endpoint.getRetryInterval()); this.endpoint.handleDisconnected(); SocketThread.LOG.debug("Reconnected to GPS socket"); running.set(false); From bb27bee487a88ce438f46679796d100d61320818 Mon Sep 17 00:00:00 2001 From: Ivaylo Stoyanov Date: Fri, 30 Jun 2017 18:20:45 +0300 Subject: [PATCH 33/63] Remove magic sleep()'s and join()'s --- .../taimos/gpsd4java/backend/GPSdEndpoint.java | 18 +++++------------- .../taimos/gpsd4java/backend/SocketThread.java | 5 ++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 44e0d77..fafcdf0 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -117,12 +117,6 @@ public GPSdEndpoint(final String server, final int port, final AbstractResultPar public void start() { this.listenThread = new SocketThread(this.in, this, this.resultParser); this.listenThread.start(); - - try { - Thread.sleep(500); - } catch (final InterruptedException e) { - GPSdEndpoint.LOG.debug("Interrupted while sleeping", e); - } } /** @@ -136,14 +130,12 @@ public void stop() { GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage()); } - try { - this.listeners.clear(); - if (this.listenThread != null) { - this.listenThread.halt(); - } - } catch (final Exception e) { - GPSdEndpoint.LOG.debug("Interrupted while waiting for listenThread to stop", e); + this.listeners.clear(); + + if (this.listenThread != null) { + this.listenThread.halt(); } + this.listenThread = null; } diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index 4ddbdea..52ba515 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -114,15 +114,14 @@ protected void retry() { /** * Halts the socket thread. * - * @throws InterruptedException */ - public void halt() throws InterruptedException { + public void halt() { this.running.set(false); + try { this.reader.close(); } catch (final IOException e) { // ignore } - this.join(1000); } } \ No newline at end of file From 72712e5ca1d8ee5e0e3ecdcbfb532fdc4d9cf5cb Mon Sep 17 00:00:00 2001 From: Ivaylo Stoyanov Date: Fri, 30 Jun 2017 18:24:26 +0300 Subject: [PATCH 34/63] Don't create SocketThread as a daemon thread --- src/main/java/de/taimos/gpsd4java/backend/SocketThread.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index 52ba515..d52337e 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -64,7 +64,6 @@ public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, fi this.endpoint = endpoint; this.resultParser = resultParser; - this.setDaemon(true); this.setName("GPS Socket Thread"); } From 56e5e335f8877afc52d2c296ded2c732b07ab35d Mon Sep 17 00:00:00 2001 From: Ivaylo Stoyanov Date: Sat, 1 Jul 2017 12:18:08 +0300 Subject: [PATCH 35/63] Make SocketThread daemon flag configurable via constructors --- .../gpsd4java/backend/GPSdEndpoint.java | 27 ++++++++++++++++--- .../gpsd4java/backend/SocketThread.java | 16 +++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index fafcdf0..c05c58d 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -65,6 +65,8 @@ public class GPSdEndpoint { private SocketThread listenThread; + private final boolean daemon; + private final List listeners = new ArrayList(1); private IGPSObject asyncResult = null; @@ -88,11 +90,13 @@ public class GPSdEndpoint { * * @param server the server name or IP * @param port the server port - * @param resultParser + * @param resultParser the result parser + * @param daemon whether to start the underlying socket thread as a daemon, as defined in {@link Thread#setDaemon} * @throws UnknownHostException * @throws IOException */ - public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser) throws UnknownHostException, IOException { + public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser, final boolean daemon) + throws UnknownHostException, IOException { this.server = server; this.port = port; if (server == null) { @@ -109,13 +113,28 @@ public GPSdEndpoint(final String server, final int port, final AbstractResultPar this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); this.resultParser = resultParser; + + this.daemon = daemon; + } + + /** + * Instantiate this class to connect to a GPSd server + * + * @param server the server name or IP + * @param port the server port + * @param resultParser the result parser + * @throws UnknownHostException + * @throws IOException + */ + public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser) throws UnknownHostException, IOException { + this(server, port, resultParser, true); } /** * start the endpoint */ public void start() { - this.listenThread = new SocketThread(this.in, this, this.resultParser); + this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); this.listenThread.start(); } @@ -324,7 +343,7 @@ void handleDisconnected() throws IOException { this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); - this.listenThread = new SocketThread(this.in, this, this.resultParser); + this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); this.listenThread.start(); if (lastWatch != null) { // restore watch if we had one. this.syncCommand(lastWatch, WatchObject.class); diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index d52337e..63835f5 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -47,9 +47,11 @@ public class SocketThread extends Thread { /** * @param reader the socket input * @param endpoint the endpoint - * @param resultParser + * @param resultParser the result parser + * @param daemon whether to configure the thread as a daemon, as defined in {@link Thread#setDaemon} */ - public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, final AbstractResultParser resultParser) { + public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, + final AbstractResultParser resultParser, final boolean daemon) { if (reader == null) { throw new IllegalArgumentException("reader can not be null!"); } @@ -64,9 +66,19 @@ public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, fi this.endpoint = endpoint; this.resultParser = resultParser; + this.setDaemon(daemon); this.setName("GPS Socket Thread"); } + /** + * @param reader the socket input + * @param endpoint the endpoint + * @param resultParser the result parser + */ + public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, final AbstractResultParser resultParser) { + this(reader, endpoint, resultParser, true); + } + @Override public void run() { while (this.running.get()) { From 5914b03ac74b7ea1b4620d0de6477bb43ce2542e Mon Sep 17 00:00:00 2001 From: Ivaylo Stoyanov Date: Sat, 1 Jul 2017 12:21:12 +0300 Subject: [PATCH 36/63] SocketThread: Fix messed up javadocs indentation --- src/main/java/de/taimos/gpsd4java/backend/SocketThread.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index 63835f5..c9b8d68 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -71,9 +71,9 @@ public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, } /** - * @param reader the socket input - * @param endpoint the endpoint - * @param resultParser the result parser + * @param reader the socket input + * @param endpoint the endpoint + * @param resultParser the result parser */ public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, final AbstractResultParser resultParser) { this(reader, endpoint, resultParser, true); From 814659c99b5f4774f4b76d93f7aec48d4a423c56 Mon Sep 17 00:00:00 2001 From: ext-szabozol Date: Wed, 5 Jul 2017 08:43:36 +0200 Subject: [PATCH 37/63] Do not open socket in main thread (#25) --- .../gpsd4java/backend/GPSdEndpoint.java | 17 +++---- .../gpsd4java/backend/SocketThread.java | 47 ++++++++++--------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index c05c58d..cbd6751 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -108,10 +108,7 @@ public GPSdEndpoint(final String server, final int port, final AbstractResultPar if (resultParser == null) { throw new IllegalArgumentException("resultParser can not be null!"); } - - this.socket = new Socket(server, port); - this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); - this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); + this.resultParser = resultParser; this.daemon = daemon; @@ -236,13 +233,16 @@ public void removeListener(final IObjectListener listener) { */ private T syncCommand(final String command, final Class responseClass) throws IOException { synchronized (this.asyncMutex) { - this.out.write(command + "\n"); - this.out.flush(); + if (out != null) { + this.out.write(command + "\n"); + this.out.flush(); + } if (responseClass == WatchObject.class) { lastWatch = command; } while (true) { // wait for awaited message + // FIXME possible infinite loop if expected result arrives but new result overrides expected result before getting to this point. final IGPSObject result = this.waitForResult(); if ((result == null) || result.getClass().equals(responseClass)) { return responseClass.cast(result); @@ -254,7 +254,6 @@ private T syncCommand(final String command, final Class Date: Fri, 7 Jul 2017 11:51:34 +0200 Subject: [PATCH 38/63] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..5e0fe57 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at info@taimos.de. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From 0bca4dd9bb78a76b19a3963082b72f769a00842d Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Mon, 24 Jul 2017 07:25:40 +0000 Subject: [PATCH 39/63] [maven-release-plugin] prepare release v1.9 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e77a154..5d542cf 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.9-SNAPSHOT + 1.9 bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD + v1.9 From 46d2c696a45bf08aec37f8c24a6b8567bb4aa1d0 Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Mon, 24 Jul 2017 07:25:46 +0000 Subject: [PATCH 40/63] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5d542cf..61b9bd2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.9 + 1.10-SNAPSHOT bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - v1.9 + HEAD From 26882e708705ecd89aa116df5e1d943a36e20dc2 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Mon, 24 Jul 2017 09:51:14 +0200 Subject: [PATCH 41/63] maven central badge --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fe308f..07c6e25 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.taimos/gpsd4java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.taimos/gpsd4java) + About GPSd4Java =============== @@ -13,7 +15,7 @@ You can use GPSd4Java with a Maven project. Just add the following lines to your de.taimos gpsd4java - 1.8 + $VERSION From 6db11fe93192a8b79c8eeeeb4157e8810765255f Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 25 Jul 2017 14:57:57 +0200 Subject: [PATCH 42/63] deduplicate ResultParser code --- .../gpsd4java/backend/LegacyResultParser.java | 391 +----------------- .../gpsd4java/backend/ResultParser.java | 42 +- 2 files changed, 25 insertions(+), 408 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java index d3dadd6..27fe766 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java @@ -20,239 +20,23 @@ * #L% */ -import de.taimos.gpsd4java.types.ATTObject; -import de.taimos.gpsd4java.types.DeviceObject; -import de.taimos.gpsd4java.types.DevicesObject; -import de.taimos.gpsd4java.types.ENMEAMode; -import de.taimos.gpsd4java.types.EParity; -import de.taimos.gpsd4java.types.GSTObject; +import org.json.JSONObject; + import de.taimos.gpsd4java.types.IGPSObject; import de.taimos.gpsd4java.types.ParseException; import de.taimos.gpsd4java.types.PollObject; -import de.taimos.gpsd4java.types.SATObject; import de.taimos.gpsd4java.types.SKYObject; import de.taimos.gpsd4java.types.TPVObject; -import de.taimos.gpsd4java.types.VersionObject; -import de.taimos.gpsd4java.types.WatchObject; -import de.taimos.gpsd4java.types.subframes.ALMANACObject; -import de.taimos.gpsd4java.types.subframes.EPHEM1Object; -import de.taimos.gpsd4java.types.subframes.EPHEM2Object; -import de.taimos.gpsd4java.types.subframes.EPHEM3Object; -import de.taimos.gpsd4java.types.subframes.ERDObject; -import de.taimos.gpsd4java.types.subframes.HEALTH2Object; -import de.taimos.gpsd4java.types.subframes.HEALTHObject; -import de.taimos.gpsd4java.types.subframes.IONOObject; -import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; - -import org.json.JSONObject; /** * This class is used to parse responses from GPSd
* * @author thoeger */ -public class LegacyResultParser extends AbstractResultParser { +public class LegacyResultParser extends ResultParser { - /** - * parse {@link JSONObject} into {@link IGPSObject} - * - * @param json the {@link JSONObject} to parse - * @return the parsed object - * @throws ParseException if parsing fails - */ @Override - public IGPSObject parse(final JSONObject json) throws ParseException { - IGPSObject gps = null; - final String clazz = json.optString("class"); - - if (TPVObject.NAME.equals(clazz)) { - gps = this.parseTPV(json); - } else if (SKYObject.NAME.equals(clazz)) { - gps = this.parseSKY(json); - } else if (GSTObject.NAME.equals(clazz)) { - gps = this.parseGST(json); - } else if (ATTObject.NAME.equals(clazz)) { - gps = this.parseATT(json); - } else if (SUBFRAMEObject.NAME.equals(clazz)) { - gps = this.parseSUBFRAME(json); - } else if (VersionObject.NAME.equals(clazz)) { - gps = this.parseVERSION(json); - } else if (DevicesObject.NAME.equals(clazz)) { - gps = this.parseDEVICES(json); - } else if (DeviceObject.NAME.equals(clazz)) { - gps = this.parseDEVICE(json); - } else if (WatchObject.NAME.equals(clazz)) { - gps = this.parseWATCH(json); - } else if (PollObject.NAME.equals(clazz)) { - gps = this.parsePOLL(json); - } else if (json.has("PRN")) { // SATObject - gps = this.parsePRN(json); - } else if (json.has("deltai")) { // ALMANACObject - gps = this.parseALMANAC(json); - } else if (json.has("IODC")) { // EPHEM1Object - gps = this.parseEPHEM1(json); - } else if (json.has("Crs")) { // EPHEM2Object - gps = this.parseEPHEM2(json); - } else if (json.has("IDOT")) { // EPHEM3Object - gps = this.parseEPHEM3(json); - } else if (json.has("ERD30")) { // ERDObject - gps = this.parseERD(json); - } else if (json.has("SVH32")) { // HEALTHObject - gps = this.parseHEALTH(json); - } else if (json.has("WNa")) { // HEALTH2Object - gps = this.parseHEALTH2(json); - } else if (json.has("WNlsf")) { // IONOObject - gps = this.parseIONO(json); - } else { - throw new ParseException("Invalid object class: " + clazz); - } - return gps; - } - - private IGPSObject parseIONO(final JSONObject json) { - IGPSObject gps; - final IONOObject iono = new IONOObject(); - iono.setAlpha0(json.optDouble("a0", Double.NaN)); - iono.setAlpha1(json.optDouble("a1", Double.NaN)); - iono.setAlpha2(json.optDouble("a2", Double.NaN)); - iono.setAlpha3(json.optDouble("a3", Double.NaN)); - iono.setBeta0(json.optDouble("b0", Double.NaN)); - iono.setBeta1(json.optDouble("b1", Double.NaN)); - iono.setBeta2(json.optDouble("b2", Double.NaN)); - iono.setBeta3(json.optDouble("b3", Double.NaN)); - iono.setA0(json.optDouble("A0", Double.NaN)); - iono.setA1(json.optDouble("A1", Double.NaN)); - iono.setTot(json.optDouble("tot", Double.NaN)); - iono.setWNt(json.optInt("WNt")); - iono.setLeap(json.optInt("ls")); - iono.setWNlsf(json.optInt("WNlsf")); - iono.setDN(json.optInt("DN")); - iono.setLsf(json.optInt("lsf")); - gps = iono; - return gps; - } - - private IGPSObject parseHEALTH2(final JSONObject json) { - IGPSObject gps; - final HEALTH2Object health2 = new HEALTH2Object(); - health2.setToa(json.optInt("toa")); - health2.setWNa(json.optInt("WNa")); - for (int index = 1; index <= 24; index++) { - health2.setSVbyIndex(index - 1, json.optInt("SV" + index)); - } - gps = health2; - return gps; - } - - private IGPSObject parseHEALTH(final JSONObject json) { - IGPSObject gps; - final HEALTHObject health = new HEALTHObject(); - health.setData_id(json.optInt("data_id")); - for (int index = 1; index <= 32; index++) { - health.setSVbyIndex(index - 1, json.optInt("SV" + index)); - } - for (int index = 0; index <= 7; index++) { - health.setSVHbyIndex(index, json.optInt("SVH" + (index + 25))); - } - gps = health; - return gps; - } - - private IGPSObject parseERD(final JSONObject json) { - IGPSObject gps; - final ERDObject erd = new ERDObject(); - erd.setAi(json.optInt("ai")); - for (int index = 1; index <= 30; index++) { - erd.setERDbyIndex(index - 1, json.optInt("ERD" + index)); - } - gps = erd; - return gps; - } - - private IGPSObject parseEPHEM3(final JSONObject json) { - IGPSObject gps; - final EPHEM3Object emphem3 = new EPHEM3Object(); - emphem3.setIODE(json.optInt("IODE")); - emphem3.setIDOT(json.optDouble("IDOT", Double.NaN)); - emphem3.setCic(json.optDouble("Cic", Double.NaN)); - emphem3.setOmega0(json.optDouble("Omega0", Double.NaN)); - emphem3.setCis(json.optDouble("Cis", Double.NaN)); - emphem3.setI0(json.optDouble("i0", Double.NaN)); - emphem3.setCrc(json.optDouble("Crc", Double.NaN)); - emphem3.setOmega(json.optDouble("omega", Double.NaN)); - emphem3.setOmegad(json.optDouble("Omegad", Double.NaN)); - gps = emphem3; - return gps; - } - - private IGPSObject parseEPHEM2(final JSONObject json) { - IGPSObject gps; - final EPHEM2Object emphem2 = new EPHEM2Object(); - emphem2.setIODE(json.optInt("IODE")); - emphem2.setCrs(json.optDouble("Crs", Double.NaN)); - emphem2.setDeltan(json.optDouble("deltan", Double.NaN)); - emphem2.setM0(json.optDouble("M0", Double.NaN)); - emphem2.setCuc(json.optDouble("Cuc", Double.NaN)); - emphem2.setE(json.optDouble("e", Double.NaN)); - emphem2.setCus(json.optDouble("Cus", Double.NaN)); - emphem2.setSqrtA(json.optInt("sqrtA")); - emphem2.setToe(json.optInt("toe")); - emphem2.setFIT(json.optInt("FIT")); - emphem2.setAODO(json.optInt("AODO")); - gps = emphem2; - return gps; - } - - private IGPSObject parseEPHEM1(final JSONObject json) { - IGPSObject gps; - final EPHEM1Object emphem1 = new EPHEM1Object(); - emphem1.setWN(json.optInt("WN")); - emphem1.setIODC(json.optInt("IODC")); - emphem1.setL2(json.optInt("L2")); - emphem1.setUra(json.optDouble("ura", Double.NaN)); - emphem1.setHlth(json.optDouble("hlth", Double.NaN)); - emphem1.setL2P(json.optInt("L2P")); - emphem1.setTgd(json.optDouble("Tgd", Double.NaN)); - emphem1.setToc(json.optInt("toc")); - emphem1.setAf2(json.optDouble("af2", Double.NaN)); - emphem1.setAf1(json.optDouble("af1", Double.NaN)); - emphem1.setAf0(json.optDouble("af0", Double.NaN)); - gps = emphem1; - return gps; - } - - private IGPSObject parseALMANAC(final JSONObject json) { - IGPSObject gps; - final ALMANACObject almanac = new ALMANACObject(); - almanac.setID(json.optInt("ID")); - almanac.setHealth(json.optInt("Health")); - almanac.setE(json.optDouble("e", Double.NaN)); - almanac.setToa(json.optInt("toa")); - almanac.setDeltai(json.optDouble("deltai", Double.NaN)); - almanac.setOmegad(json.optDouble("Omegad", Double.NaN)); - almanac.setSqrtA(json.optDouble("sqrtA", Double.NaN)); - almanac.setOmega0(json.optDouble("Omega0", Double.NaN)); - almanac.setOmega(json.optDouble("omega", Double.NaN)); - almanac.setM0(json.optDouble("M0", Double.NaN)); - almanac.setAf0(json.optDouble("af0", Double.NaN)); - almanac.setAf1(json.optDouble("af1", Double.NaN)); - gps = almanac; - return gps; - } - - private IGPSObject parsePRN(final JSONObject json) { - IGPSObject gps; - final SATObject sat = new SATObject(); - sat.setPRN(json.optInt("PRN", -1)); - sat.setAzimuth(json.optInt("az", -1)); - sat.setElevation(json.optInt("el", -1)); - sat.setSignalStrength(json.optInt("ss", -1)); - sat.setUsed(json.optBoolean("used", false)); - gps = sat; - return gps; - } - - private IGPSObject parsePOLL(final JSONObject json) throws ParseException { + protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { IGPSObject gps; // check this for gpsd version <= 3.5 final PollObject poll = new PollObject(); @@ -264,171 +48,4 @@ private IGPSObject parsePOLL(final JSONObject json) throws ParseException { return gps; } - private IGPSObject parseWATCH(final JSONObject json) { - IGPSObject gps; - final WatchObject watch = new WatchObject(); - watch.setEnable(json.optBoolean("enable", true)); - watch.setDump(json.optBoolean("json", false)); - gps = watch; - return gps; - } - - private IGPSObject parseDEVICE(final JSONObject json) { - IGPSObject gps; - final DeviceObject dev = new DeviceObject(); - dev.setPath(json.optString("path", null)); - dev.setActivated(this.parseTimestamp(json, "activated")); - dev.setDriver(json.optString("driver", null)); - dev.setBps(json.optInt("bps", 0)); - dev.setParity(EParity.fromString(json.optString("parity"))); - dev.setStopbit(json.optInt("stopbit")); - dev.setNativeMode(json.optInt("native", 0) == 1); - dev.setCycle(json.optInt("cycle")); - dev.setMincycle(json.optInt("mincycle")); - gps = dev; - return gps; - } - - private IGPSObject parseDEVICES(final JSONObject json) throws ParseException { - IGPSObject gps; - final DevicesObject devs = new DevicesObject(); - devs.setDevices(this.parseObjectArray(json.optJSONArray("devices"), DeviceObject.class)); - gps = devs; - return gps; - } - - private IGPSObject parseVERSION(final JSONObject json) { - IGPSObject gps; - final VersionObject ver = new VersionObject(); - ver.setRelease(json.optString("release", null)); - ver.setRev(json.optString("rev", null)); - ver.setProtocolMajor(json.optDouble("proto_major", 0)); - ver.setProtocolMinor(json.optDouble("proto_minor", 0)); - gps = ver; - return gps; - } - - private IGPSObject parseSUBFRAME(final JSONObject json) throws ParseException { - IGPSObject gps; - final SUBFRAMEObject subframe = new SUBFRAMEObject(); - subframe.setDevice(json.optString("device", null)); - subframe.setMSBs(json.optInt("TOW17")); - subframe.setSatelliteNumber(json.optInt("tSV")); - subframe.setSubframeNumber(json.optInt("frame")); - subframe.setScaled(json.optBoolean("scaled", false)); - subframe.setPageid(json.optInt("pageid")); - if (json.has("system_message")) { - subframe.setSystemMessage(json.optString("system_message")); - } else if (json.has(ALMANACObject.NAME)) { - subframe.setAlmanac((ALMANACObject) this.parse(json.optJSONObject(ALMANACObject.NAME))); - } else if (json.has(EPHEM1Object.NAME)) { - subframe.setEphem1((EPHEM1Object) this.parse(json.optJSONObject(EPHEM1Object.NAME))); - } else if (json.has(EPHEM2Object.NAME)) { - subframe.setEphem2((EPHEM2Object) this.parse(json.optJSONObject(EPHEM2Object.NAME))); - } else if (json.has(EPHEM3Object.NAME)) { - subframe.setEphem3((EPHEM3Object) this.parse(json.optJSONObject(EPHEM3Object.NAME))); - } else if (json.has(ERDObject.NAME)) { - subframe.setErd((ERDObject) this.parse(json.optJSONObject(ERDObject.NAME))); - } else if (json.has(HEALTHObject.NAME)) { - subframe.setHealth((HEALTHObject) this.parse(json.optJSONObject(HEALTHObject.NAME))); - } else if (json.has(HEALTH2Object.NAME)) { - subframe.setHealth2((HEALTH2Object) this.parse(json.optJSONObject(HEALTH2Object.NAME))); - } else if (json.has(IONOObject.NAME)) { - subframe.setIono((IONOObject) this.parse(json.optJSONObject(IONOObject.NAME))); - } else { - AbstractResultParser.LOG.error("Unknown subframe: {}", json.toString()); - } - gps = subframe; - return gps; - } - - private IGPSObject parseATT(final JSONObject json) { - IGPSObject gps; - final ATTObject att = new ATTObject(); - att.setTag(json.optString("tag", null)); - att.setDevice(json.optString("device", null)); - att.setTimestamp(this.parseTimestamp(json, "time")); - att.setHeading(json.optDouble("heading", Double.NaN)); - att.setPitch(json.optDouble("pitch", Double.NaN)); - att.setYaw(json.optDouble("yaw", Double.NaN)); - att.setRoll(json.optDouble("roll", Double.NaN)); - att.setDip(json.optDouble("dip", Double.NaN)); - att.setMag_len(json.optDouble("mag_len", Double.NaN)); - att.setMag_x(json.optDouble("mag_x", Double.NaN)); - att.setMag_y(json.optDouble("mag_y", Double.NaN)); - att.setMag_z(json.optDouble("mag_z", Double.NaN)); - att.setAcc_len(json.optDouble("acc_len", Double.NaN)); - att.setAcc_x(json.optDouble("acc_x", Double.NaN)); - att.setAcc_y(json.optDouble("acc_y", Double.NaN)); - att.setAcc_z(json.optDouble("acc_z", Double.NaN)); - att.setGyro_x(json.optDouble("gyro_x", Double.NaN)); - att.setGyro_y(json.optDouble("gyro_y", Double.NaN)); - att.setDepth(json.optDouble("depth", Double.NaN)); - att.setTemperature(json.optDouble("temperature", Double.NaN)); - att.setMagState(json.optString("mag_st", null)); - att.setRollState(json.optString("roll_st", null)); - att.setPitchState(json.optString("pitch_st", null)); - att.setYawState(json.optString("yaw_st", null)); - gps = att; - return gps; - } - - private IGPSObject parseGST(final JSONObject json) { - IGPSObject gps; - final GSTObject gst = new GSTObject(); - gst.setTag(json.optString("tag", null)); - gst.setDevice(json.optString("device", null)); - gst.setTimestamp(this.parseTimestamp(json, "time")); - gst.setRms(json.optDouble("rms", Double.NaN)); - gst.setMajor(json.optDouble("major", Double.NaN)); - gst.setMinor(json.optDouble("minor", Double.NaN)); - gst.setOrient(json.optDouble("orient", Double.NaN)); - gst.setLat(json.optDouble("lat", Double.NaN)); - gst.setLon(json.optDouble("lon", Double.NaN)); - gst.setAlt(json.optDouble("alt", Double.NaN)); - gps = gst; - return gps; - } - - private IGPSObject parseSKY(final JSONObject json) throws ParseException { - IGPSObject gps; - final SKYObject sky = new SKYObject(); - sky.setTag(json.optString("tag", null)); - sky.setDevice(json.optString("device", null)); - sky.setTimestamp(this.parseTimestamp(json, "time")); - sky.setLongitudeDOP(json.optDouble("xdop", Double.NaN)); - sky.setLatitudeDOP(json.optDouble("ydop", Double.NaN)); - sky.setAltitudeDOP(json.optDouble("vdop", Double.NaN)); - sky.setTimestampDOP(json.optDouble("tdop", Double.NaN)); - sky.setHorizontalDOP(json.optDouble("hdop", Double.NaN)); - sky.setSphericalDOP(json.optDouble("pdop", Double.NaN)); - sky.setHypersphericalDOP(json.optDouble("gdop", Double.NaN)); - sky.setSatellites(this.parseObjectArray(json.optJSONArray("satellites"), SATObject.class)); - gps = sky; - return gps; - } - - private IGPSObject parseTPV(final JSONObject json) { - IGPSObject gps; - final TPVObject tpv = new TPVObject(); - tpv.setTag(json.optString("tag", null)); - tpv.setDevice(json.optString("device", null)); - tpv.setTimestamp(this.parseTimestamp(json, "time")); - tpv.setTimestampError(json.optDouble("ept", Double.NaN)); - tpv.setLatitude(json.optDouble("lat", Double.NaN)); - tpv.setLongitude(json.optDouble("lon", Double.NaN)); - tpv.setAltitude(json.optDouble("alt", Double.NaN)); - tpv.setLongitudeError(json.optDouble("epx", Double.NaN)); - tpv.setLatitudeError(json.optDouble("epy", Double.NaN)); - tpv.setAltitudeError(json.optDouble("epv", Double.NaN)); - tpv.setCourse(json.optDouble("track", Double.NaN)); - tpv.setSpeed(json.optDouble("speed", Double.NaN)); - tpv.setClimbRate(json.optDouble("climb", Double.NaN)); - tpv.setCourseError(json.optDouble("epd", Double.NaN)); - tpv.setSpeedError(json.optDouble("eps", Double.NaN)); - tpv.setClimbRateError(json.optDouble("epc", Double.NaN)); - tpv.setMode(ENMEAMode.fromInt(json.optInt("mode", 0))); - gps = tpv; - return gps; - } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 0c37e8d..8821e7a 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -20,6 +20,8 @@ * #L% */ +import org.json.JSONObject; + import de.taimos.gpsd4java.types.ATTObject; import de.taimos.gpsd4java.types.DeviceObject; import de.taimos.gpsd4java.types.DevicesObject; @@ -44,8 +46,6 @@ import de.taimos.gpsd4java.types.subframes.IONOObject; import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; -import org.json.JSONObject; - /** * This class is used to parse responses from GPSd
* @@ -109,7 +109,7 @@ public IGPSObject parse(final JSONObject json) throws ParseException { return gps; } - private IGPSObject parseIONO(final JSONObject json) { + protected IGPSObject parseIONO(final JSONObject json) { IGPSObject gps; final IONOObject iono = new IONOObject(); iono.setAlpha0(json.optDouble("a0", Double.NaN)); @@ -132,7 +132,7 @@ private IGPSObject parseIONO(final JSONObject json) { return gps; } - private IGPSObject parseHEALTH2(final JSONObject json) { + protected IGPSObject parseHEALTH2(final JSONObject json) { IGPSObject gps; final HEALTH2Object health2 = new HEALTH2Object(); health2.setToa(json.optInt("toa")); @@ -144,7 +144,7 @@ private IGPSObject parseHEALTH2(final JSONObject json) { return gps; } - private IGPSObject parseHEALTH(final JSONObject json) { + protected IGPSObject parseHEALTH(final JSONObject json) { IGPSObject gps; final HEALTHObject health = new HEALTHObject(); health.setData_id(json.optInt("data_id")); @@ -158,7 +158,7 @@ private IGPSObject parseHEALTH(final JSONObject json) { return gps; } - private IGPSObject parseERD(final JSONObject json) { + protected IGPSObject parseERD(final JSONObject json) { IGPSObject gps; final ERDObject erd = new ERDObject(); erd.setAi(json.optInt("ai")); @@ -169,7 +169,7 @@ private IGPSObject parseERD(final JSONObject json) { return gps; } - private IGPSObject parseEPHEM3(final JSONObject json) { + protected IGPSObject parseEPHEM3(final JSONObject json) { IGPSObject gps; final EPHEM3Object emphem3 = new EPHEM3Object(); emphem3.setIODE(json.optInt("IODE")); @@ -185,7 +185,7 @@ private IGPSObject parseEPHEM3(final JSONObject json) { return gps; } - private IGPSObject parseEPHEM2(final JSONObject json) { + protected IGPSObject parseEPHEM2(final JSONObject json) { IGPSObject gps; final EPHEM2Object emphem2 = new EPHEM2Object(); emphem2.setIODE(json.optInt("IODE")); @@ -203,7 +203,7 @@ private IGPSObject parseEPHEM2(final JSONObject json) { return gps; } - private IGPSObject parseEPHEM1(final JSONObject json) { + protected IGPSObject parseEPHEM1(final JSONObject json) { IGPSObject gps; final EPHEM1Object emphem1 = new EPHEM1Object(); emphem1.setWN(json.optInt("WN")); @@ -221,7 +221,7 @@ private IGPSObject parseEPHEM1(final JSONObject json) { return gps; } - private IGPSObject parseALMANAC(final JSONObject json) { + protected IGPSObject parseALMANAC(final JSONObject json) { IGPSObject gps; final ALMANACObject almanac = new ALMANACObject(); almanac.setID(json.optInt("ID")); @@ -240,7 +240,7 @@ private IGPSObject parseALMANAC(final JSONObject json) { return gps; } - private IGPSObject parsePRN(final JSONObject json) { + protected IGPSObject parsePRN(final JSONObject json) { IGPSObject gps; final SATObject sat = new SATObject(); sat.setPRN(json.optInt("PRN", -1)); @@ -252,7 +252,7 @@ private IGPSObject parsePRN(final JSONObject json) { return gps; } - private IGPSObject parsePOLL(final JSONObject json) throws ParseException { + protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { IGPSObject gps; // for gpsd version > 3.5 final PollObject poll = new PollObject(); @@ -265,7 +265,7 @@ private IGPSObject parsePOLL(final JSONObject json) throws ParseException { return gps; } - private IGPSObject parseWATCH(final JSONObject json) { + protected IGPSObject parseWATCH(final JSONObject json) { IGPSObject gps; final WatchObject watch = new WatchObject(); watch.setEnable(json.optBoolean("enable", true)); @@ -274,7 +274,7 @@ private IGPSObject parseWATCH(final JSONObject json) { return gps; } - private IGPSObject parseDEVICE(final JSONObject json) { + protected IGPSObject parseDEVICE(final JSONObject json) { IGPSObject gps; final DeviceObject dev = new DeviceObject(); dev.setPath(json.optString("path", null)); @@ -290,7 +290,7 @@ private IGPSObject parseDEVICE(final JSONObject json) { return gps; } - private IGPSObject parseDEVICES(final JSONObject json) throws ParseException { + protected IGPSObject parseDEVICES(final JSONObject json) throws ParseException { IGPSObject gps; final DevicesObject devs = new DevicesObject(); devs.setDevices(this.parseObjectArray(json.optJSONArray("devices"), DeviceObject.class)); @@ -298,7 +298,7 @@ private IGPSObject parseDEVICES(final JSONObject json) throws ParseException { return gps; } - private IGPSObject parseVERSION(final JSONObject json) { + protected IGPSObject parseVERSION(final JSONObject json) { IGPSObject gps; final VersionObject ver = new VersionObject(); ver.setRelease(json.optString("release", null)); @@ -309,7 +309,7 @@ private IGPSObject parseVERSION(final JSONObject json) { return gps; } - private IGPSObject parseSUBFRAME(final JSONObject json) throws ParseException { + protected IGPSObject parseSUBFRAME(final JSONObject json) throws ParseException { IGPSObject gps; final SUBFRAMEObject subframe = new SUBFRAMEObject(); subframe.setDevice(json.optString("device", null)); @@ -343,7 +343,7 @@ private IGPSObject parseSUBFRAME(final JSONObject json) throws ParseException { return gps; } - private IGPSObject parseATT(final JSONObject json) { + protected IGPSObject parseATT(final JSONObject json) { IGPSObject gps; final ATTObject att = new ATTObject(); att.setTag(json.optString("tag", null)); @@ -374,7 +374,7 @@ private IGPSObject parseATT(final JSONObject json) { return gps; } - private IGPSObject parseGST(final JSONObject json) { + protected IGPSObject parseGST(final JSONObject json) { IGPSObject gps; final GSTObject gst = new GSTObject(); gst.setTag(json.optString("tag", null)); @@ -391,7 +391,7 @@ private IGPSObject parseGST(final JSONObject json) { return gps; } - private IGPSObject parseSKY(final JSONObject json) throws ParseException { + protected IGPSObject parseSKY(final JSONObject json) throws ParseException { IGPSObject gps; final SKYObject sky = new SKYObject(); sky.setTag(json.optString("tag", null)); @@ -409,7 +409,7 @@ private IGPSObject parseSKY(final JSONObject json) throws ParseException { return gps; } - private IGPSObject parseTPV(final JSONObject json) { + protected IGPSObject parseTPV(final JSONObject json) { IGPSObject gps; final TPVObject tpv = new TPVObject(); tpv.setTag(json.optString("tag", null)); From 95e769d4f97f4ce1223fc85ad97634a35f4dc085 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 25 Jul 2017 15:11:08 +0200 Subject: [PATCH 43/63] fix warning message on first start #29 --- .../de/taimos/gpsd4java/backend/SocketThread.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index 16d4829..e40c158 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -96,14 +96,16 @@ public void run() { } } } - if (running.get() && !Thread.interrupted()) { - SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line, attempting restart"); + if (this.running.get() && !Thread.interrupted()) { + if (this.reader != null) { + SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line, attempting restart"); + } retry(); } } protected void retry() { - if (reader != null) { + if (this.reader != null) { SocketThread.LOG.debug("Disconnected from GPS socket, retrying connection"); } else { SocketThread.LOG.debug("Connecting to GPSD socket"); @@ -111,10 +113,10 @@ protected void retry() { while (this.running.get()) { try { - running.waitFor(this.endpoint.getRetryInterval()); + this.running.waitFor(this.endpoint.getRetryInterval()); this.endpoint.handleDisconnected(); SocketThread.LOG.debug("Connected to GPS socket"); - running.set(false); + this.running.set(false); } catch (InterruptedException ix) { break; } catch (IOException e) { From 966388b45388e32d19e8ad88bb75b97bd44de431 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 25 Jul 2017 15:56:04 +0200 Subject: [PATCH 44/63] handle multiple versions with same parser --- .../gpsd4java/backend/LegacyResultParser.java | 2 ++ .../gpsd4java/backend/ResultParser.java | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java index 27fe766..5f8443a 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java @@ -30,9 +30,11 @@ /** * This class is used to parse responses from GPSd
+ * @deprecated use ResultParser; it handles old fields correctly * * @author thoeger */ +@Deprecated public class LegacyResultParser extends ResultParser { @Override diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 8821e7a..4476799 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -256,11 +256,29 @@ protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { IGPSObject gps; // for gpsd version > 3.5 final PollObject poll = new PollObject(); - poll.setTimestamp(this.parseTimestamp(json, "time")); + if (json.has("time")) { + poll.setTimestamp(this.parseTimestamp(json, "time")); + } else if (json.has("timestamp")) { + poll.setTimestamp(json.optDouble("timestamp", Double.NaN)); + } + poll.setActive(json.optInt("active", 0)); - poll.setFixes(this.parseObjectArray(json.optJSONArray("tpv"), TPVObject.class)); - poll.setSkyviews(this.parseObjectArray(json.optJSONArray("sky"), SKYObject.class)); - poll.setGst(this.parseObjectArray(json.optJSONArray("gst"), GSTObject.class)); + + if (json.has("tpv")) { + poll.setFixes(this.parseObjectArray(json.optJSONArray("tpv"), TPVObject.class)); + } else if (json.has("fixes")) { + poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); + } + + if (json.has("sky")) { + poll.setSkyviews(this.parseObjectArray(json.optJSONArray("sky"), SKYObject.class)); + } else if (json.has("skyviews")) { + poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); + } + + if (json.has("gst")) { + poll.setGst(this.parseObjectArray(json.optJSONArray("gst"), GSTObject.class)); + } gps = poll; return gps; } From 1ac0ad7a1ce345e7f078350a33692a1eae2d36e1 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 25 Jul 2017 15:57:40 +0200 Subject: [PATCH 45/63] additional constructor with default ResultParser --- .../de/taimos/gpsd4java/backend/GPSdEndpoint.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index cbd6751..d0dcf36 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -127,6 +127,17 @@ public GPSdEndpoint(final String server, final int port, final AbstractResultPar this(server, port, resultParser, true); } + /** + * Instantiate this class to connect to a GPSd server and use default parser + * + * @param server the server name or IP + * @param port the server port + * @throws IOException + */ + public GPSdEndpoint(final String server, final int port) throws IOException { + this(server, port, new ResultParser(), true); + } + /** * start the endpoint */ From 4541d80152e253d9e6a864691cf3311ae626ef7e Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 25 Jul 2017 16:18:19 +0200 Subject: [PATCH 46/63] get rid of IOExceptions in new constructors --- .../java/de/taimos/gpsd4java/backend/GPSdEndpoint.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index d0dcf36..7f9b871 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -92,11 +92,8 @@ public class GPSdEndpoint { * @param port the server port * @param resultParser the result parser * @param daemon whether to start the underlying socket thread as a daemon, as defined in {@link Thread#setDaemon} - * @throws UnknownHostException - * @throws IOException */ - public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser, final boolean daemon) - throws UnknownHostException, IOException { + public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser, final boolean daemon) { this.server = server; this.port = port; if (server == null) { @@ -132,9 +129,8 @@ public GPSdEndpoint(final String server, final int port, final AbstractResultPar * * @param server the server name or IP * @param port the server port - * @throws IOException */ - public GPSdEndpoint(final String server, final int port) throws IOException { + public GPSdEndpoint(final String server, final int port) { this(server, port, new ResultParser(), true); } From 983633d2364c7ac01fec17996e2d0d20e14ebc52 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Tue, 25 Jul 2017 17:26:09 +0200 Subject: [PATCH 47/63] fallback to double for timestamps --- .../de/taimos/gpsd4java/backend/AbstractResultParser.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java index d294fca..13ed68c 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java @@ -109,6 +109,11 @@ protected double parseTimestamp(final JSONObject json, final String fieldName) { return date.getTime() / 1000.0; } } catch (final Exception ex) { + // trying to parse field as double + double d = json.optDouble(fieldName, Double.NaN); + if (d != Double.NaN) { + return d; + } AbstractResultParser.LOG.info("Failed to parse time", ex); } return Double.NaN; From 75ccbbe80e88783a677c5f04b8695d92b841b2b9 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Wed, 26 Jul 2017 12:05:58 +0200 Subject: [PATCH 48/63] fix NPE in toString methods fixes #30 --- src/main/java/de/taimos/gpsd4java/types/DevicesObject.java | 2 +- src/main/java/de/taimos/gpsd4java/types/PollObject.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java b/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java index f35552d..2583284 100644 --- a/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java @@ -84,7 +84,7 @@ public boolean equals(final Object obj) { @Override public String toString() { - return "DevicesObject{devices=" + this.devices.size() + "}"; + return "DevicesObject{devices=" + ((this.devices == null) ? 0 : this.devices.size()) + "}"; } } diff --git a/src/main/java/de/taimos/gpsd4java/types/PollObject.java b/src/main/java/de/taimos/gpsd4java/types/PollObject.java index 3e4ae66..61eb40b 100644 --- a/src/main/java/de/taimos/gpsd4java/types/PollObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/PollObject.java @@ -193,11 +193,11 @@ public String toString() { sb.append(", active="); sb.append(this.active); sb.append(", fixes="); - sb.append(this.fixes.size()); + sb.append(((this.fixes == null) ? 0 : this.fixes.size())); sb.append(", skyviews="); - sb.append(this.skyviews.size()); + sb.append(((this.skyviews == null) ? 0 : this.skyviews.size())); sb.append(", gst="); - sb.append(this.gst.size()); + sb.append(((this.gst == null) ? 0 : this.gst.size())); sb.append("}"); return sb.toString(); From 9fd9569a0677fb48c107fb2b2768f07fa337bc23 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Thu, 27 Jul 2017 11:52:24 +0200 Subject: [PATCH 49/63] add fallbacks for poll fields --- .../de/taimos/gpsd4java/backend/ResultParser.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 4476799..96392d2 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -20,6 +20,8 @@ * #L% */ +import java.util.Collections; + import org.json.JSONObject; import de.taimos.gpsd4java.types.ATTObject; @@ -260,6 +262,9 @@ protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { poll.setTimestamp(this.parseTimestamp(json, "time")); } else if (json.has("timestamp")) { poll.setTimestamp(json.optDouble("timestamp", Double.NaN)); + } else { + // fallback to current timestamp + poll.setTimestamp(System.currentTimeMillis()); } poll.setActive(json.optInt("active", 0)); @@ -268,16 +273,22 @@ protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { poll.setFixes(this.parseObjectArray(json.optJSONArray("tpv"), TPVObject.class)); } else if (json.has("fixes")) { poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); + } else { + poll.setFixes(Collections.emptyList()); } if (json.has("sky")) { poll.setSkyviews(this.parseObjectArray(json.optJSONArray("sky"), SKYObject.class)); } else if (json.has("skyviews")) { poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); + } else { + poll.setSkyviews(Collections.emptyList()); } if (json.has("gst")) { poll.setGst(this.parseObjectArray(json.optJSONArray("gst"), GSTObject.class)); + } else { + poll.setGst(Collections.emptyList()); } gps = poll; return gps; From 727d055f39cda81d15350c006d8a2f6d53d06e8d Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Mon, 31 Jul 2017 22:08:00 +0200 Subject: [PATCH 50/63] fix #32 potential NPE in stop method --- src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 7f9b871..063935b 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -148,7 +148,9 @@ public void start() { public void stop() { try { - this.socket.close(); + if (this.socket != null) { + this.socket.close(); + } } catch (final IOException e1) { GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage()); } From cb3006c2e071f39a38eb152b66a96120b2d044e8 Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Mon, 28 Aug 2017 20:16:18 +0000 Subject: [PATCH 51/63] [maven-release-plugin] prepare release v1.10 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 61b9bd2..8947372 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.10-SNAPSHOT + 1.10 bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - HEAD + v1.10 From f3bdfcc5eed628417ea72bf20d108519f24d105b Mon Sep 17 00:00:00 2001 From: Taimos CI Date: Mon, 28 Aug 2017 20:16:24 +0000 Subject: [PATCH 52/63] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8947372..c4382c2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 5 gpsd4java - 1.10 + 1.11-SNAPSHOT bundle GPSd4Java Java Client library for GPSd deamon @@ -68,7 +68,7 @@ scm:git:git@github.com:taimos/GPSd4Java.git scm:git:git@github.com:taimos/GPSd4Java.git git@github.com:taimos/GPSd4Java.git - v1.10 + HEAD From d750e33a3ee271ad84217133ad1339a3eb5e0830 Mon Sep 17 00:00:00 2001 From: Dmytro Pishchukhin Date: Tue, 26 Sep 2017 11:04:07 +0200 Subject: [PATCH 53/63] add support of PPS and TOFF types --- .../gpsd4java/backend/ResultParser.java | 59 ++++---- .../de/taimos/gpsd4java/types/PpsObject.java | 136 ++++++++++++++++++ .../de/taimos/gpsd4java/types/ToffObject.java | 111 ++++++++++++++ 3 files changed, 280 insertions(+), 26 deletions(-) create mode 100644 src/main/java/de/taimos/gpsd4java/types/PpsObject.java create mode 100644 src/main/java/de/taimos/gpsd4java/types/ToffObject.java diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 96392d2..02b8cfc 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -20,33 +20,11 @@ * #L% */ -import java.util.Collections; - +import de.taimos.gpsd4java.types.*; +import de.taimos.gpsd4java.types.subframes.*; import org.json.JSONObject; -import de.taimos.gpsd4java.types.ATTObject; -import de.taimos.gpsd4java.types.DeviceObject; -import de.taimos.gpsd4java.types.DevicesObject; -import de.taimos.gpsd4java.types.ENMEAMode; -import de.taimos.gpsd4java.types.EParity; -import de.taimos.gpsd4java.types.GSTObject; -import de.taimos.gpsd4java.types.IGPSObject; -import de.taimos.gpsd4java.types.ParseException; -import de.taimos.gpsd4java.types.PollObject; -import de.taimos.gpsd4java.types.SATObject; -import de.taimos.gpsd4java.types.SKYObject; -import de.taimos.gpsd4java.types.TPVObject; -import de.taimos.gpsd4java.types.VersionObject; -import de.taimos.gpsd4java.types.WatchObject; -import de.taimos.gpsd4java.types.subframes.ALMANACObject; -import de.taimos.gpsd4java.types.subframes.EPHEM1Object; -import de.taimos.gpsd4java.types.subframes.EPHEM2Object; -import de.taimos.gpsd4java.types.subframes.EPHEM3Object; -import de.taimos.gpsd4java.types.subframes.ERDObject; -import de.taimos.gpsd4java.types.subframes.HEALTH2Object; -import de.taimos.gpsd4java.types.subframes.HEALTHObject; -import de.taimos.gpsd4java.types.subframes.IONOObject; -import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; +import java.util.Collections; /** * This class is used to parse responses from GPSd
@@ -87,6 +65,10 @@ public IGPSObject parse(final JSONObject json) throws ParseException { gps = this.parseWATCH(json); } else if (PollObject.NAME.equals(clazz)) { gps = this.parsePOLL(json); + } else if (PpsObject.NAME.equals(clazz)) { + gps = this.parsePPS(json); + } else if (ToffObject.NAME.equals(clazz)) { + gps = this.parseTOFF(json); } else if (json.has("PRN")) { // SATObject gps = this.parsePRN(json); } else if (json.has("deltai")) { // ALMANACObject @@ -110,7 +92,7 @@ public IGPSObject parse(final JSONObject json) throws ParseException { } return gps; } - + protected IGPSObject parseIONO(final JSONObject json) { IGPSObject gps; final IONOObject iono = new IONOObject(); @@ -461,4 +443,29 @@ protected IGPSObject parseTPV(final JSONObject json) { gps = tpv; return gps; } + + protected IGPSObject parsePPS(final JSONObject json) { + IGPSObject gps; + final PpsObject pps = new PpsObject(); + pps.setDevice(json.optString("device", null)); + pps.setRealSec(json.optDouble("real_sec", Double.NaN)); + pps.setRealNsec(json.optDouble("real_nsec", Double.NaN)); + pps.setClockSec(json.optDouble("clock_sec", Double.NaN)); + pps.setClockNsec(json.optDouble("clock_nsec", Double.NaN)); + pps.setPrecision(json.optDouble("precision", Double.NaN)); + gps = pps; + return gps; + } + + protected IGPSObject parseTOFF(final JSONObject json) { + IGPSObject gps; + final ToffObject toff = new ToffObject(); + toff.setDevice(json.optString("device", null)); + toff.setRealSec(json.optDouble("real_sec", Double.NaN)); + toff.setRealNsec(json.optDouble("real_nsec", Double.NaN)); + toff.setClockSec(json.optDouble("clock_sec", Double.NaN)); + toff.setClockNsec(json.optDouble("clock_nsec", Double.NaN)); + gps = toff; + return gps; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/PpsObject.java b/src/main/java/de/taimos/gpsd4java/types/PpsObject.java new file mode 100644 index 0000000..ffb030c --- /dev/null +++ b/src/main/java/de/taimos/gpsd4java/types/PpsObject.java @@ -0,0 +1,136 @@ +package de.taimos.gpsd4java.types; + +/** + * This message is emitted each time the daemon sees a valid PPS (Pulse Per Second) strobe from a device. + * This message exactly mirrors the TOFF message except for two details. + * PPS emits the NTP precision. See the NTP documentation for their definition of precision. + * The TOFF message reports the GPS time as derived from the GPS serial data stream. The PPS message reports the GPS time as derived from the GPS PPS pulse. + * + * @author dpishchukhin + */ +public class PpsObject implements IGPSObject { + /** + * the PPS internal name + */ + public static final String NAME = "PPS"; + + private String device = null; + + private double realSec = Double.NaN; + + private double realNsec = Double.NaN; + + private double clockSec = Double.NaN; + + private double clockNsec = Double.NaN; + + private double precision = Double.NaN; + + /** + * Name of originating device + * + * @return device + */ + public String getDevice() { + return device; + } + + /** + * Name of originating device + * + * @param device device + */ + public void setDevice(String device) { + this.device = device; + } + + /** + * seconds from the PPS source + * + * @return seconds + */ + public double getRealSec() { + return realSec; + } + + /** + * seconds from the PPS source + * + * @param realSec seconds + */ + public void setRealSec(double realSec) { + this.realSec = realSec; + } + + /** + * nanoseconds from the PPS source + * + * @return nanoseconds + */ + public double getRealNsec() { + return realNsec; + } + + /** + * nanoseconds from the PPS source + * + * @param realNsec nanoseconds + */ + public void setRealNsec(double realNsec) { + this.realNsec = realNsec; + } + + /** + * seconds from the system clock + * + * @return seconds + */ + public double getClockSec() { + return clockSec; + } + + /** + * seconds from the system clock + * + * @param clockSec seconds + */ + public void setClockSec(double clockSec) { + this.clockSec = clockSec; + } + + /** + * nanoseconds from the system clock + * + * @return nanoseconds + */ + public double getClockNsec() { + return clockNsec; + } + + /** + * nanoseconds from the system clock + * + * @param clockNsec nanoseconds + */ + public void setClockNsec(double clockNsec) { + this.clockNsec = clockNsec; + } + + /** + * NTP style estimate of PPS precision + * + * @return precision + */ + public double getPrecision() { + return precision; + } + + /** + * NTP style estimate of PPS precision + * + * @param precision precision + */ + public void setPrecision(double precision) { + this.precision = precision; + } +} diff --git a/src/main/java/de/taimos/gpsd4java/types/ToffObject.java b/src/main/java/de/taimos/gpsd4java/types/ToffObject.java new file mode 100644 index 0000000..b7c191c --- /dev/null +++ b/src/main/java/de/taimos/gpsd4java/types/ToffObject.java @@ -0,0 +1,111 @@ +package de.taimos.gpsd4java.types; + +/** + * @author dpishchukhin + */ +public class ToffObject implements IGPSObject { + /** + * the TOFF internal name + */ + public static final String NAME = "TOFF"; + + private String device = null; + + private double realSec = Double.NaN; + + private double realNsec = Double.NaN; + + private double clockSec = Double.NaN; + + private double clockNsec = Double.NaN; + + /** + * Name of originating device + * + * @return device + */ + public String getDevice() { + return device; + } + + /** + * Name of originating device + * + * @param device device + */ + public void setDevice(String device) { + this.device = device; + } + + /** + * seconds from the GPS clock + * + * @return seconds + */ + public double getRealSec() { + return realSec; + } + + /** + * seconds from the GPS clock + * + * @param realSec seconds + */ + public void setRealSec(double realSec) { + this.realSec = realSec; + } + + /** + * nanoseconds from the GPS clock + * + * @return nanoseconds + */ + public double getRealNsec() { + return realNsec; + } + + /** + * nanoseconds from the GPS clock + * + * @param realNsec nanoseconds + */ + public void setRealNsec(double realNsec) { + this.realNsec = realNsec; + } + + /** + * seconds from the system clock + * + * @return seconds + */ + public double getClockSec() { + return clockSec; + } + + /** + * seconds from the system clock + * + * @param clockSec seconds + */ + public void setClockSec(double clockSec) { + this.clockSec = clockSec; + } + + /** + * nanoseconds from the system clock + * + * @return nanoseconds + */ + public double getClockNsec() { + return clockNsec; + } + + /** + * nanoseconds from the system clock + * + * @param clockNsec nanoseconds + */ + public void setClockNsec(double clockNsec) { + this.clockNsec = clockNsec; + } +} From 7da077ce677ee05f7784f1f12cd61ed118589691 Mon Sep 17 00:00:00 2001 From: Dmytro Pishchukhin Date: Tue, 26 Sep 2017 11:06:19 +0200 Subject: [PATCH 54/63] add javadoc for TOFF type --- src/main/java/de/taimos/gpsd4java/types/PpsObject.java | 3 ++- src/main/java/de/taimos/gpsd4java/types/ToffObject.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/taimos/gpsd4java/types/PpsObject.java b/src/main/java/de/taimos/gpsd4java/types/PpsObject.java index ffb030c..342c6cf 100644 --- a/src/main/java/de/taimos/gpsd4java/types/PpsObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/PpsObject.java @@ -4,7 +4,8 @@ * This message is emitted each time the daemon sees a valid PPS (Pulse Per Second) strobe from a device. * This message exactly mirrors the TOFF message except for two details. * PPS emits the NTP precision. See the NTP documentation for their definition of precision. - * The TOFF message reports the GPS time as derived from the GPS serial data stream. The PPS message reports the GPS time as derived from the GPS PPS pulse. + * The TOFF message reports the GPS time as derived from the GPS serial data stream. + * The PPS message reports the GPS time as derived from the GPS PPS pulse. * * @author dpishchukhin */ diff --git a/src/main/java/de/taimos/gpsd4java/types/ToffObject.java b/src/main/java/de/taimos/gpsd4java/types/ToffObject.java index b7c191c..4bc14dc 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ToffObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/ToffObject.java @@ -1,6 +1,13 @@ package de.taimos.gpsd4java.types; /** + * This message is emitted on each cycle and reports the offset between the host's clock time and the GPS time at top + * of second (actually, when the first data for the reporting cycle is received). + * This message exactly mirrors the PPS message except for two details. + * TOFF emits no NTP precision, this is assumed to be -2. See the NTP documentation for their definition of precision. + * The TOFF message reports the GPS time as derived from the GPS serial data stream. The PPS message reports the GPS + * time as derived from the GPS PPS pulse. + * * @author dpishchukhin */ public class ToffObject implements IGPSObject { From 50385fc8bfc5f2bba6d543c1180c6adb8739744a Mon Sep 17 00:00:00 2001 From: pierantoniomerlino Date: Wed, 10 Aug 2022 10:22:55 +0200 Subject: [PATCH 55/63] Fixed potential NPE Signed-off-by: pierantoniomerlino --- .../java/de/taimos/gpsd4java/backend/SocketThread.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index e40c158..f019713 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -132,10 +132,12 @@ protected void retry() { public void halt() { this.running.set(false); - try { - this.reader.close(); - } catch (final IOException e) { - // ignore + if (this.reader != null) { + try { + this.reader.close(); + } catch (final IOException e) { + // ignore + } } } } \ No newline at end of file From 852459b69145b574569390ef9e3404acd6db9ff4 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Wed, 10 Aug 2022 08:45:30 +0000 Subject: [PATCH 56/63] fix imports --- .gitpod.yml | 5 ++++ .../gpsd4java/backend/ResultParser.java | 29 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..a388729 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,5 @@ + +tasks: + - init: mvn install -DskipTests=false + + diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 02b8cfc..5649a7e 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -20,11 +20,34 @@ * #L% */ -import de.taimos.gpsd4java.types.*; -import de.taimos.gpsd4java.types.subframes.*; +import java.util.Collections; import org.json.JSONObject; -import java.util.Collections; +import de.taimos.gpsd4java.types.ATTObject; +import de.taimos.gpsd4java.types.DeviceObject; +import de.taimos.gpsd4java.types.DevicesObject; +import de.taimos.gpsd4java.types.ENMEAMode; +import de.taimos.gpsd4java.types.EParity; +import de.taimos.gpsd4java.types.GSTObject; +import de.taimos.gpsd4java.types.IGPSObject; +import de.taimos.gpsd4java.types.ParseException; +import de.taimos.gpsd4java.types.PollObject; +import de.taimos.gpsd4java.types.PpsObject; +import de.taimos.gpsd4java.types.SATObject; +import de.taimos.gpsd4java.types.SKYObject; +import de.taimos.gpsd4java.types.TPVObject; +import de.taimos.gpsd4java.types.ToffObject; +import de.taimos.gpsd4java.types.VersionObject; +import de.taimos.gpsd4java.types.WatchObject; +import de.taimos.gpsd4java.types.subframes.ALMANACObject; +import de.taimos.gpsd4java.types.subframes.EPHEM1Object; +import de.taimos.gpsd4java.types.subframes.EPHEM2Object; +import de.taimos.gpsd4java.types.subframes.EPHEM3Object; +import de.taimos.gpsd4java.types.subframes.ERDObject; +import de.taimos.gpsd4java.types.subframes.HEALTH2Object; +import de.taimos.gpsd4java.types.subframes.HEALTHObject; +import de.taimos.gpsd4java.types.subframes.IONOObject; +import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; /** * This class is used to parse responses from GPSd
From 2757f150ff8a47903b69bc6d5aef2adbe1543354 Mon Sep 17 00:00:00 2001 From: Dennis van Beek Date: Thu, 6 Feb 2025 17:04:37 +0100 Subject: [PATCH 57/63] Upgrade dependencies and Java (#41) (#42) * Upgrade dependencies and Java (#41) Signed-off-by: Dennis van Beek * Java version back to 11 for higher applicability (#41) Signed-off-by: Dennis van Beek --------- Signed-off-by: Dennis van Beek Co-authored-by: Dennis van Beek --- pom.xml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index c4382c2..805733e 100644 --- a/pom.xml +++ b/pom.xml @@ -43,23 +43,17 @@ org.json json - 20160810 + 20220924 org.slf4j slf4j-api - 1.7.23 - - - junit - junit - 4.12 - test + 1.7.36 ch.qos.logback logback-classic - 1.2.1 + 1.2.11 test @@ -86,8 +80,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.6 - 1.6 + 11 + 11 true
@@ -107,7 +101,7 @@ org.apache.felix maven-bundle-plugin - 2.5.4 + 5.1.8 true From a28473954509fdb84e0d21a1ae2b114953c7be33 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Thu, 6 Feb 2025 15:48:31 +0100 Subject: [PATCH 58/63] upgrade of dependencies --- pom.xml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 805733e..54a7c0c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 @@ -37,23 +37,32 @@ Martin Nordqvist + + Ben Turner + org.json json - 20220924 + 20250107 org.slf4j slf4j-api - 1.7.36 + 2.0.16 + + + junit + junit + 4.13.2 + test ch.qos.logback logback-classic - 1.2.11 + 1.5.16 test @@ -90,7 +99,7 @@ 3.0.2 - + true true @@ -106,4 +115,4 @@ - \ No newline at end of file +
From 8f01bfd8ea1339e314241f24550671d7e3cf05ed Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Thu, 6 Feb 2025 15:49:30 +0100 Subject: [PATCH 59/63] google code format on entire project --- .../gpsd4java/api/DistanceListener.java | 51 +- .../taimos/gpsd4java/api/IObjectListener.java | 65 +- .../taimos/gpsd4java/api/ObjectListener.java | 65 +- .../backend/AbstractResultParser.java | 164 ++- .../de/taimos/gpsd4java/backend/GISTool.java | 102 +- .../gpsd4java/backend/GPSdEndpoint.java | 685 ++++++----- .../gpsd4java/backend/LegacyResultParser.java | 36 +- .../gpsd4java/backend/ResultParser.java | 875 +++++++------ .../gpsd4java/backend/SocketThread.java | 226 ++-- .../gpsd4java/backend/WaitableBoolean.java | 40 +- .../de/taimos/gpsd4java/types/ATTObject.java | 1089 +++++++++-------- .../taimos/gpsd4java/types/DeviceObject.java | 567 ++++----- .../taimos/gpsd4java/types/DevicesObject.java | 123 +- .../de/taimos/gpsd4java/types/ENMEAMode.java | 70 +- .../de/taimos/gpsd4java/types/EParity.java | 64 +- .../de/taimos/gpsd4java/types/GSTObject.java | 630 +++++----- .../de/taimos/gpsd4java/types/IGPSObject.java | 10 +- .../gpsd4java/types/ParseException.java | 65 +- .../de/taimos/gpsd4java/types/PollObject.java | 354 +++--- .../de/taimos/gpsd4java/types/PpsObject.java | 256 ++-- .../de/taimos/gpsd4java/types/SATObject.java | 347 +++--- .../de/taimos/gpsd4java/types/SKYObject.java | 707 +++++------ .../de/taimos/gpsd4java/types/TPVObject.java | 1012 +++++++-------- .../de/taimos/gpsd4java/types/ToffObject.java | 218 ++-- .../taimos/gpsd4java/types/VersionObject.java | 273 ++--- .../taimos/gpsd4java/types/WatchObject.java | 163 ++- .../types/subframes/ALMANACObject.java | 616 +++++----- .../types/subframes/EPHEM1Object.java | 567 +++++---- .../types/subframes/EPHEM2Object.java | 569 +++++---- .../types/subframes/EPHEM3Object.java | 483 ++++---- .../gpsd4java/types/subframes/ERDObject.java | 198 ++- .../types/subframes/HEALTH2Object.java | 214 ++-- .../types/subframes/HEALTHObject.java | 226 ++-- .../gpsd4java/types/subframes/IONOObject.java | 797 ++++++------ .../types/subframes/SUBFRAMEObject.java | 885 +++++++------- .../java/de/taimos/gpsd4java/test/Tester.java | 188 ++- 36 files changed, 6480 insertions(+), 6520 deletions(-) diff --git a/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java b/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java index f05cb32..26eba2e 100644 --- a/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java +++ b/src/main/java/de/taimos/gpsd4java/api/DistanceListener.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,31 +24,32 @@ import de.taimos.gpsd4java.types.TPVObject; /** - * Derive this class to implement a listener for location updates which reacts to changes greater a given threshold + * Derive this class to implement a listener for location updates which reacts to changes greater a + * given threshold * * @author thoeger */ public abstract class DistanceListener extends ObjectListener { - - private TPVObject lastPosition; - - private final double threshold; - - /** - * @param threshold the threshold to fire in kilometers - */ - public DistanceListener(final double threshold) { - this.threshold = threshold; - } - - @Override - public void handleTPV(final TPVObject tpv) { - if ((this.lastPosition == null) || (GISTool.getDistance(tpv, this.lastPosition) > this.threshold)) { - this.lastPosition = tpv; - this.handleLocation(tpv); - } - } - - protected abstract void handleLocation(TPVObject tpv); - + + private TPVObject lastPosition; + + private final double threshold; + + /** + * @param threshold the threshold to fire in kilometers + */ + public DistanceListener(final double threshold) { + this.threshold = threshold; + } + + @Override + public void handleTPV(final TPVObject tpv) { + if ((this.lastPosition == null) + || (GISTool.getDistance(tpv, this.lastPosition) > this.threshold)) { + this.lastPosition = tpv; + this.handleLocation(tpv); + } + } + + protected abstract void handleLocation(TPVObject tpv); } diff --git a/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java b/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java index f7aa4e0..719c616 100644 --- a/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java +++ b/src/main/java/de/taimos/gpsd4java/api/IObjectListener.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,35 +33,34 @@ * @author thoeger */ public interface IObjectListener { - - /** - * @param tpv the TPV object - */ - void handleTPV(TPVObject tpv); - - /** - * @param sky the SKY object - */ - void handleSKY(SKYObject sky); - - /** - * @param att the ATT object - */ - void handleATT(ATTObject att); - - /** - * @param subframe the SUBFRAME object - */ - void handleSUBFRAME(SUBFRAMEObject subframe); - - /** - * @param devices the devices object - */ - void handleDevices(DevicesObject devices); - - /** - * @param device the device object - */ - void handleDevice(DeviceObject device); - + + /** + * @param tpv the TPV object + */ + void handleTPV(TPVObject tpv); + + /** + * @param sky the SKY object + */ + void handleSKY(SKYObject sky); + + /** + * @param att the ATT object + */ + void handleATT(ATTObject att); + + /** + * @param subframe the SUBFRAME object + */ + void handleSUBFRAME(SUBFRAMEObject subframe); + + /** + * @param devices the devices object + */ + void handleDevices(DevicesObject devices); + + /** + * @param device the device object + */ + void handleDevice(DeviceObject device); } diff --git a/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java b/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java index e769a16..117ddfb 100644 --- a/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java +++ b/src/main/java/de/taimos/gpsd4java/api/ObjectListener.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,35 +33,34 @@ * @author thoeger */ public class ObjectListener implements IObjectListener { - - @Override - public void handleTPV(final TPVObject tpv) { - // implement in subclass if needed - } - - @Override - public void handleSKY(final SKYObject sky) { - // implement in subclass if needed - } - - @Override - public void handleATT(final ATTObject att) { - // implement in subclass if needed - } - - @Override - public void handleSUBFRAME(final SUBFRAMEObject subframe) { - // implement in subclass if needed - } - - @Override - public void handleDevices(final DevicesObject devices) { - // implement in subclass if needed - } - - @Override - public void handleDevice(final DeviceObject device) { - // implement in subclass if needed - } - + + @Override + public void handleTPV(final TPVObject tpv) { + // implement in subclass if needed + } + + @Override + public void handleSKY(final SKYObject sky) { + // implement in subclass if needed + } + + @Override + public void handleATT(final ATTObject att) { + // implement in subclass if needed + } + + @Override + public void handleSUBFRAME(final SUBFRAMEObject subframe) { + // implement in subclass if needed + } + + @Override + public void handleDevices(final DevicesObject devices) { + // implement in subclass if needed + } + + @Override + public void handleDevice(final DeviceObject device) { + // implement in subclass if needed + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java index 13ed68c..1217490 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,102 +20,98 @@ * #L% */ +import de.taimos.gpsd4java.types.IGPSObject; +import de.taimos.gpsd4java.types.ParseException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.TimeZone; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.taimos.gpsd4java.types.IGPSObject; -import de.taimos.gpsd4java.types.ParseException; - /** * @author irakli, thoeger */ public abstract class AbstractResultParser { - - protected static final Logger LOG = LoggerFactory.getLogger(ResultParser.class); - - protected final DateFormat dateFormat; // Don't make this static! - - /** - * Create new ResultParser - */ - public AbstractResultParser() { - this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - /** - * Parse a received line into a {@link IGPSObject} - * - * @param line the line read from GPSd - * @return the parsed object - * @throws ParseException if parsing fails - */ - public IGPSObject parse(final String line) throws ParseException { - try { - final JSONObject json = new JSONObject(line); - return this.parse(json); - } catch (final JSONException e) { - throw new ParseException("Parsing failed", e); - } - } - - /** - * @param json - * @return the parsed {@link IGPSObject} - * @throws ParseException - */ - public abstract IGPSObject parse(final JSONObject json) throws ParseException; - - /** - * parse a whole JSONArray into a list of IGPSObjects - */ - @SuppressWarnings({"unchecked", "unused"}) - protected List parseObjectArray(final JSONArray array, final Class type) throws ParseException { - try { - if (array == null) { - return new ArrayList(10); - } - final List objects = new ArrayList(10); - for (int i = 0; i < array.length(); i++) { - objects.add((T) this.parse(array.getJSONObject(i))); - } - return objects; - } catch (final JSONException e) { - throw new ParseException("Parsing failed", e); - } - } - - protected double parseTimestamp(final JSONObject json, final String fieldName) { - try { - final String text = json.optString(fieldName, null); - AbstractResultParser.LOG.debug(fieldName + ": {}", text); - - if (text != null) { - final Date date = this.dateFormat.parse(text); - if (AbstractResultParser.LOG.isDebugEnabled()) { - final String ds = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date); - AbstractResultParser.LOG.debug("Date: {}", ds); - } - return date.getTime() / 1000.0; - } - } catch (final Exception ex) { - // trying to parse field as double - double d = json.optDouble(fieldName, Double.NaN); - if (d != Double.NaN) { - return d; - } - AbstractResultParser.LOG.info("Failed to parse time", ex); - } - return Double.NaN; - } + + protected static final Logger LOG = LoggerFactory.getLogger(ResultParser.class); + + protected final DateFormat dateFormat; // Don't make this static! + + /** Create new ResultParser */ + public AbstractResultParser() { + this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + /** + * Parse a received line into a {@link IGPSObject} + * + * @param line the line read from GPSd + * @return the parsed object + * @throws ParseException if parsing fails + */ + public IGPSObject parse(final String line) throws ParseException { + try { + final JSONObject json = new JSONObject(line); + return this.parse(json); + } catch (final JSONException e) { + throw new ParseException("Parsing failed", e); + } + } + + /** + * @param json + * @return the parsed {@link IGPSObject} + * @throws ParseException + */ + public abstract IGPSObject parse(final JSONObject json) throws ParseException; + + /** parse a whole JSONArray into a list of IGPSObjects */ + @SuppressWarnings({"unchecked", "unused"}) + protected List parseObjectArray( + final JSONArray array, final Class type) throws ParseException { + try { + if (array == null) { + return new ArrayList(10); + } + final List objects = new ArrayList(10); + for (int i = 0; i < array.length(); i++) { + objects.add((T) this.parse(array.getJSONObject(i))); + } + return objects; + } catch (final JSONException e) { + throw new ParseException("Parsing failed", e); + } + } + + protected double parseTimestamp(final JSONObject json, final String fieldName) { + try { + final String text = json.optString(fieldName, null); + AbstractResultParser.LOG.debug(fieldName + ": {}", text); + + if (text != null) { + final Date date = this.dateFormat.parse(text); + if (AbstractResultParser.LOG.isDebugEnabled()) { + final String ds = + DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date); + AbstractResultParser.LOG.debug("Date: {}", ds); + } + return date.getTime() / 1000.0; + } + } catch (final Exception ex) { + // trying to parse field as double + double d = json.optDouble(fieldName, Double.NaN); + if (d != Double.NaN) { + return d; + } + AbstractResultParser.LOG.info("Failed to parse time", ex); + } + return Double.NaN; + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/GISTool.java b/src/main/java/de/taimos/gpsd4java/backend/GISTool.java index 2551a09..443fb64 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GISTool.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GISTool.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,51 +28,55 @@ * @author thoeger */ public final class GISTool { - - private static final int EARTH_RADIUS_KILOMETERS = 6371; - - private GISTool() { - // - } - - /** - * calculates the distance between two {@link TPVObject} in kilometers
- * the method used is the great-circle-distance with hypersine formula - * - * @param tpv1 - position 1 - * @param tpv2 - position 2 - * @return distance in kilometers - */ - public static double getDistance(final TPVObject tpv1, final TPVObject tpv2) { - return GISTool.getDistance(tpv1.getLongitude(), tpv2.getLongitude(), tpv1.getLatitude(), tpv2.getLatitude()); - } - - /** - * calculates the distance between two locations, which are given as coordinates, in kilometers
- * the method used is the great-circle-distance with hypersine formula - * - * @param x1 - longitude of position 1 - * @param x2 - longitude of position 2 - * @param y1 - latitude of position 1 - * @param y2 - latitude of position 2 - * @return distance in kilometers - */ - public static double getDistance(final double x1, final double x2, final double y1, final double y2) { - // transform to radian - final double deg2rad = Math.PI / 180; - - final double x1rad = x1 * deg2rad; - final double x2rad = x2 * deg2rad; - final double y1rad = y1 * deg2rad; - final double y2rad = y2 * deg2rad; - - // great-circle-distance with hypersine formula - final double dlong = x1rad - x2rad; - final double dlat = y1rad - y2rad; - final double a = Math.pow(Math.sin(dlat / 2), 2) + (Math.cos(y1rad) * Math.cos(y2rad) * Math.pow(Math.sin(dlong / 2), 2)); - final double c = 2 * Math.asin(Math.sqrt(a)); - - return GISTool.EARTH_RADIUS_KILOMETERS * c; - } - + + private static final int EARTH_RADIUS_KILOMETERS = 6371; + + private GISTool() { + // + } + + /** + * calculates the distance between two {@link TPVObject} in kilometers
+ * the method used is the great-circle-distance with hypersine formula + * + * @param tpv1 - position 1 + * @param tpv2 - position 2 + * @return distance in kilometers + */ + public static double getDistance(final TPVObject tpv1, final TPVObject tpv2) { + return GISTool.getDistance( + tpv1.getLongitude(), tpv2.getLongitude(), tpv1.getLatitude(), tpv2.getLatitude()); + } + + /** + * calculates the distance between two locations, which are given as coordinates, in kilometers + *
+ * the method used is the great-circle-distance with hypersine formula + * + * @param x1 - longitude of position 1 + * @param x2 - longitude of position 2 + * @param y1 - latitude of position 1 + * @param y2 - latitude of position 2 + * @return distance in kilometers + */ + public static double getDistance( + final double x1, final double x2, final double y1, final double y2) { + // transform to radian + final double deg2rad = Math.PI / 180; + + final double x1rad = x1 * deg2rad; + final double x2rad = x2 * deg2rad; + final double y1rad = y1 * deg2rad; + final double y2rad = y2 * deg2rad; + + // great-circle-distance with hypersine formula + final double dlong = x1rad - x2rad; + final double dlat = y1rad - y2rad; + final double a = + Math.pow(Math.sin(dlat / 2), 2) + + (Math.cos(y1rad) * Math.cos(y2rad) * Math.pow(Math.sin(dlong / 2), 2)); + final double c = 2 * Math.asin(Math.sqrt(a)); + + return GISTool.EARTH_RADIUS_KILOMETERS * c; + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java index 063935b..032070e 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java +++ b/src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,17 @@ * #L% */ +import de.taimos.gpsd4java.api.IObjectListener; +import de.taimos.gpsd4java.types.ATTObject; +import de.taimos.gpsd4java.types.DeviceObject; +import de.taimos.gpsd4java.types.DevicesObject; +import de.taimos.gpsd4java.types.IGPSObject; +import de.taimos.gpsd4java.types.PollObject; +import de.taimos.gpsd4java.types.SKYObject; +import de.taimos.gpsd4java.types.TPVObject; +import de.taimos.gpsd4java.types.VersionObject; +import de.taimos.gpsd4java.types.WatchObject; +import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -30,356 +41,344 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; - import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.taimos.gpsd4java.api.IObjectListener; -import de.taimos.gpsd4java.types.ATTObject; -import de.taimos.gpsd4java.types.DeviceObject; -import de.taimos.gpsd4java.types.DevicesObject; -import de.taimos.gpsd4java.types.IGPSObject; -import de.taimos.gpsd4java.types.PollObject; -import de.taimos.gpsd4java.types.SKYObject; -import de.taimos.gpsd4java.types.TPVObject; -import de.taimos.gpsd4java.types.VersionObject; -import de.taimos.gpsd4java.types.WatchObject; -import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; - /** * GPSd client endpoint * * @author thoeger */ public class GPSdEndpoint { - - private static final Logger LOG = LoggerFactory.getLogger(GPSdEndpoint.class); - - private Socket socket; - - private BufferedReader in; - - private BufferedWriter out; - - private SocketThread listenThread; - - private final boolean daemon; - - private final List listeners = new ArrayList(1); - - private IGPSObject asyncResult = null; - - private final Object asyncMutex = new Object(); - - private final Object asyncWaitMutex = new Object(); - - private final AbstractResultParser resultParser; - - private String server; - - private int port; - - private String lastWatch; - - private AtomicLong retryInterval = new AtomicLong(1000); - - /** - * Instantiate this class to connect to a GPSd server - * - * @param server the server name or IP - * @param port the server port - * @param resultParser the result parser - * @param daemon whether to start the underlying socket thread as a daemon, as defined in {@link Thread#setDaemon} - */ - public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser, final boolean daemon) { - this.server = server; - this.port = port; - if (server == null) { - throw new IllegalArgumentException("server can not be null!"); - } - if ((port < 0) || (port > 65535)) { - throw new IllegalArgumentException("Illegal port number: " + port); - } - if (resultParser == null) { - throw new IllegalArgumentException("resultParser can not be null!"); - } - - this.resultParser = resultParser; - - this.daemon = daemon; - } - - /** - * Instantiate this class to connect to a GPSd server - * - * @param server the server name or IP - * @param port the server port - * @param resultParser the result parser - * @throws UnknownHostException - * @throws IOException - */ - public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser) throws UnknownHostException, IOException { - this(server, port, resultParser, true); - } - - /** - * Instantiate this class to connect to a GPSd server and use default parser - * - * @param server the server name or IP - * @param port the server port - */ - public GPSdEndpoint(final String server, final int port) { - this(server, port, new ResultParser(), true); - } - - /** - * start the endpoint - */ - public void start() { - this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); - this.listenThread.start(); - } - - /** - * Stops the endpoint. - */ - public void stop() { - - try { - if (this.socket != null) { - this.socket.close(); - } - } catch (final IOException e1) { - GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage()); - } - - this.listeners.clear(); - - if (this.listenThread != null) { - this.listenThread.halt(); - } - - this.listenThread = null; - } - - /** - * send WATCH command - * - * @param enable enable/disable watch mode - * @param dumpData enable/disable dumping of data - * @return {@link WatchObject} - * @throws IOException on IO error in socket - * @throws JSONException - */ - public WatchObject watch(final boolean enable, final boolean dumpData) throws IOException, JSONException { - return this.watch(enable, dumpData, null); - } - - /** - * send WATCH command - * - * @param enable enable/disable watch mode - * @param dumpData enable/disable dumping of data - * @param device If present, enable watching only of the specified device rather than all devices - * @return {@link WatchObject} - * @throws IOException on IO error in socket - * @throws JSONException - */ - public WatchObject watch(final boolean enable, final boolean dumpData, final String device) throws IOException, JSONException { - JSONObject watch = new JSONObject(); - watch.put("class", "WATCH"); - watch.put("enable", enable); - watch.put("json", dumpData); - if (device != null) { - watch.put("device", device); - } - return this.syncCommand("?WATCH=" + watch.toString(), WatchObject.class); - } - - /** - * Poll GPSd for Message - * - * @return {@link PollObject} - * @throws IOException on IO error in socket - */ - public PollObject poll() throws IOException { - return this.syncCommand("?POLL;", PollObject.class); - } - - /** - * Poll GPSd version - * - * @return {@link VersionObject} - * @throws IOException on IO error in socket - */ - public VersionObject version() throws IOException { - return this.syncCommand("?VERSION;", VersionObject.class); - } - - // TODO implement rest of commands - // ######################################################## - - /** - * @param listener the listener to add - */ - public void addListener(final IObjectListener listener) { - this.listeners.add(listener); - } - - /** - * @param listener the listener to remove - */ - public void removeListener(final IObjectListener listener) { - this.listeners.remove(listener); - } - - // ######################################################## - - /* - * send command to GPSd and wait for response - */ - private T syncCommand(final String command, final Class responseClass) throws IOException { - synchronized (this.asyncMutex) { - if (out != null) { - this.out.write(command + "\n"); - this.out.flush(); - } - if (responseClass == WatchObject.class) { - lastWatch = command; - } - while (true) { - // wait for awaited message - // FIXME possible infinite loop if expected result arrives but new result overrides expected result before getting to this point. - final IGPSObject result = this.waitForResult(); - if ((result == null) || result.getClass().equals(responseClass)) { - return responseClass.cast(result); - } - } - } - } - - /* - * send command without response - */ - private void voidCommand(final String command) throws IOException { - synchronized (this.asyncMutex) { - this.out.write(command + "\n"); - this.out.flush(); - } - } - - /* - * wait for a response for one second - */ - private IGPSObject waitForResult() { - synchronized (this.asyncWaitMutex) { - if (this.asyncResult == null) { - try { - this.asyncWaitMutex.wait(1000); - } catch (final InterruptedException e) { - GPSdEndpoint.LOG.info("Interrupted while waiting for result", e); - } - } - final IGPSObject result = this.asyncResult; - this.asyncResult = null; - return result; - } - } - - /* - * handle incoming messages and dispatch them - */ - void handle(final IGPSObject object) { - if (object instanceof TPVObject) { - for (final IObjectListener l : this.listeners) { - l.handleTPV((TPVObject) object); - } - } else if (object instanceof SKYObject) { - for (final IObjectListener l : this.listeners) { - l.handleSKY((SKYObject) object); - } - } else if (object instanceof ATTObject) { - for (final IObjectListener l : this.listeners) { - l.handleATT((ATTObject) object); - } - } else if (object instanceof SUBFRAMEObject) { - for (final IObjectListener l : this.listeners) { - l.handleSUBFRAME((SUBFRAMEObject) object); - } - } else if (object instanceof DevicesObject) { - for (final IObjectListener l : this.listeners) { - l.handleDevices((DevicesObject) object); - } - } else if (object instanceof DeviceObject) { - for (final IObjectListener l : this.listeners) { - l.handleDevice((DeviceObject) object); - } - } else { - // object was requested, so put it in the response object - synchronized (this.asyncWaitMutex) { - this.asyncResult = object; - this.asyncWaitMutex.notifyAll(); - } - } - } - - /** - * Attempt to kick a failed device back into life on gpsd server. - *

- * see: https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html - * - * @param path Path of device known to gpsd - * @throws IOException - * @throws JSONException - */ - public void kickDevice(String path) throws IOException, JSONException { - final JSONObject d = new JSONObject(); - d.put("class", "DEVICE"); - d.put("path", path); - this.voidCommand("?DEVICE=" + d); - } - - /** - * Our socket thread got disconnect and is exiting. - */ - void handleDisconnected() throws IOException { - synchronized (this.asyncMutex) { - if (socket != null) { - socket.close(); - } - this.socket = new Socket(server, port); - this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); - this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); - - this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); - this.listenThread.start(); - if (lastWatch != null) { // restore watch if we had one. - this.syncCommand(lastWatch, WatchObject.class); - } - } - - } - - /** - * Set a retry interval for reconnecting to GPSD if the socket closes. - * Default value is 1000ms. - * - * @param millis how long to wait between each reconnection attempts. - */ - public void setRetryInterval(long millis) { - retryInterval.set(millis); - } - - /** - * Returns the retry interval for reconnecting to GPSD if the socket closes. - * Default value is 1000ms. - * - * @return retry interval - */ - public long getRetryInterval() { - return retryInterval.get(); - } - + + private static final Logger LOG = LoggerFactory.getLogger(GPSdEndpoint.class); + + private Socket socket; + + private BufferedReader in; + + private BufferedWriter out; + + private SocketThread listenThread; + + private final boolean daemon; + + private final List listeners = new ArrayList(1); + + private IGPSObject asyncResult = null; + + private final Object asyncMutex = new Object(); + + private final Object asyncWaitMutex = new Object(); + + private final AbstractResultParser resultParser; + + private String server; + + private int port; + + private String lastWatch; + + private AtomicLong retryInterval = new AtomicLong(1000); + + /** + * Instantiate this class to connect to a GPSd server + * + * @param server the server name or IP + * @param port the server port + * @param resultParser the result parser + * @param daemon whether to start the underlying socket thread as a daemon, as defined in {@link + * Thread#setDaemon} + */ + public GPSdEndpoint( + final String server, + final int port, + final AbstractResultParser resultParser, + final boolean daemon) { + this.server = server; + this.port = port; + if (server == null) { + throw new IllegalArgumentException("server can not be null!"); + } + if ((port < 0) || (port > 65535)) { + throw new IllegalArgumentException("Illegal port number: " + port); + } + if (resultParser == null) { + throw new IllegalArgumentException("resultParser can not be null!"); + } + + this.resultParser = resultParser; + + this.daemon = daemon; + } + + /** + * Instantiate this class to connect to a GPSd server + * + * @param server the server name or IP + * @param port the server port + * @param resultParser the result parser + * @throws UnknownHostException + * @throws IOException + */ + public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser) + throws UnknownHostException, IOException { + this(server, port, resultParser, true); + } + + /** + * Instantiate this class to connect to a GPSd server and use default parser + * + * @param server the server name or IP + * @param port the server port + */ + public GPSdEndpoint(final String server, final int port) { + this(server, port, new ResultParser(), true); + } + + /** start the endpoint */ + public void start() { + this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); + this.listenThread.start(); + } + + /** Stops the endpoint. */ + public void stop() { + + try { + if (this.socket != null) { + this.socket.close(); + } + } catch (final IOException e1) { + GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage()); + } + + this.listeners.clear(); + + if (this.listenThread != null) { + this.listenThread.halt(); + } + + this.listenThread = null; + } + + /** + * send WATCH command + * + * @param enable enable/disable watch mode + * @param dumpData enable/disable dumping of data + * @return {@link WatchObject} + * @throws IOException on IO error in socket + * @throws JSONException + */ + public WatchObject watch(final boolean enable, final boolean dumpData) + throws IOException, JSONException { + return this.watch(enable, dumpData, null); + } + + /** + * send WATCH command + * + * @param enable enable/disable watch mode + * @param dumpData enable/disable dumping of data + * @param device If present, enable watching only of the specified device rather than all devices + * @return {@link WatchObject} + * @throws IOException on IO error in socket + * @throws JSONException + */ + public WatchObject watch(final boolean enable, final boolean dumpData, final String device) + throws IOException, JSONException { + JSONObject watch = new JSONObject(); + watch.put("class", "WATCH"); + watch.put("enable", enable); + watch.put("json", dumpData); + if (device != null) { + watch.put("device", device); + } + return this.syncCommand("?WATCH=" + watch.toString(), WatchObject.class); + } + + /** + * Poll GPSd for Message + * + * @return {@link PollObject} + * @throws IOException on IO error in socket + */ + public PollObject poll() throws IOException { + return this.syncCommand("?POLL;", PollObject.class); + } + + /** + * Poll GPSd version + * + * @return {@link VersionObject} + * @throws IOException on IO error in socket + */ + public VersionObject version() throws IOException { + return this.syncCommand("?VERSION;", VersionObject.class); + } + + // TODO implement rest of commands + // ######################################################## + + /** + * @param listener the listener to add + */ + public void addListener(final IObjectListener listener) { + this.listeners.add(listener); + } + + /** + * @param listener the listener to remove + */ + public void removeListener(final IObjectListener listener) { + this.listeners.remove(listener); + } + + // ######################################################## + + /* + * send command to GPSd and wait for response + */ + private T syncCommand(final String command, final Class responseClass) + throws IOException { + synchronized (this.asyncMutex) { + if (out != null) { + this.out.write(command + "\n"); + this.out.flush(); + } + if (responseClass == WatchObject.class) { + lastWatch = command; + } + while (true) { + // wait for awaited message + // FIXME possible infinite loop if expected result arrives but new result overrides expected + // result before getting to this point. + final IGPSObject result = this.waitForResult(); + if ((result == null) || result.getClass().equals(responseClass)) { + return responseClass.cast(result); + } + } + } + } + + /* + * send command without response + */ + private void voidCommand(final String command) throws IOException { + synchronized (this.asyncMutex) { + this.out.write(command + "\n"); + this.out.flush(); + } + } + + /* + * wait for a response for one second + */ + private IGPSObject waitForResult() { + synchronized (this.asyncWaitMutex) { + if (this.asyncResult == null) { + try { + this.asyncWaitMutex.wait(1000); + } catch (final InterruptedException e) { + GPSdEndpoint.LOG.info("Interrupted while waiting for result", e); + } + } + final IGPSObject result = this.asyncResult; + this.asyncResult = null; + return result; + } + } + + /* + * handle incoming messages and dispatch them + */ + void handle(final IGPSObject object) { + if (object instanceof TPVObject) { + for (final IObjectListener l : this.listeners) { + l.handleTPV((TPVObject) object); + } + } else if (object instanceof SKYObject) { + for (final IObjectListener l : this.listeners) { + l.handleSKY((SKYObject) object); + } + } else if (object instanceof ATTObject) { + for (final IObjectListener l : this.listeners) { + l.handleATT((ATTObject) object); + } + } else if (object instanceof SUBFRAMEObject) { + for (final IObjectListener l : this.listeners) { + l.handleSUBFRAME((SUBFRAMEObject) object); + } + } else if (object instanceof DevicesObject) { + for (final IObjectListener l : this.listeners) { + l.handleDevices((DevicesObject) object); + } + } else if (object instanceof DeviceObject) { + for (final IObjectListener l : this.listeners) { + l.handleDevice((DeviceObject) object); + } + } else { + // object was requested, so put it in the response object + synchronized (this.asyncWaitMutex) { + this.asyncResult = object; + this.asyncWaitMutex.notifyAll(); + } + } + } + + /** + * Attempt to kick a failed device back into life on gpsd server. + * + *

see: https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html + * + * @param path Path of device known to gpsd + * @throws IOException + * @throws JSONException + */ + public void kickDevice(String path) throws IOException, JSONException { + final JSONObject d = new JSONObject(); + d.put("class", "DEVICE"); + d.put("path", path); + this.voidCommand("?DEVICE=" + d); + } + + /** Our socket thread got disconnect and is exiting. */ + void handleDisconnected() throws IOException { + synchronized (this.asyncMutex) { + if (socket != null) { + socket.close(); + } + this.socket = new Socket(server, port); + this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); + this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); + + this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); + this.listenThread.start(); + if (lastWatch != null) { // restore watch if we had one. + this.syncCommand(lastWatch, WatchObject.class); + } + } + } + + /** + * Set a retry interval for reconnecting to GPSD if the socket closes. Default value is 1000ms. + * + * @param millis how long to wait between each reconnection attempts. + */ + public void setRetryInterval(long millis) { + retryInterval.set(millis); + } + + /** + * Returns the retry interval for reconnecting to GPSD if the socket closes. Default value is + * 1000ms. + * + * @return retry interval + */ + public long getRetryInterval() { + return retryInterval.get(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java index 5f8443a..269ad92 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,34 +20,32 @@ * #L% */ -import org.json.JSONObject; - import de.taimos.gpsd4java.types.IGPSObject; import de.taimos.gpsd4java.types.ParseException; import de.taimos.gpsd4java.types.PollObject; import de.taimos.gpsd4java.types.SKYObject; import de.taimos.gpsd4java.types.TPVObject; +import org.json.JSONObject; /** * This class is used to parse responses from GPSd
- * @deprecated use ResultParser; it handles old fields correctly * + * @deprecated use ResultParser; it handles old fields correctly * @author thoeger */ @Deprecated public class LegacyResultParser extends ResultParser { - - @Override - protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { - IGPSObject gps; - // check this for gpsd version <= 3.5 - final PollObject poll = new PollObject(); - poll.setTimestamp(this.parseTimestamp(json, "time")); - poll.setActive(json.optInt("active", 0)); - poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); - poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); - gps = poll; - return gps; - } - + + @Override + protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { + IGPSObject gps; + // check this for gpsd version <= 3.5 + final PollObject poll = new PollObject(); + poll.setTimestamp(this.parseTimestamp(json, "time")); + poll.setActive(json.optInt("active", 0)); + poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); + poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); + gps = poll; + return gps; + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 5649a7e..620bd6e 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,6 @@ * #L% */ -import java.util.Collections; -import org.json.JSONObject; - import de.taimos.gpsd4java.types.ATTObject; import de.taimos.gpsd4java.types.DeviceObject; import de.taimos.gpsd4java.types.DevicesObject; @@ -48,6 +45,8 @@ import de.taimos.gpsd4java.types.subframes.HEALTHObject; import de.taimos.gpsd4java.types.subframes.IONOObject; import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; +import java.util.Collections; +import org.json.JSONObject; /** * This class is used to parse responses from GPSd
@@ -55,440 +54,440 @@ * @author thoeger */ public class ResultParser extends AbstractResultParser { - - /** - * parse {@link JSONObject} into {@link IGPSObject} - * - * @param json the {@link JSONObject} to parse - * @return the parsed object - * @throws ParseException if parsing fails - */ - @Override - public IGPSObject parse(final JSONObject json) throws ParseException { - IGPSObject gps = null; - final String clazz = json.optString("class"); - - if (TPVObject.NAME.equals(clazz)) { - gps = this.parseTPV(json); - } else if (SKYObject.NAME.equals(clazz)) { - gps = this.parseSKY(json); - } else if (GSTObject.NAME.equals(clazz)) { - gps = this.parseGST(json); - } else if (ATTObject.NAME.equals(clazz)) { - gps = this.parseATT(json); - } else if (SUBFRAMEObject.NAME.equals(clazz)) { - gps = this.parseSUBFRAME(json); - } else if (VersionObject.NAME.equals(clazz)) { - gps = this.parseVERSION(json); - } else if (DevicesObject.NAME.equals(clazz)) { - gps = this.parseDEVICES(json); - } else if (DeviceObject.NAME.equals(clazz)) { - gps = this.parseDEVICE(json); - } else if (WatchObject.NAME.equals(clazz)) { - gps = this.parseWATCH(json); - } else if (PollObject.NAME.equals(clazz)) { - gps = this.parsePOLL(json); - } else if (PpsObject.NAME.equals(clazz)) { - gps = this.parsePPS(json); - } else if (ToffObject.NAME.equals(clazz)) { - gps = this.parseTOFF(json); - } else if (json.has("PRN")) { // SATObject - gps = this.parsePRN(json); - } else if (json.has("deltai")) { // ALMANACObject - gps = this.parseALMANAC(json); - } else if (json.has("IODC")) { // EPHEM1Object - gps = this.parseEPHEM1(json); - } else if (json.has("Crs")) { // EPHEM2Object - gps = this.parseEPHEM2(json); - } else if (json.has("IDOT")) { // EPHEM3Object - gps = this.parseEPHEM3(json); - } else if (json.has("ERD30")) { // ERDObject - gps = this.parseERD(json); - } else if (json.has("SVH32")) { // HEALTHObject - gps = this.parseHEALTH(json); - } else if (json.has("WNa")) { // HEALTH2Object - gps = this.parseHEALTH2(json); - } else if (json.has("WNlsf")) { // IONOObject - gps = this.parseIONO(json); - } else { - throw new ParseException("Invalid object class: " + clazz); - } - return gps; - } - protected IGPSObject parseIONO(final JSONObject json) { - IGPSObject gps; - final IONOObject iono = new IONOObject(); - iono.setAlpha0(json.optDouble("a0", Double.NaN)); - iono.setAlpha1(json.optDouble("a1", Double.NaN)); - iono.setAlpha2(json.optDouble("a2", Double.NaN)); - iono.setAlpha3(json.optDouble("a3", Double.NaN)); - iono.setBeta0(json.optDouble("b0", Double.NaN)); - iono.setBeta1(json.optDouble("b1", Double.NaN)); - iono.setBeta2(json.optDouble("b2", Double.NaN)); - iono.setBeta3(json.optDouble("b3", Double.NaN)); - iono.setA0(json.optDouble("A0", Double.NaN)); - iono.setA1(json.optDouble("A1", Double.NaN)); - iono.setTot(json.optDouble("tot", Double.NaN)); - iono.setWNt(json.optInt("WNt")); - iono.setLeap(json.optInt("ls")); - iono.setWNlsf(json.optInt("WNlsf")); - iono.setDN(json.optInt("DN")); - iono.setLsf(json.optInt("lsf")); - gps = iono; - return gps; - } - - protected IGPSObject parseHEALTH2(final JSONObject json) { - IGPSObject gps; - final HEALTH2Object health2 = new HEALTH2Object(); - health2.setToa(json.optInt("toa")); - health2.setWNa(json.optInt("WNa")); - for (int index = 1; index <= 24; index++) { - health2.setSVbyIndex(index - 1, json.optInt("SV" + index)); - } - gps = health2; - return gps; - } - - protected IGPSObject parseHEALTH(final JSONObject json) { - IGPSObject gps; - final HEALTHObject health = new HEALTHObject(); - health.setData_id(json.optInt("data_id")); - for (int index = 1; index <= 32; index++) { - health.setSVbyIndex(index - 1, json.optInt("SV" + index)); - } - for (int index = 0; index <= 7; index++) { - health.setSVHbyIndex(index, json.optInt("SVH" + (index + 25))); - } - gps = health; - return gps; - } - - protected IGPSObject parseERD(final JSONObject json) { - IGPSObject gps; - final ERDObject erd = new ERDObject(); - erd.setAi(json.optInt("ai")); - for (int index = 1; index <= 30; index++) { - erd.setERDbyIndex(index - 1, json.optInt("ERD" + index)); - } - gps = erd; - return gps; - } - - protected IGPSObject parseEPHEM3(final JSONObject json) { - IGPSObject gps; - final EPHEM3Object emphem3 = new EPHEM3Object(); - emphem3.setIODE(json.optInt("IODE")); - emphem3.setIDOT(json.optDouble("IDOT", Double.NaN)); - emphem3.setCic(json.optDouble("Cic", Double.NaN)); - emphem3.setOmega0(json.optDouble("Omega0", Double.NaN)); - emphem3.setCis(json.optDouble("Cis", Double.NaN)); - emphem3.setI0(json.optDouble("i0", Double.NaN)); - emphem3.setCrc(json.optDouble("Crc", Double.NaN)); - emphem3.setOmega(json.optDouble("omega", Double.NaN)); - emphem3.setOmegad(json.optDouble("Omegad", Double.NaN)); - gps = emphem3; - return gps; - } - - protected IGPSObject parseEPHEM2(final JSONObject json) { - IGPSObject gps; - final EPHEM2Object emphem2 = new EPHEM2Object(); - emphem2.setIODE(json.optInt("IODE")); - emphem2.setCrs(json.optDouble("Crs", Double.NaN)); - emphem2.setDeltan(json.optDouble("deltan", Double.NaN)); - emphem2.setM0(json.optDouble("M0", Double.NaN)); - emphem2.setCuc(json.optDouble("Cuc", Double.NaN)); - emphem2.setE(json.optDouble("e", Double.NaN)); - emphem2.setCus(json.optDouble("Cus", Double.NaN)); - emphem2.setSqrtA(json.optInt("sqrtA")); - emphem2.setToe(json.optInt("toe")); - emphem2.setFIT(json.optInt("FIT")); - emphem2.setAODO(json.optInt("AODO")); - gps = emphem2; - return gps; - } - - protected IGPSObject parseEPHEM1(final JSONObject json) { - IGPSObject gps; - final EPHEM1Object emphem1 = new EPHEM1Object(); - emphem1.setWN(json.optInt("WN")); - emphem1.setIODC(json.optInt("IODC")); - emphem1.setL2(json.optInt("L2")); - emphem1.setUra(json.optDouble("ura", Double.NaN)); - emphem1.setHlth(json.optDouble("hlth", Double.NaN)); - emphem1.setL2P(json.optInt("L2P")); - emphem1.setTgd(json.optDouble("Tgd", Double.NaN)); - emphem1.setToc(json.optInt("toc")); - emphem1.setAf2(json.optDouble("af2", Double.NaN)); - emphem1.setAf1(json.optDouble("af1", Double.NaN)); - emphem1.setAf0(json.optDouble("af0", Double.NaN)); - gps = emphem1; - return gps; - } - - protected IGPSObject parseALMANAC(final JSONObject json) { - IGPSObject gps; - final ALMANACObject almanac = new ALMANACObject(); - almanac.setID(json.optInt("ID")); - almanac.setHealth(json.optInt("Health")); - almanac.setE(json.optDouble("e", Double.NaN)); - almanac.setToa(json.optInt("toa")); - almanac.setDeltai(json.optDouble("deltai", Double.NaN)); - almanac.setOmegad(json.optDouble("Omegad", Double.NaN)); - almanac.setSqrtA(json.optDouble("sqrtA", Double.NaN)); - almanac.setOmega0(json.optDouble("Omega0", Double.NaN)); - almanac.setOmega(json.optDouble("omega", Double.NaN)); - almanac.setM0(json.optDouble("M0", Double.NaN)); - almanac.setAf0(json.optDouble("af0", Double.NaN)); - almanac.setAf1(json.optDouble("af1", Double.NaN)); - gps = almanac; - return gps; - } - - protected IGPSObject parsePRN(final JSONObject json) { - IGPSObject gps; - final SATObject sat = new SATObject(); - sat.setPRN(json.optInt("PRN", -1)); - sat.setAzimuth(json.optInt("az", -1)); - sat.setElevation(json.optInt("el", -1)); - sat.setSignalStrength(json.optInt("ss", -1)); - sat.setUsed(json.optBoolean("used", false)); - gps = sat; - return gps; - } - - protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { - IGPSObject gps; - // for gpsd version > 3.5 - final PollObject poll = new PollObject(); - if (json.has("time")) { - poll.setTimestamp(this.parseTimestamp(json, "time")); - } else if (json.has("timestamp")) { - poll.setTimestamp(json.optDouble("timestamp", Double.NaN)); - } else { - // fallback to current timestamp - poll.setTimestamp(System.currentTimeMillis()); - } - - poll.setActive(json.optInt("active", 0)); - - if (json.has("tpv")) { - poll.setFixes(this.parseObjectArray(json.optJSONArray("tpv"), TPVObject.class)); - } else if (json.has("fixes")) { - poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); - } else { - poll.setFixes(Collections.emptyList()); - } - - if (json.has("sky")) { - poll.setSkyviews(this.parseObjectArray(json.optJSONArray("sky"), SKYObject.class)); - } else if (json.has("skyviews")) { - poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); - } else { - poll.setSkyviews(Collections.emptyList()); - } - - if (json.has("gst")) { - poll.setGst(this.parseObjectArray(json.optJSONArray("gst"), GSTObject.class)); - } else { - poll.setGst(Collections.emptyList()); - } - gps = poll; - return gps; - } - - protected IGPSObject parseWATCH(final JSONObject json) { - IGPSObject gps; - final WatchObject watch = new WatchObject(); - watch.setEnable(json.optBoolean("enable", true)); - watch.setDump(json.optBoolean("json", false)); - gps = watch; - return gps; - } - - protected IGPSObject parseDEVICE(final JSONObject json) { - IGPSObject gps; - final DeviceObject dev = new DeviceObject(); - dev.setPath(json.optString("path", null)); - dev.setActivated(this.parseTimestamp(json, "activated")); - dev.setDriver(json.optString("driver", null)); - dev.setBps(json.optInt("bps", 0)); - dev.setParity(EParity.fromString(json.optString("parity"))); - dev.setStopbit(json.optInt("stopbit")); - dev.setNativeMode(json.optInt("native", 0) == 1); - dev.setCycle(json.optInt("cycle")); - dev.setMincycle(json.optInt("mincycle")); - gps = dev; - return gps; - } - - protected IGPSObject parseDEVICES(final JSONObject json) throws ParseException { - IGPSObject gps; - final DevicesObject devs = new DevicesObject(); - devs.setDevices(this.parseObjectArray(json.optJSONArray("devices"), DeviceObject.class)); - gps = devs; - return gps; - } - - protected IGPSObject parseVERSION(final JSONObject json) { - IGPSObject gps; - final VersionObject ver = new VersionObject(); - ver.setRelease(json.optString("release", null)); - ver.setRev(json.optString("rev", null)); - ver.setProtocolMajor(json.optDouble("proto_major", 0)); - ver.setProtocolMinor(json.optDouble("proto_minor", 0)); - gps = ver; - return gps; - } - - protected IGPSObject parseSUBFRAME(final JSONObject json) throws ParseException { - IGPSObject gps; - final SUBFRAMEObject subframe = new SUBFRAMEObject(); - subframe.setDevice(json.optString("device", null)); - subframe.setMSBs(json.optInt("TOW17")); - subframe.setSatelliteNumber(json.optInt("tSV")); - subframe.setSubframeNumber(json.optInt("frame")); - subframe.setScaled(json.optBoolean("scaled", false)); - subframe.setPageid(json.optInt("pageid")); - if (json.has("system_message")) { - subframe.setSystemMessage(json.optString("system_message")); - } else if (json.has(ALMANACObject.NAME)) { - subframe.setAlmanac((ALMANACObject) this.parse(json.optJSONObject(ALMANACObject.NAME))); - } else if (json.has(EPHEM1Object.NAME)) { - subframe.setEphem1((EPHEM1Object) this.parse(json.optJSONObject(EPHEM1Object.NAME))); - } else if (json.has(EPHEM2Object.NAME)) { - subframe.setEphem2((EPHEM2Object) this.parse(json.optJSONObject(EPHEM2Object.NAME))); - } else if (json.has(EPHEM3Object.NAME)) { - subframe.setEphem3((EPHEM3Object) this.parse(json.optJSONObject(EPHEM3Object.NAME))); - } else if (json.has(ERDObject.NAME)) { - subframe.setErd((ERDObject) this.parse(json.optJSONObject(ERDObject.NAME))); - } else if (json.has(HEALTHObject.NAME)) { - subframe.setHealth((HEALTHObject) this.parse(json.optJSONObject(HEALTHObject.NAME))); - } else if (json.has(HEALTH2Object.NAME)) { - subframe.setHealth2((HEALTH2Object) this.parse(json.optJSONObject(HEALTH2Object.NAME))); - } else if (json.has(IONOObject.NAME)) { - subframe.setIono((IONOObject) this.parse(json.optJSONObject(IONOObject.NAME))); - } else { - AbstractResultParser.LOG.error("Unknown subframe: {}", json.toString()); - } - gps = subframe; - return gps; - } - - protected IGPSObject parseATT(final JSONObject json) { - IGPSObject gps; - final ATTObject att = new ATTObject(); - att.setTag(json.optString("tag", null)); - att.setDevice(json.optString("device", null)); - att.setTimestamp(this.parseTimestamp(json, "time")); - att.setHeading(json.optDouble("heading", Double.NaN)); - att.setPitch(json.optDouble("pitch", Double.NaN)); - att.setYaw(json.optDouble("yaw", Double.NaN)); - att.setRoll(json.optDouble("roll", Double.NaN)); - att.setDip(json.optDouble("dip", Double.NaN)); - att.setMag_len(json.optDouble("mag_len", Double.NaN)); - att.setMag_x(json.optDouble("mag_x", Double.NaN)); - att.setMag_y(json.optDouble("mag_y", Double.NaN)); - att.setMag_z(json.optDouble("mag_z", Double.NaN)); - att.setAcc_len(json.optDouble("acc_len", Double.NaN)); - att.setAcc_x(json.optDouble("acc_x", Double.NaN)); - att.setAcc_y(json.optDouble("acc_y", Double.NaN)); - att.setAcc_z(json.optDouble("acc_z", Double.NaN)); - att.setGyro_x(json.optDouble("gyro_x", Double.NaN)); - att.setGyro_y(json.optDouble("gyro_y", Double.NaN)); - att.setDepth(json.optDouble("depth", Double.NaN)); - att.setTemperature(json.optDouble("temperature", Double.NaN)); - att.setMagState(json.optString("mag_st", null)); - att.setRollState(json.optString("roll_st", null)); - att.setPitchState(json.optString("pitch_st", null)); - att.setYawState(json.optString("yaw_st", null)); - gps = att; - return gps; - } - - protected IGPSObject parseGST(final JSONObject json) { - IGPSObject gps; - final GSTObject gst = new GSTObject(); - gst.setTag(json.optString("tag", null)); - gst.setDevice(json.optString("device", null)); - gst.setTimestamp(this.parseTimestamp(json, "time")); - gst.setRms(json.optDouble("rms", Double.NaN)); - gst.setMajor(json.optDouble("major", Double.NaN)); - gst.setMinor(json.optDouble("minor", Double.NaN)); - gst.setOrient(json.optDouble("orient", Double.NaN)); - gst.setLat(json.optDouble("lat", Double.NaN)); - gst.setLon(json.optDouble("lon", Double.NaN)); - gst.setAlt(json.optDouble("alt", Double.NaN)); - gps = gst; - return gps; - } - - protected IGPSObject parseSKY(final JSONObject json) throws ParseException { - IGPSObject gps; - final SKYObject sky = new SKYObject(); - sky.setTag(json.optString("tag", null)); - sky.setDevice(json.optString("device", null)); - sky.setTimestamp(this.parseTimestamp(json, "time")); - sky.setLongitudeDOP(json.optDouble("xdop", Double.NaN)); - sky.setLatitudeDOP(json.optDouble("ydop", Double.NaN)); - sky.setAltitudeDOP(json.optDouble("vdop", Double.NaN)); - sky.setTimestampDOP(json.optDouble("tdop", Double.NaN)); - sky.setHorizontalDOP(json.optDouble("hdop", Double.NaN)); - sky.setSphericalDOP(json.optDouble("pdop", Double.NaN)); - sky.setHypersphericalDOP(json.optDouble("gdop", Double.NaN)); - sky.setSatellites(this.parseObjectArray(json.optJSONArray("satellites"), SATObject.class)); - gps = sky; - return gps; - } - - protected IGPSObject parseTPV(final JSONObject json) { - IGPSObject gps; - final TPVObject tpv = new TPVObject(); - tpv.setTag(json.optString("tag", null)); - tpv.setDevice(json.optString("device", null)); - tpv.setTimestamp(this.parseTimestamp(json, "time")); - tpv.setTimestampError(json.optDouble("ept", Double.NaN)); - tpv.setLatitude(json.optDouble("lat", Double.NaN)); - tpv.setLongitude(json.optDouble("lon", Double.NaN)); - tpv.setAltitude(json.optDouble("alt", Double.NaN)); - tpv.setLongitudeError(json.optDouble("epx", Double.NaN)); - tpv.setLatitudeError(json.optDouble("epy", Double.NaN)); - tpv.setAltitudeError(json.optDouble("epv", Double.NaN)); - tpv.setCourse(json.optDouble("track", Double.NaN)); - tpv.setSpeed(json.optDouble("speed", Double.NaN)); - tpv.setClimbRate(json.optDouble("climb", Double.NaN)); - tpv.setCourseError(json.optDouble("epd", Double.NaN)); - tpv.setSpeedError(json.optDouble("eps", Double.NaN)); - tpv.setClimbRateError(json.optDouble("epc", Double.NaN)); - tpv.setMode(ENMEAMode.fromInt(json.optInt("mode", 0))); - gps = tpv; - return gps; - } + /** + * parse {@link JSONObject} into {@link IGPSObject} + * + * @param json the {@link JSONObject} to parse + * @return the parsed object + * @throws ParseException if parsing fails + */ + @Override + public IGPSObject parse(final JSONObject json) throws ParseException { + IGPSObject gps = null; + final String clazz = json.optString("class"); + + if (TPVObject.NAME.equals(clazz)) { + gps = this.parseTPV(json); + } else if (SKYObject.NAME.equals(clazz)) { + gps = this.parseSKY(json); + } else if (GSTObject.NAME.equals(clazz)) { + gps = this.parseGST(json); + } else if (ATTObject.NAME.equals(clazz)) { + gps = this.parseATT(json); + } else if (SUBFRAMEObject.NAME.equals(clazz)) { + gps = this.parseSUBFRAME(json); + } else if (VersionObject.NAME.equals(clazz)) { + gps = this.parseVERSION(json); + } else if (DevicesObject.NAME.equals(clazz)) { + gps = this.parseDEVICES(json); + } else if (DeviceObject.NAME.equals(clazz)) { + gps = this.parseDEVICE(json); + } else if (WatchObject.NAME.equals(clazz)) { + gps = this.parseWATCH(json); + } else if (PollObject.NAME.equals(clazz)) { + gps = this.parsePOLL(json); + } else if (PpsObject.NAME.equals(clazz)) { + gps = this.parsePPS(json); + } else if (ToffObject.NAME.equals(clazz)) { + gps = this.parseTOFF(json); + } else if (json.has("PRN")) { // SATObject + gps = this.parsePRN(json); + } else if (json.has("deltai")) { // ALMANACObject + gps = this.parseALMANAC(json); + } else if (json.has("IODC")) { // EPHEM1Object + gps = this.parseEPHEM1(json); + } else if (json.has("Crs")) { // EPHEM2Object + gps = this.parseEPHEM2(json); + } else if (json.has("IDOT")) { // EPHEM3Object + gps = this.parseEPHEM3(json); + } else if (json.has("ERD30")) { // ERDObject + gps = this.parseERD(json); + } else if (json.has("SVH32")) { // HEALTHObject + gps = this.parseHEALTH(json); + } else if (json.has("WNa")) { // HEALTH2Object + gps = this.parseHEALTH2(json); + } else if (json.has("WNlsf")) { // IONOObject + gps = this.parseIONO(json); + } else { + throw new ParseException("Invalid object class: " + clazz); + } + return gps; + } + + protected IGPSObject parseIONO(final JSONObject json) { + IGPSObject gps; + final IONOObject iono = new IONOObject(); + iono.setAlpha0(json.optDouble("a0", Double.NaN)); + iono.setAlpha1(json.optDouble("a1", Double.NaN)); + iono.setAlpha2(json.optDouble("a2", Double.NaN)); + iono.setAlpha3(json.optDouble("a3", Double.NaN)); + iono.setBeta0(json.optDouble("b0", Double.NaN)); + iono.setBeta1(json.optDouble("b1", Double.NaN)); + iono.setBeta2(json.optDouble("b2", Double.NaN)); + iono.setBeta3(json.optDouble("b3", Double.NaN)); + iono.setA0(json.optDouble("A0", Double.NaN)); + iono.setA1(json.optDouble("A1", Double.NaN)); + iono.setTot(json.optDouble("tot", Double.NaN)); + iono.setWNt(json.optInt("WNt")); + iono.setLeap(json.optInt("ls")); + iono.setWNlsf(json.optInt("WNlsf")); + iono.setDN(json.optInt("DN")); + iono.setLsf(json.optInt("lsf")); + gps = iono; + return gps; + } + + protected IGPSObject parseHEALTH2(final JSONObject json) { + IGPSObject gps; + final HEALTH2Object health2 = new HEALTH2Object(); + health2.setToa(json.optInt("toa")); + health2.setWNa(json.optInt("WNa")); + for (int index = 1; index <= 24; index++) { + health2.setSVbyIndex(index - 1, json.optInt("SV" + index)); + } + gps = health2; + return gps; + } + + protected IGPSObject parseHEALTH(final JSONObject json) { + IGPSObject gps; + final HEALTHObject health = new HEALTHObject(); + health.setData_id(json.optInt("data_id")); + for (int index = 1; index <= 32; index++) { + health.setSVbyIndex(index - 1, json.optInt("SV" + index)); + } + for (int index = 0; index <= 7; index++) { + health.setSVHbyIndex(index, json.optInt("SVH" + (index + 25))); + } + gps = health; + return gps; + } + + protected IGPSObject parseERD(final JSONObject json) { + IGPSObject gps; + final ERDObject erd = new ERDObject(); + erd.setAi(json.optInt("ai")); + for (int index = 1; index <= 30; index++) { + erd.setERDbyIndex(index - 1, json.optInt("ERD" + index)); + } + gps = erd; + return gps; + } + + protected IGPSObject parseEPHEM3(final JSONObject json) { + IGPSObject gps; + final EPHEM3Object emphem3 = new EPHEM3Object(); + emphem3.setIODE(json.optInt("IODE")); + emphem3.setIDOT(json.optDouble("IDOT", Double.NaN)); + emphem3.setCic(json.optDouble("Cic", Double.NaN)); + emphem3.setOmega0(json.optDouble("Omega0", Double.NaN)); + emphem3.setCis(json.optDouble("Cis", Double.NaN)); + emphem3.setI0(json.optDouble("i0", Double.NaN)); + emphem3.setCrc(json.optDouble("Crc", Double.NaN)); + emphem3.setOmega(json.optDouble("omega", Double.NaN)); + emphem3.setOmegad(json.optDouble("Omegad", Double.NaN)); + gps = emphem3; + return gps; + } + + protected IGPSObject parseEPHEM2(final JSONObject json) { + IGPSObject gps; + final EPHEM2Object emphem2 = new EPHEM2Object(); + emphem2.setIODE(json.optInt("IODE")); + emphem2.setCrs(json.optDouble("Crs", Double.NaN)); + emphem2.setDeltan(json.optDouble("deltan", Double.NaN)); + emphem2.setM0(json.optDouble("M0", Double.NaN)); + emphem2.setCuc(json.optDouble("Cuc", Double.NaN)); + emphem2.setE(json.optDouble("e", Double.NaN)); + emphem2.setCus(json.optDouble("Cus", Double.NaN)); + emphem2.setSqrtA(json.optInt("sqrtA")); + emphem2.setToe(json.optInt("toe")); + emphem2.setFIT(json.optInt("FIT")); + emphem2.setAODO(json.optInt("AODO")); + gps = emphem2; + return gps; + } + + protected IGPSObject parseEPHEM1(final JSONObject json) { + IGPSObject gps; + final EPHEM1Object emphem1 = new EPHEM1Object(); + emphem1.setWN(json.optInt("WN")); + emphem1.setIODC(json.optInt("IODC")); + emphem1.setL2(json.optInt("L2")); + emphem1.setUra(json.optDouble("ura", Double.NaN)); + emphem1.setHlth(json.optDouble("hlth", Double.NaN)); + emphem1.setL2P(json.optInt("L2P")); + emphem1.setTgd(json.optDouble("Tgd", Double.NaN)); + emphem1.setToc(json.optInt("toc")); + emphem1.setAf2(json.optDouble("af2", Double.NaN)); + emphem1.setAf1(json.optDouble("af1", Double.NaN)); + emphem1.setAf0(json.optDouble("af0", Double.NaN)); + gps = emphem1; + return gps; + } + + protected IGPSObject parseALMANAC(final JSONObject json) { + IGPSObject gps; + final ALMANACObject almanac = new ALMANACObject(); + almanac.setID(json.optInt("ID")); + almanac.setHealth(json.optInt("Health")); + almanac.setE(json.optDouble("e", Double.NaN)); + almanac.setToa(json.optInt("toa")); + almanac.setDeltai(json.optDouble("deltai", Double.NaN)); + almanac.setOmegad(json.optDouble("Omegad", Double.NaN)); + almanac.setSqrtA(json.optDouble("sqrtA", Double.NaN)); + almanac.setOmega0(json.optDouble("Omega0", Double.NaN)); + almanac.setOmega(json.optDouble("omega", Double.NaN)); + almanac.setM0(json.optDouble("M0", Double.NaN)); + almanac.setAf0(json.optDouble("af0", Double.NaN)); + almanac.setAf1(json.optDouble("af1", Double.NaN)); + gps = almanac; + return gps; + } + + protected IGPSObject parsePRN(final JSONObject json) { + IGPSObject gps; + final SATObject sat = new SATObject(); + sat.setPRN(json.optInt("PRN", -1)); + sat.setAzimuth(json.optInt("az", -1)); + sat.setElevation(json.optInt("el", -1)); + sat.setSignalStrength(json.optInt("ss", -1)); + sat.setUsed(json.optBoolean("used", false)); + gps = sat; + return gps; + } + + protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { + IGPSObject gps; + // for gpsd version > 3.5 + final PollObject poll = new PollObject(); + if (json.has("time")) { + poll.setTimestamp(this.parseTimestamp(json, "time")); + } else if (json.has("timestamp")) { + poll.setTimestamp(json.optDouble("timestamp", Double.NaN)); + } else { + // fallback to current timestamp + poll.setTimestamp(System.currentTimeMillis()); + } + + poll.setActive(json.optInt("active", 0)); + + if (json.has("tpv")) { + poll.setFixes(this.parseObjectArray(json.optJSONArray("tpv"), TPVObject.class)); + } else if (json.has("fixes")) { + poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); + } else { + poll.setFixes(Collections.emptyList()); + } + + if (json.has("sky")) { + poll.setSkyviews(this.parseObjectArray(json.optJSONArray("sky"), SKYObject.class)); + } else if (json.has("skyviews")) { + poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); + } else { + poll.setSkyviews(Collections.emptyList()); + } + + if (json.has("gst")) { + poll.setGst(this.parseObjectArray(json.optJSONArray("gst"), GSTObject.class)); + } else { + poll.setGst(Collections.emptyList()); + } + gps = poll; + return gps; + } + + protected IGPSObject parseWATCH(final JSONObject json) { + IGPSObject gps; + final WatchObject watch = new WatchObject(); + watch.setEnable(json.optBoolean("enable", true)); + watch.setDump(json.optBoolean("json", false)); + gps = watch; + return gps; + } + + protected IGPSObject parseDEVICE(final JSONObject json) { + IGPSObject gps; + final DeviceObject dev = new DeviceObject(); + dev.setPath(json.optString("path", null)); + dev.setActivated(this.parseTimestamp(json, "activated")); + dev.setDriver(json.optString("driver", null)); + dev.setBps(json.optInt("bps", 0)); + dev.setParity(EParity.fromString(json.optString("parity"))); + dev.setStopbit(json.optInt("stopbit")); + dev.setNativeMode(json.optInt("native", 0) == 1); + dev.setCycle(json.optInt("cycle")); + dev.setMincycle(json.optInt("mincycle")); + gps = dev; + return gps; + } + + protected IGPSObject parseDEVICES(final JSONObject json) throws ParseException { + IGPSObject gps; + final DevicesObject devs = new DevicesObject(); + devs.setDevices(this.parseObjectArray(json.optJSONArray("devices"), DeviceObject.class)); + gps = devs; + return gps; + } + + protected IGPSObject parseVERSION(final JSONObject json) { + IGPSObject gps; + final VersionObject ver = new VersionObject(); + ver.setRelease(json.optString("release", null)); + ver.setRev(json.optString("rev", null)); + ver.setProtocolMajor(json.optDouble("proto_major", 0)); + ver.setProtocolMinor(json.optDouble("proto_minor", 0)); + gps = ver; + return gps; + } + + protected IGPSObject parseSUBFRAME(final JSONObject json) throws ParseException { + IGPSObject gps; + final SUBFRAMEObject subframe = new SUBFRAMEObject(); + subframe.setDevice(json.optString("device", null)); + subframe.setMSBs(json.optInt("TOW17")); + subframe.setSatelliteNumber(json.optInt("tSV")); + subframe.setSubframeNumber(json.optInt("frame")); + subframe.setScaled(json.optBoolean("scaled", false)); + subframe.setPageid(json.optInt("pageid")); + if (json.has("system_message")) { + subframe.setSystemMessage(json.optString("system_message")); + } else if (json.has(ALMANACObject.NAME)) { + subframe.setAlmanac((ALMANACObject) this.parse(json.optJSONObject(ALMANACObject.NAME))); + } else if (json.has(EPHEM1Object.NAME)) { + subframe.setEphem1((EPHEM1Object) this.parse(json.optJSONObject(EPHEM1Object.NAME))); + } else if (json.has(EPHEM2Object.NAME)) { + subframe.setEphem2((EPHEM2Object) this.parse(json.optJSONObject(EPHEM2Object.NAME))); + } else if (json.has(EPHEM3Object.NAME)) { + subframe.setEphem3((EPHEM3Object) this.parse(json.optJSONObject(EPHEM3Object.NAME))); + } else if (json.has(ERDObject.NAME)) { + subframe.setErd((ERDObject) this.parse(json.optJSONObject(ERDObject.NAME))); + } else if (json.has(HEALTHObject.NAME)) { + subframe.setHealth((HEALTHObject) this.parse(json.optJSONObject(HEALTHObject.NAME))); + } else if (json.has(HEALTH2Object.NAME)) { + subframe.setHealth2((HEALTH2Object) this.parse(json.optJSONObject(HEALTH2Object.NAME))); + } else if (json.has(IONOObject.NAME)) { + subframe.setIono((IONOObject) this.parse(json.optJSONObject(IONOObject.NAME))); + } else { + AbstractResultParser.LOG.error("Unknown subframe: {}", json.toString()); + } + gps = subframe; + return gps; + } + + protected IGPSObject parseATT(final JSONObject json) { + IGPSObject gps; + final ATTObject att = new ATTObject(); + att.setTag(json.optString("tag", null)); + att.setDevice(json.optString("device", null)); + att.setTimestamp(this.parseTimestamp(json, "time")); + att.setHeading(json.optDouble("heading", Double.NaN)); + att.setPitch(json.optDouble("pitch", Double.NaN)); + att.setYaw(json.optDouble("yaw", Double.NaN)); + att.setRoll(json.optDouble("roll", Double.NaN)); + att.setDip(json.optDouble("dip", Double.NaN)); + att.setMag_len(json.optDouble("mag_len", Double.NaN)); + att.setMag_x(json.optDouble("mag_x", Double.NaN)); + att.setMag_y(json.optDouble("mag_y", Double.NaN)); + att.setMag_z(json.optDouble("mag_z", Double.NaN)); + att.setAcc_len(json.optDouble("acc_len", Double.NaN)); + att.setAcc_x(json.optDouble("acc_x", Double.NaN)); + att.setAcc_y(json.optDouble("acc_y", Double.NaN)); + att.setAcc_z(json.optDouble("acc_z", Double.NaN)); + att.setGyro_x(json.optDouble("gyro_x", Double.NaN)); + att.setGyro_y(json.optDouble("gyro_y", Double.NaN)); + att.setDepth(json.optDouble("depth", Double.NaN)); + att.setTemperature(json.optDouble("temperature", Double.NaN)); + att.setMagState(json.optString("mag_st", null)); + att.setRollState(json.optString("roll_st", null)); + att.setPitchState(json.optString("pitch_st", null)); + att.setYawState(json.optString("yaw_st", null)); + gps = att; + return gps; + } + + protected IGPSObject parseGST(final JSONObject json) { + IGPSObject gps; + final GSTObject gst = new GSTObject(); + gst.setTag(json.optString("tag", null)); + gst.setDevice(json.optString("device", null)); + gst.setTimestamp(this.parseTimestamp(json, "time")); + gst.setRms(json.optDouble("rms", Double.NaN)); + gst.setMajor(json.optDouble("major", Double.NaN)); + gst.setMinor(json.optDouble("minor", Double.NaN)); + gst.setOrient(json.optDouble("orient", Double.NaN)); + gst.setLat(json.optDouble("lat", Double.NaN)); + gst.setLon(json.optDouble("lon", Double.NaN)); + gst.setAlt(json.optDouble("alt", Double.NaN)); + gps = gst; + return gps; + } + + protected IGPSObject parseSKY(final JSONObject json) throws ParseException { + IGPSObject gps; + final SKYObject sky = new SKYObject(); + sky.setTag(json.optString("tag", null)); + sky.setDevice(json.optString("device", null)); + sky.setTimestamp(this.parseTimestamp(json, "time")); + sky.setLongitudeDOP(json.optDouble("xdop", Double.NaN)); + sky.setLatitudeDOP(json.optDouble("ydop", Double.NaN)); + sky.setAltitudeDOP(json.optDouble("vdop", Double.NaN)); + sky.setTimestampDOP(json.optDouble("tdop", Double.NaN)); + sky.setHorizontalDOP(json.optDouble("hdop", Double.NaN)); + sky.setSphericalDOP(json.optDouble("pdop", Double.NaN)); + sky.setHypersphericalDOP(json.optDouble("gdop", Double.NaN)); + sky.setSatellites(this.parseObjectArray(json.optJSONArray("satellites"), SATObject.class)); + gps = sky; + return gps; + } + + protected IGPSObject parseTPV(final JSONObject json) { + IGPSObject gps; + final TPVObject tpv = new TPVObject(); + tpv.setTag(json.optString("tag", null)); + tpv.setDevice(json.optString("device", null)); + tpv.setTimestamp(this.parseTimestamp(json, "time")); + tpv.setTimestampError(json.optDouble("ept", Double.NaN)); + tpv.setLatitude(json.optDouble("lat", Double.NaN)); + tpv.setLongitude(json.optDouble("lon", Double.NaN)); + tpv.setAltitude(json.optDouble("alt", Double.NaN)); + tpv.setLongitudeError(json.optDouble("epx", Double.NaN)); + tpv.setLatitudeError(json.optDouble("epy", Double.NaN)); + tpv.setAltitudeError(json.optDouble("epv", Double.NaN)); + tpv.setCourse(json.optDouble("track", Double.NaN)); + tpv.setSpeed(json.optDouble("speed", Double.NaN)); + tpv.setClimbRate(json.optDouble("climb", Double.NaN)); + tpv.setCourseError(json.optDouble("epd", Double.NaN)); + tpv.setSpeedError(json.optDouble("eps", Double.NaN)); + tpv.setClimbRateError(json.optDouble("epc", Double.NaN)); + tpv.setMode(ENMEAMode.fromInt(json.optInt("mode", 0))); + gps = tpv; + return gps; + } - protected IGPSObject parsePPS(final JSONObject json) { - IGPSObject gps; - final PpsObject pps = new PpsObject(); - pps.setDevice(json.optString("device", null)); - pps.setRealSec(json.optDouble("real_sec", Double.NaN)); - pps.setRealNsec(json.optDouble("real_nsec", Double.NaN)); - pps.setClockSec(json.optDouble("clock_sec", Double.NaN)); - pps.setClockNsec(json.optDouble("clock_nsec", Double.NaN)); - pps.setPrecision(json.optDouble("precision", Double.NaN)); - gps = pps; - return gps; - } + protected IGPSObject parsePPS(final JSONObject json) { + IGPSObject gps; + final PpsObject pps = new PpsObject(); + pps.setDevice(json.optString("device", null)); + pps.setRealSec(json.optDouble("real_sec", Double.NaN)); + pps.setRealNsec(json.optDouble("real_nsec", Double.NaN)); + pps.setClockSec(json.optDouble("clock_sec", Double.NaN)); + pps.setClockNsec(json.optDouble("clock_nsec", Double.NaN)); + pps.setPrecision(json.optDouble("precision", Double.NaN)); + gps = pps; + return gps; + } - protected IGPSObject parseTOFF(final JSONObject json) { - IGPSObject gps; - final ToffObject toff = new ToffObject(); - toff.setDevice(json.optString("device", null)); - toff.setRealSec(json.optDouble("real_sec", Double.NaN)); - toff.setRealNsec(json.optDouble("real_nsec", Double.NaN)); - toff.setClockSec(json.optDouble("clock_sec", Double.NaN)); - toff.setClockNsec(json.optDouble("clock_nsec", Double.NaN)); - gps = toff; - return gps; - } + protected IGPSObject parseTOFF(final JSONObject json) { + IGPSObject gps; + final ToffObject toff = new ToffObject(); + toff.setDevice(json.optString("device", null)); + toff.setRealSec(json.optDouble("real_sec", Double.NaN)); + toff.setRealNsec(json.optDouble("real_nsec", Double.NaN)); + toff.setClockSec(json.optDouble("clock_sec", Double.NaN)); + toff.setClockNsec(json.optDouble("clock_nsec", Double.NaN)); + gps = toff; + return gps; + } } diff --git a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java index f019713..f8c6e30 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java +++ b/src/main/java/de/taimos/gpsd4java/backend/SocketThread.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.net.SocketException; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,111 +32,116 @@ * @author thoeger */ public class SocketThread extends Thread { - - private static final Logger LOG = LoggerFactory.getLogger(SocketThread.class); - - private final BufferedReader reader; - - private final GPSdEndpoint endpoint; - - private final AbstractResultParser resultParser; - - private final WaitableBoolean running = new WaitableBoolean(true); - - /** - * @param reader the socket input - * @param endpoint the endpoint - * @param resultParser the result parser - * @param daemon whether to configure the thread as a daemon, as defined in {@link Thread#setDaemon} - */ - public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, - final AbstractResultParser resultParser, final boolean daemon) { - - if (resultParser == null) { - throw new IllegalArgumentException("resultParser can not be null!"); - } - - this.reader = reader; - this.endpoint = endpoint; - this.resultParser = resultParser; - - this.setDaemon(daemon); - this.setName("GPS Socket Thread"); - } - - /** - * @param reader the socket input - * @param endpoint the endpoint - * @param resultParser the result parser - */ - public SocketThread(final BufferedReader reader, final GPSdEndpoint endpoint, final AbstractResultParser resultParser) { - this(reader, endpoint, resultParser, true); - } - - @Override - public void run() { - if (this.reader != null) { - while (this.running.get()) { - try { - // read line from socket - final String s = this.reader.readLine(); - if (s == null) { - break; - } - if (!s.isEmpty()) { - // parse line and handle it accordingly - this.endpoint.handle(this.resultParser.parse(s)); - } - } catch (final SocketException e) { - break; // stop - } catch (final Exception e) { - // TODO handle this better - SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line", e); - } - } - } - if (this.running.get() && !Thread.interrupted()) { - if (this.reader != null) { - SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line, attempting restart"); - } - retry(); - } - } - - protected void retry() { - if (this.reader != null) { - SocketThread.LOG.debug("Disconnected from GPS socket, retrying connection"); - } else { - SocketThread.LOG.debug("Connecting to GPSD socket"); - } - - while (this.running.get()) { - try { - this.running.waitFor(this.endpoint.getRetryInterval()); - this.endpoint.handleDisconnected(); - SocketThread.LOG.debug("Connected to GPS socket"); - this.running.set(false); - } catch (InterruptedException ix) { - break; - } catch (IOException e) { - SocketThread.LOG.debug("Still disconnected from GPS socket, retrying connection again"); - } - } - } - - /** - * Halts the socket thread. - * - */ - public void halt() { - this.running.set(false); - - if (this.reader != null) { - try { - this.reader.close(); - } catch (final IOException e) { - // ignore - } - } - } -} \ No newline at end of file + + private static final Logger LOG = LoggerFactory.getLogger(SocketThread.class); + + private final BufferedReader reader; + + private final GPSdEndpoint endpoint; + + private final AbstractResultParser resultParser; + + private final WaitableBoolean running = new WaitableBoolean(true); + + /** + * @param reader the socket input + * @param endpoint the endpoint + * @param resultParser the result parser + * @param daemon whether to configure the thread as a daemon, as defined in {@link + * Thread#setDaemon} + */ + public SocketThread( + final BufferedReader reader, + final GPSdEndpoint endpoint, + final AbstractResultParser resultParser, + final boolean daemon) { + + if (resultParser == null) { + throw new IllegalArgumentException("resultParser can not be null!"); + } + + this.reader = reader; + this.endpoint = endpoint; + this.resultParser = resultParser; + + this.setDaemon(daemon); + this.setName("GPS Socket Thread"); + } + + /** + * @param reader the socket input + * @param endpoint the endpoint + * @param resultParser the result parser + */ + public SocketThread( + final BufferedReader reader, + final GPSdEndpoint endpoint, + final AbstractResultParser resultParser) { + this(reader, endpoint, resultParser, true); + } + + @Override + public void run() { + if (this.reader != null) { + while (this.running.get()) { + try { + // read line from socket + final String s = this.reader.readLine(); + if (s == null) { + break; + } + if (!s.isEmpty()) { + // parse line and handle it accordingly + this.endpoint.handle(this.resultParser.parse(s)); + } + } catch (final SocketException e) { + break; // stop + } catch (final Exception e) { + // TODO handle this better + SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line", e); + } + } + } + if (this.running.get() && !Thread.interrupted()) { + if (this.reader != null) { + SocketThread.LOG.warn( + "Problem encountered while reading/parsing/handling line, attempting restart"); + } + retry(); + } + } + + protected void retry() { + if (this.reader != null) { + SocketThread.LOG.debug("Disconnected from GPS socket, retrying connection"); + } else { + SocketThread.LOG.debug("Connecting to GPSD socket"); + } + + while (this.running.get()) { + try { + this.running.waitFor(this.endpoint.getRetryInterval()); + this.endpoint.handleDisconnected(); + SocketThread.LOG.debug("Connected to GPS socket"); + this.running.set(false); + } catch (InterruptedException ix) { + break; + } catch (IOException e) { + SocketThread.LOG.debug("Still disconnected from GPS socket, retrying connection again"); + } + } + } + + /** Halts the socket thread. */ + public void halt() { + this.running.set(false); + + if (this.reader != null) { + try { + this.reader.close(); + } catch (final IOException e) { + // ignore + } + } + } +} diff --git a/src/main/java/de/taimos/gpsd4java/backend/WaitableBoolean.java b/src/main/java/de/taimos/gpsd4java/backend/WaitableBoolean.java index 434f2ab..b843435 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/WaitableBoolean.java +++ b/src/main/java/de/taimos/gpsd4java/backend/WaitableBoolean.java @@ -6,23 +6,23 @@ * @author TimW */ class WaitableBoolean { - - private boolean val; - - public WaitableBoolean(boolean b) { - this.val = b; - } - - synchronized void set(boolean value) { - this.val = value; - notifyAll(); - } - - synchronized boolean get() { - return this.val; - } - - synchronized public void waitFor(long millis) throws InterruptedException { - super.wait(millis); - } -} \ No newline at end of file + + private boolean val; + + public WaitableBoolean(boolean b) { + this.val = b; + } + + synchronized void set(boolean value) { + this.val = value; + notifyAll(); + } + + synchronized boolean get() { + return this.val; + } + + public synchronized void waitFor(long millis) throws InterruptedException { + super.wait(millis); + } +} diff --git a/src/main/java/de/taimos/gpsd4java/types/ATTObject.java b/src/main/java/de/taimos/gpsd4java/types/ATTObject.java index c6e9fdd..8cce7c7 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ATTObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/ATTObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,553 +21,554 @@ */ /** - * An ATT object is a vehicle-attitude report. It is returned by digital-compass and gyroscope sensors; depending on device, it may include: - * heading, pitch, roll, yaw, gyroscope, and magnetic-field readings. Because such sensors are often bundled as part of marine-navigation + * An ATT object is a vehicle-attitude report. It is returned by digital-compass and gyroscope + * sensors; depending on device, it may include: heading, pitch, roll, yaw, gyroscope, and + * magnetic-field readings. Because such sensors are often bundled as part of marine-navigation * systems, the ATT response may also include water depth.
*
- *

- * all getters for double values may return Double.NaN if value is not present
+ * + *

all getters for double values may return Double.NaN if value is not present
* other getters may return null * * @author thoeger */ public class ATTObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "ATT"; - - private String tag = null; - - private String device = null; - - private double timestamp = Double.NaN; - - private double heading = Double.NaN; - - private double pitch = Double.NaN; - - private double yaw = Double.NaN; - - private double roll = Double.NaN; - - private double dip = Double.NaN; - - private double mag_len = Double.NaN; - - private double mag_x = Double.NaN; - - private double mag_y = Double.NaN; - - private double mag_z = Double.NaN; - - private double acc_len = Double.NaN; - - private double acc_x = Double.NaN; - - private double acc_y = Double.NaN; - - private double acc_z = Double.NaN; - - private double gyro_x = Double.NaN; - - private double gyro_y = Double.NaN; - - private double depth = Double.NaN; - - private double temperature = Double.NaN; - - private String magState = null; - - private String pitchState = null; - - private String yawState = null; - - private String rollState = null; - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @return the tag - */ - public String getTag() { - return this.tag; - } - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag the tag to set - */ - public void setTag(final String tag) { - this.tag = tag; - } - - /** - * Name of originating device - * - * @return the device - */ - public String getDevice() { - return this.device; - } - - /** - * Name of originating device - * - * @param device the device to set - */ - public void setDevice(final String device) { - this.device = device; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @return the timestamp - */ - public double getTimestamp() { - return this.timestamp; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @param timestamp the timestamp to set - */ - public void setTimestamp(final double timestamp) { - this.timestamp = timestamp; - } - - /** - * Heading, degrees from true north. - * - * @return the heading - */ - public double getHeading() { - return this.heading; - } - - /** - * Heading, degrees from true north. - * - * @param heading the heading to set - */ - public void setHeading(final double heading) { - this.heading = heading; - } - - /** - * Pitch in degrees. - * - * @return the pitch - */ - public double getPitch() { - return this.pitch; - } - - /** - * Pitch in degrees. - * - * @param pitch the pitch to set - */ - public void setPitch(final double pitch) { - this.pitch = pitch; - } - - /** - * Yaw in degrees - * - * @return the yaw - */ - public double getYaw() { - return this.yaw; - } - - /** - * Yaw in degrees - * - * @param yaw the yaw to set - */ - public void setYaw(final double yaw) { - this.yaw = yaw; - } - - /** - * Roll in degrees. - * - * @return the roll - */ - public double getRoll() { - return this.roll; - } - - /** - * Roll in degrees. - * - * @param roll the roll to set - */ - public void setRoll(final double roll) { - this.roll = roll; - } - - /** - * Roll in degrees. - * - * @return the dip - */ - public double getDip() { - return this.dip; - } - - /** - * Roll in degrees. - * - * @param dip the dip to set - */ - public void setDip(final double dip) { - this.dip = dip; - } - - /** - * Scalar magnetic field strength. - * - * @return the mag_len - */ - public double getMag_len() { - return this.mag_len; - } - - /** - * Scalar magnetic field strength. - * - * @param mag_len the mag_len to set - */ - public void setMag_len(final double mag_len) { - this.mag_len = mag_len; - } - - /** - * X component of magnetic field strength. - * - * @return the mag_x - */ - public double getMag_x() { - return this.mag_x; - } - - /** - * X component of magnetic field strength. - * - * @param mag_x the mag_x to set - */ - public void setMag_x(final double mag_x) { - this.mag_x = mag_x; - } - - /** - * Y component of magnetic field strength. - * - * @return the mag_y - */ - public double getMag_y() { - return this.mag_y; - } - - /** - * Y component of magnetic field strength. - * - * @param mag_y the mag_y to set - */ - public void setMag_y(final double mag_y) { - this.mag_y = mag_y; - } - - /** - * Z component of magnetic field strength. - * - * @return the mag_z - */ - public double getMag_z() { - return this.mag_z; - } - - /** - * Z component of magnetic field strength. - * - * @param mag_z the mag_z to set - */ - public void setMag_z(final double mag_z) { - this.mag_z = mag_z; - } - - /** - * Scalar acceleration. - * - * @return the acc_len - */ - public double getAcc_len() { - return this.acc_len; - } - - /** - * Scalar acceleration. - * - * @param acc_len the acc_len to set - */ - public void setAcc_len(final double acc_len) { - this.acc_len = acc_len; - } - - /** - * X component of acceleration. - * - * @return the acc_x - */ - public double getAcc_x() { - return this.acc_x; - } - - /** - * X component of acceleration. - * - * @param acc_x the acc_x to set - */ - public void setAcc_x(final double acc_x) { - this.acc_x = acc_x; - } - - /** - * Y component of acceleration. - * - * @return the acc_y - */ - public double getAcc_y() { - return this.acc_y; - } - - /** - * Y component of acceleration. - * - * @param acc_y the acc_y to set - */ - public void setAcc_y(final double acc_y) { - this.acc_y = acc_y; - } - - /** - * Z component of acceleration. - * - * @return the acc_z - */ - public double getAcc_z() { - return this.acc_z; - } - - /** - * Z component of acceleration. - * - * @param acc_z the acc_z to set - */ - public void setAcc_z(final double acc_z) { - this.acc_z = acc_z; - } - - /** - * X component of acceleration. - * - * @return the gyro_x - */ - public double getGyro_x() { - return this.gyro_x; - } - - /** - * X component of acceleration. - * - * @param gyro_x the gyro_x to set - */ - public void setGyro_x(final double gyro_x) { - this.gyro_x = gyro_x; - } - - /** - * Y component of acceleration. - * - * @return the gyro_y - */ - public double getGyro_y() { - return this.gyro_y; - } - - /** - * Y component of acceleration. - * - * @param gyro_y the gyro_y to set - */ - public void setGyro_y(final double gyro_y) { - this.gyro_y = gyro_y; - } - - /** - * Water depth in meters. - * - * @return the depth - */ - public double getDepth() { - return this.depth; - } - - /** - * Water depth in meters. - * - * @param depth the depth to set - */ - public void setDepth(final double depth) { - this.depth = depth; - } - - /** - * Temperature at sensor, degrees centigrade. - * - * @return the temperature - */ - public double getTemperature() { - return this.temperature; - } - - /** - * Temperature at sensor, degrees centigrade. - * - * @param temperature the temperature to set - */ - public void setTemperature(final double temperature) { - this.temperature = temperature; - } - - /** - * Magnetometer status. - * - * @return the magState - */ - public String getMagState() { - return this.magState; - } - - /** - * Magnetometer status. - * - * @param magState the magState to set - */ - public void setMagState(final String magState) { - this.magState = magState; - } - - /** - * Pitch sensor status. - * - * @return the pitchState - */ - public String getPitchState() { - return this.pitchState; - } - - /** - * Pitch sensor status. - * - * @param pitchState the pitchState to set - */ - public void setPitchState(final String pitchState) { - this.pitchState = pitchState; - } - - /** - * Yaw sensor status. - * - * @return the yawState - */ - public String getYawState() { - return this.yawState; - } - - /** - * Yaw sensor status. - * - * @param yawState the yawState to set - */ - public void setYawState(final String yawState) { - this.yawState = yawState; - } - - /** - * Roll sensor status. - * - * @return the rollState - */ - public String getRollState() { - return this.rollState; - } - - /** - * Roll sensor status. - * - * @param rollState the rollState to set - */ - public void setRollState(final String rollState) { - this.rollState = rollState; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ATTObject{tag="); - sb.append(this.tag); - sb.append(", device="); - sb.append(this.device); - sb.append(", timestamp="); - sb.append(this.timestamp); - sb.append(", heading="); - sb.append(this.heading); - sb.append(", mag_st="); - sb.append(this.magState); - sb.append(", pitch="); - sb.append(this.pitch); - sb.append(", pitch_st="); - sb.append(this.pitchState); - sb.append(", yaw="); - sb.append(this.yawState); - sb.append(", roll="); - sb.append(this.roll); - sb.append(", roll_st="); - sb.append(this.rollState); - sb.append(", dip="); - sb.append(this.dip); - sb.append(", mag_len="); - sb.append(this.mag_len); - sb.append(", mag_x="); - sb.append(this.mag_x); - sb.append(", mag_y="); - sb.append(this.mag_y); - sb.append(", mag_z="); - sb.append(this.mag_z); - sb.append(", acc_len="); - sb.append(this.acc_len); - sb.append(", acc_x="); - sb.append(this.acc_x); - sb.append(", acc_y="); - sb.append(this.acc_y); - sb.append(", acc_z="); - sb.append(this.acc_z); - sb.append(", gyro_x="); - sb.append(this.gyro_x); - sb.append(", gyro_y="); - sb.append(this.gyro_y); - sb.append(", depth="); - sb.append(this.depth); - sb.append(", temperature="); - sb.append(this.temperature); - sb.append("}"); - return sb.toString(); - } + + /** the GPSd internal name */ + public static final String NAME = "ATT"; + + private String tag = null; + + private String device = null; + + private double timestamp = Double.NaN; + + private double heading = Double.NaN; + + private double pitch = Double.NaN; + + private double yaw = Double.NaN; + + private double roll = Double.NaN; + + private double dip = Double.NaN; + + private double mag_len = Double.NaN; + + private double mag_x = Double.NaN; + + private double mag_y = Double.NaN; + + private double mag_z = Double.NaN; + + private double acc_len = Double.NaN; + + private double acc_x = Double.NaN; + + private double acc_y = Double.NaN; + + private double acc_z = Double.NaN; + + private double gyro_x = Double.NaN; + + private double gyro_y = Double.NaN; + + private double depth = Double.NaN; + + private double temperature = Double.NaN; + + private String magState = null; + + private String pitchState = null; + + private String yawState = null; + + private String rollState = null; + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @return the tag + */ + public String getTag() { + return this.tag; + } + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @param tag the tag to set + */ + public void setTag(final String tag) { + this.tag = tag; + } + + /** + * Name of originating device + * + * @return the device + */ + public String getDevice() { + return this.device; + } + + /** + * Name of originating device + * + * @param device the device to set + */ + public void setDevice(final String device) { + this.device = device; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. + * + * @return the timestamp + */ + public double getTimestamp() { + return this.timestamp; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. + * + * @param timestamp the timestamp to set + */ + public void setTimestamp(final double timestamp) { + this.timestamp = timestamp; + } + + /** + * Heading, degrees from true north. + * + * @return the heading + */ + public double getHeading() { + return this.heading; + } + + /** + * Heading, degrees from true north. + * + * @param heading the heading to set + */ + public void setHeading(final double heading) { + this.heading = heading; + } + + /** + * Pitch in degrees. + * + * @return the pitch + */ + public double getPitch() { + return this.pitch; + } + + /** + * Pitch in degrees. + * + * @param pitch the pitch to set + */ + public void setPitch(final double pitch) { + this.pitch = pitch; + } + + /** + * Yaw in degrees + * + * @return the yaw + */ + public double getYaw() { + return this.yaw; + } + + /** + * Yaw in degrees + * + * @param yaw the yaw to set + */ + public void setYaw(final double yaw) { + this.yaw = yaw; + } + + /** + * Roll in degrees. + * + * @return the roll + */ + public double getRoll() { + return this.roll; + } + + /** + * Roll in degrees. + * + * @param roll the roll to set + */ + public void setRoll(final double roll) { + this.roll = roll; + } + + /** + * Roll in degrees. + * + * @return the dip + */ + public double getDip() { + return this.dip; + } + + /** + * Roll in degrees. + * + * @param dip the dip to set + */ + public void setDip(final double dip) { + this.dip = dip; + } + + /** + * Scalar magnetic field strength. + * + * @return the mag_len + */ + public double getMag_len() { + return this.mag_len; + } + + /** + * Scalar magnetic field strength. + * + * @param mag_len the mag_len to set + */ + public void setMag_len(final double mag_len) { + this.mag_len = mag_len; + } + + /** + * X component of magnetic field strength. + * + * @return the mag_x + */ + public double getMag_x() { + return this.mag_x; + } + + /** + * X component of magnetic field strength. + * + * @param mag_x the mag_x to set + */ + public void setMag_x(final double mag_x) { + this.mag_x = mag_x; + } + + /** + * Y component of magnetic field strength. + * + * @return the mag_y + */ + public double getMag_y() { + return this.mag_y; + } + + /** + * Y component of magnetic field strength. + * + * @param mag_y the mag_y to set + */ + public void setMag_y(final double mag_y) { + this.mag_y = mag_y; + } + + /** + * Z component of magnetic field strength. + * + * @return the mag_z + */ + public double getMag_z() { + return this.mag_z; + } + + /** + * Z component of magnetic field strength. + * + * @param mag_z the mag_z to set + */ + public void setMag_z(final double mag_z) { + this.mag_z = mag_z; + } + + /** + * Scalar acceleration. + * + * @return the acc_len + */ + public double getAcc_len() { + return this.acc_len; + } + + /** + * Scalar acceleration. + * + * @param acc_len the acc_len to set + */ + public void setAcc_len(final double acc_len) { + this.acc_len = acc_len; + } + + /** + * X component of acceleration. + * + * @return the acc_x + */ + public double getAcc_x() { + return this.acc_x; + } + + /** + * X component of acceleration. + * + * @param acc_x the acc_x to set + */ + public void setAcc_x(final double acc_x) { + this.acc_x = acc_x; + } + + /** + * Y component of acceleration. + * + * @return the acc_y + */ + public double getAcc_y() { + return this.acc_y; + } + + /** + * Y component of acceleration. + * + * @param acc_y the acc_y to set + */ + public void setAcc_y(final double acc_y) { + this.acc_y = acc_y; + } + + /** + * Z component of acceleration. + * + * @return the acc_z + */ + public double getAcc_z() { + return this.acc_z; + } + + /** + * Z component of acceleration. + * + * @param acc_z the acc_z to set + */ + public void setAcc_z(final double acc_z) { + this.acc_z = acc_z; + } + + /** + * X component of acceleration. + * + * @return the gyro_x + */ + public double getGyro_x() { + return this.gyro_x; + } + + /** + * X component of acceleration. + * + * @param gyro_x the gyro_x to set + */ + public void setGyro_x(final double gyro_x) { + this.gyro_x = gyro_x; + } + + /** + * Y component of acceleration. + * + * @return the gyro_y + */ + public double getGyro_y() { + return this.gyro_y; + } + + /** + * Y component of acceleration. + * + * @param gyro_y the gyro_y to set + */ + public void setGyro_y(final double gyro_y) { + this.gyro_y = gyro_y; + } + + /** + * Water depth in meters. + * + * @return the depth + */ + public double getDepth() { + return this.depth; + } + + /** + * Water depth in meters. + * + * @param depth the depth to set + */ + public void setDepth(final double depth) { + this.depth = depth; + } + + /** + * Temperature at sensor, degrees centigrade. + * + * @return the temperature + */ + public double getTemperature() { + return this.temperature; + } + + /** + * Temperature at sensor, degrees centigrade. + * + * @param temperature the temperature to set + */ + public void setTemperature(final double temperature) { + this.temperature = temperature; + } + + /** + * Magnetometer status. + * + * @return the magState + */ + public String getMagState() { + return this.magState; + } + + /** + * Magnetometer status. + * + * @param magState the magState to set + */ + public void setMagState(final String magState) { + this.magState = magState; + } + + /** + * Pitch sensor status. + * + * @return the pitchState + */ + public String getPitchState() { + return this.pitchState; + } + + /** + * Pitch sensor status. + * + * @param pitchState the pitchState to set + */ + public void setPitchState(final String pitchState) { + this.pitchState = pitchState; + } + + /** + * Yaw sensor status. + * + * @return the yawState + */ + public String getYawState() { + return this.yawState; + } + + /** + * Yaw sensor status. + * + * @param yawState the yawState to set + */ + public void setYawState(final String yawState) { + this.yawState = yawState; + } + + /** + * Roll sensor status. + * + * @return the rollState + */ + public String getRollState() { + return this.rollState; + } + + /** + * Roll sensor status. + * + * @param rollState the rollState to set + */ + public void setRollState(final String rollState) { + this.rollState = rollState; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("ATTObject{tag="); + sb.append(this.tag); + sb.append(", device="); + sb.append(this.device); + sb.append(", timestamp="); + sb.append(this.timestamp); + sb.append(", heading="); + sb.append(this.heading); + sb.append(", mag_st="); + sb.append(this.magState); + sb.append(", pitch="); + sb.append(this.pitch); + sb.append(", pitch_st="); + sb.append(this.pitchState); + sb.append(", yaw="); + sb.append(this.yawState); + sb.append(", roll="); + sb.append(this.roll); + sb.append(", roll_st="); + sb.append(this.rollState); + sb.append(", dip="); + sb.append(this.dip); + sb.append(", mag_len="); + sb.append(this.mag_len); + sb.append(", mag_x="); + sb.append(this.mag_x); + sb.append(", mag_y="); + sb.append(this.mag_y); + sb.append(", mag_z="); + sb.append(this.mag_z); + sb.append(", acc_len="); + sb.append(this.acc_len); + sb.append(", acc_x="); + sb.append(this.acc_x); + sb.append(", acc_y="); + sb.append(this.acc_y); + sb.append(", acc_z="); + sb.append(this.acc_z); + sb.append(", gyro_x="); + sb.append(this.gyro_x); + sb.append(", gyro_y="); + sb.append(this.gyro_y); + sb.append(", depth="); + sb.append(this.depth); + sb.append(", temperature="); + sb.append(this.temperature); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java b/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java index 39601bc..bdabec1 100644 --- a/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/DeviceObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,285 +24,286 @@ * @author thoeger */ public class DeviceObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "DEVICE"; - - private String path; - - private double activated; - - private String driver; - - private int bps; - - private EParity parity; - - private int stopbit; - - private boolean nativeMode; - - private double cycle; - - private double mincycle; - - /** - * Name the device for which the control bits are being reported - * - * @return the path - */ - public String getPath() { - return this.path; - } - - /** - * Name the device for which the control bits are being reported - * - * @param path the path to set - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * Time the device was activated, or 0 if it is being closed. - * - * @return the activated - */ - public double getActivated() { - return this.activated; - } - - /** - * Time the device was activated, or 0 if it is being closed. - * - * @param activated the activated to set - */ - public void setActivated(final double activated) { - this.activated = activated; - } - - /** - * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable packets from the device. - * - * @return the driver - */ - public String getDriver() { - return this.driver; - } - - /** - * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable packets from the device. - * - * @param driver the driver to set - */ - public void setDriver(final String driver) { - this.driver = driver; - } - - /** - * Device speed in bits per second. - * - * @return the bps - */ - public int getBps() { - return this.bps; - } - - /** - * Device speed in bits per second. - * - * @param bps the bps to set - */ - public void setBps(final int bps) { - this.bps = bps; - } - - /** - * Device parity - * - * @return the parity - */ - public EParity getParity() { - return this.parity; - } - - /** - * Device parity - * - * @param parity the parity to set - */ - public void setParity(final EParity parity) { - this.parity = parity; - } - - /** - * Device Stopbits - * - * @return the stopbit - */ - public int getStopbit() { - return this.stopbit; - } - - /** - * Device Stopbits - * - * @param stopbit the stopbit to set - */ - public void setStopbit(final int stopbit) { - this.stopbit = stopbit; - } - - /** - * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and Evermore chipsets in particular). - * - * @return the nativeMode - */ - public boolean isNativeMode() { - return this.nativeMode; - } - - /** - * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and Evermore chipsets in particular). - * - * @param nativeMode the nativeMode to set - */ - public void setNativeMode(final boolean nativeMode) { - this.nativeMode = nativeMode; - } - - /** - * Device cycle time in seconds. - * - * @return the cycle - */ - public double getCycle() { - return this.cycle; - } - - /** - * Device cycle time in seconds. - * - * @param cycle the cycle to set - */ - public void setCycle(final double cycle) { - this.cycle = cycle; - } - - /** - * Device minimum cycle time in seconds. - * - * @return the mincycle - */ - public double getMincycle() { - return this.mincycle; - } - - /** - * Device minimum cycle time in seconds. - * - * @param mincycle the mincycle to set - */ - public void setMincycle(final double mincycle) { - this.mincycle = mincycle; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(this.activated); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + this.bps; - temp = Double.doubleToLongBits(this.cycle); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.driver == null) ? 0 : this.driver.hashCode()); - temp = Double.doubleToLongBits(this.mincycle); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + (this.nativeMode ? 1231 : 1237); - result = (prime * result) + ((this.parity == null) ? 0 : this.parity.hashCode()); - result = (prime * result) + ((this.path == null) ? 0 : this.path.hashCode()); - result = (prime * result) + this.stopbit; - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final DeviceObject other = (DeviceObject) obj; - if (Double.doubleToLongBits(this.activated) != Double.doubleToLongBits(other.activated)) { - return false; - } - if (this.bps != other.bps) { - return false; - } - if (Double.doubleToLongBits(this.cycle) != Double.doubleToLongBits(other.cycle)) { - return false; - } - if (this.driver == null) { - if (other.driver != null) { - return false; - } - } else if (!this.driver.equals(other.driver)) { - return false; - } - if (Double.doubleToLongBits(this.mincycle) != Double.doubleToLongBits(other.mincycle)) { - return false; - } - if (this.nativeMode != other.nativeMode) { - return false; - } - if (this.parity != other.parity) { - return false; - } - if (this.path == null) { - if (other.path != null) { - return false; - } - } else if (!this.path.equals(other.path)) { - return false; - } - if (this.stopbit != other.stopbit) { - return false; - } - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("DeviceObject{path="); - sb.append(this.path); - sb.append(", driver="); - sb.append(this.driver); - sb.append(", activated="); - sb.append((long) this.activated); - sb.append(", bps="); - sb.append(this.bps); - sb.append(", parity="); - sb.append(this.parity); - sb.append(", stopbit="); - sb.append(this.stopbit); - sb.append(", nativeMode="); - sb.append(this.nativeMode); - sb.append(", cycle="); - sb.append(this.cycle); - sb.append(", minCycle="); - sb.append(this.mincycle); - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "DEVICE"; + + private String path; + + private double activated; + + private String driver; + + private int bps; + + private EParity parity; + + private int stopbit; + + private boolean nativeMode; + + private double cycle; + + private double mincycle; + + /** + * Name the device for which the control bits are being reported + * + * @return the path + */ + public String getPath() { + return this.path; + } + + /** + * Name the device for which the control bits are being reported + * + * @param path the path to set + */ + public void setPath(final String path) { + this.path = path; + } + + /** + * Time the device was activated, or 0 if it is being closed. + * + * @return the activated + */ + public double getActivated() { + return this.activated; + } + + /** + * Time the device was activated, or 0 if it is being closed. + * + * @param activated the activated to set + */ + public void setActivated(final double activated) { + this.activated = activated; + } + + /** + * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable + * packets from the device. + * + * @return the driver + */ + public String getDriver() { + return this.driver; + } + + /** + * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable + * packets from the device. + * + * @param driver the driver to set + */ + public void setDriver(final String driver) { + this.driver = driver; + } + + /** + * Device speed in bits per second. + * + * @return the bps + */ + public int getBps() { + return this.bps; + } + + /** + * Device speed in bits per second. + * + * @param bps the bps to set + */ + public void setBps(final int bps) { + this.bps = bps; + } + + /** + * Device parity + * + * @return the parity + */ + public EParity getParity() { + return this.parity; + } + + /** + * Device parity + * + * @param parity the parity to set + */ + public void setParity(final EParity parity) { + this.parity = parity; + } + + /** + * Device Stopbits + * + * @return the stopbit + */ + public int getStopbit() { + return this.stopbit; + } + + /** + * Device Stopbits + * + * @param stopbit the stopbit to set + */ + public void setStopbit(final int stopbit) { + this.stopbit = stopbit; + } + + /** + * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and + * Evermore chipsets in particular). + * + * @return the nativeMode + */ + public boolean isNativeMode() { + return this.nativeMode; + } + + /** + * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and + * Evermore chipsets in particular). + * + * @param nativeMode the nativeMode to set + */ + public void setNativeMode(final boolean nativeMode) { + this.nativeMode = nativeMode; + } + + /** + * Device cycle time in seconds. + * + * @return the cycle + */ + public double getCycle() { + return this.cycle; + } + + /** + * Device cycle time in seconds. + * + * @param cycle the cycle to set + */ + public void setCycle(final double cycle) { + this.cycle = cycle; + } + + /** + * Device minimum cycle time in seconds. + * + * @return the mincycle + */ + public double getMincycle() { + return this.mincycle; + } + + /** + * Device minimum cycle time in seconds. + * + * @param mincycle the mincycle to set + */ + public void setMincycle(final double mincycle) { + this.mincycle = mincycle; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.activated); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + this.bps; + temp = Double.doubleToLongBits(this.cycle); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.driver == null) ? 0 : this.driver.hashCode()); + temp = Double.doubleToLongBits(this.mincycle); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + (this.nativeMode ? 1231 : 1237); + result = (prime * result) + ((this.parity == null) ? 0 : this.parity.hashCode()); + result = (prime * result) + ((this.path == null) ? 0 : this.path.hashCode()); + result = (prime * result) + this.stopbit; + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final DeviceObject other = (DeviceObject) obj; + if (Double.doubleToLongBits(this.activated) != Double.doubleToLongBits(other.activated)) { + return false; + } + if (this.bps != other.bps) { + return false; + } + if (Double.doubleToLongBits(this.cycle) != Double.doubleToLongBits(other.cycle)) { + return false; + } + if (this.driver == null) { + if (other.driver != null) { + return false; + } + } else if (!this.driver.equals(other.driver)) { + return false; + } + if (Double.doubleToLongBits(this.mincycle) != Double.doubleToLongBits(other.mincycle)) { + return false; + } + if (this.nativeMode != other.nativeMode) { + return false; + } + if (this.parity != other.parity) { + return false; + } + if (this.path == null) { + if (other.path != null) { + return false; + } + } else if (!this.path.equals(other.path)) { + return false; + } + if (this.stopbit != other.stopbit) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("DeviceObject{path="); + sb.append(this.path); + sb.append(", driver="); + sb.append(this.driver); + sb.append(", activated="); + sb.append((long) this.activated); + sb.append(", bps="); + sb.append(this.bps); + sb.append(", parity="); + sb.append(this.parity); + sb.append(", stopbit="); + sb.append(this.stopbit); + sb.append(", nativeMode="); + sb.append(this.nativeMode); + sb.append(", cycle="); + sb.append(this.cycle); + sb.append(", minCycle="); + sb.append(this.mincycle); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java b/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java index 2583284..b6aad21 100644 --- a/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/DevicesObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,65 +26,62 @@ * @author thoeger */ public class DevicesObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "DEVICES"; - - private List devices; - - /** - * list of devices - * - * @return the devices - */ - public List getDevices() { - return this.devices; - } - - /** - * list of devices - * - * @param devices the devices to set - */ - public void setDevices(final List devices) { - this.devices = devices; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = (prime * result) + ((this.devices == null) ? 0 : this.devices.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final DevicesObject other = (DevicesObject) obj; - if (this.devices == null) { - if (other.devices != null) { - return false; - } - } else if (!this.devices.equals(other.devices)) { - return false; - } - return true; - } - - @Override - public String toString() { - return "DevicesObject{devices=" + ((this.devices == null) ? 0 : this.devices.size()) + "}"; - } - + + /** the GPSd internal name */ + public static final String NAME = "DEVICES"; + + private List devices; + + /** + * list of devices + * + * @return the devices + */ + public List getDevices() { + return this.devices; + } + + /** + * list of devices + * + * @param devices the devices to set + */ + public void setDevices(final List devices) { + this.devices = devices; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + ((this.devices == null) ? 0 : this.devices.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final DevicesObject other = (DevicesObject) obj; + if (this.devices == null) { + if (other.devices != null) { + return false; + } + } else if (!this.devices.equals(other.devices)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "DevicesObject{devices=" + ((this.devices == null) ? 0 : this.devices.size()) + "}"; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java b/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java index 10e453a..9261852 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java +++ b/src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,41 +26,33 @@ * @author thoeger */ public enum ENMEAMode { - - /** - * no mode value yet seen - */ - NotSeen, - /** - * No fix available - */ - NoFix, - /** - * two dimensional fix - */ - TwoDimensional, - /** - * three dimensional fix - */ - ThreeDimensional; - - /** - * @param mode - mode integer - * @return {@link ENMEAMode} - */ - public static ENMEAMode fromInt(final int mode) { - switch (mode) { - case 0: - return NotSeen; - case 1: - return NoFix; - case 2: - return TwoDimensional; - case 3: - return ThreeDimensional; - default: - break; - } - return NotSeen; - } + + /** no mode value yet seen */ + NotSeen, + /** No fix available */ + NoFix, + /** two dimensional fix */ + TwoDimensional, + /** three dimensional fix */ + ThreeDimensional; + + /** + * @param mode - mode integer + * @return {@link ENMEAMode} + */ + public static ENMEAMode fromInt(final int mode) { + switch (mode) { + case 0: + return NotSeen; + case 1: + return NoFix; + case 2: + return TwoDimensional; + case 3: + return ThreeDimensional; + default: + break; + } + return NotSeen; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/EParity.java b/src/main/java/de/taimos/gpsd4java/types/EParity.java index 3f0f2bc..bf0aa42 100644 --- a/src/main/java/de/taimos/gpsd4java/types/EParity.java +++ b/src/main/java/de/taimos/gpsd4java/types/EParity.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,37 +24,31 @@ * @author thoeger */ public enum EParity { - - /** - * - */ - NO, - /** - * - */ - ODD, - /** - * - */ - EVEN; - - /** - * @param parity the parity string - * @return {@link EParity} - */ - public static EParity fromString(final String parity) { - if (parity == null) { - return NO; - } - if (parity.equals("N")) { - return NO; - } - if (parity.equals("O")) { - return ODD; - } - if (parity.equals("E")) { - return EVEN; - } - return NO; - } + + /** */ + NO, + /** */ + ODD, + /** */ + EVEN; + + /** + * @param parity the parity string + * @return {@link EParity} + */ + public static EParity fromString(final String parity) { + if (parity == null) { + return NO; + } + if (parity.equals("N")) { + return NO; + } + if (parity.equals("O")) { + return ODD; + } + if (parity.equals("E")) { + return EVEN; + } + return NO; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/GSTObject.java b/src/main/java/de/taimos/gpsd4java/types/GSTObject.java index d581b21..65bad7a 100644 --- a/src/main/java/de/taimos/gpsd4java/types/GSTObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/GSTObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,317 +28,317 @@ * @author thoeger */ public class GSTObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "GST"; - - private String tag = null; - - private String device = null; - - private double timestamp = Double.NaN; - - private double rms = Double.NaN; - - private double major = Double.NaN; - - private double minor = Double.NaN; - - private double orient = Double.NaN; - - private double lat = Double.NaN; - - private double lon = Double.NaN; - - private double alt = Double.NaN; - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @return the tag - */ - public String getTag() { - return this.tag; - } - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag the tag to set - */ - public void setTag(final String tag) { - this.tag = tag; - } - - /** - * Name of originating device - * - * @return the device - */ - public String getDevice() { - return this.device; - } - - /** - * Name of originating device - * - * @param device the device to set - */ - public void setDevice(final String device) { - this.device = device; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @return the timestamp - */ - public double getTimestamp() { - return this.timestamp; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @param timestamp the timestamp to set - */ - public void setTimestamp(final double timestamp) { - this.timestamp = timestamp; - } - - /** - * Value of the standard deviation of the range inputs to the navigation process (range inputs include pseudoranges and DGPS - * corrections). - * - * @return the rms - */ - public double getRms() { - return this.rms; - } - - /** - * Value of the standard deviation of the range inputs to the navigation process (range inputs include pseudoranges and DGPS - * corrections). - * - * @param rms the rms to set - */ - public void setRms(final double rms) { - this.rms = rms; - } - - /** - * Standard deviation of semi-major axis of error ellipse, in meters. - * - * @return the major - */ - public double getMajor() { - return this.major; - } - - /** - * Standard deviation of semi-major axis of error ellipse, in meters. - * - * @param major the major to set - */ - public void setMajor(final double major) { - this.major = major; - } - - /** - * Standard deviation of semi-minor axis of error ellipse, in meters. - * - * @return the minor - */ - public double getMinor() { - return this.minor; - } - - /** - * Standard deviation of semi-minor axis of error ellipse, in meters. - * - * @param minor the minor to set - */ - public void setMinor(final double minor) { - this.minor = minor; - } - - /** - * Orientation of semi-major axis of error ellipse, in degrees from true north. - * - * @return the orient - */ - public double getOrient() { - return this.orient; - } - - /** - * Orientation of semi-major axis of error ellipse, in degrees from true north. - * - * @param orient the orient to set - */ - public void setOrient(final double orient) { - this.orient = orient; - } - - /** - * Standard deviation of latitude error, in meters. - * - * @return the lat - */ - public double getLat() { - return this.lat; - } - - /** - * Standard deviation of latitude error, in meters. - * - * @param lat the lat to set - */ - public void setLat(final double lat) { - this.lat = lat; - } - - /** - * Standard deviation of longitude error, in meters. - * - * @return the lon - */ - public double getLon() { - return this.lon; - } - - /** - * Standard deviation of longitude error, in meters. - * - * @param lon the lon to set - */ - public void setLon(final double lon) { - this.lon = lon; - } - - /** - * Standard deviation of altitude error, in meters. - * - * @return the alt - */ - public double getAlt() { - return this.alt; - } - - /** - * Standard deviation of altitude error, in meters. - * - * @param alt the alt to set - */ - public void setAlt(final double alt) { - this.alt = alt; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(this.alt); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); - temp = Double.doubleToLongBits(this.lat); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.lon); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.major); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.minor); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.orient); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.rms); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); - temp = Double.doubleToLongBits(this.timestamp); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final GSTObject other = (GSTObject) obj; - if (Double.doubleToLongBits(this.alt) != Double.doubleToLongBits(other.alt)) { - return false; - } - if (this.device == null) { - if (other.device != null) { - return false; - } - } else if (!this.device.equals(other.device)) { - return false; - } - if (Double.doubleToLongBits(this.lat) != Double.doubleToLongBits(other.lat)) { - return false; - } - if (Double.doubleToLongBits(this.lon) != Double.doubleToLongBits(other.lon)) { - return false; - } - if (Double.doubleToLongBits(this.major) != Double.doubleToLongBits(other.major)) { - return false; - } - if (Double.doubleToLongBits(this.minor) != Double.doubleToLongBits(other.minor)) { - return false; - } - if (Double.doubleToLongBits(this.orient) != Double.doubleToLongBits(other.orient)) { - return false; - } - if (Double.doubleToLongBits(this.rms) != Double.doubleToLongBits(other.rms)) { - return false; - } - if (this.tag == null) { - if (other.tag != null) { - return false; - } - } else if (!this.tag.equals(other.tag)) { - return false; - } - if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { - return false; - } - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("GSTObject{tag="); - sb.append(this.tag); - sb.append(", device="); - sb.append(this.device); - sb.append(", timestamp="); - sb.append(this.timestamp); - sb.append(", rms="); - sb.append(this.rms); - sb.append(", major="); - sb.append(this.major); - sb.append(", minor="); - sb.append(this.minor); - sb.append(", orient="); - sb.append(this.orient); - sb.append(", lat="); - sb.append(this.lat); - sb.append(", lon="); - sb.append(this.lon); - sb.append(", alt="); - sb.append(this.alt); - sb.append("}"); - return sb.toString(); - } + + /** the GPSd internal name */ + public static final String NAME = "GST"; + + private String tag = null; + + private String device = null; + + private double timestamp = Double.NaN; + + private double rms = Double.NaN; + + private double major = Double.NaN; + + private double minor = Double.NaN; + + private double orient = Double.NaN; + + private double lat = Double.NaN; + + private double lon = Double.NaN; + + private double alt = Double.NaN; + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @return the tag + */ + public String getTag() { + return this.tag; + } + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @param tag the tag to set + */ + public void setTag(final String tag) { + this.tag = tag; + } + + /** + * Name of originating device + * + * @return the device + */ + public String getDevice() { + return this.device; + } + + /** + * Name of originating device + * + * @param device the device to set + */ + public void setDevice(final String device) { + this.device = device; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. + * + * @return the timestamp + */ + public double getTimestamp() { + return this.timestamp; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. + * + * @param timestamp the timestamp to set + */ + public void setTimestamp(final double timestamp) { + this.timestamp = timestamp; + } + + /** + * Value of the standard deviation of the range inputs to the navigation process (range inputs + * include pseudoranges and DGPS corrections). + * + * @return the rms + */ + public double getRms() { + return this.rms; + } + + /** + * Value of the standard deviation of the range inputs to the navigation process (range inputs + * include pseudoranges and DGPS corrections). + * + * @param rms the rms to set + */ + public void setRms(final double rms) { + this.rms = rms; + } + + /** + * Standard deviation of semi-major axis of error ellipse, in meters. + * + * @return the major + */ + public double getMajor() { + return this.major; + } + + /** + * Standard deviation of semi-major axis of error ellipse, in meters. + * + * @param major the major to set + */ + public void setMajor(final double major) { + this.major = major; + } + + /** + * Standard deviation of semi-minor axis of error ellipse, in meters. + * + * @return the minor + */ + public double getMinor() { + return this.minor; + } + + /** + * Standard deviation of semi-minor axis of error ellipse, in meters. + * + * @param minor the minor to set + */ + public void setMinor(final double minor) { + this.minor = minor; + } + + /** + * Orientation of semi-major axis of error ellipse, in degrees from true north. + * + * @return the orient + */ + public double getOrient() { + return this.orient; + } + + /** + * Orientation of semi-major axis of error ellipse, in degrees from true north. + * + * @param orient the orient to set + */ + public void setOrient(final double orient) { + this.orient = orient; + } + + /** + * Standard deviation of latitude error, in meters. + * + * @return the lat + */ + public double getLat() { + return this.lat; + } + + /** + * Standard deviation of latitude error, in meters. + * + * @param lat the lat to set + */ + public void setLat(final double lat) { + this.lat = lat; + } + + /** + * Standard deviation of longitude error, in meters. + * + * @return the lon + */ + public double getLon() { + return this.lon; + } + + /** + * Standard deviation of longitude error, in meters. + * + * @param lon the lon to set + */ + public void setLon(final double lon) { + this.lon = lon; + } + + /** + * Standard deviation of altitude error, in meters. + * + * @return the alt + */ + public double getAlt() { + return this.alt; + } + + /** + * Standard deviation of altitude error, in meters. + * + * @param alt the alt to set + */ + public void setAlt(final double alt) { + this.alt = alt; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.alt); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); + temp = Double.doubleToLongBits(this.lat); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.lon); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.major); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.minor); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.orient); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.rms); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); + temp = Double.doubleToLongBits(this.timestamp); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final GSTObject other = (GSTObject) obj; + if (Double.doubleToLongBits(this.alt) != Double.doubleToLongBits(other.alt)) { + return false; + } + if (this.device == null) { + if (other.device != null) { + return false; + } + } else if (!this.device.equals(other.device)) { + return false; + } + if (Double.doubleToLongBits(this.lat) != Double.doubleToLongBits(other.lat)) { + return false; + } + if (Double.doubleToLongBits(this.lon) != Double.doubleToLongBits(other.lon)) { + return false; + } + if (Double.doubleToLongBits(this.major) != Double.doubleToLongBits(other.major)) { + return false; + } + if (Double.doubleToLongBits(this.minor) != Double.doubleToLongBits(other.minor)) { + return false; + } + if (Double.doubleToLongBits(this.orient) != Double.doubleToLongBits(other.orient)) { + return false; + } + if (Double.doubleToLongBits(this.rms) != Double.doubleToLongBits(other.rms)) { + return false; + } + if (this.tag == null) { + if (other.tag != null) { + return false; + } + } else if (!this.tag.equals(other.tag)) { + return false; + } + if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("GSTObject{tag="); + sb.append(this.tag); + sb.append(", device="); + sb.append(this.device); + sb.append(", timestamp="); + sb.append(this.timestamp); + sb.append(", rms="); + sb.append(this.rms); + sb.append(", major="); + sb.append(this.major); + sb.append(", minor="); + sb.append(this.minor); + sb.append(", orient="); + sb.append(this.orient); + sb.append(", lat="); + sb.append(this.lat); + sb.append(", lon="); + sb.append(this.lon); + sb.append(", alt="); + sb.append(this.alt); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java b/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java index 5851a18..2ed3a74 100644 --- a/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/IGPSObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ * @author thoeger */ public interface IGPSObject { - - // this is only a marker interface - + + // this is only a marker interface + } diff --git a/src/main/java/de/taimos/gpsd4java/types/ParseException.java b/src/main/java/de/taimos/gpsd4java/types/ParseException.java index 9f4fce0..04ec16c 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ParseException.java +++ b/src/main/java/de/taimos/gpsd4java/types/ParseException.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,36 +26,33 @@ * @author thoeger */ public class ParseException extends Exception { - - private static final long serialVersionUID = 7747422116792199432L; - - /** - * - */ - public ParseException() { - super(); - } - - /** - * @param message the message - */ - public ParseException(final String message) { - super(message); - } - - /** - * @param message the message - * @param cause the cause - */ - public ParseException(final String message, final Throwable cause) { - super(message, cause); - } - - /** - * @param cause the cause - */ - public ParseException(final Throwable cause) { - super(cause); - } - + + private static final long serialVersionUID = 7747422116792199432L; + + /** */ + public ParseException() { + super(); + } + + /** + * @param message the message + */ + public ParseException(final String message) { + super(message); + } + + /** + * @param message the message + * @param cause the cause + */ + public ParseException(final String message, final Throwable cause) { + super(message, cause); + } + + /** + * @param cause the cause + */ + public ParseException(final Throwable cause) { + super(cause); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/PollObject.java b/src/main/java/de/taimos/gpsd4java/types/PollObject.java index 61eb40b..f116cd7 100644 --- a/src/main/java/de/taimos/gpsd4java/types/PollObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/PollObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,180 +26,178 @@ * @author thoeger */ public class PollObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "POLL"; - - private double timestamp; - - private int active; - - private List fixes; - - private List skyviews; - - private List gst; - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @return the timestamp - */ - public double getTimestamp() { - return this.timestamp; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. - * - * @param timestamp the timestamp to set - */ - public void setTimestamp(final double timestamp) { - this.timestamp = timestamp; - } - - /** - * Count of active devices. - * - * @return the active - */ - public int getActive() { - return this.active; - } - - /** - * Count of active devices. - * - * @param active the active to set - */ - public void setActive(final int active) { - this.active = active; - } - - /** - * list of TPV objects - * - * @return the fixes - */ - public List getFixes() { - return this.fixes; - } - - /** - * list of TPV objects - * - * @param fixes the fixes to set - */ - public void setFixes(final List fixes) { - this.fixes = fixes; - } - - /** - * list of SKY objects - * - * @return the skyviews - */ - public List getSkyviews() { - return this.skyviews; - } - - /** - * list of SKY objects - * - * @param skyviews the skyviews to set - */ - public void setSkyviews(final List skyviews) { - this.skyviews = skyviews; - } - - /** - * @return the gst - */ - public List getGst() { - return this.gst; - } - - /** - * @param gst the gst to set - */ - public void setGst(final List gst) { - this.gst = gst; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = (prime * result) + this.active; - result = (prime * result) + ((this.fixes == null) ? 0 : this.fixes.hashCode()); - result = (prime * result) + ((this.skyviews == null) ? 0 : this.skyviews.hashCode()); - result = (prime * result) + ((this.gst == null) ? 0 : this.gst.hashCode()); - long temp; - temp = Double.doubleToLongBits(this.timestamp); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final PollObject other = (PollObject) obj; - if (this.active != other.active) { - return false; - } - if (this.fixes == null) { - if (other.fixes != null) { - return false; - } - } else if (!this.fixes.equals(other.fixes)) { - return false; - } - if (this.skyviews == null) { - if (other.skyviews != null) { - return false; - } - } else if (!this.skyviews.equals(other.skyviews)) { - return false; - } - if (this.gst == null) { - if (other.gst != null) { - return false; - } - } else if (!this.gst.equals(other.gst)) { - return false; - } - if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { - return false; - } - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - - sb.append("PollObject{timestamp="); - sb.append(this.timestamp); - sb.append(", active="); - sb.append(this.active); - sb.append(", fixes="); - sb.append(((this.fixes == null) ? 0 : this.fixes.size())); - sb.append(", skyviews="); - sb.append(((this.skyviews == null) ? 0 : this.skyviews.size())); - sb.append(", gst="); - sb.append(((this.gst == null) ? 0 : this.gst.size())); - sb.append("}"); - - return sb.toString(); - } + + /** the GPSd internal name */ + public static final String NAME = "POLL"; + + private double timestamp; + + private int active; + + private List fixes; + + private List skyviews; + + private List gst; + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. + * + * @return the timestamp + */ + public double getTimestamp() { + return this.timestamp; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. + * + * @param timestamp the timestamp to set + */ + public void setTimestamp(final double timestamp) { + this.timestamp = timestamp; + } + + /** + * Count of active devices. + * + * @return the active + */ + public int getActive() { + return this.active; + } + + /** + * Count of active devices. + * + * @param active the active to set + */ + public void setActive(final int active) { + this.active = active; + } + + /** + * list of TPV objects + * + * @return the fixes + */ + public List getFixes() { + return this.fixes; + } + + /** + * list of TPV objects + * + * @param fixes the fixes to set + */ + public void setFixes(final List fixes) { + this.fixes = fixes; + } + + /** + * list of SKY objects + * + * @return the skyviews + */ + public List getSkyviews() { + return this.skyviews; + } + + /** + * list of SKY objects + * + * @param skyviews the skyviews to set + */ + public void setSkyviews(final List skyviews) { + this.skyviews = skyviews; + } + + /** + * @return the gst + */ + public List getGst() { + return this.gst; + } + + /** + * @param gst the gst to set + */ + public void setGst(final List gst) { + this.gst = gst; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + this.active; + result = (prime * result) + ((this.fixes == null) ? 0 : this.fixes.hashCode()); + result = (prime * result) + ((this.skyviews == null) ? 0 : this.skyviews.hashCode()); + result = (prime * result) + ((this.gst == null) ? 0 : this.gst.hashCode()); + long temp; + temp = Double.doubleToLongBits(this.timestamp); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final PollObject other = (PollObject) obj; + if (this.active != other.active) { + return false; + } + if (this.fixes == null) { + if (other.fixes != null) { + return false; + } + } else if (!this.fixes.equals(other.fixes)) { + return false; + } + if (this.skyviews == null) { + if (other.skyviews != null) { + return false; + } + } else if (!this.skyviews.equals(other.skyviews)) { + return false; + } + if (this.gst == null) { + if (other.gst != null) { + return false; + } + } else if (!this.gst.equals(other.gst)) { + return false; + } + if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + + sb.append("PollObject{timestamp="); + sb.append(this.timestamp); + sb.append(", active="); + sb.append(this.active); + sb.append(", fixes="); + sb.append(((this.fixes == null) ? 0 : this.fixes.size())); + sb.append(", skyviews="); + sb.append(((this.skyviews == null) ? 0 : this.skyviews.size())); + sb.append(", gst="); + sb.append(((this.gst == null) ? 0 : this.gst.size())); + sb.append("}"); + + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/PpsObject.java b/src/main/java/de/taimos/gpsd4java/types/PpsObject.java index 342c6cf..d9fc555 100644 --- a/src/main/java/de/taimos/gpsd4java/types/PpsObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/PpsObject.java @@ -1,137 +1,135 @@ package de.taimos.gpsd4java.types; /** - * This message is emitted each time the daemon sees a valid PPS (Pulse Per Second) strobe from a device. - * This message exactly mirrors the TOFF message except for two details. - * PPS emits the NTP precision. See the NTP documentation for their definition of precision. - * The TOFF message reports the GPS time as derived from the GPS serial data stream. - * The PPS message reports the GPS time as derived from the GPS PPS pulse. + * This message is emitted each time the daemon sees a valid PPS (Pulse Per Second) strobe from a + * device. This message exactly mirrors the TOFF message except for two details. PPS emits the NTP + * precision. See the NTP documentation for their definition of precision. The TOFF message reports + * the GPS time as derived from the GPS serial data stream. The PPS message reports the GPS time as + * derived from the GPS PPS pulse. * * @author dpishchukhin */ public class PpsObject implements IGPSObject { - /** - * the PPS internal name - */ - public static final String NAME = "PPS"; - - private String device = null; - - private double realSec = Double.NaN; - - private double realNsec = Double.NaN; - - private double clockSec = Double.NaN; - - private double clockNsec = Double.NaN; - - private double precision = Double.NaN; - - /** - * Name of originating device - * - * @return device - */ - public String getDevice() { - return device; - } - - /** - * Name of originating device - * - * @param device device - */ - public void setDevice(String device) { - this.device = device; - } - - /** - * seconds from the PPS source - * - * @return seconds - */ - public double getRealSec() { - return realSec; - } - - /** - * seconds from the PPS source - * - * @param realSec seconds - */ - public void setRealSec(double realSec) { - this.realSec = realSec; - } - - /** - * nanoseconds from the PPS source - * - * @return nanoseconds - */ - public double getRealNsec() { - return realNsec; - } - - /** - * nanoseconds from the PPS source - * - * @param realNsec nanoseconds - */ - public void setRealNsec(double realNsec) { - this.realNsec = realNsec; - } - - /** - * seconds from the system clock - * - * @return seconds - */ - public double getClockSec() { - return clockSec; - } - - /** - * seconds from the system clock - * - * @param clockSec seconds - */ - public void setClockSec(double clockSec) { - this.clockSec = clockSec; - } - - /** - * nanoseconds from the system clock - * - * @return nanoseconds - */ - public double getClockNsec() { - return clockNsec; - } - - /** - * nanoseconds from the system clock - * - * @param clockNsec nanoseconds - */ - public void setClockNsec(double clockNsec) { - this.clockNsec = clockNsec; - } - - /** - * NTP style estimate of PPS precision - * - * @return precision - */ - public double getPrecision() { - return precision; - } - - /** - * NTP style estimate of PPS precision - * - * @param precision precision - */ - public void setPrecision(double precision) { - this.precision = precision; - } + /** the PPS internal name */ + public static final String NAME = "PPS"; + + private String device = null; + + private double realSec = Double.NaN; + + private double realNsec = Double.NaN; + + private double clockSec = Double.NaN; + + private double clockNsec = Double.NaN; + + private double precision = Double.NaN; + + /** + * Name of originating device + * + * @return device + */ + public String getDevice() { + return device; + } + + /** + * Name of originating device + * + * @param device device + */ + public void setDevice(String device) { + this.device = device; + } + + /** + * seconds from the PPS source + * + * @return seconds + */ + public double getRealSec() { + return realSec; + } + + /** + * seconds from the PPS source + * + * @param realSec seconds + */ + public void setRealSec(double realSec) { + this.realSec = realSec; + } + + /** + * nanoseconds from the PPS source + * + * @return nanoseconds + */ + public double getRealNsec() { + return realNsec; + } + + /** + * nanoseconds from the PPS source + * + * @param realNsec nanoseconds + */ + public void setRealNsec(double realNsec) { + this.realNsec = realNsec; + } + + /** + * seconds from the system clock + * + * @return seconds + */ + public double getClockSec() { + return clockSec; + } + + /** + * seconds from the system clock + * + * @param clockSec seconds + */ + public void setClockSec(double clockSec) { + this.clockSec = clockSec; + } + + /** + * nanoseconds from the system clock + * + * @return nanoseconds + */ + public double getClockNsec() { + return clockNsec; + } + + /** + * nanoseconds from the system clock + * + * @param clockNsec nanoseconds + */ + public void setClockNsec(double clockNsec) { + this.clockNsec = clockNsec; + } + + /** + * NTP style estimate of PPS precision + * + * @return precision + */ + public double getPrecision() { + return precision; + } + + /** + * NTP style estimate of PPS precision + * + * @param precision precision + */ + public void setPrecision(double precision) { + this.precision = precision; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/SATObject.java b/src/main/java/de/taimos/gpsd4java/types/SATObject.java index df109bd..3c48c85 100644 --- a/src/main/java/de/taimos/gpsd4java/types/SATObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/SATObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,175 +24,176 @@ * @author aevdokimov */ public class SATObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "SAT"; - - private int PRN = -1; - - private int azimuth = -1; - - private int elevation = -1; - - private int signalStrength = -1; - - private boolean used = false; - - /** - * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites - * - * @return PRN - */ - public int getPRN() { - return this.PRN; - } - - /** - * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites - * - * @param PRN the PRN to set - */ - public void setPRN(final int PRN) { - this.PRN = PRN; - } - - /** - * Azimuth, degrees from true north. - * - * @return azimuth - */ - public int getAzimuth() { - return this.azimuth; - } - - /** - * Azimuth, degrees from true north. - * - * @param azimuth the azimuth to set - */ - public void setAzimuth(final int azimuth) { - this.azimuth = azimuth; - } - - /** - * Elevation in degrees. - * - * @return elevation - */ - public int getElevation() { - return this.elevation; - } - - /** - * Elevation in degrees. - * - * @param elevation the elevation to set - */ - public void setElevation(final int elevation) { - this.elevation = elevation; - } - - /** - * Signal strength in dB. - * - * @return signal strength - */ - public int getSignalStrength() { - return this.signalStrength; - } - - /** - * Signal strength in dB. - * - * @param signalStrength the signal strength to set - */ - public void setSignalStrength(final int signalStrength) { - this.signalStrength = signalStrength; - } - - /** - * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all - * drivers make this information available.) - * - * @return used - */ - public boolean getUsed() { - return this.used; - } - - /** - * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all - * drivers make this information available.) - * - * @param used the used flag to set - */ - public void setUsed(final boolean used) { - this.used = used; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(this.PRN); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.azimuth); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.elevation); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.signalStrength); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.used) ? 1 : 0); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final SATObject other = (SATObject) obj; - if (Double.doubleToLongBits(this.PRN) != Double.doubleToLongBits(other.PRN)) { - return false; - } - if (Double.doubleToLongBits(this.azimuth) != Double.doubleToLongBits(other.azimuth)) { - return false; - } - if (Double.doubleToLongBits(this.elevation) != Double.doubleToLongBits(other.elevation)) { - return false; - } - if (Double.doubleToLongBits(this.signalStrength) != Double.doubleToLongBits(other.signalStrength)) { - return false; - } - if (this.used != other.used) { - return false; - } - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("SATObject{PRN="); - sb.append(this.PRN); - sb.append(", az="); - sb.append(this.azimuth); - sb.append(", el="); - sb.append(this.elevation); - sb.append(", ss="); - sb.append(this.signalStrength); - sb.append(", used="); - sb.append(this.used ? "Y" : "N"); - sb.append("}"); - return sb.toString(); - } + + /** the GPSd internal name */ + public static final String NAME = "SAT"; + + private int PRN = -1; + + private int azimuth = -1; + + private int elevation = -1; + + private int signalStrength = -1; + + private boolean used = false; + + /** + * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are + * SBAS satellites + * + * @return PRN + */ + public int getPRN() { + return this.PRN; + } + + /** + * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are + * SBAS satellites + * + * @param PRN the PRN to set + */ + public void setPRN(final int PRN) { + this.PRN = PRN; + } + + /** + * Azimuth, degrees from true north. + * + * @return azimuth + */ + public int getAzimuth() { + return this.azimuth; + } + + /** + * Azimuth, degrees from true north. + * + * @param azimuth the azimuth to set + */ + public void setAzimuth(final int azimuth) { + this.azimuth = azimuth; + } + + /** + * Elevation in degrees. + * + * @return elevation + */ + public int getElevation() { + return this.elevation; + } + + /** + * Elevation in degrees. + * + * @param elevation the elevation to set + */ + public void setElevation(final int elevation) { + this.elevation = elevation; + } + + /** + * Signal strength in dB. + * + * @return signal strength + */ + public int getSignalStrength() { + return this.signalStrength; + } + + /** + * Signal strength in dB. + * + * @param signalStrength the signal strength to set + */ + public void setSignalStrength(final int signalStrength) { + this.signalStrength = signalStrength; + } + + /** + * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has + * corrections from them, but not all drivers make this information available.) + * + * @return used + */ + public boolean getUsed() { + return this.used; + } + + /** + * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has + * corrections from them, but not all drivers make this information available.) + * + * @param used the used flag to set + */ + public void setUsed(final boolean used) { + this.used = used; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.PRN); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.azimuth); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.elevation); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.signalStrength); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.used) ? 1 : 0); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final SATObject other = (SATObject) obj; + if (Double.doubleToLongBits(this.PRN) != Double.doubleToLongBits(other.PRN)) { + return false; + } + if (Double.doubleToLongBits(this.azimuth) != Double.doubleToLongBits(other.azimuth)) { + return false; + } + if (Double.doubleToLongBits(this.elevation) != Double.doubleToLongBits(other.elevation)) { + return false; + } + if (Double.doubleToLongBits(this.signalStrength) + != Double.doubleToLongBits(other.signalStrength)) { + return false; + } + if (this.used != other.used) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("SATObject{PRN="); + sb.append(this.PRN); + sb.append(", az="); + sb.append(this.azimuth); + sb.append(", el="); + sb.append(this.elevation); + sb.append(", ss="); + sb.append(this.signalStrength); + sb.append(", used="); + sb.append(this.used ? "Y" : "N"); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/SKYObject.java b/src/main/java/de/taimos/gpsd4java/types/SKYObject.java index bff720c..8e19763 100644 --- a/src/main/java/de/taimos/gpsd4java/types/SKYObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/SKYObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,348 +27,363 @@ * @author aevdokimov */ public class SKYObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "SKY"; - - private String tag = null; - - private String device = null; - - private double timestamp = Double.NaN; - - private double longitudeDOP = Double.NaN; - - private double latitudeDOP = Double.NaN; - - private double altitudeDOP = Double.NaN; - - private double timestampDOP = Double.NaN; - - private double horizontalDOP = Double.NaN; - - private double sphericalDOP = Double.NaN; - - private double hypersphericalDOP = Double.NaN; - - private List satellites; - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @return the tag - */ - public String getTag() { - return this.tag; - } - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag the tag to set - */ - public void setTag(final String tag) { - this.tag = tag; - } - - /** - * Name of originating device - * - * @return the device - */ - public String getDevice() { - return this.device; - } - - /** - * Name of originating device - * - * @param device the device to set - */ - public void setDevice(final String device) { - this.device = device; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * - * @return the timestamp - */ - public double getTimestamp() { - return this.timestamp; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * - * @param timestamp the timestamp to set - */ - public void setTimestamp(final double timestamp) { - this.timestamp = timestamp; - } - - /** - * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @return the longitude DOP - */ - public double getLongitudeDOP() { - return this.longitudeDOP; - } - - /** - * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param longitudeDOP the longitude DOP to set - */ - public void setLongitudeDOP(final double longitudeDOP) { - this.longitudeDOP = longitudeDOP; - } - - /** - * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @return the latitude DOP - */ - public double getLatitudeDOP() { - return this.latitudeDOP; - } - - /** - * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param latitudeDOP the latitude DOP to set - */ - public void setLatitudeDOP(final double latitudeDOP) { - this.latitudeDOP = latitudeDOP; - } - - /** - * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @return the altitude DOP - */ - public double getAltitudeDOP() { - return this.altitudeDOP; - } - - /** - * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param altitudeDOP the altitude DOP to set - */ - public void setAltitudeDOP(final double altitudeDOP) { - this.altitudeDOP = altitudeDOP; - } - - /** - * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @return the timestamp DOP - */ - public double getTimestampDOP() { - return this.timestampDOP; - } - - /** - * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param timestampDOP the timestamp DOP to set - */ - public void setTimestampDOP(final double timestampDOP) { - this.timestampDOP = timestampDOP; - } - - /** - * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get a circular error estimate. - * - * @return the horizontal DOP - */ - public double getHorizontalDOP() { - return this.horizontalDOP; - } - - /** - * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get a circular error estimate. - * - * @param horizontalDOP the horizontal DOP to set - */ - public void setHorizontalDOP(final double horizontalDOP) { - this.horizontalDOP = horizontalDOP; - } - - /** - * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @return the spherical DOP - */ - public double getSphericalDOP() { - return this.sphericalDOP; - } - - /** - * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param sphericalDOP the spherical DOP to set - */ - public void setSphericalDOP(final double sphericalDOP) { - this.sphericalDOP = sphericalDOP; - } - - /** - * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @return the hyperspherical DOP - */ - public double getHypersphericalDOP() { - return this.hypersphericalDOP; - } - - /** - * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a base UERE to get an error estimate. - * - * @param hypersphericalDOP the hyperspherical DOP to set - */ - public void setHypersphericalDOP(final double hypersphericalDOP) { - this.hypersphericalDOP = hypersphericalDOP; - } - - /** - * list of Satellite objects - * - * @return the satellites - */ - public List getSatellites() { - return this.satellites; - } - - /** - * list of Satellite objects - * - * @param satellites the satellites to set - */ - public void setSatellites(final List satellites) { - this.satellites = satellites; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(this.altitudeDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); - temp = Double.doubleToLongBits(this.horizontalDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.hypersphericalDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.latitudeDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.longitudeDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.sphericalDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); - temp = Double.doubleToLongBits(this.timestamp); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.timestampDOP); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final SKYObject other = (SKYObject) obj; - if (Double.doubleToLongBits(this.altitudeDOP) != Double.doubleToLongBits(other.altitudeDOP)) { - return false; - } - if (this.device == null) { - if (other.device != null) { - return false; - } - } else if (!this.device.equals(other.device)) { - return false; - } - if (Double.doubleToLongBits(this.horizontalDOP) != Double.doubleToLongBits(other.horizontalDOP)) { - return false; - } - if (Double.doubleToLongBits(this.hypersphericalDOP) != Double.doubleToLongBits(other.hypersphericalDOP)) { - return false; - } - if (Double.doubleToLongBits(this.latitudeDOP) != Double.doubleToLongBits(other.latitudeDOP)) { - return false; - } - if (Double.doubleToLongBits(this.longitudeDOP) != Double.doubleToLongBits(other.longitudeDOP)) { - return false; - } - if (Double.doubleToLongBits(this.sphericalDOP) != Double.doubleToLongBits(other.sphericalDOP)) { - return false; - } - if (this.tag == null) { - if (other.tag != null) { - return false; - } - } else if (!this.tag.equals(other.tag)) { - return false; - } - if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { - return false; - } - if (Double.doubleToLongBits(this.timestampDOP) != Double.doubleToLongBits(other.timestampDOP)) { - return false; - } - if (this.satellites.size() != other.satellites.size()) { - return false; - } - try { - for (int i = 0; i < this.satellites.size(); i++) { - if (!this.satellites.get(i).equals(other.satellites.get(i))) { - return false; - } - } - } catch (final IndexOutOfBoundsException e) { - return false; - } - - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("SKYObject{time="); - sb.append(this.timestamp); - sb.append(", xdop="); - sb.append(this.longitudeDOP); - sb.append(", ydop="); - sb.append(this.latitudeDOP); - sb.append(", vdop="); - sb.append(this.altitudeDOP); - sb.append(", tdop="); - sb.append(this.timestampDOP); - sb.append(", hdop="); - sb.append(this.horizontalDOP); - sb.append(", pdop="); - sb.append(this.sphericalDOP); - sb.append(", gdop="); - sb.append(this.hypersphericalDOP); - sb.append(", sat="); - sb.append(this.satellites == null ? 0 : this.satellites.size()); - sb.append("}"); - - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "SKY"; + + private String tag = null; + + private String device = null; + + private double timestamp = Double.NaN; + + private double longitudeDOP = Double.NaN; + + private double latitudeDOP = Double.NaN; + + private double altitudeDOP = Double.NaN; + + private double timestampDOP = Double.NaN; + + private double horizontalDOP = Double.NaN; + + private double sphericalDOP = Double.NaN; + + private double hypersphericalDOP = Double.NaN; + + private List satellites; + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @return the tag + */ + public String getTag() { + return this.tag; + } + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @param tag the tag to set + */ + public void setTag(final String tag) { + this.tag = tag; + } + + /** + * Name of originating device + * + * @return the device + */ + public String getDevice() { + return this.device; + } + + /** + * Name of originating device + * + * @param device the device to set + */ + public void setDevice(final String device) { + this.device = device; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. + * + * @return the timestamp + */ + public double getTimestamp() { + return this.timestamp; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. + * + * @param timestamp the timestamp to set + */ + public void setTimestamp(final double timestamp) { + this.timestamp = timestamp; + } + + /** + * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @return the longitude DOP + */ + public double getLongitudeDOP() { + return this.longitudeDOP; + } + + /** + * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @param longitudeDOP the longitude DOP to set + */ + public void setLongitudeDOP(final double longitudeDOP) { + this.longitudeDOP = longitudeDOP; + } + + /** + * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @return the latitude DOP + */ + public double getLatitudeDOP() { + return this.latitudeDOP; + } + + /** + * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @param latitudeDOP the latitude DOP to set + */ + public void setLatitudeDOP(final double latitudeDOP) { + this.latitudeDOP = latitudeDOP; + } + + /** + * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @return the altitude DOP + */ + public double getAltitudeDOP() { + return this.altitudeDOP; + } + + /** + * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @param altitudeDOP the altitude DOP to set + */ + public void setAltitudeDOP(final double altitudeDOP) { + this.altitudeDOP = altitudeDOP; + } + + /** + * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to + * get an error estimate. + * + * @return the timestamp DOP + */ + public double getTimestampDOP() { + return this.timestampDOP; + } + + /** + * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to + * get an error estimate. + * + * @param timestampDOP the timestamp DOP to set + */ + public void setTimestampDOP(final double timestampDOP) { + this.timestampDOP = timestampDOP; + } + + /** + * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get a circular error estimate. + * + * @return the horizontal DOP + */ + public double getHorizontalDOP() { + return this.horizontalDOP; + } + + /** + * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get a circular error estimate. + * + * @param horizontalDOP the horizontal DOP to set + */ + public void setHorizontalDOP(final double horizontalDOP) { + this.horizontalDOP = horizontalDOP; + } + + /** + * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @return the spherical DOP + */ + public double getSphericalDOP() { + return this.sphericalDOP; + } + + /** + * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base + * UERE to get an error estimate. + * + * @param sphericalDOP the spherical DOP to set + */ + public void setSphericalDOP(final double sphericalDOP) { + this.sphericalDOP = sphericalDOP; + } + + /** + * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a + * base UERE to get an error estimate. + * + * @return the hyperspherical DOP + */ + public double getHypersphericalDOP() { + return this.hypersphericalDOP; + } + + /** + * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a + * base UERE to get an error estimate. + * + * @param hypersphericalDOP the hyperspherical DOP to set + */ + public void setHypersphericalDOP(final double hypersphericalDOP) { + this.hypersphericalDOP = hypersphericalDOP; + } + + /** + * list of Satellite objects + * + * @return the satellites + */ + public List getSatellites() { + return this.satellites; + } + + /** + * list of Satellite objects + * + * @param satellites the satellites to set + */ + public void setSatellites(final List satellites) { + this.satellites = satellites; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.altitudeDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); + temp = Double.doubleToLongBits(this.horizontalDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.hypersphericalDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.latitudeDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.longitudeDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.sphericalDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); + temp = Double.doubleToLongBits(this.timestamp); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.timestampDOP); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final SKYObject other = (SKYObject) obj; + if (Double.doubleToLongBits(this.altitudeDOP) != Double.doubleToLongBits(other.altitudeDOP)) { + return false; + } + if (this.device == null) { + if (other.device != null) { + return false; + } + } else if (!this.device.equals(other.device)) { + return false; + } + if (Double.doubleToLongBits(this.horizontalDOP) + != Double.doubleToLongBits(other.horizontalDOP)) { + return false; + } + if (Double.doubleToLongBits(this.hypersphericalDOP) + != Double.doubleToLongBits(other.hypersphericalDOP)) { + return false; + } + if (Double.doubleToLongBits(this.latitudeDOP) != Double.doubleToLongBits(other.latitudeDOP)) { + return false; + } + if (Double.doubleToLongBits(this.longitudeDOP) != Double.doubleToLongBits(other.longitudeDOP)) { + return false; + } + if (Double.doubleToLongBits(this.sphericalDOP) != Double.doubleToLongBits(other.sphericalDOP)) { + return false; + } + if (this.tag == null) { + if (other.tag != null) { + return false; + } + } else if (!this.tag.equals(other.tag)) { + return false; + } + if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { + return false; + } + if (Double.doubleToLongBits(this.timestampDOP) != Double.doubleToLongBits(other.timestampDOP)) { + return false; + } + if (this.satellites.size() != other.satellites.size()) { + return false; + } + try { + for (int i = 0; i < this.satellites.size(); i++) { + if (!this.satellites.get(i).equals(other.satellites.get(i))) { + return false; + } + } + } catch (final IndexOutOfBoundsException e) { + return false; + } + + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("SKYObject{time="); + sb.append(this.timestamp); + sb.append(", xdop="); + sb.append(this.longitudeDOP); + sb.append(", ydop="); + sb.append(this.latitudeDOP); + sb.append(", vdop="); + sb.append(this.altitudeDOP); + sb.append(", tdop="); + sb.append(this.timestampDOP); + sb.append(", hdop="); + sb.append(this.horizontalDOP); + sb.append(", pdop="); + sb.append(this.sphericalDOP); + sb.append(", gdop="); + sb.append(this.hypersphericalDOP); + sb.append(", sat="); + sb.append(this.satellites == null ? 0 : this.satellites.size()); + sb.append("}"); + + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/TPVObject.java b/src/main/java/de/taimos/gpsd4java/types/TPVObject.java index e24f8ae..18219d7 100644 --- a/src/main/java/de/taimos/gpsd4java/types/TPVObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/TPVObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,506 +29,510 @@ * @author thoeger */ public class TPVObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "TPV"; - - private String tag = null; - - private String device = null; - - private double timestamp = Double.NaN; - - private double timestampError = Double.NaN; - - private double latitude = Double.NaN; - - private double longitude = Double.NaN; - - private double altitude = Double.NaN; - - private double latitudeError = Double.NaN; - - private double longitudeError = Double.NaN; - - private double altitudeError = Double.NaN; - - private double course = Double.NaN; - - private double speed = Double.NaN; - - private double climbRate = Double.NaN; - - private double courseError = Double.NaN; - - private double speedError = Double.NaN; - - private double climbRateError = Double.NaN; - - private ENMEAMode mode; - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @return the tag - */ - public String getTag() { - return this.tag; - } - - /** - * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. - * - * @param tag the tag to set - */ - public void setTag(final String tag) { - this.tag = tag; - } - - /** - * Name of originating device - * - * @return the device - */ - public String getDevice() { - return this.device; - } - - /** - * Name of originating device - * - * @param device the device to set - */ - public void setDevice(final String device) { - this.device = device; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * - * @return the timestamp - */ - public double getTimestamp() { - return this.timestamp; - } - - /** - * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. - * - * @param timestamp the timestamp to set - */ - public void setTimestamp(final double timestamp) { - this.timestamp = timestamp; - } - - /** - * Estimated timestamp error (%f, seconds, 95% confidence). - * - * @return the timestampError - */ - public double getTimestampError() { - return this.timestampError; - } - - /** - * Estimated timestamp error (%f, seconds, 95% confidence). - * - * @param timestampError the timestampError to set - */ - public void setTimestampError(final double timestampError) { - this.timestampError = timestampError; - } - - /** - * Latitude in degrees: +/- signifies North/South - * - * @return the latitude - */ - public double getLatitude() { - return this.latitude; - } - - /** - * Latitude in degrees: +/- signifies North/South - * - * @param latitude the latitude to set - */ - public void setLatitude(final double latitude) { - this.latitude = latitude; - } - - /** - * Longitude in degrees: +/- signifies East/West - * - * @return the longitude - */ - public double getLongitude() { - return this.longitude; - } - - /** - * Longitude in degrees: +/- signifies East/West - * - * @param longitude the longitude to set - */ - public void setLongitude(final double longitude) { - this.longitude = longitude; - } - - /** - * Altitude in meters. - * - * @return the altitude - */ - public double getAltitude() { - return this.altitude; - } - - /** - * Altitude in meters. - * - * @param altitude the altitude to set - */ - public void setAltitude(final double altitude) { - this.altitude = altitude; - } - - /** - * Latitude error estimate in meters, 95% confidence. - * - * @return the latitudeError - */ - public double getLatitudeError() { - return this.latitudeError; - } - - /** - * Latitude error estimate in meters, 95% confidence. - * - * @param latitudeError the latitudeError to set - */ - public void setLatitudeError(final double latitudeError) { - this.latitudeError = latitudeError; - } - - /** - * Longitude error estimate in meters, 95% confidence. - * - * @return the longitudeError - */ - public double getLongitudeError() { - return this.longitudeError; - } - - /** - * Longitude error estimate in meters, 95% confidence. - * - * @param longitudeError the longitudeError to set - */ - public void setLongitudeError(final double longitudeError) { - this.longitudeError = longitudeError; - } - - /** - * Estimated vertical error in meters, 95% confidence. - * - * @return the altitudeError - */ - public double getAltitudeError() { - return this.altitudeError; - } - - /** - * Estimated vertical error in meters, 95% confidence. - * - * @param altitudeError the altitudeError to set - */ - public void setAltitudeError(final double altitudeError) { - this.altitudeError = altitudeError; - } - - /** - * Course over ground, degrees from true north. - * - * @return the course - */ - public double getCourse() { - return this.course; - } - - /** - * Course over ground, degrees from true north. - * - * @param course the course to set - */ - public void setCourse(final double course) { - this.course = course; - } - - /** - * Speed over ground, meters per second. - * - * @return the speed - */ - public double getSpeed() { - return this.speed; - } - - /** - * Speed over ground, meters per second. - * - * @param speed the speed to set - */ - public void setSpeed(final double speed) { - this.speed = speed; - } - - /** - * Climb (positive) or sink (negative) rate, meters per second. - * - * @return the climbRate - */ - public double getClimbRate() { - return this.climbRate; - } - - /** - * Climb (positive) or sink (negative) rate, meters per second. - * - * @param climbRate the climbRate to set - */ - public void setClimbRate(final double climbRate) { - this.climbRate = climbRate; - } - - /** - * Direction error estimate in degrees, 95% confidence. - * - * @return the courseError - */ - public double getCourseError() { - return this.courseError; - } - - /** - * Direction error estimate in degrees, 95% confidence. - * - * @param courseError the courseError to set - */ - public void setCourseError(final double courseError) { - this.courseError = courseError; - } - - /** - * Speed error estimate in meters/sec, 95% confidence. - * - * @return the speedError - */ - public double getSpeedError() { - return this.speedError; - } - - /** - * Speed error estimate in meters/sec, 95% confidence. - * - * @param speedError the speedError to set - */ - public void setSpeedError(final double speedError) { - this.speedError = speedError; - } - - /** - * Climb/sink error estimate in meters/sec, 95% confidence. - * - * @return the climbRateError - */ - public double getClimbRateError() { - return this.climbRateError; - } - - /** - * Climb/sink error estimate in meters/sec, 95% confidence. - * - * @param climbRateError the climbRateError to set - */ - public void setClimbRateError(final double climbRateError) { - this.climbRateError = climbRateError; - } - - /** - * NMEA mode - * - * @return the mode - */ - public ENMEAMode getMode() { - return this.mode; - } - - /** - * NMEA mode - * - * @param mode the mode to set - */ - public void setMode(final ENMEAMode mode) { - this.mode = mode; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(this.altitude); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.altitudeError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.climbRate); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.climbRateError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.course); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.courseError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); - temp = Double.doubleToLongBits(this.latitude); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.latitudeError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.longitude); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.longitudeError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.mode == null) ? 0 : this.mode.hashCode()); - temp = Double.doubleToLongBits(this.speed); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.speedError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); - temp = Double.doubleToLongBits(this.timestamp); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.timestampError); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final TPVObject other = (TPVObject) obj; - if (Double.doubleToLongBits(this.altitude) != Double.doubleToLongBits(other.altitude)) { - return false; - } - if (Double.doubleToLongBits(this.altitudeError) != Double.doubleToLongBits(other.altitudeError)) { - return false; - } - if (Double.doubleToLongBits(this.climbRate) != Double.doubleToLongBits(other.climbRate)) { - return false; - } - if (Double.doubleToLongBits(this.climbRateError) != Double.doubleToLongBits(other.climbRateError)) { - return false; - } - if (Double.doubleToLongBits(this.course) != Double.doubleToLongBits(other.course)) { - return false; - } - if (Double.doubleToLongBits(this.courseError) != Double.doubleToLongBits(other.courseError)) { - return false; - } - if (this.device == null) { - if (other.device != null) { - return false; - } - } else if (!this.device.equals(other.device)) { - return false; - } - if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { - return false; - } - if (Double.doubleToLongBits(this.latitudeError) != Double.doubleToLongBits(other.latitudeError)) { - return false; - } - if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { - return false; - } - if (Double.doubleToLongBits(this.longitudeError) != Double.doubleToLongBits(other.longitudeError)) { - return false; - } - if (this.mode != other.mode) { - return false; - } - if (Double.doubleToLongBits(this.speed) != Double.doubleToLongBits(other.speed)) { - return false; - } - if (Double.doubleToLongBits(this.speedError) != Double.doubleToLongBits(other.speedError)) { - return false; - } - if (this.tag == null) { - if (other.tag != null) { - return false; - } - } else if (!this.tag.equals(other.tag)) { - return false; - } - if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { - return false; - } - if (Double.doubleToLongBits(this.timestampError) != Double.doubleToLongBits(other.timestampError)) { - return false; - } - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("TPVObject{tag="); - sb.append(this.tag); - sb.append(", device="); - sb.append(this.device); - sb.append(", timestamp="); - sb.append(this.timestamp); - sb.append(", timestampError="); - sb.append(this.timestampError); - sb.append(", latitude="); - sb.append(this.latitude); - sb.append(", longitude="); - sb.append(this.longitude); - sb.append(", altitude="); - sb.append(this.altitude); - sb.append(", latitudeError="); - sb.append(this.latitudeError); - sb.append(", longitudeError="); - sb.append(this.longitudeError); - sb.append(", altitudeError="); - sb.append(this.altitudeError); - sb.append(", course="); - sb.append(this.course); - sb.append(", speed="); - sb.append(this.speed); - sb.append(", climbRate="); - sb.append(this.climbRate); - sb.append(", courseError="); - sb.append(this.courseError); - sb.append(", speedError="); - sb.append(this.speedError); - sb.append(", climbRateError="); - sb.append(this.climbRateError); - if (mode != null) { - sb.append(", mode="); - sb.append(this.mode.name()); - } - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "TPV"; + + private String tag = null; + + private String device = null; + + private double timestamp = Double.NaN; + + private double timestampError = Double.NaN; + + private double latitude = Double.NaN; + + private double longitude = Double.NaN; + + private double altitude = Double.NaN; + + private double latitudeError = Double.NaN; + + private double longitudeError = Double.NaN; + + private double altitudeError = Double.NaN; + + private double course = Double.NaN; + + private double speed = Double.NaN; + + private double climbRate = Double.NaN; + + private double courseError = Double.NaN; + + private double speedError = Double.NaN; + + private double climbRateError = Double.NaN; + + private ENMEAMode mode; + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @return the tag + */ + public String getTag() { + return this.tag; + } + + /** + * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence + * type. + * + * @param tag the tag to set + */ + public void setTag(final String tag) { + this.tag = tag; + } + + /** + * Name of originating device + * + * @return the device + */ + public String getDevice() { + return this.device; + } + + /** + * Name of originating device + * + * @param device the device to set + */ + public void setDevice(final String device) { + this.device = device; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. + * + * @return the timestamp + */ + public double getTimestamp() { + return this.timestamp; + } + + /** + * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. + * + * @param timestamp the timestamp to set + */ + public void setTimestamp(final double timestamp) { + this.timestamp = timestamp; + } + + /** + * Estimated timestamp error (%f, seconds, 95% confidence). + * + * @return the timestampError + */ + public double getTimestampError() { + return this.timestampError; + } + + /** + * Estimated timestamp error (%f, seconds, 95% confidence). + * + * @param timestampError the timestampError to set + */ + public void setTimestampError(final double timestampError) { + this.timestampError = timestampError; + } + + /** + * Latitude in degrees: +/- signifies North/South + * + * @return the latitude + */ + public double getLatitude() { + return this.latitude; + } + + /** + * Latitude in degrees: +/- signifies North/South + * + * @param latitude the latitude to set + */ + public void setLatitude(final double latitude) { + this.latitude = latitude; + } + + /** + * Longitude in degrees: +/- signifies East/West + * + * @return the longitude + */ + public double getLongitude() { + return this.longitude; + } + + /** + * Longitude in degrees: +/- signifies East/West + * + * @param longitude the longitude to set + */ + public void setLongitude(final double longitude) { + this.longitude = longitude; + } + + /** + * Altitude in meters. + * + * @return the altitude + */ + public double getAltitude() { + return this.altitude; + } + + /** + * Altitude in meters. + * + * @param altitude the altitude to set + */ + public void setAltitude(final double altitude) { + this.altitude = altitude; + } + + /** + * Latitude error estimate in meters, 95% confidence. + * + * @return the latitudeError + */ + public double getLatitudeError() { + return this.latitudeError; + } + + /** + * Latitude error estimate in meters, 95% confidence. + * + * @param latitudeError the latitudeError to set + */ + public void setLatitudeError(final double latitudeError) { + this.latitudeError = latitudeError; + } + + /** + * Longitude error estimate in meters, 95% confidence. + * + * @return the longitudeError + */ + public double getLongitudeError() { + return this.longitudeError; + } + + /** + * Longitude error estimate in meters, 95% confidence. + * + * @param longitudeError the longitudeError to set + */ + public void setLongitudeError(final double longitudeError) { + this.longitudeError = longitudeError; + } + + /** + * Estimated vertical error in meters, 95% confidence. + * + * @return the altitudeError + */ + public double getAltitudeError() { + return this.altitudeError; + } + + /** + * Estimated vertical error in meters, 95% confidence. + * + * @param altitudeError the altitudeError to set + */ + public void setAltitudeError(final double altitudeError) { + this.altitudeError = altitudeError; + } + + /** + * Course over ground, degrees from true north. + * + * @return the course + */ + public double getCourse() { + return this.course; + } + + /** + * Course over ground, degrees from true north. + * + * @param course the course to set + */ + public void setCourse(final double course) { + this.course = course; + } + + /** + * Speed over ground, meters per second. + * + * @return the speed + */ + public double getSpeed() { + return this.speed; + } + + /** + * Speed over ground, meters per second. + * + * @param speed the speed to set + */ + public void setSpeed(final double speed) { + this.speed = speed; + } + + /** + * Climb (positive) or sink (negative) rate, meters per second. + * + * @return the climbRate + */ + public double getClimbRate() { + return this.climbRate; + } + + /** + * Climb (positive) or sink (negative) rate, meters per second. + * + * @param climbRate the climbRate to set + */ + public void setClimbRate(final double climbRate) { + this.climbRate = climbRate; + } + + /** + * Direction error estimate in degrees, 95% confidence. + * + * @return the courseError + */ + public double getCourseError() { + return this.courseError; + } + + /** + * Direction error estimate in degrees, 95% confidence. + * + * @param courseError the courseError to set + */ + public void setCourseError(final double courseError) { + this.courseError = courseError; + } + + /** + * Speed error estimate in meters/sec, 95% confidence. + * + * @return the speedError + */ + public double getSpeedError() { + return this.speedError; + } + + /** + * Speed error estimate in meters/sec, 95% confidence. + * + * @param speedError the speedError to set + */ + public void setSpeedError(final double speedError) { + this.speedError = speedError; + } + + /** + * Climb/sink error estimate in meters/sec, 95% confidence. + * + * @return the climbRateError + */ + public double getClimbRateError() { + return this.climbRateError; + } + + /** + * Climb/sink error estimate in meters/sec, 95% confidence. + * + * @param climbRateError the climbRateError to set + */ + public void setClimbRateError(final double climbRateError) { + this.climbRateError = climbRateError; + } + + /** + * NMEA mode + * + * @return the mode + */ + public ENMEAMode getMode() { + return this.mode; + } + + /** + * NMEA mode + * + * @param mode the mode to set + */ + public void setMode(final ENMEAMode mode) { + this.mode = mode; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.altitude); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.altitudeError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.climbRate); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.climbRateError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.course); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.courseError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); + temp = Double.doubleToLongBits(this.latitude); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.latitudeError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.longitude); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.longitudeError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.mode == null) ? 0 : this.mode.hashCode()); + temp = Double.doubleToLongBits(this.speed); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.speedError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); + temp = Double.doubleToLongBits(this.timestamp); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.timestampError); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final TPVObject other = (TPVObject) obj; + if (Double.doubleToLongBits(this.altitude) != Double.doubleToLongBits(other.altitude)) { + return false; + } + if (Double.doubleToLongBits(this.altitudeError) + != Double.doubleToLongBits(other.altitudeError)) { + return false; + } + if (Double.doubleToLongBits(this.climbRate) != Double.doubleToLongBits(other.climbRate)) { + return false; + } + if (Double.doubleToLongBits(this.climbRateError) + != Double.doubleToLongBits(other.climbRateError)) { + return false; + } + if (Double.doubleToLongBits(this.course) != Double.doubleToLongBits(other.course)) { + return false; + } + if (Double.doubleToLongBits(this.courseError) != Double.doubleToLongBits(other.courseError)) { + return false; + } + if (this.device == null) { + if (other.device != null) { + return false; + } + } else if (!this.device.equals(other.device)) { + return false; + } + if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { + return false; + } + if (Double.doubleToLongBits(this.latitudeError) + != Double.doubleToLongBits(other.latitudeError)) { + return false; + } + if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { + return false; + } + if (Double.doubleToLongBits(this.longitudeError) + != Double.doubleToLongBits(other.longitudeError)) { + return false; + } + if (this.mode != other.mode) { + return false; + } + if (Double.doubleToLongBits(this.speed) != Double.doubleToLongBits(other.speed)) { + return false; + } + if (Double.doubleToLongBits(this.speedError) != Double.doubleToLongBits(other.speedError)) { + return false; + } + if (this.tag == null) { + if (other.tag != null) { + return false; + } + } else if (!this.tag.equals(other.tag)) { + return false; + } + if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { + return false; + } + if (Double.doubleToLongBits(this.timestampError) + != Double.doubleToLongBits(other.timestampError)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("TPVObject{tag="); + sb.append(this.tag); + sb.append(", device="); + sb.append(this.device); + sb.append(", timestamp="); + sb.append(this.timestamp); + sb.append(", timestampError="); + sb.append(this.timestampError); + sb.append(", latitude="); + sb.append(this.latitude); + sb.append(", longitude="); + sb.append(this.longitude); + sb.append(", altitude="); + sb.append(this.altitude); + sb.append(", latitudeError="); + sb.append(this.latitudeError); + sb.append(", longitudeError="); + sb.append(this.longitudeError); + sb.append(", altitudeError="); + sb.append(this.altitudeError); + sb.append(", course="); + sb.append(this.course); + sb.append(", speed="); + sb.append(this.speed); + sb.append(", climbRate="); + sb.append(this.climbRate); + sb.append(", courseError="); + sb.append(this.courseError); + sb.append(", speedError="); + sb.append(this.speedError); + sb.append(", climbRateError="); + sb.append(this.climbRateError); + if (mode != null) { + sb.append(", mode="); + sb.append(this.mode.name()); + } + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/ToffObject.java b/src/main/java/de/taimos/gpsd4java/types/ToffObject.java index 4bc14dc..32e7f8d 100644 --- a/src/main/java/de/taimos/gpsd4java/types/ToffObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/ToffObject.java @@ -1,118 +1,116 @@ package de.taimos.gpsd4java.types; /** - * This message is emitted on each cycle and reports the offset between the host's clock time and the GPS time at top - * of second (actually, when the first data for the reporting cycle is received). - * This message exactly mirrors the PPS message except for two details. - * TOFF emits no NTP precision, this is assumed to be -2. See the NTP documentation for their definition of precision. - * The TOFF message reports the GPS time as derived from the GPS serial data stream. The PPS message reports the GPS - * time as derived from the GPS PPS pulse. + * This message is emitted on each cycle and reports the offset between the host's clock time and + * the GPS time at top of second (actually, when the first data for the reporting cycle is + * received). This message exactly mirrors the PPS message except for two details. TOFF emits no NTP + * precision, this is assumed to be -2. See the NTP documentation for their definition of precision. + * The TOFF message reports the GPS time as derived from the GPS serial data stream. The PPS message + * reports the GPS time as derived from the GPS PPS pulse. * * @author dpishchukhin */ public class ToffObject implements IGPSObject { - /** - * the TOFF internal name - */ - public static final String NAME = "TOFF"; - - private String device = null; - - private double realSec = Double.NaN; - - private double realNsec = Double.NaN; - - private double clockSec = Double.NaN; - - private double clockNsec = Double.NaN; - - /** - * Name of originating device - * - * @return device - */ - public String getDevice() { - return device; - } - - /** - * Name of originating device - * - * @param device device - */ - public void setDevice(String device) { - this.device = device; - } - - /** - * seconds from the GPS clock - * - * @return seconds - */ - public double getRealSec() { - return realSec; - } - - /** - * seconds from the GPS clock - * - * @param realSec seconds - */ - public void setRealSec(double realSec) { - this.realSec = realSec; - } - - /** - * nanoseconds from the GPS clock - * - * @return nanoseconds - */ - public double getRealNsec() { - return realNsec; - } - - /** - * nanoseconds from the GPS clock - * - * @param realNsec nanoseconds - */ - public void setRealNsec(double realNsec) { - this.realNsec = realNsec; - } - - /** - * seconds from the system clock - * - * @return seconds - */ - public double getClockSec() { - return clockSec; - } - - /** - * seconds from the system clock - * - * @param clockSec seconds - */ - public void setClockSec(double clockSec) { - this.clockSec = clockSec; - } - - /** - * nanoseconds from the system clock - * - * @return nanoseconds - */ - public double getClockNsec() { - return clockNsec; - } - - /** - * nanoseconds from the system clock - * - * @param clockNsec nanoseconds - */ - public void setClockNsec(double clockNsec) { - this.clockNsec = clockNsec; - } + /** the TOFF internal name */ + public static final String NAME = "TOFF"; + + private String device = null; + + private double realSec = Double.NaN; + + private double realNsec = Double.NaN; + + private double clockSec = Double.NaN; + + private double clockNsec = Double.NaN; + + /** + * Name of originating device + * + * @return device + */ + public String getDevice() { + return device; + } + + /** + * Name of originating device + * + * @param device device + */ + public void setDevice(String device) { + this.device = device; + } + + /** + * seconds from the GPS clock + * + * @return seconds + */ + public double getRealSec() { + return realSec; + } + + /** + * seconds from the GPS clock + * + * @param realSec seconds + */ + public void setRealSec(double realSec) { + this.realSec = realSec; + } + + /** + * nanoseconds from the GPS clock + * + * @return nanoseconds + */ + public double getRealNsec() { + return realNsec; + } + + /** + * nanoseconds from the GPS clock + * + * @param realNsec nanoseconds + */ + public void setRealNsec(double realNsec) { + this.realNsec = realNsec; + } + + /** + * seconds from the system clock + * + * @return seconds + */ + public double getClockSec() { + return clockSec; + } + + /** + * seconds from the system clock + * + * @param clockSec seconds + */ + public void setClockSec(double clockSec) { + this.clockSec = clockSec; + } + + /** + * nanoseconds from the system clock + * + * @return nanoseconds + */ + public double getClockNsec() { + return clockNsec; + } + + /** + * nanoseconds from the system clock + * + * @param clockNsec nanoseconds + */ + public void setClockNsec(double clockNsec) { + this.clockNsec = clockNsec; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/VersionObject.java b/src/main/java/de/taimos/gpsd4java/types/VersionObject.java index 50d7a90..b25c5c5 100644 --- a/src/main/java/de/taimos/gpsd4java/types/VersionObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/VersionObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,139 +24,138 @@ * @author thoeger */ public class VersionObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "VERSION"; - - private String release; - - private String rev; - - private double protocolMajor; - - private double protocolMinor; - - /** - * @return the release - */ - public String getRelease() { - return this.release; - } - - /** - * @param release the release to set - */ - public void setRelease(final String release) { - this.release = release; - } - - /** - * @return the rev - */ - public String getRev() { - return this.rev; - } - - /** - * @param rev the rev to set - */ - public void setRev(final String rev) { - this.rev = rev; - } - - /** - * @return the protocolMajor - */ - public double getProtocolMajor() { - return this.protocolMajor; - } - - /** - * @param protocolMajor the protocolMajor to set - */ - public void setProtocolMajor(final double protocolMajor) { - this.protocolMajor = protocolMajor; - } - - /** - * @return the protocolMinor - */ - public double getProtocolMinor() { - return this.protocolMinor; - } - - /** - * @param protocolMinor the protocolMinor to set - */ - public void setProtocolMinor(final double protocolMinor) { - this.protocolMinor = protocolMinor; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(this.protocolMajor); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(this.protocolMinor); - result = (prime * result) + (int) (temp ^ (temp >>> 32)); - result = (prime * result) + ((this.release == null) ? 0 : this.release.hashCode()); - result = (prime * result) + ((this.rev == null) ? 0 : this.rev.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final VersionObject other = (VersionObject) obj; - if (Double.doubleToLongBits(this.protocolMajor) != Double.doubleToLongBits(other.protocolMajor)) { - return false; - } - if (Double.doubleToLongBits(this.protocolMinor) != Double.doubleToLongBits(other.protocolMinor)) { - return false; - } - if (this.release == null) { - if (other.release != null) { - return false; - } - } else if (!this.release.equals(other.release)) { - return false; - } - if (this.rev == null) { - if (other.rev != null) { - return false; - } - } else if (!this.rev.equals(other.rev)) { - return false; - } - return true; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - - sb.append("VersionObject{release="); - sb.append(this.release); - sb.append(", rev="); - sb.append(this.rev); - sb.append(", protocolMajor="); - sb.append(this.protocolMajor); - sb.append(", protocolMinor="); - sb.append(this.protocolMinor); - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "VERSION"; + + private String release; + + private String rev; + + private double protocolMajor; + + private double protocolMinor; + + /** + * @return the release + */ + public String getRelease() { + return this.release; + } + + /** + * @param release the release to set + */ + public void setRelease(final String release) { + this.release = release; + } + + /** + * @return the rev + */ + public String getRev() { + return this.rev; + } + + /** + * @param rev the rev to set + */ + public void setRev(final String rev) { + this.rev = rev; + } + + /** + * @return the protocolMajor + */ + public double getProtocolMajor() { + return this.protocolMajor; + } + + /** + * @param protocolMajor the protocolMajor to set + */ + public void setProtocolMajor(final double protocolMajor) { + this.protocolMajor = protocolMajor; + } + + /** + * @return the protocolMinor + */ + public double getProtocolMinor() { + return this.protocolMinor; + } + + /** + * @param protocolMinor the protocolMinor to set + */ + public void setProtocolMinor(final double protocolMinor) { + this.protocolMinor = protocolMinor; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.protocolMajor); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.protocolMinor); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); + result = (prime * result) + ((this.release == null) ? 0 : this.release.hashCode()); + result = (prime * result) + ((this.rev == null) ? 0 : this.rev.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final VersionObject other = (VersionObject) obj; + if (Double.doubleToLongBits(this.protocolMajor) + != Double.doubleToLongBits(other.protocolMajor)) { + return false; + } + if (Double.doubleToLongBits(this.protocolMinor) + != Double.doubleToLongBits(other.protocolMinor)) { + return false; + } + if (this.release == null) { + if (other.release != null) { + return false; + } + } else if (!this.release.equals(other.release)) { + return false; + } + if (this.rev == null) { + if (other.rev != null) { + return false; + } + } else if (!this.rev.equals(other.rev)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + + sb.append("VersionObject{release="); + sb.append(this.release); + sb.append(", rev="); + sb.append(this.rev); + sb.append(", protocolMajor="); + sb.append(this.protocolMajor); + sb.append(", protocolMinor="); + sb.append(this.protocolMinor); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/WatchObject.java b/src/main/java/de/taimos/gpsd4java/types/WatchObject.java index 445a209..53db95f 100644 --- a/src/main/java/de/taimos/gpsd4java/types/WatchObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/WatchObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,85 +24,82 @@ * @author thoeger */ public class WatchObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "WATCH"; - - private boolean enable = true; - - private boolean dump = false; - - /** - * Enable (true) or disable (false) watcher mode. Default is true. - * - * @return the enable - */ - public boolean isEnable() { - return this.enable; - } - - /** - * Enable (true) or disable (false) watcher mode. Default is true. - * - * @param enable the enable to set - */ - public void setEnable(final boolean enable) { - this.enable = enable; - } - - /** - * Enable (true) or disable (false) dumping of JSON reports. Default is false. - * - * @return the json - */ - public boolean isDump() { - return this.dump; - } - - /** - * Enable (true) or disable (false) dumping of JSON reports. Default is false. - * - * @param dump the dump to set - */ - public void setDump(final boolean dump) { - this.dump = dump; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = (prime * result) + (this.dump ? 1231 : 1237); - result = (prime * result) + (this.enable ? 1231 : 1237); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (this.getClass() != obj.getClass()) { - return false; - } - final WatchObject other = (WatchObject) obj; - if (this.dump != other.dump) { - return false; - } - if (this.enable != other.enable) { - return false; - } - return true; - } - - @Override - public String toString() { - return "WatchObject{enable=" + this.enable + ", dump=" + this.dump + "}"; - } - + + /** the GPSd internal name */ + public static final String NAME = "WATCH"; + + private boolean enable = true; + + private boolean dump = false; + + /** + * Enable (true) or disable (false) watcher mode. Default is true. + * + * @return the enable + */ + public boolean isEnable() { + return this.enable; + } + + /** + * Enable (true) or disable (false) watcher mode. Default is true. + * + * @param enable the enable to set + */ + public void setEnable(final boolean enable) { + this.enable = enable; + } + + /** + * Enable (true) or disable (false) dumping of JSON reports. Default is false. + * + * @return the json + */ + public boolean isDump() { + return this.dump; + } + + /** + * Enable (true) or disable (false) dumping of JSON reports. Default is false. + * + * @param dump the dump to set + */ + public void setDump(final boolean dump) { + this.dump = dump; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + (this.dump ? 1231 : 1237); + result = (prime * result) + (this.enable ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final WatchObject other = (WatchObject) obj; + if (this.dump != other.dump) { + return false; + } + if (this.enable != other.enable) { + return false; + } + return true; + } + + @Override + public String toString() { + return "WatchObject{enable=" + this.enable + ", dump=" + this.dump + "}"; + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java index 53de4e7..ddb1625 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,311 +26,309 @@ * @author aevdokimov */ public class ALMANACObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "ALMANAC"; - - private int ID = -1; - - private int Health = -1; - - private double e = Double.NaN; - - private int toa = -1; - - private double deltai = Double.NaN; - - private double Omegad = Double.NaN; - - private double sqrtA = Double.NaN; - - private double Omega0 = Double.NaN; - - private double omega = Double.NaN; - - private double M0 = Double.NaN; - - private double af0 = Double.NaN; - - private double af1 = Double.NaN; - - /** - * @return the iD - */ - public int getID() { - return this.ID; - } - - /** - * @param iD the iD to set - */ - public void setID(final int iD) { - this.ID = iD; - } - - /** - * @return the health - */ - public int getHealth() { - return this.Health; - } - - /** - * @param health the health to set - */ - public void setHealth(final int health) { - this.Health = health; - } - - /** - * @return the e - */ - public double getE() { - return this.e; - } - - /** - * @param e the e to set - */ - public void setE(final double e) { - this.e = e; - } - - /** - * @return the toa - */ - public int getToa() { - return this.toa; - } - - /** - * @param toa the toa to set - */ - public void setToa(final int toa) { - this.toa = toa; - } - - /** - * @return the deltai - */ - public double getDeltai() { - return this.deltai; - } - - /** - * @param deltai the deltai to set - */ - public void setDeltai(final double deltai) { - this.deltai = deltai; - } - - /** - * @return the omegad - */ - public double getOmegad() { - return this.Omegad; - } - - /** - * @param omegad the omegad to set - */ - public void setOmegad(final double omegad) { - this.Omegad = omegad; - } - - /** - * @return the sqrtA - */ - public double getSqrtA() { - return this.sqrtA; - } - - /** - * @param sqrtA the sqrtA to set - */ - public void setSqrtA(final double sqrtA) { - this.sqrtA = sqrtA; - } - - /** - * @return the omega0 - */ - public double getOmega0() { - return this.Omega0; - } - - /** - * @param omega0 the omega0 to set - */ - public void setOmega0(final double omega0) { - this.Omega0 = omega0; - } - - /** - * @return the omega - */ - public double getOmega() { - return this.omega; - } - - /** - * @param omega the omega to set - */ - public void setOmega(final double omega) { - this.omega = omega; - } - - /** - * @return the m0 - */ - public double getM0() { - return this.M0; - } - - /** - * @param m0 the m0 to set - */ - public void setM0(final double m0) { - this.M0 = m0; - } - - /** - * @return the af0 - */ - public double getAf0() { - return this.af0; - } - - /** - * @param af0 the af0 to set - */ - public void setAf0(final double af0) { - this.af0 = af0; - } - - /** - * @return the af1 - */ - public double getAf1() { - return this.af1; - } - - /** - * @param af1 the af1 to set - */ - public void setAf1(final double af1) { - this.af1 = af1; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ALMANACObject)) { - return false; - } - - final ALMANACObject that = (ALMANACObject) o; - - if (this.Health != that.Health) { - return false; - } - if (this.ID != that.ID) { - return false; - } - if (Double.compare(that.M0, this.M0) != 0) { - return false; - } - if (Double.compare(that.Omega0, this.Omega0) != 0) { - return false; - } - if (Double.compare(that.Omegad, this.Omegad) != 0) { - return false; - } - if (Double.compare(that.af0, this.af0) != 0) { - return false; - } - if (Double.compare(that.af1, this.af1) != 0) { - return false; - } - if (Double.compare(that.deltai, this.deltai) != 0) { - return false; - } - if (Double.compare(that.e, this.e) != 0) { - return false; - } - if (Double.compare(that.omega, this.omega) != 0) { - return false; - } - if (Double.compare(that.sqrtA, this.sqrtA) != 0) { - return false; - } - if (this.toa != that.toa) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result; - long temp; - result = this.ID; - result = (31 * result) + this.Health; - temp = this.e != +0.0d ? Double.doubleToLongBits(this.e) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - result = (31 * result) + this.toa; - temp = this.deltai != +0.0d ? Double.doubleToLongBits(this.deltai) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Omegad != +0.0d ? Double.doubleToLongBits(this.Omegad) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.sqrtA != +0.0d ? Double.doubleToLongBits(this.sqrtA) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Omega0 != +0.0d ? Double.doubleToLongBits(this.Omega0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.omega != +0.0d ? Double.doubleToLongBits(this.omega) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.M0 != +0.0d ? Double.doubleToLongBits(this.M0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.af0 != +0.0d ? Double.doubleToLongBits(this.af0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.af1 != +0.0d ? Double.doubleToLongBits(this.af1) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ALMANACObject{ID="); - sb.append(this.ID); - sb.append(", Health="); - sb.append(this.Health); - sb.append(", e="); - sb.append(this.e); - sb.append(", toa="); - sb.append(this.toa); - sb.append(", deltai="); - sb.append(this.deltai); - sb.append(", Omegad="); - sb.append(this.Omegad); - sb.append(", sqrtA="); - sb.append(this.sqrtA); - sb.append(", Omega0="); - sb.append(this.Omega0); - sb.append(", omega="); - sb.append(this.omega); - sb.append(", M0="); - sb.append(this.M0); - sb.append(", af0="); - sb.append(this.af0); - sb.append(", af1="); - sb.append(this.af1); - sb.append("}"); - return sb.toString(); - } + + /** the GPSd internal name */ + public static final String NAME = "ALMANAC"; + + private int ID = -1; + + private int Health = -1; + + private double e = Double.NaN; + + private int toa = -1; + + private double deltai = Double.NaN; + + private double Omegad = Double.NaN; + + private double sqrtA = Double.NaN; + + private double Omega0 = Double.NaN; + + private double omega = Double.NaN; + + private double M0 = Double.NaN; + + private double af0 = Double.NaN; + + private double af1 = Double.NaN; + + /** + * @return the iD + */ + public int getID() { + return this.ID; + } + + /** + * @param iD the iD to set + */ + public void setID(final int iD) { + this.ID = iD; + } + + /** + * @return the health + */ + public int getHealth() { + return this.Health; + } + + /** + * @param health the health to set + */ + public void setHealth(final int health) { + this.Health = health; + } + + /** + * @return the e + */ + public double getE() { + return this.e; + } + + /** + * @param e the e to set + */ + public void setE(final double e) { + this.e = e; + } + + /** + * @return the toa + */ + public int getToa() { + return this.toa; + } + + /** + * @param toa the toa to set + */ + public void setToa(final int toa) { + this.toa = toa; + } + + /** + * @return the deltai + */ + public double getDeltai() { + return this.deltai; + } + + /** + * @param deltai the deltai to set + */ + public void setDeltai(final double deltai) { + this.deltai = deltai; + } + + /** + * @return the omegad + */ + public double getOmegad() { + return this.Omegad; + } + + /** + * @param omegad the omegad to set + */ + public void setOmegad(final double omegad) { + this.Omegad = omegad; + } + + /** + * @return the sqrtA + */ + public double getSqrtA() { + return this.sqrtA; + } + + /** + * @param sqrtA the sqrtA to set + */ + public void setSqrtA(final double sqrtA) { + this.sqrtA = sqrtA; + } + + /** + * @return the omega0 + */ + public double getOmega0() { + return this.Omega0; + } + + /** + * @param omega0 the omega0 to set + */ + public void setOmega0(final double omega0) { + this.Omega0 = omega0; + } + + /** + * @return the omega + */ + public double getOmega() { + return this.omega; + } + + /** + * @param omega the omega to set + */ + public void setOmega(final double omega) { + this.omega = omega; + } + + /** + * @return the m0 + */ + public double getM0() { + return this.M0; + } + + /** + * @param m0 the m0 to set + */ + public void setM0(final double m0) { + this.M0 = m0; + } + + /** + * @return the af0 + */ + public double getAf0() { + return this.af0; + } + + /** + * @param af0 the af0 to set + */ + public void setAf0(final double af0) { + this.af0 = af0; + } + + /** + * @return the af1 + */ + public double getAf1() { + return this.af1; + } + + /** + * @param af1 the af1 to set + */ + public void setAf1(final double af1) { + this.af1 = af1; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ALMANACObject)) { + return false; + } + + final ALMANACObject that = (ALMANACObject) o; + + if (this.Health != that.Health) { + return false; + } + if (this.ID != that.ID) { + return false; + } + if (Double.compare(that.M0, this.M0) != 0) { + return false; + } + if (Double.compare(that.Omega0, this.Omega0) != 0) { + return false; + } + if (Double.compare(that.Omegad, this.Omegad) != 0) { + return false; + } + if (Double.compare(that.af0, this.af0) != 0) { + return false; + } + if (Double.compare(that.af1, this.af1) != 0) { + return false; + } + if (Double.compare(that.deltai, this.deltai) != 0) { + return false; + } + if (Double.compare(that.e, this.e) != 0) { + return false; + } + if (Double.compare(that.omega, this.omega) != 0) { + return false; + } + if (Double.compare(that.sqrtA, this.sqrtA) != 0) { + return false; + } + if (this.toa != that.toa) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result; + long temp; + result = this.ID; + result = (31 * result) + this.Health; + temp = this.e != +0.0d ? Double.doubleToLongBits(this.e) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + result = (31 * result) + this.toa; + temp = this.deltai != +0.0d ? Double.doubleToLongBits(this.deltai) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Omegad != +0.0d ? Double.doubleToLongBits(this.Omegad) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.sqrtA != +0.0d ? Double.doubleToLongBits(this.sqrtA) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Omega0 != +0.0d ? Double.doubleToLongBits(this.Omega0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.omega != +0.0d ? Double.doubleToLongBits(this.omega) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.M0 != +0.0d ? Double.doubleToLongBits(this.M0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.af0 != +0.0d ? Double.doubleToLongBits(this.af0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.af1 != +0.0d ? Double.doubleToLongBits(this.af1) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("ALMANACObject{ID="); + sb.append(this.ID); + sb.append(", Health="); + sb.append(this.Health); + sb.append(", e="); + sb.append(this.e); + sb.append(", toa="); + sb.append(this.toa); + sb.append(", deltai="); + sb.append(this.deltai); + sb.append(", Omegad="); + sb.append(this.Omegad); + sb.append(", sqrtA="); + sb.append(this.sqrtA); + sb.append(", Omega0="); + sb.append(this.Omega0); + sb.append(", omega="); + sb.append(this.omega); + sb.append(", M0="); + sb.append(this.M0); + sb.append(", af0="); + sb.append(this.af0); + sb.append(", af1="); + sb.append(this.af1); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java index 3f39147..ea51fd4 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,287 +26,284 @@ * @author aevdokimov */ public class EPHEM1Object implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "EPHEM1"; - - private int WN = -1; - - private int IODC = -1; - - private int L2 = -1; - - private double ura = Double.NaN; - - private double hlth = Double.NaN; - - private int L2P = -1; - - private double Tgd = Double.NaN; - - private int toc = -1; - - private double af2 = Double.NaN; - - private double af1 = Double.NaN; - - private double af0 = Double.NaN; - - /** - * @return the wN - */ - public int getWN() { - return this.WN; - } - - /** - * @param wN the wN to set - */ - public void setWN(final int wN) { - this.WN = wN; - } - - /** - * @return the iODC - */ - public int getIODC() { - return this.IODC; - } - - /** - * @param iODC the iODC to set - */ - public void setIODC(final int iODC) { - this.IODC = iODC; - } - - /** - * @return the l2 - */ - public int getL2() { - return this.L2; - } - - /** - * @param l2 the l2 to set - */ - public void setL2(final int l2) { - this.L2 = l2; - } - - /** - * @return the ura - */ - public double getUra() { - return this.ura; - } - - /** - * @param ura the ura to set - */ - public void setUra(final double ura) { - this.ura = ura; - } - - /** - * @return the hlth - */ - public double getHlth() { - return this.hlth; - } - - /** - * @param hlth the hlth to set - */ - public void setHlth(final double hlth) { - this.hlth = hlth; - } - - /** - * @return the l2P - */ - public int getL2P() { - return this.L2P; - } - - /** - * @param l2p the l2P to set - */ - public void setL2P(final int l2p) { - this.L2P = l2p; - } - - /** - * @return the tgd - */ - public double getTgd() { - return this.Tgd; - } - - /** - * @param tgd the tgd to set - */ - public void setTgd(final double tgd) { - this.Tgd = tgd; - } - - /** - * @return the toc - */ - public int getToc() { - return this.toc; - } - - /** - * @param toc the toc to set - */ - public void setToc(final int toc) { - this.toc = toc; - } - - /** - * @return the af2 - */ - public double getAf2() { - return this.af2; - } - - /** - * @param af2 the af2 to set - */ - public void setAf2(final double af2) { - this.af2 = af2; - } - - /** - * @return the af1 - */ - public double getAf1() { - return this.af1; - } - - /** - * @param af1 the af1 to set - */ - public void setAf1(final double af1) { - this.af1 = af1; - } - - /** - * @return the af0 - */ - public double getAf0() { - return this.af0; - } - - /** - * @param af0 the af0 to set - */ - public void setAf0(final double af0) { - this.af0 = af0; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if ((o == null) || (this.getClass() != o.getClass())) { - return false; - } - - final EPHEM1Object that = (EPHEM1Object) o; - - if (this.IODC != that.IODC) { - return false; - } - if (this.L2 != that.L2) { - return false; - } - if (this.L2P != that.L2P) { - return false; - } - if (Double.compare(that.Tgd, this.Tgd) != 0) { - return false; - } - if (this.WN != that.WN) { - return false; - } - if (Double.compare(that.af0, this.af0) != 0) { - return false; - } - if (Double.compare(that.af1, this.af1) != 0) { - return false; - } - if (Double.compare(that.af2, this.af2) != 0) { - return false; - } - if (Double.compare(that.hlth, this.hlth) != 0) { - return false; - } - if (this.toc != that.toc) { - return false; - } - if (Double.compare(that.ura, this.ura) != 0) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result; - long temp; - result = this.WN; - result = (31 * result) + this.IODC; - result = (31 * result) + this.L2; - temp = this.ura != +0.0d ? Double.doubleToLongBits(this.ura) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.hlth != +0.0d ? Double.doubleToLongBits(this.hlth) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - result = (31 * result) + this.L2P; - temp = this.Tgd != +0.0d ? Double.doubleToLongBits(this.Tgd) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - result = (31 * result) + this.toc; - temp = this.af2 != +0.0d ? Double.doubleToLongBits(this.af2) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.af1 != +0.0d ? Double.doubleToLongBits(this.af1) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.af0 != +0.0d ? Double.doubleToLongBits(this.af0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("EPHEM1Object{WN="); - sb.append(this.WN); - sb.append(", IODC="); - sb.append(this.IODC); - sb.append(", ura="); - sb.append(this.ura); - sb.append(", L2="); - sb.append(this.L2); - sb.append(", hlth="); - sb.append(this.hlth); - sb.append(", L2P="); - sb.append(this.L2P); - sb.append(", Tgd="); - sb.append(this.Tgd); - sb.append(", toc="); - sb.append(this.toc); - sb.append(", af2="); - sb.append(this.af2); - sb.append(", af0="); - sb.append(this.af0); - sb.append(", af1="); - sb.append(this.af1); - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "EPHEM1"; + + private int WN = -1; + + private int IODC = -1; + + private int L2 = -1; + + private double ura = Double.NaN; + + private double hlth = Double.NaN; + + private int L2P = -1; + + private double Tgd = Double.NaN; + + private int toc = -1; + + private double af2 = Double.NaN; + + private double af1 = Double.NaN; + + private double af0 = Double.NaN; + + /** + * @return the wN + */ + public int getWN() { + return this.WN; + } + + /** + * @param wN the wN to set + */ + public void setWN(final int wN) { + this.WN = wN; + } + + /** + * @return the iODC + */ + public int getIODC() { + return this.IODC; + } + + /** + * @param iODC the iODC to set + */ + public void setIODC(final int iODC) { + this.IODC = iODC; + } + + /** + * @return the l2 + */ + public int getL2() { + return this.L2; + } + + /** + * @param l2 the l2 to set + */ + public void setL2(final int l2) { + this.L2 = l2; + } + + /** + * @return the ura + */ + public double getUra() { + return this.ura; + } + + /** + * @param ura the ura to set + */ + public void setUra(final double ura) { + this.ura = ura; + } + + /** + * @return the hlth + */ + public double getHlth() { + return this.hlth; + } + + /** + * @param hlth the hlth to set + */ + public void setHlth(final double hlth) { + this.hlth = hlth; + } + + /** + * @return the l2P + */ + public int getL2P() { + return this.L2P; + } + + /** + * @param l2p the l2P to set + */ + public void setL2P(final int l2p) { + this.L2P = l2p; + } + + /** + * @return the tgd + */ + public double getTgd() { + return this.Tgd; + } + + /** + * @param tgd the tgd to set + */ + public void setTgd(final double tgd) { + this.Tgd = tgd; + } + + /** + * @return the toc + */ + public int getToc() { + return this.toc; + } + + /** + * @param toc the toc to set + */ + public void setToc(final int toc) { + this.toc = toc; + } + + /** + * @return the af2 + */ + public double getAf2() { + return this.af2; + } + + /** + * @param af2 the af2 to set + */ + public void setAf2(final double af2) { + this.af2 = af2; + } + + /** + * @return the af1 + */ + public double getAf1() { + return this.af1; + } + + /** + * @param af1 the af1 to set + */ + public void setAf1(final double af1) { + this.af1 = af1; + } + + /** + * @return the af0 + */ + public double getAf0() { + return this.af0; + } + + /** + * @param af0 the af0 to set + */ + public void setAf0(final double af0) { + this.af0 = af0; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if ((o == null) || (this.getClass() != o.getClass())) { + return false; + } + + final EPHEM1Object that = (EPHEM1Object) o; + + if (this.IODC != that.IODC) { + return false; + } + if (this.L2 != that.L2) { + return false; + } + if (this.L2P != that.L2P) { + return false; + } + if (Double.compare(that.Tgd, this.Tgd) != 0) { + return false; + } + if (this.WN != that.WN) { + return false; + } + if (Double.compare(that.af0, this.af0) != 0) { + return false; + } + if (Double.compare(that.af1, this.af1) != 0) { + return false; + } + if (Double.compare(that.af2, this.af2) != 0) { + return false; + } + if (Double.compare(that.hlth, this.hlth) != 0) { + return false; + } + if (this.toc != that.toc) { + return false; + } + if (Double.compare(that.ura, this.ura) != 0) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result; + long temp; + result = this.WN; + result = (31 * result) + this.IODC; + result = (31 * result) + this.L2; + temp = this.ura != +0.0d ? Double.doubleToLongBits(this.ura) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.hlth != +0.0d ? Double.doubleToLongBits(this.hlth) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + result = (31 * result) + this.L2P; + temp = this.Tgd != +0.0d ? Double.doubleToLongBits(this.Tgd) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + result = (31 * result) + this.toc; + temp = this.af2 != +0.0d ? Double.doubleToLongBits(this.af2) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.af1 != +0.0d ? Double.doubleToLongBits(this.af1) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.af0 != +0.0d ? Double.doubleToLongBits(this.af0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("EPHEM1Object{WN="); + sb.append(this.WN); + sb.append(", IODC="); + sb.append(this.IODC); + sb.append(", ura="); + sb.append(this.ura); + sb.append(", L2="); + sb.append(this.L2); + sb.append(", hlth="); + sb.append(this.hlth); + sb.append(", L2P="); + sb.append(this.L2P); + sb.append(", Tgd="); + sb.append(this.Tgd); + sb.append(", toc="); + sb.append(this.toc); + sb.append(", af2="); + sb.append(this.af2); + sb.append(", af0="); + sb.append(this.af0); + sb.append(", af1="); + sb.append(this.af1); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java index 5a52a4c..b705b74 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,288 +26,285 @@ * @author aevdokimov */ public class EPHEM2Object implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "EPHEM2"; - - private int IODE = -1; - - private double Crs = Double.NaN; - - private double deltan = Double.NaN; - - private double M0 = Double.NaN; - - private double Cuc = Double.NaN; - - private double e = Double.NaN; - - private double Cus = Double.NaN; - - private double sqrtA = Double.NaN; - - private int toe = -1; - - private int FIT = -1; - - private int AODO = -1; - - /** - * @return the iODE - */ - public int getIODE() { - return this.IODE; - } - - /** - * @param iODE the iODE to set - */ - public void setIODE(final int iODE) { - this.IODE = iODE; - } - - /** - * @return the crs - */ - public double getCrs() { - return this.Crs; - } - - /** - * @param crs the crs to set - */ - public void setCrs(final double crs) { - this.Crs = crs; - } - - /** - * @return the deltan - */ - public double getDeltan() { - return this.deltan; - } - - /** - * @param deltan the deltan to set - */ - public void setDeltan(final double deltan) { - this.deltan = deltan; - } - - /** - * @return the m0 - */ - public double getM0() { - return this.M0; - } - - /** - * @param m0 the m0 to set - */ - public void setM0(final double m0) { - this.M0 = m0; - } - - /** - * @return the cuc - */ - public double getCuc() { - return this.Cuc; - } - - /** - * @param cuc the cuc to set - */ - public void setCuc(final double cuc) { - this.Cuc = cuc; - } - - /** - * @return the e - */ - public double getE() { - return this.e; - } - - /** - * @param e the e to set - */ - public void setE(final double e) { - this.e = e; - } - - /** - * @return the cus - */ - public double getCus() { - return this.Cus; - } - - /** - * @param cus the cus to set - */ - public void setCus(final double cus) { - this.Cus = cus; - } - - /** - * @return the sqrtA - */ - public double getSqrtA() { - return this.sqrtA; - } - - /** - * @param sqrtA the sqrtA to set - */ - public void setSqrtA(final double sqrtA) { - this.sqrtA = sqrtA; - } - - /** - * @return the toe - */ - public int getToe() { - return this.toe; - } - - /** - * @param toe the toe to set - */ - public void setToe(final int toe) { - this.toe = toe; - } - - /** - * @return the fIT - */ - public int getFIT() { - return this.FIT; - } - - /** - * @param fIT the fIT to set - */ - public void setFIT(final int fIT) { - this.FIT = fIT; - } - - /** - * @return the aODO - */ - public int getAODO() { - return this.AODO; - } - - /** - * @param aODO the aODO to set - */ - public void setAODO(final int aODO) { - this.AODO = aODO; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if ((o == null) || (this.getClass() != o.getClass())) { - return false; - } - - final EPHEM2Object that = (EPHEM2Object) o; - - if (this.AODO != that.AODO) { - return false; - } - if (Double.compare(that.Crs, this.Crs) != 0) { - return false; - } - if (Double.compare(that.Cuc, this.Cuc) != 0) { - return false; - } - if (Double.compare(that.Cus, this.Cus) != 0) { - return false; - } - if (this.FIT != that.FIT) { - return false; - } - if (this.IODE != that.IODE) { - return false; - } - if (Double.compare(that.M0, this.M0) != 0) { - return false; - } - if (Double.compare(that.deltan, this.deltan) != 0) { - return false; - } - if (Double.compare(that.e, this.e) != 0) { - return false; - } - if (Double.compare(that.sqrtA, this.sqrtA) != 0) { - return false; - } - if (this.toe != that.toe) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result; - long temp; - result = this.IODE; - temp = this.Crs != +0.0d ? Double.doubleToLongBits(this.Crs) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.deltan != +0.0d ? Double.doubleToLongBits(this.deltan) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.M0 != +0.0d ? Double.doubleToLongBits(this.M0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Cuc != +0.0d ? Double.doubleToLongBits(this.Cuc) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.e != +0.0d ? Double.doubleToLongBits(this.e) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Cus != +0.0d ? Double.doubleToLongBits(this.Cus) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.sqrtA != +0.0d ? Double.doubleToLongBits(this.sqrtA) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - result = (31 * result) + this.toe; - result = (31 * result) + this.FIT; - result = (31 * result) + this.AODO; - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("EPHEM2Object{IODE="); - sb.append(this.IODE); - sb.append(", Crs="); - sb.append(this.Crs); - sb.append(", deltan="); - sb.append(this.deltan); - sb.append(", M0="); - sb.append(this.M0); - sb.append(", Cuc="); - sb.append(this.Cuc); - sb.append(", e="); - sb.append(this.e); - sb.append(", Cus="); - sb.append(this.Cus); - sb.append(", sqrtA="); - sb.append(this.sqrtA); - sb.append(", toe="); - sb.append(this.toe); - sb.append(", FIT="); - sb.append(this.FIT); - sb.append(", AODO="); - sb.append(this.AODO); - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "EPHEM2"; + + private int IODE = -1; + + private double Crs = Double.NaN; + + private double deltan = Double.NaN; + + private double M0 = Double.NaN; + + private double Cuc = Double.NaN; + + private double e = Double.NaN; + + private double Cus = Double.NaN; + + private double sqrtA = Double.NaN; + + private int toe = -1; + + private int FIT = -1; + + private int AODO = -1; + + /** + * @return the iODE + */ + public int getIODE() { + return this.IODE; + } + + /** + * @param iODE the iODE to set + */ + public void setIODE(final int iODE) { + this.IODE = iODE; + } + + /** + * @return the crs + */ + public double getCrs() { + return this.Crs; + } + + /** + * @param crs the crs to set + */ + public void setCrs(final double crs) { + this.Crs = crs; + } + + /** + * @return the deltan + */ + public double getDeltan() { + return this.deltan; + } + + /** + * @param deltan the deltan to set + */ + public void setDeltan(final double deltan) { + this.deltan = deltan; + } + + /** + * @return the m0 + */ + public double getM0() { + return this.M0; + } + + /** + * @param m0 the m0 to set + */ + public void setM0(final double m0) { + this.M0 = m0; + } + + /** + * @return the cuc + */ + public double getCuc() { + return this.Cuc; + } + + /** + * @param cuc the cuc to set + */ + public void setCuc(final double cuc) { + this.Cuc = cuc; + } + + /** + * @return the e + */ + public double getE() { + return this.e; + } + + /** + * @param e the e to set + */ + public void setE(final double e) { + this.e = e; + } + + /** + * @return the cus + */ + public double getCus() { + return this.Cus; + } + + /** + * @param cus the cus to set + */ + public void setCus(final double cus) { + this.Cus = cus; + } + + /** + * @return the sqrtA + */ + public double getSqrtA() { + return this.sqrtA; + } + + /** + * @param sqrtA the sqrtA to set + */ + public void setSqrtA(final double sqrtA) { + this.sqrtA = sqrtA; + } + + /** + * @return the toe + */ + public int getToe() { + return this.toe; + } + + /** + * @param toe the toe to set + */ + public void setToe(final int toe) { + this.toe = toe; + } + + /** + * @return the fIT + */ + public int getFIT() { + return this.FIT; + } + + /** + * @param fIT the fIT to set + */ + public void setFIT(final int fIT) { + this.FIT = fIT; + } + + /** + * @return the aODO + */ + public int getAODO() { + return this.AODO; + } + + /** + * @param aODO the aODO to set + */ + public void setAODO(final int aODO) { + this.AODO = aODO; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if ((o == null) || (this.getClass() != o.getClass())) { + return false; + } + + final EPHEM2Object that = (EPHEM2Object) o; + + if (this.AODO != that.AODO) { + return false; + } + if (Double.compare(that.Crs, this.Crs) != 0) { + return false; + } + if (Double.compare(that.Cuc, this.Cuc) != 0) { + return false; + } + if (Double.compare(that.Cus, this.Cus) != 0) { + return false; + } + if (this.FIT != that.FIT) { + return false; + } + if (this.IODE != that.IODE) { + return false; + } + if (Double.compare(that.M0, this.M0) != 0) { + return false; + } + if (Double.compare(that.deltan, this.deltan) != 0) { + return false; + } + if (Double.compare(that.e, this.e) != 0) { + return false; + } + if (Double.compare(that.sqrtA, this.sqrtA) != 0) { + return false; + } + if (this.toe != that.toe) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result; + long temp; + result = this.IODE; + temp = this.Crs != +0.0d ? Double.doubleToLongBits(this.Crs) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.deltan != +0.0d ? Double.doubleToLongBits(this.deltan) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.M0 != +0.0d ? Double.doubleToLongBits(this.M0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Cuc != +0.0d ? Double.doubleToLongBits(this.Cuc) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.e != +0.0d ? Double.doubleToLongBits(this.e) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Cus != +0.0d ? Double.doubleToLongBits(this.Cus) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.sqrtA != +0.0d ? Double.doubleToLongBits(this.sqrtA) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + result = (31 * result) + this.toe; + result = (31 * result) + this.FIT; + result = (31 * result) + this.AODO; + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("EPHEM2Object{IODE="); + sb.append(this.IODE); + sb.append(", Crs="); + sb.append(this.Crs); + sb.append(", deltan="); + sb.append(this.deltan); + sb.append(", M0="); + sb.append(this.M0); + sb.append(", Cuc="); + sb.append(this.Cuc); + sb.append(", e="); + sb.append(this.e); + sb.append(", Cus="); + sb.append(this.Cus); + sb.append(", sqrtA="); + sb.append(this.sqrtA); + sb.append(", toe="); + sb.append(this.toe); + sb.append(", FIT="); + sb.append(this.FIT); + sb.append(", AODO="); + sb.append(this.AODO); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java index 0321d8e..178084f 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,245 +26,242 @@ * @author aevdokimov */ public class EPHEM3Object implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "EPHEM3"; - - private int IODE = -1; - - private double IDOT = Double.NaN; - - private double Cic = Double.NaN; - - private double Omega0 = Double.NaN; - - private double Cis = Double.NaN; - - private double i0 = Double.NaN; - - private double Crc = Double.NaN; - - private double omega = Double.NaN; - - private double Omegad = Double.NaN; - - /** - * @return the iODE - */ - public int getIODE() { - return this.IODE; - } - - /** - * @param iODE the iODE to set - */ - public void setIODE(final int iODE) { - this.IODE = iODE; - } - - /** - * @return the iDOT - */ - public double getIDOT() { - return this.IDOT; - } - - /** - * @param iDOT the iDOT to set - */ - public void setIDOT(final double iDOT) { - this.IDOT = iDOT; - } - - /** - * @return the cic - */ - public double getCic() { - return this.Cic; - } - - /** - * @param cic the cic to set - */ - public void setCic(final double cic) { - this.Cic = cic; - } - - /** - * @return the omega0 - */ - public double getOmega0() { - return this.Omega0; - } - - /** - * @param omega0 the omega0 to set - */ - public void setOmega0(final double omega0) { - this.Omega0 = omega0; - } - - /** - * @return the cis - */ - public double getCis() { - return this.Cis; - } - - /** - * @param cis the cis to set - */ - public void setCis(final double cis) { - this.Cis = cis; - } - - /** - * @return the i0 - */ - public double getI0() { - return this.i0; - } - - /** - * @param i0 the i0 to set - */ - public void setI0(final double i0) { - this.i0 = i0; - } - - /** - * @return the crc - */ - public double getCrc() { - return this.Crc; - } - - /** - * @param crc the crc to set - */ - public void setCrc(final double crc) { - this.Crc = crc; - } - - /** - * @return the omega - */ - public double getOmega() { - return this.omega; - } - - /** - * @param omega the omega to set - */ - public void setOmega(final double omega) { - this.omega = omega; - } - - /** - * @return the omegad - */ - public double getOmegad() { - return this.Omegad; - } - - /** - * @param omegad the omegad to set - */ - public void setOmegad(final double omegad) { - this.Omegad = omegad; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof EPHEM3Object)) { - return false; - } - - final EPHEM3Object that = (EPHEM3Object) o; - - if (Double.compare(that.Cic, this.Cic) != 0) { - return false; - } - if (Double.compare(that.Cis, this.Cis) != 0) { - return false; - } - if (Double.compare(that.Crc, this.Crc) != 0) { - return false; - } - if (Double.compare(that.IDOT, this.IDOT) != 0) { - return false; - } - if (this.IODE != that.IODE) { - return false; - } - if (Double.compare(that.Omega0, this.Omega0) != 0) { - return false; - } - if (Double.compare(that.Omegad, this.Omegad) != 0) { - return false; - } - if (Double.compare(that.i0, this.i0) != 0) { - return false; - } - if (Double.compare(that.omega, this.omega) != 0) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result; - long temp; - result = this.IODE; - temp = this.IDOT != +0.0d ? Double.doubleToLongBits(this.IDOT) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Cic != +0.0d ? Double.doubleToLongBits(this.Cic) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Omega0 != +0.0d ? Double.doubleToLongBits(this.Omega0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Cis != +0.0d ? Double.doubleToLongBits(this.Cis) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.i0 != +0.0d ? Double.doubleToLongBits(this.i0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Crc != +0.0d ? Double.doubleToLongBits(this.Crc) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.omega != +0.0d ? Double.doubleToLongBits(this.omega) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.Omegad != +0.0d ? Double.doubleToLongBits(this.Omegad) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("EPHEM3Object{IODE="); - sb.append(this.IODE); - sb.append(", IDOT="); - sb.append(this.IDOT); - sb.append(", Cic="); - sb.append(this.Cic); - sb.append(", Omega0="); - sb.append(this.Omega0); - sb.append(", Cis="); - sb.append(this.Cis); - sb.append(", i0="); - sb.append(this.i0); - sb.append(", Crc="); - sb.append(this.Crc); - sb.append(", omega="); - sb.append(this.omega); - sb.append(", Omegad="); - sb.append(this.Omegad); - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "EPHEM3"; + + private int IODE = -1; + + private double IDOT = Double.NaN; + + private double Cic = Double.NaN; + + private double Omega0 = Double.NaN; + + private double Cis = Double.NaN; + + private double i0 = Double.NaN; + + private double Crc = Double.NaN; + + private double omega = Double.NaN; + + private double Omegad = Double.NaN; + + /** + * @return the iODE + */ + public int getIODE() { + return this.IODE; + } + + /** + * @param iODE the iODE to set + */ + public void setIODE(final int iODE) { + this.IODE = iODE; + } + + /** + * @return the iDOT + */ + public double getIDOT() { + return this.IDOT; + } + + /** + * @param iDOT the iDOT to set + */ + public void setIDOT(final double iDOT) { + this.IDOT = iDOT; + } + + /** + * @return the cic + */ + public double getCic() { + return this.Cic; + } + + /** + * @param cic the cic to set + */ + public void setCic(final double cic) { + this.Cic = cic; + } + + /** + * @return the omega0 + */ + public double getOmega0() { + return this.Omega0; + } + + /** + * @param omega0 the omega0 to set + */ + public void setOmega0(final double omega0) { + this.Omega0 = omega0; + } + + /** + * @return the cis + */ + public double getCis() { + return this.Cis; + } + + /** + * @param cis the cis to set + */ + public void setCis(final double cis) { + this.Cis = cis; + } + + /** + * @return the i0 + */ + public double getI0() { + return this.i0; + } + + /** + * @param i0 the i0 to set + */ + public void setI0(final double i0) { + this.i0 = i0; + } + + /** + * @return the crc + */ + public double getCrc() { + return this.Crc; + } + + /** + * @param crc the crc to set + */ + public void setCrc(final double crc) { + this.Crc = crc; + } + + /** + * @return the omega + */ + public double getOmega() { + return this.omega; + } + + /** + * @param omega the omega to set + */ + public void setOmega(final double omega) { + this.omega = omega; + } + + /** + * @return the omegad + */ + public double getOmegad() { + return this.Omegad; + } + + /** + * @param omegad the omegad to set + */ + public void setOmegad(final double omegad) { + this.Omegad = omegad; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof EPHEM3Object)) { + return false; + } + + final EPHEM3Object that = (EPHEM3Object) o; + + if (Double.compare(that.Cic, this.Cic) != 0) { + return false; + } + if (Double.compare(that.Cis, this.Cis) != 0) { + return false; + } + if (Double.compare(that.Crc, this.Crc) != 0) { + return false; + } + if (Double.compare(that.IDOT, this.IDOT) != 0) { + return false; + } + if (this.IODE != that.IODE) { + return false; + } + if (Double.compare(that.Omega0, this.Omega0) != 0) { + return false; + } + if (Double.compare(that.Omegad, this.Omegad) != 0) { + return false; + } + if (Double.compare(that.i0, this.i0) != 0) { + return false; + } + if (Double.compare(that.omega, this.omega) != 0) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result; + long temp; + result = this.IODE; + temp = this.IDOT != +0.0d ? Double.doubleToLongBits(this.IDOT) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Cic != +0.0d ? Double.doubleToLongBits(this.Cic) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Omega0 != +0.0d ? Double.doubleToLongBits(this.Omega0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Cis != +0.0d ? Double.doubleToLongBits(this.Cis) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.i0 != +0.0d ? Double.doubleToLongBits(this.i0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Crc != +0.0d ? Double.doubleToLongBits(this.Crc) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.omega != +0.0d ? Double.doubleToLongBits(this.omega) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.Omegad != +0.0d ? Double.doubleToLongBits(this.Omegad) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("EPHEM3Object{IODE="); + sb.append(this.IODE); + sb.append(", IDOT="); + sb.append(this.IDOT); + sb.append(", Cic="); + sb.append(this.Cic); + sb.append(", Omega0="); + sb.append(this.Omega0); + sb.append(", Cis="); + sb.append(this.Cis); + sb.append(", i0="); + sb.append(this.i0); + sb.append(", Crc="); + sb.append(this.Crc); + sb.append(", omega="); + sb.append(this.omega); + sb.append(", Omegad="); + sb.append(this.Omegad); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java index 8916c63..1804e70 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,109 +20,105 @@ * #L% */ -import java.util.Arrays; - import de.taimos.gpsd4java.types.IGPSObject; +import java.util.Arrays; /** * @author aevdokimov */ public class ERDObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "ERD"; - - private int[] ERD = new int[30]; - - private int ai = -1; - - /** - * @return the eRD - */ - public int[] getERD() { - return this.ERD; - } - - /** - * @param eRD the eRD to set - */ - public void setERD(final int[] eRD) { - this.ERD = eRD; - } - - /** - * @return the ai - */ - public int getAi() { - return this.ai; - } - - /** - * @param ai the ai to set - */ - public void setAi(final int ai) { - this.ai = ai; - } - - /** - * @param index - * @return the ERD - */ - public int getERDbyIndex(final int index) { - return this.ERD[index]; - } - - /** - * @param index the index - * @param ERDvalue the ERD - */ - public void setERDbyIndex(final int index, final int ERDvalue) { - this.ERD[index] = ERDvalue; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ERDObject)) { - return false; - } - - final ERDObject erdObject = (ERDObject) o; - - if (this.ai != erdObject.ai) { - return false; - } - if (!Arrays.equals(this.ERD, erdObject.ERD)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = this.ERD != null ? Arrays.hashCode(this.ERD) : 0; - result = (31 * result) + this.ai; - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("ERDObject{ai="); - sb.append(this.ai); - for (int index = 1; index <= 30; index++) { - sb.append(", ERD"); - sb.append(index); - sb.append("="); - sb.append(this.ERD[index - 1]); - } - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "ERD"; + + private int[] ERD = new int[30]; + + private int ai = -1; + + /** + * @return the eRD + */ + public int[] getERD() { + return this.ERD; + } + + /** + * @param eRD the eRD to set + */ + public void setERD(final int[] eRD) { + this.ERD = eRD; + } + + /** + * @return the ai + */ + public int getAi() { + return this.ai; + } + + /** + * @param ai the ai to set + */ + public void setAi(final int ai) { + this.ai = ai; + } + + /** + * @param index + * @return the ERD + */ + public int getERDbyIndex(final int index) { + return this.ERD[index]; + } + + /** + * @param index the index + * @param ERDvalue the ERD + */ + public void setERDbyIndex(final int index, final int ERDvalue) { + this.ERD[index] = ERDvalue; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ERDObject)) { + return false; + } + + final ERDObject erdObject = (ERDObject) o; + + if (this.ai != erdObject.ai) { + return false; + } + if (!Arrays.equals(this.ERD, erdObject.ERD)) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = this.ERD != null ? Arrays.hashCode(this.ERD) : 0; + result = (31 * result) + this.ai; + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("ERDObject{ai="); + sb.append(this.ai); + for (int index = 1; index <= 30; index++) { + sb.append(", ERD"); + sb.append(index); + sb.append("="); + sb.append(this.ERD[index - 1]); + } + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java index ef193ff..6786a71 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,117 +20,113 @@ * #L% */ -import java.util.Arrays; - import de.taimos.gpsd4java.types.IGPSObject; +import java.util.Arrays; /** * @author aevdokimov */ public class HEALTH2Object implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "HEALTH2"; - - private final int[] SV = new int[24]; - - private int toa = -1; - - private int WNa = -1; - - /** - * @return the toa - */ - public int getToa() { - return this.toa; - } - - /** - * @param toa the toa to set - */ - public void setToa(final int toa) { - this.toa = toa; - } - - /** - * @return the wNa - */ - public int getWNa() { - return this.WNa; - } - - /** - * @param wNa the wNa to set - */ - public void setWNa(final int wNa) { - this.WNa = wNa; - } - - /** - * @param index the index - * @return the SV - */ - public int getSVbyIndex(final int index) { - return this.SV[index]; - } - - /** - * @param index the index - * @param SVvalue the SV - */ - public void setSVbyIndex(final int index, final int SVvalue) { - this.SV[index] = SVvalue; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof HEALTH2Object)) { - return false; - } - - final HEALTH2Object that = (HEALTH2Object) o; - - if (this.WNa != that.WNa) { - return false; - } - if (this.toa != that.toa) { - return false; - } - if (!Arrays.equals(this.SV, that.SV)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = this.SV != null ? Arrays.hashCode(this.SV) : 0; - result = (31 * result) + this.toa; - result = (31 * result) + this.WNa; - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("HEALTH2Object{toa="); - sb.append(this.toa); - sb.append(", WNa="); - sb.append(this.WNa); - for (int index = 1; index <= 24; index++) { - sb.append(", SV"); - sb.append(index); - sb.append("="); - sb.append(this.SV[index - 1]); - } - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "HEALTH2"; + + private final int[] SV = new int[24]; + + private int toa = -1; + + private int WNa = -1; + + /** + * @return the toa + */ + public int getToa() { + return this.toa; + } + + /** + * @param toa the toa to set + */ + public void setToa(final int toa) { + this.toa = toa; + } + + /** + * @return the wNa + */ + public int getWNa() { + return this.WNa; + } + + /** + * @param wNa the wNa to set + */ + public void setWNa(final int wNa) { + this.WNa = wNa; + } + + /** + * @param index the index + * @return the SV + */ + public int getSVbyIndex(final int index) { + return this.SV[index]; + } + + /** + * @param index the index + * @param SVvalue the SV + */ + public void setSVbyIndex(final int index, final int SVvalue) { + this.SV[index] = SVvalue; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof HEALTH2Object)) { + return false; + } + + final HEALTH2Object that = (HEALTH2Object) o; + + if (this.WNa != that.WNa) { + return false; + } + if (this.toa != that.toa) { + return false; + } + if (!Arrays.equals(this.SV, that.SV)) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = this.SV != null ? Arrays.hashCode(this.SV) : 0; + result = (31 * result) + this.toa; + result = (31 * result) + this.WNa; + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("HEALTH2Object{toa="); + sb.append(this.toa); + sb.append(", WNa="); + sb.append(this.WNa); + for (int index = 1; index <= 24; index++) { + sb.append(", SV"); + sb.append(index); + sb.append("="); + sb.append(this.SV[index - 1]); + } + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java index 51a8723..608b63c 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,123 +20,119 @@ * #L% */ -import java.util.Arrays; - import de.taimos.gpsd4java.types.IGPSObject; +import java.util.Arrays; /** * @author aevdokimov */ public class HEALTHObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "HEALTH"; - - private final int[] SV = new int[32]; - - private final int[] SVH = new int[8]; - - private int data_id = -1; - - /** - * @return the data_id - */ - public int getData_id() { - return this.data_id; - } - - /** - * @param data_id the data_id to set - */ - public void setData_id(final int data_id) { - this.data_id = data_id; - } - - /** - * @param index the index - * @return the SV - */ - public int getSVbyIndex(final int index) { - return this.SV[index]; - } - - /** - * @param index the index - * @param SVvalue the SV - */ - public void setSVbyIndex(final int index, final int SVvalue) { - this.SV[index] = SVvalue; - } - - /** - * @param index the index - * @return the SVH - */ - public int getSVHbyIndex(final int index) { - return this.SVH[index]; - } - - /** - * @param index the index - * @param SVHvalue the SVH - */ - public void setSVHbyIndex(final int index, final int SVHvalue) { - this.SVH[index] = SVHvalue; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof HEALTHObject)) { - return false; - } - - final HEALTHObject that = (HEALTHObject) o; - - if (this.data_id != that.data_id) { - return false; - } - if (!Arrays.equals(this.SV, that.SV)) { - return false; - } - if (!Arrays.equals(this.SVH, that.SVH)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = this.SV != null ? Arrays.hashCode(this.SV) : 0; - result = (31 * result) + (this.SVH != null ? Arrays.hashCode(this.SVH) : 0); - result = (31 * result) + this.data_id; - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("HEALTHObject{data_id="); - sb.append(this.data_id); - for (int index = 1; index <= 32; index++) { - sb.append(", SV"); - sb.append(index); - sb.append("="); - sb.append(this.SV[index - 1]); - } - for (int index = 0; index <= 7; index++) { - sb.append(", SVH"); - sb.append(index + 25); - sb.append("="); - sb.append(this.SVH[index]); - } - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "HEALTH"; + + private final int[] SV = new int[32]; + + private final int[] SVH = new int[8]; + + private int data_id = -1; + + /** + * @return the data_id + */ + public int getData_id() { + return this.data_id; + } + + /** + * @param data_id the data_id to set + */ + public void setData_id(final int data_id) { + this.data_id = data_id; + } + + /** + * @param index the index + * @return the SV + */ + public int getSVbyIndex(final int index) { + return this.SV[index]; + } + + /** + * @param index the index + * @param SVvalue the SV + */ + public void setSVbyIndex(final int index, final int SVvalue) { + this.SV[index] = SVvalue; + } + + /** + * @param index the index + * @return the SVH + */ + public int getSVHbyIndex(final int index) { + return this.SVH[index]; + } + + /** + * @param index the index + * @param SVHvalue the SVH + */ + public void setSVHbyIndex(final int index, final int SVHvalue) { + this.SVH[index] = SVHvalue; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof HEALTHObject)) { + return false; + } + + final HEALTHObject that = (HEALTHObject) o; + + if (this.data_id != that.data_id) { + return false; + } + if (!Arrays.equals(this.SV, that.SV)) { + return false; + } + if (!Arrays.equals(this.SVH, that.SVH)) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = this.SV != null ? Arrays.hashCode(this.SV) : 0; + result = (31 * result) + (this.SVH != null ? Arrays.hashCode(this.SVH) : 0); + result = (31 * result) + this.data_id; + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("HEALTHObject{data_id="); + sb.append(this.data_id); + for (int index = 1; index <= 32; index++) { + sb.append(", SV"); + sb.append(index); + sb.append("="); + sb.append(this.SV[index - 1]); + } + for (int index = 0; index <= 7; index++) { + sb.append(", SVH"); + sb.append(index + 25); + sb.append("="); + sb.append(this.SVH[index]); + } + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java index 7695643..f1f822c 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,402 +26,399 @@ * @author aevdokimov */ public class IONOObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "IONO"; - - private double alpha0 = Double.NaN; - - private double alpha1 = Double.NaN; - - private double alpha2 = Double.NaN; - - private double alpha3 = Double.NaN; - - private double beta0 = Double.NaN; - - private double beta1 = Double.NaN; - - private double beta2 = Double.NaN; - - private double beta3 = Double.NaN; - - private double A0 = Double.NaN; - - private double A1 = Double.NaN; - - private double tot = Double.NaN; - - private int WNt = -1; - - private int leap = -1; - - private int WNlsf = -1; - - private int DN = -1; - - private int lsf = -1; - - /** - * @return the alpha0 - */ - public double getAlpha0() { - return this.alpha0; - } - - /** - * @param alpha0 the alpha0 to set - */ - public void setAlpha0(final double alpha0) { - this.alpha0 = alpha0; - } - - /** - * @return the alpha1 - */ - public double getAlpha1() { - return this.alpha1; - } - - /** - * @param alpha1 the alpha1 to set - */ - public void setAlpha1(final double alpha1) { - this.alpha1 = alpha1; - } - - /** - * @return the alpha2 - */ - public double getAlpha2() { - return this.alpha2; - } - - /** - * @param alpha2 the alpha2 to set - */ - public void setAlpha2(final double alpha2) { - this.alpha2 = alpha2; - } - - /** - * @return the alpha3 - */ - public double getAlpha3() { - return this.alpha3; - } - - /** - * @param alpha3 the alpha3 to set - */ - public void setAlpha3(final double alpha3) { - this.alpha3 = alpha3; - } - - /** - * @return the beta0 - */ - public double getBeta0() { - return this.beta0; - } - - /** - * @param beta0 the beta0 to set - */ - public void setBeta0(final double beta0) { - this.beta0 = beta0; - } - - /** - * @return the beta1 - */ - public double getBeta1() { - return this.beta1; - } - - /** - * @param beta1 the beta1 to set - */ - public void setBeta1(final double beta1) { - this.beta1 = beta1; - } - - /** - * @return the beta2 - */ - public double getBeta2() { - return this.beta2; - } - - /** - * @param beta2 the beta2 to set - */ - public void setBeta2(final double beta2) { - this.beta2 = beta2; - } - - /** - * @return the beta3 - */ - public double getBeta3() { - return this.beta3; - } - - /** - * @param beta3 the beta3 to set - */ - public void setBeta3(final double beta3) { - this.beta3 = beta3; - } - - /** - * @return the a0 - */ - public double getA0() { - return this.A0; - } - - /** - * @param a0 the a0 to set - */ - public void setA0(final double a0) { - this.A0 = a0; - } - - /** - * @return the a1 - */ - public double getA1() { - return this.A1; - } - - /** - * @param a1 the a1 to set - */ - public void setA1(final double a1) { - this.A1 = a1; - } - - /** - * @return the tot - */ - public double getTot() { - return this.tot; - } - - /** - * @param tot the tot to set - */ - public void setTot(final double tot) { - this.tot = tot; - } - - /** - * @return the wNt - */ - public int getWNt() { - return this.WNt; - } - - /** - * @param wNt the wNt to set - */ - public void setWNt(final int wNt) { - this.WNt = wNt; - } - - /** - * @return the leap - */ - public int getLeap() { - return this.leap; - } - - /** - * @param leap the leap to set - */ - public void setLeap(final int leap) { - this.leap = leap; - } - - /** - * @return the wNlsf - */ - public int getWNlsf() { - return this.WNlsf; - } - - /** - * @param wNlsf the wNlsf to set - */ - public void setWNlsf(final int wNlsf) { - this.WNlsf = wNlsf; - } - - /** - * @return the dN - */ - public int getDN() { - return this.DN; - } - - /** - * @param dN the dN to set - */ - public void setDN(final int dN) { - this.DN = dN; - } - - /** - * @return the lsf - */ - public int getLsf() { - return this.lsf; - } - - /** - * @param lsf the lsf to set - */ - public void setLsf(final int lsf) { - this.lsf = lsf; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof IONOObject)) { - return false; - } - - final IONOObject that = (IONOObject) o; - - if (Double.compare(that.A0, this.A0) != 0) { - return false; - } - if (Double.compare(that.A1, this.A1) != 0) { - return false; - } - if (this.DN != that.DN) { - return false; - } - if (this.WNlsf != that.WNlsf) { - return false; - } - if (this.WNt != that.WNt) { - return false; - } - if (Double.compare(that.alpha0, this.alpha0) != 0) { - return false; - } - if (Double.compare(that.alpha1, this.alpha1) != 0) { - return false; - } - if (Double.compare(that.alpha2, this.alpha2) != 0) { - return false; - } - if (Double.compare(that.alpha3, this.alpha3) != 0) { - return false; - } - if (Double.compare(that.beta0, this.beta0) != 0) { - return false; - } - if (Double.compare(that.beta1, this.beta1) != 0) { - return false; - } - if (Double.compare(that.beta2, this.beta2) != 0) { - return false; - } - if (Double.compare(that.beta3, this.beta3) != 0) { - return false; - } - if (this.leap != that.leap) { - return false; - } - if (this.lsf != that.lsf) { - return false; - } - if (Double.compare(that.tot, this.tot) != 0) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result; - long temp; - temp = this.alpha0 != +0.0d ? Double.doubleToLongBits(this.alpha0) : 0L; - result = (int) (temp ^ (temp >>> 32)); - temp = this.alpha1 != +0.0d ? Double.doubleToLongBits(this.alpha1) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.alpha2 != +0.0d ? Double.doubleToLongBits(this.alpha2) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.alpha3 != +0.0d ? Double.doubleToLongBits(this.alpha3) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.beta0 != +0.0d ? Double.doubleToLongBits(this.beta0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.beta1 != +0.0d ? Double.doubleToLongBits(this.beta1) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.beta2 != +0.0d ? Double.doubleToLongBits(this.beta2) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.beta3 != +0.0d ? Double.doubleToLongBits(this.beta3) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.A0 != +0.0d ? Double.doubleToLongBits(this.A0) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.A1 != +0.0d ? Double.doubleToLongBits(this.A1) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - temp = this.tot != +0.0d ? Double.doubleToLongBits(this.tot) : 0L; - result = (31 * result) + (int) (temp ^ (temp >>> 32)); - result = (31 * result) + this.WNt; - result = (31 * result) + this.leap; - result = (31 * result) + this.WNlsf; - result = (31 * result) + this.DN; - result = (31 * result) + this.lsf; - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("IONOObject{alpha0="); - sb.append(this.alpha0); - sb.append(", alpha1="); - sb.append(this.alpha1); - sb.append(", alpha2="); - sb.append(this.alpha2); - sb.append(", alpha3="); - sb.append(this.alpha3); - sb.append(", beta0="); - sb.append(this.beta0); - sb.append(", beta1="); - sb.append(this.beta1); - sb.append(", beta2="); - sb.append(this.beta2); - sb.append(", beta3="); - sb.append(this.beta3); - sb.append(", A0="); - sb.append(this.A0); - sb.append(", A1="); - sb.append(this.A1); - sb.append(", tot="); - sb.append(this.tot); - sb.append(", WNt="); - sb.append(this.WNt); - sb.append(", leap="); - sb.append(this.leap); - sb.append(", WNlsf="); - sb.append(this.WNlsf); - sb.append(", DN="); - sb.append(this.DN); - sb.append(", lsf="); - sb.append(this.lsf); - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "IONO"; + + private double alpha0 = Double.NaN; + + private double alpha1 = Double.NaN; + + private double alpha2 = Double.NaN; + + private double alpha3 = Double.NaN; + + private double beta0 = Double.NaN; + + private double beta1 = Double.NaN; + + private double beta2 = Double.NaN; + + private double beta3 = Double.NaN; + + private double A0 = Double.NaN; + + private double A1 = Double.NaN; + + private double tot = Double.NaN; + + private int WNt = -1; + + private int leap = -1; + + private int WNlsf = -1; + + private int DN = -1; + + private int lsf = -1; + + /** + * @return the alpha0 + */ + public double getAlpha0() { + return this.alpha0; + } + + /** + * @param alpha0 the alpha0 to set + */ + public void setAlpha0(final double alpha0) { + this.alpha0 = alpha0; + } + + /** + * @return the alpha1 + */ + public double getAlpha1() { + return this.alpha1; + } + + /** + * @param alpha1 the alpha1 to set + */ + public void setAlpha1(final double alpha1) { + this.alpha1 = alpha1; + } + + /** + * @return the alpha2 + */ + public double getAlpha2() { + return this.alpha2; + } + + /** + * @param alpha2 the alpha2 to set + */ + public void setAlpha2(final double alpha2) { + this.alpha2 = alpha2; + } + + /** + * @return the alpha3 + */ + public double getAlpha3() { + return this.alpha3; + } + + /** + * @param alpha3 the alpha3 to set + */ + public void setAlpha3(final double alpha3) { + this.alpha3 = alpha3; + } + + /** + * @return the beta0 + */ + public double getBeta0() { + return this.beta0; + } + + /** + * @param beta0 the beta0 to set + */ + public void setBeta0(final double beta0) { + this.beta0 = beta0; + } + + /** + * @return the beta1 + */ + public double getBeta1() { + return this.beta1; + } + + /** + * @param beta1 the beta1 to set + */ + public void setBeta1(final double beta1) { + this.beta1 = beta1; + } + + /** + * @return the beta2 + */ + public double getBeta2() { + return this.beta2; + } + + /** + * @param beta2 the beta2 to set + */ + public void setBeta2(final double beta2) { + this.beta2 = beta2; + } + + /** + * @return the beta3 + */ + public double getBeta3() { + return this.beta3; + } + + /** + * @param beta3 the beta3 to set + */ + public void setBeta3(final double beta3) { + this.beta3 = beta3; + } + + /** + * @return the a0 + */ + public double getA0() { + return this.A0; + } + + /** + * @param a0 the a0 to set + */ + public void setA0(final double a0) { + this.A0 = a0; + } + + /** + * @return the a1 + */ + public double getA1() { + return this.A1; + } + + /** + * @param a1 the a1 to set + */ + public void setA1(final double a1) { + this.A1 = a1; + } + + /** + * @return the tot + */ + public double getTot() { + return this.tot; + } + + /** + * @param tot the tot to set + */ + public void setTot(final double tot) { + this.tot = tot; + } + + /** + * @return the wNt + */ + public int getWNt() { + return this.WNt; + } + + /** + * @param wNt the wNt to set + */ + public void setWNt(final int wNt) { + this.WNt = wNt; + } + + /** + * @return the leap + */ + public int getLeap() { + return this.leap; + } + + /** + * @param leap the leap to set + */ + public void setLeap(final int leap) { + this.leap = leap; + } + + /** + * @return the wNlsf + */ + public int getWNlsf() { + return this.WNlsf; + } + + /** + * @param wNlsf the wNlsf to set + */ + public void setWNlsf(final int wNlsf) { + this.WNlsf = wNlsf; + } + + /** + * @return the dN + */ + public int getDN() { + return this.DN; + } + + /** + * @param dN the dN to set + */ + public void setDN(final int dN) { + this.DN = dN; + } + + /** + * @return the lsf + */ + public int getLsf() { + return this.lsf; + } + + /** + * @param lsf the lsf to set + */ + public void setLsf(final int lsf) { + this.lsf = lsf; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof IONOObject)) { + return false; + } + + final IONOObject that = (IONOObject) o; + + if (Double.compare(that.A0, this.A0) != 0) { + return false; + } + if (Double.compare(that.A1, this.A1) != 0) { + return false; + } + if (this.DN != that.DN) { + return false; + } + if (this.WNlsf != that.WNlsf) { + return false; + } + if (this.WNt != that.WNt) { + return false; + } + if (Double.compare(that.alpha0, this.alpha0) != 0) { + return false; + } + if (Double.compare(that.alpha1, this.alpha1) != 0) { + return false; + } + if (Double.compare(that.alpha2, this.alpha2) != 0) { + return false; + } + if (Double.compare(that.alpha3, this.alpha3) != 0) { + return false; + } + if (Double.compare(that.beta0, this.beta0) != 0) { + return false; + } + if (Double.compare(that.beta1, this.beta1) != 0) { + return false; + } + if (Double.compare(that.beta2, this.beta2) != 0) { + return false; + } + if (Double.compare(that.beta3, this.beta3) != 0) { + return false; + } + if (this.leap != that.leap) { + return false; + } + if (this.lsf != that.lsf) { + return false; + } + if (Double.compare(that.tot, this.tot) != 0) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result; + long temp; + temp = this.alpha0 != +0.0d ? Double.doubleToLongBits(this.alpha0) : 0L; + result = (int) (temp ^ (temp >>> 32)); + temp = this.alpha1 != +0.0d ? Double.doubleToLongBits(this.alpha1) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.alpha2 != +0.0d ? Double.doubleToLongBits(this.alpha2) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.alpha3 != +0.0d ? Double.doubleToLongBits(this.alpha3) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.beta0 != +0.0d ? Double.doubleToLongBits(this.beta0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.beta1 != +0.0d ? Double.doubleToLongBits(this.beta1) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.beta2 != +0.0d ? Double.doubleToLongBits(this.beta2) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.beta3 != +0.0d ? Double.doubleToLongBits(this.beta3) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.A0 != +0.0d ? Double.doubleToLongBits(this.A0) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.A1 != +0.0d ? Double.doubleToLongBits(this.A1) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + temp = this.tot != +0.0d ? Double.doubleToLongBits(this.tot) : 0L; + result = (31 * result) + (int) (temp ^ (temp >>> 32)); + result = (31 * result) + this.WNt; + result = (31 * result) + this.leap; + result = (31 * result) + this.WNlsf; + result = (31 * result) + this.DN; + result = (31 * result) + this.lsf; + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("IONOObject{alpha0="); + sb.append(this.alpha0); + sb.append(", alpha1="); + sb.append(this.alpha1); + sb.append(", alpha2="); + sb.append(this.alpha2); + sb.append(", alpha3="); + sb.append(this.alpha3); + sb.append(", beta0="); + sb.append(this.beta0); + sb.append(", beta1="); + sb.append(this.beta1); + sb.append(", beta2="); + sb.append(this.beta2); + sb.append(", beta3="); + sb.append(this.beta3); + sb.append(", A0="); + sb.append(this.A0); + sb.append(", A1="); + sb.append(this.A1); + sb.append(", tot="); + sb.append(this.tot); + sb.append(", WNt="); + sb.append(this.WNt); + sb.append(", leap="); + sb.append(this.leap); + sb.append(", WNlsf="); + sb.append(this.WNlsf); + sb.append(", DN="); + sb.append(this.DN); + sb.append(", lsf="); + sb.append(this.lsf); + sb.append("}"); + return sb.toString(); + } } diff --git a/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java b/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java index 13173a2..9afa8a9 100644 --- a/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,445 +26,444 @@ * @author aevdokimov */ public class SUBFRAMEObject implements IGPSObject { - - /** - * the GPSd internal name - */ - public static final String NAME = "SUBFRAME"; - - private String device = null; - - private int subframeNumber = -1; - - private int satelliteNumber = -1; - - private int MSBs = -1; - - private boolean scaled = false; - - private int pageid = -1; - - private String systemMessage = null; - - private ALMANACObject almanac; - - private EPHEM1Object ephem1; - - private EPHEM2Object ephem2; - - private EPHEM3Object ephem3; - - private ERDObject erd; - - private HEALTHObject health; - - private HEALTH2Object health2; - - private IONOObject iono; - - /** - * Name of originating device - * - * @return the device - */ - public String getDevice() { - return this.device; - } - - /** - * Name of originating device - * - * @param device the device to set - */ - public void setDevice(final String device) { - this.device = device; - } - - /** - * Subframe number - * - * @return the subframe number - */ - public int getSubFrameNumber() { - return this.subframeNumber; - } - - /** - * Subframe number - * - * @param subframeNumber to set - */ - public void setSubframeNumber(final int subframeNumber) { - this.subframeNumber = subframeNumber; - } - - /** - * Satellite number - * - * @return the satellite number - */ - public int getSatelliteNumber() { - return this.satelliteNumber; - } - - /** - * Satellite number - * - * @param satelliteNumber satellite number to set - */ - public void setSatelliteNumber(final int satelliteNumber) { - this.satelliteNumber = satelliteNumber; - } - - /** - * TOW17 field containing the 17 MSBs of the start of the next 12-second message - * - * @return TOW17 - */ - public int getMSBs() { - return this.MSBs; - } - - /** - * TOW17 field containing the 17 MSBs of the start of the next 12-second message - * - * @param MSBs TOW17 to set - */ - public void setMSBs(final int MSBs) { - this.MSBs = MSBs; - } - - /** - * field telling whether the remainder of the fields are dumped in scaled or unscaled form - * - * @return scaled - */ - public boolean getScaled() { - return this.scaled; - } - - /** - * field telling whether the remainder of the fields are dumped in scaled or unscaled form - * - * @param scaled scaled to set - */ - public void setScaled(final boolean scaled) { - this.scaled = scaled; - } - - /** - * optional pageid for ERD, IONO, HEALTH and system message - * - * @return pageid - */ - public int getPageid() { - return this.pageid; - } - - /** - * optional pageid for ERD, IONO, HEALTH and system message - * - * @param pageid page id to set - */ - public void setPageid(final int pageid) { - this.pageid = pageid; - } - - /** - * optional system message - * - * @return system message - */ - public String getSystemMessage() { - return this.systemMessage; - } - - /** - * optional system message - * - * @param systemMessage system message to set - */ - public void setSystemMessage(final String systemMessage) { - this.systemMessage = systemMessage; - } - - /** - * Optional ALMANAC object - * - * @return ALMANAC - */ - public ALMANACObject getAlmanac() { - return this.almanac; - } - - /** - * Optional ALMANAC object - * - * @param almanac ALMANAC to set - */ - public void setAlmanac(final ALMANACObject almanac) { - this.almanac = almanac; - } - - /** - * Optional EPHEM1 object - * - * @return EPHEM1 - */ - public EPHEM1Object getEphem1() { - return this.ephem1; - } - - /** - * Optional EPHEM1 object - * - * @param ephem1 EPHEM1 to set - */ - public void setEphem1(final EPHEM1Object ephem1) { - this.ephem1 = ephem1; - } - - /** - * Optional EPHEM2 object - * - * @return EPHEM2 - */ - public EPHEM2Object getEphem2() { - return this.ephem2; - } - - /** - * Optional EPHEM2 object - * - * @param ephem2 EPHEM2 to set - */ - public void setEphem2(final EPHEM2Object ephem2) { - this.ephem2 = ephem2; - } - - /** - * Optional EPHEM3 object - * - * @return EPHEM3 - */ - public EPHEM3Object getEphem3() { - return this.ephem3; - } - - /** - * Optional EPHEM3 object - * - * @param ephem3 EPHEM3 to set - */ - public void setEphem3(final EPHEM3Object ephem3) { - this.ephem3 = ephem3; - } - - /** - * Optional ERD object - * - * @return ERD - */ - public ERDObject getErd() { - return this.erd; - } - - /** - * Optional ERD object - * - * @param erd ERD to set - */ - public void setErd(final ERDObject erd) { - this.erd = erd; - } - - /** - * Optional HEALTH object - * - * @return HEALTH - */ - public HEALTHObject getHealth() { - return this.health; - } - - /** - * Optional HEALTH object - * - * @param health HEALTH to set - */ - public void setHealth(final HEALTHObject health) { - this.health = health; - } - - /** - * Optional HEALTH2 object - * - * @return HEALTH2 - */ - public HEALTH2Object getHealth2() { - return this.health2; - } - - /** - * Optional HEALTH2 object - * - * @param health2 HEALTH2 to set - */ - public void setHealth2(final HEALTH2Object health2) { - this.health2 = health2; - } - - /** - * Optional IONO object - * - * @return IONO - */ - public IONOObject getIono() { - return this.iono; - } - - /** - * Optional IONO object - * - * @param iono IONO to set - */ - public void setIono(final IONOObject iono) { - this.iono = iono; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SUBFRAMEObject)) { - return false; - } - - final SUBFRAMEObject that = (SUBFRAMEObject) o; - - if (this.MSBs != that.MSBs) { - return false; - } - if (this.pageid != that.pageid) { - return false; - } - if (this.satelliteNumber != that.satelliteNumber) { - return false; - } - if (this.scaled != that.scaled) { - return false; - } - if (this.subframeNumber != that.subframeNumber) { - return false; - } - if (this.almanac != null ? !this.almanac.equals(that.almanac) : that.almanac != null) { - return false; - } - if (this.device != null ? !this.device.equals(that.device) : that.device != null) { - return false; - } - if (this.ephem1 != null ? !this.ephem1.equals(that.ephem1) : that.ephem1 != null) { - return false; - } - if (this.ephem2 != null ? !this.ephem2.equals(that.ephem2) : that.ephem2 != null) { - return false; - } - if (this.ephem3 != null ? !this.ephem3.equals(that.ephem3) : that.ephem3 != null) { - return false; - } - if (this.erd != null ? !this.erd.equals(that.erd) : that.erd != null) { - return false; - } - if (this.health != null ? !this.health.equals(that.health) : that.health != null) { - return false; - } - if (this.health2 != null ? !this.health2.equals(that.health2) : that.health2 != null) { - return false; - } - if (this.iono != null ? !this.iono.equals(that.iono) : that.iono != null) { - return false; - } - if (this.systemMessage != null ? !this.systemMessage.equals(that.systemMessage) : that.systemMessage != null) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = this.device != null ? this.device.hashCode() : 0; - result = (31 * result) + this.subframeNumber; - result = (31 * result) + this.satelliteNumber; - result = (31 * result) + this.MSBs; - result = (31 * result) + (this.scaled ? 1 : 0); - result = (31 * result) + this.pageid; - result = (31 * result) + (this.systemMessage != null ? this.systemMessage.hashCode() : 0); - result = (31 * result) + (this.almanac != null ? this.almanac.hashCode() : 0); - result = (31 * result) + (this.ephem1 != null ? this.ephem1.hashCode() : 0); - result = (31 * result) + (this.ephem2 != null ? this.ephem2.hashCode() : 0); - result = (31 * result) + (this.ephem3 != null ? this.ephem3.hashCode() : 0); - result = (31 * result) + (this.erd != null ? this.erd.hashCode() : 0); - result = (31 * result) + (this.health != null ? this.health.hashCode() : 0); - result = (31 * result) + (this.health2 != null ? this.health2.hashCode() : 0); - result = (31 * result) + (this.iono != null ? this.iono.hashCode() : 0); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("SUBFRAMEObject{device="); - sb.append(this.device); - sb.append(", subframeNumber="); - sb.append(this.subframeNumber); - sb.append(", satelliteNumber="); - sb.append(this.satelliteNumber); - sb.append(", TOW17="); - sb.append(this.MSBs); - sb.append(", scaled="); - sb.append(this.scaled); - sb.append(", pageid="); - sb.append(this.pageid); - if (this.almanac != null) { - sb.append(", almanac={"); - sb.append(this.almanac.toString()); - sb.append("}"); - } else if (this.ephem1 != null) { - sb.append(", ephem1={"); - sb.append(this.ephem1.toString()); - sb.append("}"); - } else if (this.ephem2 != null) { - sb.append(", ephem2={"); - sb.append(this.ephem2.toString()); - sb.append("}"); - } else if (this.ephem3 != null) { - sb.append(", ephem3={"); - sb.append(this.ephem3.toString()); - sb.append("}"); - } else if (this.erd != null) { - sb.append(", erd={"); - sb.append(this.erd.toString()); - sb.append("}"); - } else if (this.health != null) { - sb.append(", health={"); - sb.append(this.health.toString()); - sb.append("}"); - } else if (this.health2 != null) { - sb.append(", health2={"); - sb.append(this.health2.toString()); - sb.append("}"); - } else if (this.systemMessage != null) { - sb.append(", systemMessage="); - sb.append(this.systemMessage); - } else if (this.iono != null) { - sb.append(", iono={"); - sb.append(this.iono.toString()); - sb.append("}"); - } - sb.append("}"); - return sb.toString(); - } - + + /** the GPSd internal name */ + public static final String NAME = "SUBFRAME"; + + private String device = null; + + private int subframeNumber = -1; + + private int satelliteNumber = -1; + + private int MSBs = -1; + + private boolean scaled = false; + + private int pageid = -1; + + private String systemMessage = null; + + private ALMANACObject almanac; + + private EPHEM1Object ephem1; + + private EPHEM2Object ephem2; + + private EPHEM3Object ephem3; + + private ERDObject erd; + + private HEALTHObject health; + + private HEALTH2Object health2; + + private IONOObject iono; + + /** + * Name of originating device + * + * @return the device + */ + public String getDevice() { + return this.device; + } + + /** + * Name of originating device + * + * @param device the device to set + */ + public void setDevice(final String device) { + this.device = device; + } + + /** + * Subframe number + * + * @return the subframe number + */ + public int getSubFrameNumber() { + return this.subframeNumber; + } + + /** + * Subframe number + * + * @param subframeNumber to set + */ + public void setSubframeNumber(final int subframeNumber) { + this.subframeNumber = subframeNumber; + } + + /** + * Satellite number + * + * @return the satellite number + */ + public int getSatelliteNumber() { + return this.satelliteNumber; + } + + /** + * Satellite number + * + * @param satelliteNumber satellite number to set + */ + public void setSatelliteNumber(final int satelliteNumber) { + this.satelliteNumber = satelliteNumber; + } + + /** + * TOW17 field containing the 17 MSBs of the start of the next 12-second message + * + * @return TOW17 + */ + public int getMSBs() { + return this.MSBs; + } + + /** + * TOW17 field containing the 17 MSBs of the start of the next 12-second message + * + * @param MSBs TOW17 to set + */ + public void setMSBs(final int MSBs) { + this.MSBs = MSBs; + } + + /** + * field telling whether the remainder of the fields are dumped in scaled or unscaled form + * + * @return scaled + */ + public boolean getScaled() { + return this.scaled; + } + + /** + * field telling whether the remainder of the fields are dumped in scaled or unscaled form + * + * @param scaled scaled to set + */ + public void setScaled(final boolean scaled) { + this.scaled = scaled; + } + + /** + * optional pageid for ERD, IONO, HEALTH and system message + * + * @return pageid + */ + public int getPageid() { + return this.pageid; + } + + /** + * optional pageid for ERD, IONO, HEALTH and system message + * + * @param pageid page id to set + */ + public void setPageid(final int pageid) { + this.pageid = pageid; + } + + /** + * optional system message + * + * @return system message + */ + public String getSystemMessage() { + return this.systemMessage; + } + + /** + * optional system message + * + * @param systemMessage system message to set + */ + public void setSystemMessage(final String systemMessage) { + this.systemMessage = systemMessage; + } + + /** + * Optional ALMANAC object + * + * @return ALMANAC + */ + public ALMANACObject getAlmanac() { + return this.almanac; + } + + /** + * Optional ALMANAC object + * + * @param almanac ALMANAC to set + */ + public void setAlmanac(final ALMANACObject almanac) { + this.almanac = almanac; + } + + /** + * Optional EPHEM1 object + * + * @return EPHEM1 + */ + public EPHEM1Object getEphem1() { + return this.ephem1; + } + + /** + * Optional EPHEM1 object + * + * @param ephem1 EPHEM1 to set + */ + public void setEphem1(final EPHEM1Object ephem1) { + this.ephem1 = ephem1; + } + + /** + * Optional EPHEM2 object + * + * @return EPHEM2 + */ + public EPHEM2Object getEphem2() { + return this.ephem2; + } + + /** + * Optional EPHEM2 object + * + * @param ephem2 EPHEM2 to set + */ + public void setEphem2(final EPHEM2Object ephem2) { + this.ephem2 = ephem2; + } + + /** + * Optional EPHEM3 object + * + * @return EPHEM3 + */ + public EPHEM3Object getEphem3() { + return this.ephem3; + } + + /** + * Optional EPHEM3 object + * + * @param ephem3 EPHEM3 to set + */ + public void setEphem3(final EPHEM3Object ephem3) { + this.ephem3 = ephem3; + } + + /** + * Optional ERD object + * + * @return ERD + */ + public ERDObject getErd() { + return this.erd; + } + + /** + * Optional ERD object + * + * @param erd ERD to set + */ + public void setErd(final ERDObject erd) { + this.erd = erd; + } + + /** + * Optional HEALTH object + * + * @return HEALTH + */ + public HEALTHObject getHealth() { + return this.health; + } + + /** + * Optional HEALTH object + * + * @param health HEALTH to set + */ + public void setHealth(final HEALTHObject health) { + this.health = health; + } + + /** + * Optional HEALTH2 object + * + * @return HEALTH2 + */ + public HEALTH2Object getHealth2() { + return this.health2; + } + + /** + * Optional HEALTH2 object + * + * @param health2 HEALTH2 to set + */ + public void setHealth2(final HEALTH2Object health2) { + this.health2 = health2; + } + + /** + * Optional IONO object + * + * @return IONO + */ + public IONOObject getIono() { + return this.iono; + } + + /** + * Optional IONO object + * + * @param iono IONO to set + */ + public void setIono(final IONOObject iono) { + this.iono = iono; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof SUBFRAMEObject)) { + return false; + } + + final SUBFRAMEObject that = (SUBFRAMEObject) o; + + if (this.MSBs != that.MSBs) { + return false; + } + if (this.pageid != that.pageid) { + return false; + } + if (this.satelliteNumber != that.satelliteNumber) { + return false; + } + if (this.scaled != that.scaled) { + return false; + } + if (this.subframeNumber != that.subframeNumber) { + return false; + } + if (this.almanac != null ? !this.almanac.equals(that.almanac) : that.almanac != null) { + return false; + } + if (this.device != null ? !this.device.equals(that.device) : that.device != null) { + return false; + } + if (this.ephem1 != null ? !this.ephem1.equals(that.ephem1) : that.ephem1 != null) { + return false; + } + if (this.ephem2 != null ? !this.ephem2.equals(that.ephem2) : that.ephem2 != null) { + return false; + } + if (this.ephem3 != null ? !this.ephem3.equals(that.ephem3) : that.ephem3 != null) { + return false; + } + if (this.erd != null ? !this.erd.equals(that.erd) : that.erd != null) { + return false; + } + if (this.health != null ? !this.health.equals(that.health) : that.health != null) { + return false; + } + if (this.health2 != null ? !this.health2.equals(that.health2) : that.health2 != null) { + return false; + } + if (this.iono != null ? !this.iono.equals(that.iono) : that.iono != null) { + return false; + } + if (this.systemMessage != null + ? !this.systemMessage.equals(that.systemMessage) + : that.systemMessage != null) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = this.device != null ? this.device.hashCode() : 0; + result = (31 * result) + this.subframeNumber; + result = (31 * result) + this.satelliteNumber; + result = (31 * result) + this.MSBs; + result = (31 * result) + (this.scaled ? 1 : 0); + result = (31 * result) + this.pageid; + result = (31 * result) + (this.systemMessage != null ? this.systemMessage.hashCode() : 0); + result = (31 * result) + (this.almanac != null ? this.almanac.hashCode() : 0); + result = (31 * result) + (this.ephem1 != null ? this.ephem1.hashCode() : 0); + result = (31 * result) + (this.ephem2 != null ? this.ephem2.hashCode() : 0); + result = (31 * result) + (this.ephem3 != null ? this.ephem3.hashCode() : 0); + result = (31 * result) + (this.erd != null ? this.erd.hashCode() : 0); + result = (31 * result) + (this.health != null ? this.health.hashCode() : 0); + result = (31 * result) + (this.health2 != null ? this.health2.hashCode() : 0); + result = (31 * result) + (this.iono != null ? this.iono.hashCode() : 0); + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("SUBFRAMEObject{device="); + sb.append(this.device); + sb.append(", subframeNumber="); + sb.append(this.subframeNumber); + sb.append(", satelliteNumber="); + sb.append(this.satelliteNumber); + sb.append(", TOW17="); + sb.append(this.MSBs); + sb.append(", scaled="); + sb.append(this.scaled); + sb.append(", pageid="); + sb.append(this.pageid); + if (this.almanac != null) { + sb.append(", almanac={"); + sb.append(this.almanac.toString()); + sb.append("}"); + } else if (this.ephem1 != null) { + sb.append(", ephem1={"); + sb.append(this.ephem1.toString()); + sb.append("}"); + } else if (this.ephem2 != null) { + sb.append(", ephem2={"); + sb.append(this.ephem2.toString()); + sb.append("}"); + } else if (this.ephem3 != null) { + sb.append(", ephem3={"); + sb.append(this.ephem3.toString()); + sb.append("}"); + } else if (this.erd != null) { + sb.append(", erd={"); + sb.append(this.erd.toString()); + sb.append("}"); + } else if (this.health != null) { + sb.append(", health={"); + sb.append(this.health.toString()); + sb.append("}"); + } else if (this.health2 != null) { + sb.append(", health2={"); + sb.append(this.health2.toString()); + sb.append("}"); + } else if (this.systemMessage != null) { + sb.append(", systemMessage="); + sb.append(this.systemMessage); + } else if (this.iono != null) { + sb.append(", iono={"); + sb.append(this.iono.toString()); + sb.append("}"); + } + sb.append("}"); + return sb.toString(); + } } diff --git a/src/test/java/de/taimos/gpsd4java/test/Tester.java b/src/test/java/de/taimos/gpsd4java/test/Tester.java index f11042f..84168a4 100644 --- a/src/test/java/de/taimos/gpsd4java/test/Tester.java +++ b/src/test/java/de/taimos/gpsd4java/test/Tester.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,6 @@ * #L% */ -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import de.taimos.gpsd4java.api.ObjectListener; import de.taimos.gpsd4java.backend.GPSdEndpoint; import de.taimos.gpsd4java.backend.ResultParser; @@ -33,101 +30,100 @@ import de.taimos.gpsd4java.types.SKYObject; import de.taimos.gpsd4java.types.TPVObject; import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class provides tests during the startup phase of GPSd4Java
* It will later be replaced by JUnit Tests - * - * created: 17.01.2011 - * + * + *

created: 17.01.2011 */ public class Tester { - - static final Logger log = LoggerFactory.getLogger(Tester.class); - - - private Tester() { - } - - /** - * @param args - * the args - */ - public static void main(final String[] args) { - try { - String host = "localhost"; - int port = 2947; - - switch (args.length) { - case 0: - // Nothing to do, use default - break; - case 1: - // only server specified - host = args[0]; - break; - case 2: - // Server and port specified - host = args[0]; - if (args[1].matches("\\d+")) { - port = Integer.parseInt(args[1]); - } - break; - default: - break; - } - - final GPSdEndpoint ep = new GPSdEndpoint(host, port, new ResultParser()); - - ep.addListener(new ObjectListener() { - - @Override - public void handleTPV(final TPVObject tpv) { - Tester.log.info("TPV: {}", tpv); - } - - @Override - public void handleSKY(final SKYObject sky) { - Tester.log.info("SKY: {}", sky); - for (final SATObject sat : sky.getSatellites()) { - Tester.log.info(" SAT: {}", sat); - } - } - - @Override - public void handleSUBFRAME(final SUBFRAMEObject subframe) { - Tester.log.info("SUBFRAME: {}", subframe); - } - - @Override - public void handleATT(final ATTObject att) { - Tester.log.info("ATT: {}", att); - } - - @Override - public void handleDevice(final DeviceObject device) { - Tester.log.info("Device: {}", device); - } - - @Override - public void handleDevices(final DevicesObject devices) { - for (final DeviceObject d : devices.getDevices()) { - Tester.log.info("Device: {}", d); - } - } - }); - - ep.start(); - - Tester.log.info("Version: {}", ep.version()); - - Tester.log.info("Watch: {}", ep.watch(true, true)); - - Tester.log.info("Poll: {}", ep.poll()); - - Thread.sleep(60000); - } catch (final Exception e) { - Tester.log.error("Problem encountered", e); - } - } + + static final Logger log = LoggerFactory.getLogger(Tester.class); + + private Tester() {} + + /** + * @param args the args + */ + public static void main(final String[] args) { + try { + String host = "localhost"; + int port = 2947; + + switch (args.length) { + case 0: + // Nothing to do, use default + break; + case 1: + // only server specified + host = args[0]; + break; + case 2: + // Server and port specified + host = args[0]; + if (args[1].matches("\\d+")) { + port = Integer.parseInt(args[1]); + } + break; + default: + break; + } + + final GPSdEndpoint ep = new GPSdEndpoint(host, port, new ResultParser()); + + ep.addListener( + new ObjectListener() { + + @Override + public void handleTPV(final TPVObject tpv) { + Tester.log.info("TPV: {}", tpv); + } + + @Override + public void handleSKY(final SKYObject sky) { + Tester.log.info("SKY: {}", sky); + for (final SATObject sat : sky.getSatellites()) { + Tester.log.info(" SAT: {}", sat); + } + } + + @Override + public void handleSUBFRAME(final SUBFRAMEObject subframe) { + Tester.log.info("SUBFRAME: {}", subframe); + } + + @Override + public void handleATT(final ATTObject att) { + Tester.log.info("ATT: {}", att); + } + + @Override + public void handleDevice(final DeviceObject device) { + Tester.log.info("Device: {}", device); + } + + @Override + public void handleDevices(final DevicesObject devices) { + for (final DeviceObject d : devices.getDevices()) { + Tester.log.info("Device: {}", d); + } + } + }); + + ep.start(); + + Tester.log.info("Version: {}", ep.version()); + + Tester.log.info("Watch: {}", ep.watch(true, true)); + + Tester.log.info("Poll: {}", ep.poll()); + + Thread.sleep(60000); + } catch (final Exception e) { + Tester.log.error("Problem encountered", e); + } + } } From 42673ed04a504873aa46c8f17acef5f10819a12d Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Mon, 10 Feb 2025 08:49:27 +0100 Subject: [PATCH 60/63] #44: add gnssid to SATObject --- .../gpsd4java/backend/ResultParser.java | 1 + .../de/taimos/gpsd4java/types/SATObject.java | 22 ++++++++++ .../gpsd4java/backend/ResultParserTest.java | 40 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java diff --git a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java index 620bd6e..243db38 100644 --- a/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java +++ b/src/main/java/de/taimos/gpsd4java/backend/ResultParser.java @@ -254,6 +254,7 @@ protected IGPSObject parsePRN(final JSONObject json) { sat.setElevation(json.optInt("el", -1)); sat.setSignalStrength(json.optInt("ss", -1)); sat.setUsed(json.optBoolean("used", false)); + sat.setGnssId(json.optInt("gnssid", -1)); gps = sat; return gps; } diff --git a/src/main/java/de/taimos/gpsd4java/types/SATObject.java b/src/main/java/de/taimos/gpsd4java/types/SATObject.java index 3c48c85..44ac15b 100644 --- a/src/main/java/de/taimos/gpsd4java/types/SATObject.java +++ b/src/main/java/de/taimos/gpsd4java/types/SATObject.java @@ -36,6 +36,8 @@ public class SATObject implements IGPSObject { private int signalStrength = -1; + private int gnssId = -1; + private boolean used = false; /** @@ -132,6 +134,24 @@ public void setUsed(final boolean used) { this.used = used; } + /** + * The GNSSID field of the satellite, if available. + * + * @return gnssId + */ + public int getGnssId() { + return gnssId; + } + + /** + * The GNSSID field of the satellite, if available. + * + * @param gnssId the GNSSID field to set + */ + public void setGnssId(final int gnssId) { + this.gnssId = gnssId; + } + @Override public int hashCode() { final int prime = 31; @@ -145,6 +165,8 @@ public int hashCode() { result = (prime * result) + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.signalStrength); result = (prime * result) + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.gnssId); + result = (prime * result) + (int) (temp ^ (temp >>> 32)); result = (prime * result) + ((this.used) ? 1 : 0); return result; } diff --git a/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java b/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java new file mode 100644 index 0000000..629b6af --- /dev/null +++ b/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java @@ -0,0 +1,40 @@ +package de.taimos.gpsd4java.backend; + +import de.taimos.gpsd4java.types.SATObject; +import org.json.JSONObject; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ResultParserTest { + + private ResultParser resultParser; + + @Before + public void before() { + this.resultParser = new ResultParser(); + } + + @Test + public void testSatObject() { + final JSONObject json = new JSONObject(); + json.put("PRN", 12); + json.put("gnssid", 44); + json.put("svid", 12); + json.put("az", 229); + json.put("el", 24); + json.put("prRes", 22.9); + json.put("qual", 1); + json.put("ss", 0); + json.put("used", false); + json.put("health", 1); + final SATObject satObject = (SATObject) this.resultParser.parsePRN(json); + Assert.assertEquals(12, satObject.getPRN()); + Assert.assertEquals(44, satObject.getGnssId()); + Assert.assertEquals(229, satObject.getAzimuth()); + Assert.assertEquals(24, satObject.getElevation()); + Assert.assertFalse(satObject.getUsed()); + Assert.assertEquals(0, satObject.getSignalStrength()); + } + +} From 4ed8a958acc7b04db89174969d7546b4777d25a9 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Mon, 10 Feb 2025 09:43:33 +0100 Subject: [PATCH 61/63] addition of github build workflow --- .github/workflows/maven.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/maven.yaml diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml new file mode 100644 index 0000000..0004020 --- /dev/null +++ b/.github/workflows/maven.yaml @@ -0,0 +1,36 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "**" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 + From ef347409ff1546f9e1ff83e108f2cdf0f0ee9134 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Tue, 11 Feb 2025 15:20:21 +0100 Subject: [PATCH 62/63] addition of pre-commit rules --- .gitignore | 1 + .pre-commit-config.yaml | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore index 8e99583..c98b361 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target gpsd4java.iml .idea +.cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..48d069e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +--- +repos: + - repo: https://github.com/0x08/google-style-precommit-hook + rev: 503fa7c491becee130be17a10b03b275ce6f2330 + hooks: + - id: google-style-java + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.0-alpha.0 + hooks: + - id: prettier + - repo: "https://github.com/adrienverge/yamllint" + rev: v1.27.1 + hooks: + - id: "yamllint" + args: [--strict] From 82f9f030a577c38b20fc98fceb5c73cccbff228b Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Tue, 11 Feb 2025 15:20:54 +0100 Subject: [PATCH 63/63] addition of extra unit tests for ResultParser --- .../gpsd4java/backend/ResultParserTest.java | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java b/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java index 629b6af..4bfb530 100644 --- a/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java +++ b/src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java @@ -1,6 +1,11 @@ package de.taimos.gpsd4java.backend; +import de.taimos.gpsd4java.types.ENMEAMode; import de.taimos.gpsd4java.types.SATObject; +import de.taimos.gpsd4java.types.SKYObject; +import de.taimos.gpsd4java.types.TPVObject; +import de.taimos.gpsd4java.types.subframes.IONOObject; +import org.json.JSONArray; import org.json.JSONObject; import org.junit.Assert; import org.junit.Before; @@ -37,4 +42,158 @@ public void testSatObject() { Assert.assertEquals(0, satObject.getSignalStrength()); } + @Test + public void testIonoObject() { + final JSONObject json = new JSONObject(); + json.put("a0", 1.0); + json.put("a1", 2.0); + json.put("a2", 3.0); + json.put("b0", 11.0); + json.put("b1", 12.0); + json.put("b2", 13.0); + json.put("b3", 14.0); + json.put("A0", 21.0); + json.put("A1", 22.0); + json.put("tot", 31.0); + json.put("WNt", 100); + json.put("ls", 101); + json.put("WNlsf", 102); + json.put("DN", 103); + json.put("lsf", 104); + final IONOObject ionoObject = (IONOObject) this.resultParser.parseIONO(json); + Assert.assertEquals(1.0, ionoObject.getAlpha0(), 0); + Assert.assertEquals(2.0, ionoObject.getAlpha1(), 0); + Assert.assertEquals(3.0, ionoObject.getAlpha2(), 0); + Assert.assertEquals(11.0, ionoObject.getBeta0(), 0); + Assert.assertEquals(12.0, ionoObject.getBeta1(), 0); + Assert.assertEquals(13.0, ionoObject.getBeta2(), 0); + Assert.assertEquals(14.0, ionoObject.getBeta3(), 0); + Assert.assertEquals(21.0, ionoObject.getA0(), 0); + Assert.assertEquals(22.0, ionoObject.getA1(), 0); + Assert.assertEquals(31.0, ionoObject.getTot(), 0); + Assert.assertEquals(100, ionoObject.getWNt()); + Assert.assertEquals(101, ionoObject.getLeap()); + Assert.assertEquals(102, ionoObject.getWNlsf()); + Assert.assertEquals(103, ionoObject.getDN()); + Assert.assertEquals(104, ionoObject.getLsf()); + } + + @Test + public void testSkyObject() throws Exception { + + final JSONObject json = new JSONObject(); + json.put("device", "/dev/ttyUSB0"); + json.put("time", "2025-02-11T08:39:29.000Z"); + json.put("gdop", 1.29); + json.put("hdop", 0.61); + json.put("pdop", 1.16); + json.put("tdop", 0.56); + json.put("xdop", 0.38); + json.put("ydop", 0.49); + json.put("vdop", 0.99); + json.put("nSat", 2); + + final JSONArray satellites = new JSONArray(); + json.put("satellites", satellites); + + final JSONObject sat1 = new JSONObject(); + sat1.put("PRN", 6); + sat1.put("gnssid", 0); + sat1.put("svid", 6); + sat1.put("az", 110.0); + sat1.put("el", 2.0); + sat1.put("prRes", 11.0); + sat1.put("qual", 1); + sat1.put("ss", 0.0); + sat1.put("used", false); + sat1.put("health", 1); + + final JSONObject sat2 = new JSONObject(); + sat2.put("PRN", 10); + sat2.put("gnssid", 0); + sat2.put("svid", 10); + sat2.put("az", 303.0); + sat2.put("el", 14.0); + sat2.put("prRes", 30.3); + sat2.put("qual", 7); + sat2.put("ss", 48.0); + sat2.put("used", true); + sat2.put("health", 1); + + satellites.put(sat1); + satellites.put(sat2); + + final SKYObject skyObject = (SKYObject) this.resultParser.parseSKY(json); + + Assert.assertEquals("/dev/ttyUSB0", skyObject.getDevice()); + Assert.assertEquals(1739263169.0, skyObject.getTimestamp(), 0.0); + Assert.assertEquals(1.29, skyObject.getHypersphericalDOP(), 0.0); + Assert.assertEquals(0.61, skyObject.getHorizontalDOP(), 0.0); + Assert.assertEquals(1.16, skyObject.getSphericalDOP(), 0.0); + Assert.assertEquals(0.56, skyObject.getTimestampDOP(), 0.0); + Assert.assertEquals(0.38, skyObject.getLongitudeDOP(), 0.0); + Assert.assertEquals(0.49, skyObject.getLatitudeDOP(), 0.0); + Assert.assertEquals(0.99, skyObject.getAltitudeDOP(), 0.0); + Assert.assertEquals(2, skyObject.getSatellites().size()); + + final SATObject satObject1 = skyObject.getSatellites().get(0); + Assert.assertEquals(6, satObject1.getPRN()); + Assert.assertEquals(0, satObject1.getGnssId()); + Assert.assertEquals(110.0, satObject1.getAzimuth(), 0.0); + Assert.assertEquals(2.0, satObject1.getElevation(), 0.0); + Assert.assertEquals(0.0, satObject1.getSignalStrength(), 0.0); + Assert.assertFalse(satObject1.getUsed()); + + final SATObject satObject2 = skyObject.getSatellites().get(1); + Assert.assertEquals(10, satObject2.getPRN()); + Assert.assertEquals(0, satObject2.getGnssId()); + Assert.assertEquals(303.0, satObject2.getAzimuth(), 0.0); + Assert.assertEquals(14.0, satObject2.getElevation(), 0.0); + Assert.assertEquals(48.0, satObject2.getSignalStrength(), 0.0); + Assert.assertTrue(satObject2.getUsed()); + } + + @Test + public void testTpvObject() { + + final JSONObject json = new JSONObject(); + json.put("tag", "tag"); + json.put("alt", 136.054); + json.put("epv", 0.835); + json.put("device", "/dev/ttyUSB0"); + json.put("time", "2025-02-11T08:39:29.000Z"); + json.put("ept", 0.005); + json.put("lat", 42.7045841); + json.put("lon", 12.1588884); + json.put("alt", 136.054); + json.put("epx", 1.411); + json.put("epy", 1.822); + json.put("epv", 0.835); + json.put("track", 144.6175); + json.put("speed", 22.693); + json.put("climb", 0.023); + json.put("epd", 9.1852); + json.put("eps", 3.51); + json.put("epc", 1.68); + json.put("mode", 3); + + final TPVObject tpvObject = (TPVObject) this.resultParser.parseTPV(json); + Assert.assertEquals(136.054, tpvObject.getAltitude(), 0); + Assert.assertEquals(0.835, tpvObject.getAltitudeError(), 0); + Assert.assertEquals(0.023, tpvObject.getClimbRate(), 0); + Assert.assertEquals(1.68, tpvObject.getClimbRateError(), 0); + Assert.assertEquals(144.6175, tpvObject.getCourse(), 0); + Assert.assertEquals(9.1852, tpvObject.getCourseError(), 0); + Assert.assertEquals("/dev/ttyUSB0", tpvObject.getDevice()); + Assert.assertEquals(42.7045841, tpvObject.getLatitude(), 0); + Assert.assertEquals(1.822, tpvObject.getLatitudeError(), 0); + Assert.assertEquals(12.1588884, tpvObject.getLongitude(), 0); + Assert.assertEquals(1.411, tpvObject.getLongitudeError(), 0); + Assert.assertEquals(ENMEAMode.ThreeDimensional, tpvObject.getMode()); + Assert.assertEquals(22.693, tpvObject.getSpeed(), 0); + Assert.assertEquals(3.51, tpvObject.getSpeedError(), 0); + Assert.assertEquals("tag", tpvObject.getTag()); + Assert.assertEquals(1739263169.0, tpvObject.getTimestamp(), 0); + Assert.assertEquals(0.005, tpvObject.getTimestampError(), 0); + } }