├── .github └── workflows │ └── maven.yaml ├── .gitignore ├── .gitpod.yml ├── .pre-commit-config.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── README.md ├── pom.xml └── src ├── main └── java │ └── de │ └── taimos │ └── gpsd4java │ ├── api │ ├── DistanceListener.java │ ├── IObjectListener.java │ └── ObjectListener.java │ ├── backend │ ├── AbstractResultParser.java │ ├── GISTool.java │ ├── GPSdEndpoint.java │ ├── LegacyResultParser.java │ ├── ResultParser.java │ ├── SocketThread.java │ └── WaitableBoolean.java │ └── types │ ├── ATTObject.java │ ├── DeviceObject.java │ ├── DevicesObject.java │ ├── ENMEAMode.java │ ├── EParity.java │ ├── GSTObject.java │ ├── IGPSObject.java │ ├── ParseException.java │ ├── PollObject.java │ ├── PpsObject.java │ ├── SATObject.java │ ├── SKYObject.java │ ├── TPVObject.java │ ├── ToffObject.java │ ├── VersionObject.java │ ├── WatchObject.java │ └── subframes │ ├── ALMANACObject.java │ ├── EPHEM1Object.java │ ├── EPHEM2Object.java │ ├── EPHEM3Object.java │ ├── ERDObject.java │ ├── HEALTH2Object.java │ ├── HEALTHObject.java │ ├── IONOObject.java │ └── SUBFRAMEObject.java └── test └── java └── de └── taimos └── gpsd4java ├── backend └── ResultParserTest.java └── test └── Tester.java /.github/workflows/maven.yaml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: Java CI with Maven 10 | 11 | on: 12 | push: 13 | branches: [ "**" ] 14 | pull_request: 15 | branches: [ "**" ] 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 17 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: '17' 28 | distribution: 'temurin' 29 | cache: maven 30 | - name: Build with Maven 31 | run: mvn -B package --file pom.xml 32 | 33 | # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive 34 | - name: Update dependency graph 35 | uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 36 | 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | gpsd4java.iml 3 | .idea 4 | .cache 5 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | 2 | tasks: 3 | - init: mvn install -DskipTests=false 4 | 5 | 6 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | - repo: https://github.com/0x08/google-style-precommit-hook 4 | rev: 503fa7c491becee130be17a10b03b275ce6f2330 5 | hooks: 6 | - id: google-style-java 7 | - repo: https://github.com/pre-commit/mirrors-prettier 8 | rev: v3.0.0-alpha.0 9 | hooks: 10 | - id: prettier 11 | - repo: "https://github.com/adrienverge/yamllint" 12 | rev: v1.27.1 13 | hooks: 14 | - id: "yamllint" 15 | args: [--strict] 16 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | 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. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | 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. 28 | 29 | 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. 30 | 31 | ## Scope 32 | 33 | 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. 34 | 35 | ## Enforcement 36 | 37 | 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. 38 | 39 | 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. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.taimos/gpsd4java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.taimos/gpsd4java) 2 | 3 | About GPSd4Java 4 | =============== 5 | 6 | GPSd4Java is a library to use data from the GPSd daemon in your Java applications. 7 | It provides a library to connect to gpsd and retrieve data using a socket connection. 8 | 9 | Use GPSd4Java 10 | ============= 11 | 12 | You can use GPSd4Java with a Maven project. Just add the following lines to your pom.xml. 13 | 14 | 15 | 16 | de.taimos 17 | gpsd4java 18 | $VERSION 19 | 20 | 21 | 22 | 23 | Getting Started 24 | =============== 25 | 26 | The main entrypoint to use GPSd4Java is the class `GPSdEndpoint`. 27 | You can create a new instance by providing the host and port of the gpsd daemon. 28 | Further you have to provide a `ResultParser` instance which parses all messages sent by the GPS device. 29 | 30 | On the created endpoint you can then add listeners to handle incoming messages. 31 | This listener will receive the message on the appropriate method according to the message type. 32 | The most interesting messages are the `TPVObjects` as they contain the positional information provided by the GPS device. 33 | 34 | To get the position you just have to call the `getLatitude()` and `getLongitude()` methods on the received `TPVObject`. 35 | 36 | If all is set you activate the endpoint using the `start()` method. 37 | 38 | If this succeeds you can either poll gpsd for new messages or you can enable the watch mode to receive new data on arrival. 39 | 40 | ## Polling data 41 | 42 | To poll single messages call the `poll()` method on the endpoint instance 43 | 44 | ## Activating watch mode 45 | 46 | To get all new messages call the `watch(boolean, boolean)` method. 47 | The first param defines if you want enable or disable the watch mode and the second defines if you want to receive messega details. 48 | So the default use case would be to call `watch(true, true)`. 49 | 50 | You should now receive incoming messages in your provided listener implementation. 51 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | de.taimos 6 | oss-parent 7 | 5 8 | 9 | gpsd4java 10 | 1.11-SNAPSHOT 11 | bundle 12 | GPSd4Java 13 | Java Client library for GPSd deamon 14 | 15 | 3.0.0 16 | 17 | 18 | http://taimos.github.com/GPSd4Java/ 19 | 2011 20 | 21 | 22 | 23 | Irakli Betchvaia 24 | 25 | 26 | Andrew Evdokimov 27 | 28 | 29 | Frank Kusters 30 | 31 | 32 | Michael Erskine 33 | 34 | 35 | Tim Williscroft 36 | 37 | 38 | Martin Nordqvist 39 | 40 | 41 | Ben Turner 42 | 43 | 44 | 45 | 46 | 47 | org.json 48 | json 49 | 20250107 50 | 51 | 52 | org.slf4j 53 | slf4j-api 54 | 2.0.16 55 | 56 | 57 | junit 58 | junit 59 | 4.13.2 60 | test 61 | 62 | 63 | ch.qos.logback 64 | logback-classic 65 | 1.5.16 66 | test 67 | 68 | 69 | 70 | 71 | scm:git:git@github.com:taimos/GPSd4Java.git 72 | scm:git:git@github.com:taimos/GPSd4Java.git 73 | git@github.com:taimos/GPSd4Java.git 74 | HEAD 75 | 76 | 77 | 78 | 79 | 80 | 81 | maven-compiler-plugin 82 | 3.6.0 83 | 84 | 85 | 86 | 87 | 88 | 89 | org.apache.maven.plugins 90 | maven-compiler-plugin 91 | 92 | 11 93 | 11 94 | true 95 | 96 | 97 | 98 | maven-jar-plugin 99 | 3.0.2 100 | 101 | 102 | 103 | true 104 | 105 | true 106 | 107 | 108 | 109 | 110 | 111 | org.apache.felix 112 | maven-bundle-plugin 113 | 5.1.8 114 | true 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/api/DistanceListener.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.api; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.backend.GISTool; 24 | import de.taimos.gpsd4java.types.TPVObject; 25 | 26 | /** 27 | * Derive this class to implement a listener for location updates which reacts to changes greater a 28 | * given threshold 29 | * 30 | * @author thoeger 31 | */ 32 | public abstract class DistanceListener extends ObjectListener { 33 | 34 | private TPVObject lastPosition; 35 | 36 | private final double threshold; 37 | 38 | /** 39 | * @param threshold the threshold to fire in kilometers 40 | */ 41 | public DistanceListener(final double threshold) { 42 | this.threshold = threshold; 43 | } 44 | 45 | @Override 46 | public void handleTPV(final TPVObject tpv) { 47 | if ((this.lastPosition == null) 48 | || (GISTool.getDistance(tpv, this.lastPosition) > this.threshold)) { 49 | this.lastPosition = tpv; 50 | this.handleLocation(tpv); 51 | } 52 | } 53 | 54 | protected abstract void handleLocation(TPVObject tpv); 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/api/IObjectListener.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.api; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.ATTObject; 24 | import de.taimos.gpsd4java.types.DeviceObject; 25 | import de.taimos.gpsd4java.types.DevicesObject; 26 | import de.taimos.gpsd4java.types.SKYObject; 27 | import de.taimos.gpsd4java.types.TPVObject; 28 | import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; 29 | 30 | /** 31 | * Listener to receive response objects 32 | * 33 | * @author thoeger 34 | */ 35 | public interface IObjectListener { 36 | 37 | /** 38 | * @param tpv the TPV object 39 | */ 40 | void handleTPV(TPVObject tpv); 41 | 42 | /** 43 | * @param sky the SKY object 44 | */ 45 | void handleSKY(SKYObject sky); 46 | 47 | /** 48 | * @param att the ATT object 49 | */ 50 | void handleATT(ATTObject att); 51 | 52 | /** 53 | * @param subframe the SUBFRAME object 54 | */ 55 | void handleSUBFRAME(SUBFRAMEObject subframe); 56 | 57 | /** 58 | * @param devices the devices object 59 | */ 60 | void handleDevices(DevicesObject devices); 61 | 62 | /** 63 | * @param device the device object 64 | */ 65 | void handleDevice(DeviceObject device); 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/api/ObjectListener.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.api; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.ATTObject; 24 | import de.taimos.gpsd4java.types.DeviceObject; 25 | import de.taimos.gpsd4java.types.DevicesObject; 26 | import de.taimos.gpsd4java.types.SKYObject; 27 | import de.taimos.gpsd4java.types.TPVObject; 28 | import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; 29 | 30 | /** 31 | * Adapter class for {@link IObjectListener} 32 | * 33 | * @author thoeger 34 | */ 35 | public class ObjectListener implements IObjectListener { 36 | 37 | @Override 38 | public void handleTPV(final TPVObject tpv) { 39 | // implement in subclass if needed 40 | } 41 | 42 | @Override 43 | public void handleSKY(final SKYObject sky) { 44 | // implement in subclass if needed 45 | } 46 | 47 | @Override 48 | public void handleATT(final ATTObject att) { 49 | // implement in subclass if needed 50 | } 51 | 52 | @Override 53 | public void handleSUBFRAME(final SUBFRAMEObject subframe) { 54 | // implement in subclass if needed 55 | } 56 | 57 | @Override 58 | public void handleDevices(final DevicesObject devices) { 59 | // implement in subclass if needed 60 | } 61 | 62 | @Override 63 | public void handleDevice(final DeviceObject device) { 64 | // implement in subclass if needed 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/backend/AbstractResultParser.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | import de.taimos.gpsd4java.types.ParseException; 25 | import java.text.DateFormat; 26 | import java.text.SimpleDateFormat; 27 | import java.util.ArrayList; 28 | import java.util.Date; 29 | import java.util.List; 30 | import java.util.TimeZone; 31 | import org.json.JSONArray; 32 | import org.json.JSONException; 33 | import org.json.JSONObject; 34 | import org.slf4j.Logger; 35 | import org.slf4j.LoggerFactory; 36 | 37 | /** 38 | * @author irakli, thoeger 39 | */ 40 | public abstract class AbstractResultParser { 41 | 42 | protected static final Logger LOG = LoggerFactory.getLogger(ResultParser.class); 43 | 44 | protected final DateFormat dateFormat; // Don't make this static! 45 | 46 | /** Create new ResultParser */ 47 | public AbstractResultParser() { 48 | this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 49 | this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); 50 | } 51 | 52 | /** 53 | * Parse a received line into a {@link IGPSObject} 54 | * 55 | * @param line the line read from GPSd 56 | * @return the parsed object 57 | * @throws ParseException if parsing fails 58 | */ 59 | public IGPSObject parse(final String line) throws ParseException { 60 | try { 61 | final JSONObject json = new JSONObject(line); 62 | return this.parse(json); 63 | } catch (final JSONException e) { 64 | throw new ParseException("Parsing failed", e); 65 | } 66 | } 67 | 68 | /** 69 | * @param json 70 | * @return the parsed {@link IGPSObject} 71 | * @throws ParseException 72 | */ 73 | public abstract IGPSObject parse(final JSONObject json) throws ParseException; 74 | 75 | /** parse a whole JSONArray into a list of IGPSObjects */ 76 | @SuppressWarnings({"unchecked", "unused"}) 77 | protected List parseObjectArray( 78 | final JSONArray array, final Class type) throws ParseException { 79 | try { 80 | if (array == null) { 81 | return new ArrayList(10); 82 | } 83 | final List objects = new ArrayList(10); 84 | for (int i = 0; i < array.length(); i++) { 85 | objects.add((T) this.parse(array.getJSONObject(i))); 86 | } 87 | return objects; 88 | } catch (final JSONException e) { 89 | throw new ParseException("Parsing failed", e); 90 | } 91 | } 92 | 93 | protected double parseTimestamp(final JSONObject json, final String fieldName) { 94 | try { 95 | final String text = json.optString(fieldName, null); 96 | AbstractResultParser.LOG.debug(fieldName + ": {}", text); 97 | 98 | if (text != null) { 99 | final Date date = this.dateFormat.parse(text); 100 | if (AbstractResultParser.LOG.isDebugEnabled()) { 101 | final String ds = 102 | DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date); 103 | AbstractResultParser.LOG.debug("Date: {}", ds); 104 | } 105 | return date.getTime() / 1000.0; 106 | } 107 | } catch (final Exception ex) { 108 | // trying to parse field as double 109 | double d = json.optDouble(fieldName, Double.NaN); 110 | if (d != Double.NaN) { 111 | return d; 112 | } 113 | AbstractResultParser.LOG.info("Failed to parse time", ex); 114 | } 115 | return Double.NaN; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/backend/GISTool.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.TPVObject; 24 | 25 | /** 26 | * This class provides tools to measure the distance between two locations in WGS84 coordinates 27 | * 28 | * @author thoeger 29 | */ 30 | public final class GISTool { 31 | 32 | private static final int EARTH_RADIUS_KILOMETERS = 6371; 33 | 34 | private GISTool() { 35 | // 36 | } 37 | 38 | /** 39 | * calculates the distance between two {@link TPVObject} in kilometers
40 | * the method used is the great-circle-distance with hypersine formula 41 | * 42 | * @param tpv1 - position 1 43 | * @param tpv2 - position 2 44 | * @return distance in kilometers 45 | */ 46 | public static double getDistance(final TPVObject tpv1, final TPVObject tpv2) { 47 | return GISTool.getDistance( 48 | tpv1.getLongitude(), tpv2.getLongitude(), tpv1.getLatitude(), tpv2.getLatitude()); 49 | } 50 | 51 | /** 52 | * calculates the distance between two locations, which are given as coordinates, in kilometers 53 | *
54 | * the method used is the great-circle-distance with hypersine formula 55 | * 56 | * @param x1 - longitude of position 1 57 | * @param x2 - longitude of position 2 58 | * @param y1 - latitude of position 1 59 | * @param y2 - latitude of position 2 60 | * @return distance in kilometers 61 | */ 62 | public static double getDistance( 63 | final double x1, final double x2, final double y1, final double y2) { 64 | // transform to radian 65 | final double deg2rad = Math.PI / 180; 66 | 67 | final double x1rad = x1 * deg2rad; 68 | final double x2rad = x2 * deg2rad; 69 | final double y1rad = y1 * deg2rad; 70 | final double y2rad = y2 * deg2rad; 71 | 72 | // great-circle-distance with hypersine formula 73 | final double dlong = x1rad - x2rad; 74 | final double dlat = y1rad - y2rad; 75 | final double a = 76 | Math.pow(Math.sin(dlat / 2), 2) 77 | + (Math.cos(y1rad) * Math.cos(y2rad) * Math.pow(Math.sin(dlong / 2), 2)); 78 | final double c = 2 * Math.asin(Math.sqrt(a)); 79 | 80 | return GISTool.EARTH_RADIUS_KILOMETERS * c; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.api.IObjectListener; 24 | import de.taimos.gpsd4java.types.ATTObject; 25 | import de.taimos.gpsd4java.types.DeviceObject; 26 | import de.taimos.gpsd4java.types.DevicesObject; 27 | import de.taimos.gpsd4java.types.IGPSObject; 28 | import de.taimos.gpsd4java.types.PollObject; 29 | import de.taimos.gpsd4java.types.SKYObject; 30 | import de.taimos.gpsd4java.types.TPVObject; 31 | import de.taimos.gpsd4java.types.VersionObject; 32 | import de.taimos.gpsd4java.types.WatchObject; 33 | import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; 34 | import java.io.BufferedReader; 35 | import java.io.BufferedWriter; 36 | import java.io.IOException; 37 | import java.io.InputStreamReader; 38 | import java.io.OutputStreamWriter; 39 | import java.net.Socket; 40 | import java.net.UnknownHostException; 41 | import java.util.ArrayList; 42 | import java.util.List; 43 | import java.util.concurrent.atomic.AtomicLong; 44 | import org.json.JSONException; 45 | import org.json.JSONObject; 46 | import org.slf4j.Logger; 47 | import org.slf4j.LoggerFactory; 48 | 49 | /** 50 | * GPSd client endpoint 51 | * 52 | * @author thoeger 53 | */ 54 | public class GPSdEndpoint { 55 | 56 | private static final Logger LOG = LoggerFactory.getLogger(GPSdEndpoint.class); 57 | 58 | private Socket socket; 59 | 60 | private BufferedReader in; 61 | 62 | private BufferedWriter out; 63 | 64 | private SocketThread listenThread; 65 | 66 | private final boolean daemon; 67 | 68 | private final List listeners = new ArrayList(1); 69 | 70 | private IGPSObject asyncResult = null; 71 | 72 | private final Object asyncMutex = new Object(); 73 | 74 | private final Object asyncWaitMutex = new Object(); 75 | 76 | private final AbstractResultParser resultParser; 77 | 78 | private String server; 79 | 80 | private int port; 81 | 82 | private String lastWatch; 83 | 84 | private AtomicLong retryInterval = new AtomicLong(1000); 85 | 86 | /** 87 | * Instantiate this class to connect to a GPSd server 88 | * 89 | * @param server the server name or IP 90 | * @param port the server port 91 | * @param resultParser the result parser 92 | * @param daemon whether to start the underlying socket thread as a daemon, as defined in {@link 93 | * Thread#setDaemon} 94 | */ 95 | public GPSdEndpoint( 96 | final String server, 97 | final int port, 98 | final AbstractResultParser resultParser, 99 | final boolean daemon) { 100 | this.server = server; 101 | this.port = port; 102 | if (server == null) { 103 | throw new IllegalArgumentException("server can not be null!"); 104 | } 105 | if ((port < 0) || (port > 65535)) { 106 | throw new IllegalArgumentException("Illegal port number: " + port); 107 | } 108 | if (resultParser == null) { 109 | throw new IllegalArgumentException("resultParser can not be null!"); 110 | } 111 | 112 | this.resultParser = resultParser; 113 | 114 | this.daemon = daemon; 115 | } 116 | 117 | /** 118 | * Instantiate this class to connect to a GPSd server 119 | * 120 | * @param server the server name or IP 121 | * @param port the server port 122 | * @param resultParser the result parser 123 | * @throws UnknownHostException 124 | * @throws IOException 125 | */ 126 | public GPSdEndpoint(final String server, final int port, final AbstractResultParser resultParser) 127 | throws UnknownHostException, IOException { 128 | this(server, port, resultParser, true); 129 | } 130 | 131 | /** 132 | * Instantiate this class to connect to a GPSd server and use default parser 133 | * 134 | * @param server the server name or IP 135 | * @param port the server port 136 | */ 137 | public GPSdEndpoint(final String server, final int port) { 138 | this(server, port, new ResultParser(), true); 139 | } 140 | 141 | /** start the endpoint */ 142 | public void start() { 143 | this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); 144 | this.listenThread.start(); 145 | } 146 | 147 | /** Stops the endpoint. */ 148 | public void stop() { 149 | 150 | try { 151 | if (this.socket != null) { 152 | this.socket.close(); 153 | } 154 | } catch (final IOException e1) { 155 | GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage()); 156 | } 157 | 158 | this.listeners.clear(); 159 | 160 | if (this.listenThread != null) { 161 | this.listenThread.halt(); 162 | } 163 | 164 | this.listenThread = null; 165 | } 166 | 167 | /** 168 | * send WATCH command 169 | * 170 | * @param enable enable/disable watch mode 171 | * @param dumpData enable/disable dumping of data 172 | * @return {@link WatchObject} 173 | * @throws IOException on IO error in socket 174 | * @throws JSONException 175 | */ 176 | public WatchObject watch(final boolean enable, final boolean dumpData) 177 | throws IOException, JSONException { 178 | return this.watch(enable, dumpData, null); 179 | } 180 | 181 | /** 182 | * send WATCH command 183 | * 184 | * @param enable enable/disable watch mode 185 | * @param dumpData enable/disable dumping of data 186 | * @param device If present, enable watching only of the specified device rather than all devices 187 | * @return {@link WatchObject} 188 | * @throws IOException on IO error in socket 189 | * @throws JSONException 190 | */ 191 | public WatchObject watch(final boolean enable, final boolean dumpData, final String device) 192 | throws IOException, JSONException { 193 | JSONObject watch = new JSONObject(); 194 | watch.put("class", "WATCH"); 195 | watch.put("enable", enable); 196 | watch.put("json", dumpData); 197 | if (device != null) { 198 | watch.put("device", device); 199 | } 200 | return this.syncCommand("?WATCH=" + watch.toString(), WatchObject.class); 201 | } 202 | 203 | /** 204 | * Poll GPSd for Message 205 | * 206 | * @return {@link PollObject} 207 | * @throws IOException on IO error in socket 208 | */ 209 | public PollObject poll() throws IOException { 210 | return this.syncCommand("?POLL;", PollObject.class); 211 | } 212 | 213 | /** 214 | * Poll GPSd version 215 | * 216 | * @return {@link VersionObject} 217 | * @throws IOException on IO error in socket 218 | */ 219 | public VersionObject version() throws IOException { 220 | return this.syncCommand("?VERSION;", VersionObject.class); 221 | } 222 | 223 | // TODO implement rest of commands 224 | // ######################################################## 225 | 226 | /** 227 | * @param listener the listener to add 228 | */ 229 | public void addListener(final IObjectListener listener) { 230 | this.listeners.add(listener); 231 | } 232 | 233 | /** 234 | * @param listener the listener to remove 235 | */ 236 | public void removeListener(final IObjectListener listener) { 237 | this.listeners.remove(listener); 238 | } 239 | 240 | // ######################################################## 241 | 242 | /* 243 | * send command to GPSd and wait for response 244 | */ 245 | private T syncCommand(final String command, final Class responseClass) 246 | throws IOException { 247 | synchronized (this.asyncMutex) { 248 | if (out != null) { 249 | this.out.write(command + "\n"); 250 | this.out.flush(); 251 | } 252 | if (responseClass == WatchObject.class) { 253 | lastWatch = command; 254 | } 255 | while (true) { 256 | // wait for awaited message 257 | // FIXME possible infinite loop if expected result arrives but new result overrides expected 258 | // result before getting to this point. 259 | final IGPSObject result = this.waitForResult(); 260 | if ((result == null) || result.getClass().equals(responseClass)) { 261 | return responseClass.cast(result); 262 | } 263 | } 264 | } 265 | } 266 | 267 | /* 268 | * send command without response 269 | */ 270 | private void voidCommand(final String command) throws IOException { 271 | synchronized (this.asyncMutex) { 272 | this.out.write(command + "\n"); 273 | this.out.flush(); 274 | } 275 | } 276 | 277 | /* 278 | * wait for a response for one second 279 | */ 280 | private IGPSObject waitForResult() { 281 | synchronized (this.asyncWaitMutex) { 282 | if (this.asyncResult == null) { 283 | try { 284 | this.asyncWaitMutex.wait(1000); 285 | } catch (final InterruptedException e) { 286 | GPSdEndpoint.LOG.info("Interrupted while waiting for result", e); 287 | } 288 | } 289 | final IGPSObject result = this.asyncResult; 290 | this.asyncResult = null; 291 | return result; 292 | } 293 | } 294 | 295 | /* 296 | * handle incoming messages and dispatch them 297 | */ 298 | void handle(final IGPSObject object) { 299 | if (object instanceof TPVObject) { 300 | for (final IObjectListener l : this.listeners) { 301 | l.handleTPV((TPVObject) object); 302 | } 303 | } else if (object instanceof SKYObject) { 304 | for (final IObjectListener l : this.listeners) { 305 | l.handleSKY((SKYObject) object); 306 | } 307 | } else if (object instanceof ATTObject) { 308 | for (final IObjectListener l : this.listeners) { 309 | l.handleATT((ATTObject) object); 310 | } 311 | } else if (object instanceof SUBFRAMEObject) { 312 | for (final IObjectListener l : this.listeners) { 313 | l.handleSUBFRAME((SUBFRAMEObject) object); 314 | } 315 | } else if (object instanceof DevicesObject) { 316 | for (final IObjectListener l : this.listeners) { 317 | l.handleDevices((DevicesObject) object); 318 | } 319 | } else if (object instanceof DeviceObject) { 320 | for (final IObjectListener l : this.listeners) { 321 | l.handleDevice((DeviceObject) object); 322 | } 323 | } else { 324 | // object was requested, so put it in the response object 325 | synchronized (this.asyncWaitMutex) { 326 | this.asyncResult = object; 327 | this.asyncWaitMutex.notifyAll(); 328 | } 329 | } 330 | } 331 | 332 | /** 333 | * Attempt to kick a failed device back into life on gpsd server. 334 | * 335 | *

see: https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html 336 | * 337 | * @param path Path of device known to gpsd 338 | * @throws IOException 339 | * @throws JSONException 340 | */ 341 | public void kickDevice(String path) throws IOException, JSONException { 342 | final JSONObject d = new JSONObject(); 343 | d.put("class", "DEVICE"); 344 | d.put("path", path); 345 | this.voidCommand("?DEVICE=" + d); 346 | } 347 | 348 | /** Our socket thread got disconnect and is exiting. */ 349 | void handleDisconnected() throws IOException { 350 | synchronized (this.asyncMutex) { 351 | if (socket != null) { 352 | socket.close(); 353 | } 354 | this.socket = new Socket(server, port); 355 | this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); 356 | this.out = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); 357 | 358 | this.listenThread = new SocketThread(this.in, this, this.resultParser, this.daemon); 359 | this.listenThread.start(); 360 | if (lastWatch != null) { // restore watch if we had one. 361 | this.syncCommand(lastWatch, WatchObject.class); 362 | } 363 | } 364 | } 365 | 366 | /** 367 | * Set a retry interval for reconnecting to GPSD if the socket closes. Default value is 1000ms. 368 | * 369 | * @param millis how long to wait between each reconnection attempts. 370 | */ 371 | public void setRetryInterval(long millis) { 372 | retryInterval.set(millis); 373 | } 374 | 375 | /** 376 | * Returns the retry interval for reconnecting to GPSD if the socket closes. Default value is 377 | * 1000ms. 378 | * 379 | * @return retry interval 380 | */ 381 | public long getRetryInterval() { 382 | return retryInterval.get(); 383 | } 384 | } 385 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/backend/LegacyResultParser.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | import de.taimos.gpsd4java.types.ParseException; 25 | import de.taimos.gpsd4java.types.PollObject; 26 | import de.taimos.gpsd4java.types.SKYObject; 27 | import de.taimos.gpsd4java.types.TPVObject; 28 | import org.json.JSONObject; 29 | 30 | /** 31 | * This class is used to parse responses from GPSd
32 | * 33 | * @deprecated use ResultParser; it handles old fields correctly 34 | * @author thoeger 35 | */ 36 | @Deprecated 37 | public class LegacyResultParser extends ResultParser { 38 | 39 | @Override 40 | protected IGPSObject parsePOLL(final JSONObject json) throws ParseException { 41 | IGPSObject gps; 42 | // check this for gpsd version <= 3.5 43 | final PollObject poll = new PollObject(); 44 | poll.setTimestamp(this.parseTimestamp(json, "time")); 45 | poll.setActive(json.optInt("active", 0)); 46 | poll.setFixes(this.parseObjectArray(json.optJSONArray("fixes"), TPVObject.class)); 47 | poll.setSkyviews(this.parseObjectArray(json.optJSONArray("skyviews"), SKYObject.class)); 48 | gps = poll; 49 | return gps; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/backend/SocketThread.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.BufferedReader; 24 | import java.io.IOException; 25 | import java.net.SocketException; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * thread reading input from GPSd server 31 | * 32 | * @author thoeger 33 | */ 34 | public class SocketThread extends Thread { 35 | 36 | private static final Logger LOG = LoggerFactory.getLogger(SocketThread.class); 37 | 38 | private final BufferedReader reader; 39 | 40 | private final GPSdEndpoint endpoint; 41 | 42 | private final AbstractResultParser resultParser; 43 | 44 | private final WaitableBoolean running = new WaitableBoolean(true); 45 | 46 | /** 47 | * @param reader the socket input 48 | * @param endpoint the endpoint 49 | * @param resultParser the result parser 50 | * @param daemon whether to configure the thread as a daemon, as defined in {@link 51 | * Thread#setDaemon} 52 | */ 53 | public SocketThread( 54 | final BufferedReader reader, 55 | final GPSdEndpoint endpoint, 56 | final AbstractResultParser resultParser, 57 | final boolean daemon) { 58 | 59 | if (resultParser == null) { 60 | throw new IllegalArgumentException("resultParser can not be null!"); 61 | } 62 | 63 | this.reader = reader; 64 | this.endpoint = endpoint; 65 | this.resultParser = resultParser; 66 | 67 | this.setDaemon(daemon); 68 | this.setName("GPS Socket Thread"); 69 | } 70 | 71 | /** 72 | * @param reader the socket input 73 | * @param endpoint the endpoint 74 | * @param resultParser the result parser 75 | */ 76 | public SocketThread( 77 | final BufferedReader reader, 78 | final GPSdEndpoint endpoint, 79 | final AbstractResultParser resultParser) { 80 | this(reader, endpoint, resultParser, true); 81 | } 82 | 83 | @Override 84 | public void run() { 85 | if (this.reader != null) { 86 | while (this.running.get()) { 87 | try { 88 | // read line from socket 89 | final String s = this.reader.readLine(); 90 | if (s == null) { 91 | break; 92 | } 93 | if (!s.isEmpty()) { 94 | // parse line and handle it accordingly 95 | this.endpoint.handle(this.resultParser.parse(s)); 96 | } 97 | } catch (final SocketException e) { 98 | break; // stop 99 | } catch (final Exception e) { 100 | // TODO handle this better 101 | SocketThread.LOG.warn("Problem encountered while reading/parsing/handling line", e); 102 | } 103 | } 104 | } 105 | if (this.running.get() && !Thread.interrupted()) { 106 | if (this.reader != null) { 107 | SocketThread.LOG.warn( 108 | "Problem encountered while reading/parsing/handling line, attempting restart"); 109 | } 110 | retry(); 111 | } 112 | } 113 | 114 | protected void retry() { 115 | if (this.reader != null) { 116 | SocketThread.LOG.debug("Disconnected from GPS socket, retrying connection"); 117 | } else { 118 | SocketThread.LOG.debug("Connecting to GPSD socket"); 119 | } 120 | 121 | while (this.running.get()) { 122 | try { 123 | this.running.waitFor(this.endpoint.getRetryInterval()); 124 | this.endpoint.handleDisconnected(); 125 | SocketThread.LOG.debug("Connected to GPS socket"); 126 | this.running.set(false); 127 | } catch (InterruptedException ix) { 128 | break; 129 | } catch (IOException e) { 130 | SocketThread.LOG.debug("Still disconnected from GPS socket, retrying connection again"); 131 | } 132 | } 133 | } 134 | 135 | /** Halts the socket thread. */ 136 | public void halt() { 137 | this.running.set(false); 138 | 139 | if (this.reader != null) { 140 | try { 141 | this.reader.close(); 142 | } catch (final IOException e) { 143 | // ignore 144 | } 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/backend/WaitableBoolean.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | /** 4 | * Not as efficient as AtomicBoolean but you can wait on it. 5 | * 6 | * @author TimW 7 | */ 8 | class WaitableBoolean { 9 | 10 | private boolean val; 11 | 12 | public WaitableBoolean(boolean b) { 13 | this.val = b; 14 | } 15 | 16 | synchronized void set(boolean value) { 17 | this.val = value; 18 | notifyAll(); 19 | } 20 | 21 | synchronized boolean get() { 22 | return this.val; 23 | } 24 | 25 | public synchronized void waitFor(long millis) throws InterruptedException { 26 | super.wait(millis); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/ATTObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * An ATT object is a vehicle-attitude report. It is returned by digital-compass and gyroscope 25 | * sensors; depending on device, it may include: heading, pitch, roll, yaw, gyroscope, and 26 | * magnetic-field readings. Because such sensors are often bundled as part of marine-navigation 27 | * systems, the ATT response may also include water depth.
28 | *
29 | * 30 | *

all getters for double values may return Double.NaN if value is not present
31 | * other getters may return null 32 | * 33 | * @author thoeger 34 | */ 35 | public class ATTObject implements IGPSObject { 36 | 37 | /** the GPSd internal name */ 38 | public static final String NAME = "ATT"; 39 | 40 | private String tag = null; 41 | 42 | private String device = null; 43 | 44 | private double timestamp = Double.NaN; 45 | 46 | private double heading = Double.NaN; 47 | 48 | private double pitch = Double.NaN; 49 | 50 | private double yaw = Double.NaN; 51 | 52 | private double roll = Double.NaN; 53 | 54 | private double dip = Double.NaN; 55 | 56 | private double mag_len = Double.NaN; 57 | 58 | private double mag_x = Double.NaN; 59 | 60 | private double mag_y = Double.NaN; 61 | 62 | private double mag_z = Double.NaN; 63 | 64 | private double acc_len = Double.NaN; 65 | 66 | private double acc_x = Double.NaN; 67 | 68 | private double acc_y = Double.NaN; 69 | 70 | private double acc_z = Double.NaN; 71 | 72 | private double gyro_x = Double.NaN; 73 | 74 | private double gyro_y = Double.NaN; 75 | 76 | private double depth = Double.NaN; 77 | 78 | private double temperature = Double.NaN; 79 | 80 | private String magState = null; 81 | 82 | private String pitchState = null; 83 | 84 | private String yawState = null; 85 | 86 | private String rollState = null; 87 | 88 | /** 89 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 90 | * type. 91 | * 92 | * @return the tag 93 | */ 94 | public String getTag() { 95 | return this.tag; 96 | } 97 | 98 | /** 99 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 100 | * type. 101 | * 102 | * @param tag the tag to set 103 | */ 104 | public void setTag(final String tag) { 105 | this.tag = tag; 106 | } 107 | 108 | /** 109 | * Name of originating device 110 | * 111 | * @return the device 112 | */ 113 | public String getDevice() { 114 | return this.device; 115 | } 116 | 117 | /** 118 | * Name of originating device 119 | * 120 | * @param device the device to set 121 | */ 122 | public void setDevice(final String device) { 123 | this.device = device; 124 | } 125 | 126 | /** 127 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. 128 | * 129 | * @return the timestamp 130 | */ 131 | public double getTimestamp() { 132 | return this.timestamp; 133 | } 134 | 135 | /** 136 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. 137 | * 138 | * @param timestamp the timestamp to set 139 | */ 140 | public void setTimestamp(final double timestamp) { 141 | this.timestamp = timestamp; 142 | } 143 | 144 | /** 145 | * Heading, degrees from true north. 146 | * 147 | * @return the heading 148 | */ 149 | public double getHeading() { 150 | return this.heading; 151 | } 152 | 153 | /** 154 | * Heading, degrees from true north. 155 | * 156 | * @param heading the heading to set 157 | */ 158 | public void setHeading(final double heading) { 159 | this.heading = heading; 160 | } 161 | 162 | /** 163 | * Pitch in degrees. 164 | * 165 | * @return the pitch 166 | */ 167 | public double getPitch() { 168 | return this.pitch; 169 | } 170 | 171 | /** 172 | * Pitch in degrees. 173 | * 174 | * @param pitch the pitch to set 175 | */ 176 | public void setPitch(final double pitch) { 177 | this.pitch = pitch; 178 | } 179 | 180 | /** 181 | * Yaw in degrees 182 | * 183 | * @return the yaw 184 | */ 185 | public double getYaw() { 186 | return this.yaw; 187 | } 188 | 189 | /** 190 | * Yaw in degrees 191 | * 192 | * @param yaw the yaw to set 193 | */ 194 | public void setYaw(final double yaw) { 195 | this.yaw = yaw; 196 | } 197 | 198 | /** 199 | * Roll in degrees. 200 | * 201 | * @return the roll 202 | */ 203 | public double getRoll() { 204 | return this.roll; 205 | } 206 | 207 | /** 208 | * Roll in degrees. 209 | * 210 | * @param roll the roll to set 211 | */ 212 | public void setRoll(final double roll) { 213 | this.roll = roll; 214 | } 215 | 216 | /** 217 | * Roll in degrees. 218 | * 219 | * @return the dip 220 | */ 221 | public double getDip() { 222 | return this.dip; 223 | } 224 | 225 | /** 226 | * Roll in degrees. 227 | * 228 | * @param dip the dip to set 229 | */ 230 | public void setDip(final double dip) { 231 | this.dip = dip; 232 | } 233 | 234 | /** 235 | * Scalar magnetic field strength. 236 | * 237 | * @return the mag_len 238 | */ 239 | public double getMag_len() { 240 | return this.mag_len; 241 | } 242 | 243 | /** 244 | * Scalar magnetic field strength. 245 | * 246 | * @param mag_len the mag_len to set 247 | */ 248 | public void setMag_len(final double mag_len) { 249 | this.mag_len = mag_len; 250 | } 251 | 252 | /** 253 | * X component of magnetic field strength. 254 | * 255 | * @return the mag_x 256 | */ 257 | public double getMag_x() { 258 | return this.mag_x; 259 | } 260 | 261 | /** 262 | * X component of magnetic field strength. 263 | * 264 | * @param mag_x the mag_x to set 265 | */ 266 | public void setMag_x(final double mag_x) { 267 | this.mag_x = mag_x; 268 | } 269 | 270 | /** 271 | * Y component of magnetic field strength. 272 | * 273 | * @return the mag_y 274 | */ 275 | public double getMag_y() { 276 | return this.mag_y; 277 | } 278 | 279 | /** 280 | * Y component of magnetic field strength. 281 | * 282 | * @param mag_y the mag_y to set 283 | */ 284 | public void setMag_y(final double mag_y) { 285 | this.mag_y = mag_y; 286 | } 287 | 288 | /** 289 | * Z component of magnetic field strength. 290 | * 291 | * @return the mag_z 292 | */ 293 | public double getMag_z() { 294 | return this.mag_z; 295 | } 296 | 297 | /** 298 | * Z component of magnetic field strength. 299 | * 300 | * @param mag_z the mag_z to set 301 | */ 302 | public void setMag_z(final double mag_z) { 303 | this.mag_z = mag_z; 304 | } 305 | 306 | /** 307 | * Scalar acceleration. 308 | * 309 | * @return the acc_len 310 | */ 311 | public double getAcc_len() { 312 | return this.acc_len; 313 | } 314 | 315 | /** 316 | * Scalar acceleration. 317 | * 318 | * @param acc_len the acc_len to set 319 | */ 320 | public void setAcc_len(final double acc_len) { 321 | this.acc_len = acc_len; 322 | } 323 | 324 | /** 325 | * X component of acceleration. 326 | * 327 | * @return the acc_x 328 | */ 329 | public double getAcc_x() { 330 | return this.acc_x; 331 | } 332 | 333 | /** 334 | * X component of acceleration. 335 | * 336 | * @param acc_x the acc_x to set 337 | */ 338 | public void setAcc_x(final double acc_x) { 339 | this.acc_x = acc_x; 340 | } 341 | 342 | /** 343 | * Y component of acceleration. 344 | * 345 | * @return the acc_y 346 | */ 347 | public double getAcc_y() { 348 | return this.acc_y; 349 | } 350 | 351 | /** 352 | * Y component of acceleration. 353 | * 354 | * @param acc_y the acc_y to set 355 | */ 356 | public void setAcc_y(final double acc_y) { 357 | this.acc_y = acc_y; 358 | } 359 | 360 | /** 361 | * Z component of acceleration. 362 | * 363 | * @return the acc_z 364 | */ 365 | public double getAcc_z() { 366 | return this.acc_z; 367 | } 368 | 369 | /** 370 | * Z component of acceleration. 371 | * 372 | * @param acc_z the acc_z to set 373 | */ 374 | public void setAcc_z(final double acc_z) { 375 | this.acc_z = acc_z; 376 | } 377 | 378 | /** 379 | * X component of acceleration. 380 | * 381 | * @return the gyro_x 382 | */ 383 | public double getGyro_x() { 384 | return this.gyro_x; 385 | } 386 | 387 | /** 388 | * X component of acceleration. 389 | * 390 | * @param gyro_x the gyro_x to set 391 | */ 392 | public void setGyro_x(final double gyro_x) { 393 | this.gyro_x = gyro_x; 394 | } 395 | 396 | /** 397 | * Y component of acceleration. 398 | * 399 | * @return the gyro_y 400 | */ 401 | public double getGyro_y() { 402 | return this.gyro_y; 403 | } 404 | 405 | /** 406 | * Y component of acceleration. 407 | * 408 | * @param gyro_y the gyro_y to set 409 | */ 410 | public void setGyro_y(final double gyro_y) { 411 | this.gyro_y = gyro_y; 412 | } 413 | 414 | /** 415 | * Water depth in meters. 416 | * 417 | * @return the depth 418 | */ 419 | public double getDepth() { 420 | return this.depth; 421 | } 422 | 423 | /** 424 | * Water depth in meters. 425 | * 426 | * @param depth the depth to set 427 | */ 428 | public void setDepth(final double depth) { 429 | this.depth = depth; 430 | } 431 | 432 | /** 433 | * Temperature at sensor, degrees centigrade. 434 | * 435 | * @return the temperature 436 | */ 437 | public double getTemperature() { 438 | return this.temperature; 439 | } 440 | 441 | /** 442 | * Temperature at sensor, degrees centigrade. 443 | * 444 | * @param temperature the temperature to set 445 | */ 446 | public void setTemperature(final double temperature) { 447 | this.temperature = temperature; 448 | } 449 | 450 | /** 451 | * Magnetometer status. 452 | * 453 | * @return the magState 454 | */ 455 | public String getMagState() { 456 | return this.magState; 457 | } 458 | 459 | /** 460 | * Magnetometer status. 461 | * 462 | * @param magState the magState to set 463 | */ 464 | public void setMagState(final String magState) { 465 | this.magState = magState; 466 | } 467 | 468 | /** 469 | * Pitch sensor status. 470 | * 471 | * @return the pitchState 472 | */ 473 | public String getPitchState() { 474 | return this.pitchState; 475 | } 476 | 477 | /** 478 | * Pitch sensor status. 479 | * 480 | * @param pitchState the pitchState to set 481 | */ 482 | public void setPitchState(final String pitchState) { 483 | this.pitchState = pitchState; 484 | } 485 | 486 | /** 487 | * Yaw sensor status. 488 | * 489 | * @return the yawState 490 | */ 491 | public String getYawState() { 492 | return this.yawState; 493 | } 494 | 495 | /** 496 | * Yaw sensor status. 497 | * 498 | * @param yawState the yawState to set 499 | */ 500 | public void setYawState(final String yawState) { 501 | this.yawState = yawState; 502 | } 503 | 504 | /** 505 | * Roll sensor status. 506 | * 507 | * @return the rollState 508 | */ 509 | public String getRollState() { 510 | return this.rollState; 511 | } 512 | 513 | /** 514 | * Roll sensor status. 515 | * 516 | * @param rollState the rollState to set 517 | */ 518 | public void setRollState(final String rollState) { 519 | this.rollState = rollState; 520 | } 521 | 522 | @Override 523 | public String toString() { 524 | final StringBuilder sb = new StringBuilder(); 525 | sb.append("ATTObject{tag="); 526 | sb.append(this.tag); 527 | sb.append(", device="); 528 | sb.append(this.device); 529 | sb.append(", timestamp="); 530 | sb.append(this.timestamp); 531 | sb.append(", heading="); 532 | sb.append(this.heading); 533 | sb.append(", mag_st="); 534 | sb.append(this.magState); 535 | sb.append(", pitch="); 536 | sb.append(this.pitch); 537 | sb.append(", pitch_st="); 538 | sb.append(this.pitchState); 539 | sb.append(", yaw="); 540 | sb.append(this.yawState); 541 | sb.append(", roll="); 542 | sb.append(this.roll); 543 | sb.append(", roll_st="); 544 | sb.append(this.rollState); 545 | sb.append(", dip="); 546 | sb.append(this.dip); 547 | sb.append(", mag_len="); 548 | sb.append(this.mag_len); 549 | sb.append(", mag_x="); 550 | sb.append(this.mag_x); 551 | sb.append(", mag_y="); 552 | sb.append(this.mag_y); 553 | sb.append(", mag_z="); 554 | sb.append(this.mag_z); 555 | sb.append(", acc_len="); 556 | sb.append(this.acc_len); 557 | sb.append(", acc_x="); 558 | sb.append(this.acc_x); 559 | sb.append(", acc_y="); 560 | sb.append(this.acc_y); 561 | sb.append(", acc_z="); 562 | sb.append(this.acc_z); 563 | sb.append(", gyro_x="); 564 | sb.append(this.gyro_x); 565 | sb.append(", gyro_y="); 566 | sb.append(this.gyro_y); 567 | sb.append(", depth="); 568 | sb.append(this.depth); 569 | sb.append(", temperature="); 570 | sb.append(this.temperature); 571 | sb.append("}"); 572 | return sb.toString(); 573 | } 574 | } 575 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/DeviceObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * @author thoeger 25 | */ 26 | public class DeviceObject implements IGPSObject { 27 | 28 | /** the GPSd internal name */ 29 | public static final String NAME = "DEVICE"; 30 | 31 | private String path; 32 | 33 | private double activated; 34 | 35 | private String driver; 36 | 37 | private int bps; 38 | 39 | private EParity parity; 40 | 41 | private int stopbit; 42 | 43 | private boolean nativeMode; 44 | 45 | private double cycle; 46 | 47 | private double mincycle; 48 | 49 | /** 50 | * Name the device for which the control bits are being reported 51 | * 52 | * @return the path 53 | */ 54 | public String getPath() { 55 | return this.path; 56 | } 57 | 58 | /** 59 | * Name the device for which the control bits are being reported 60 | * 61 | * @param path the path to set 62 | */ 63 | public void setPath(final String path) { 64 | this.path = path; 65 | } 66 | 67 | /** 68 | * Time the device was activated, or 0 if it is being closed. 69 | * 70 | * @return the activated 71 | */ 72 | public double getActivated() { 73 | return this.activated; 74 | } 75 | 76 | /** 77 | * Time the device was activated, or 0 if it is being closed. 78 | * 79 | * @param activated the activated to set 80 | */ 81 | public void setActivated(final double activated) { 82 | this.activated = activated; 83 | } 84 | 85 | /** 86 | * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable 87 | * packets from the device. 88 | * 89 | * @return the driver 90 | */ 91 | public String getDriver() { 92 | return this.driver; 93 | } 94 | 95 | /** 96 | * GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable 97 | * packets from the device. 98 | * 99 | * @param driver the driver to set 100 | */ 101 | public void setDriver(final String driver) { 102 | this.driver = driver; 103 | } 104 | 105 | /** 106 | * Device speed in bits per second. 107 | * 108 | * @return the bps 109 | */ 110 | public int getBps() { 111 | return this.bps; 112 | } 113 | 114 | /** 115 | * Device speed in bits per second. 116 | * 117 | * @param bps the bps to set 118 | */ 119 | public void setBps(final int bps) { 120 | this.bps = bps; 121 | } 122 | 123 | /** 124 | * Device parity 125 | * 126 | * @return the parity 127 | */ 128 | public EParity getParity() { 129 | return this.parity; 130 | } 131 | 132 | /** 133 | * Device parity 134 | * 135 | * @param parity the parity to set 136 | */ 137 | public void setParity(final EParity parity) { 138 | this.parity = parity; 139 | } 140 | 141 | /** 142 | * Device Stopbits 143 | * 144 | * @return the stopbit 145 | */ 146 | public int getStopbit() { 147 | return this.stopbit; 148 | } 149 | 150 | /** 151 | * Device Stopbits 152 | * 153 | * @param stopbit the stopbit to set 154 | */ 155 | public void setStopbit(final int stopbit) { 156 | this.stopbit = stopbit; 157 | } 158 | 159 | /** 160 | * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and 161 | * Evermore chipsets in particular). 162 | * 163 | * @return the nativeMode 164 | */ 165 | public boolean isNativeMode() { 166 | return this.nativeMode; 167 | } 168 | 169 | /** 170 | * false means NMEA mode and true means alternate mode (binary if it has one, for SiRF and 171 | * Evermore chipsets in particular). 172 | * 173 | * @param nativeMode the nativeMode to set 174 | */ 175 | public void setNativeMode(final boolean nativeMode) { 176 | this.nativeMode = nativeMode; 177 | } 178 | 179 | /** 180 | * Device cycle time in seconds. 181 | * 182 | * @return the cycle 183 | */ 184 | public double getCycle() { 185 | return this.cycle; 186 | } 187 | 188 | /** 189 | * Device cycle time in seconds. 190 | * 191 | * @param cycle the cycle to set 192 | */ 193 | public void setCycle(final double cycle) { 194 | this.cycle = cycle; 195 | } 196 | 197 | /** 198 | * Device minimum cycle time in seconds. 199 | * 200 | * @return the mincycle 201 | */ 202 | public double getMincycle() { 203 | return this.mincycle; 204 | } 205 | 206 | /** 207 | * Device minimum cycle time in seconds. 208 | * 209 | * @param mincycle the mincycle to set 210 | */ 211 | public void setMincycle(final double mincycle) { 212 | this.mincycle = mincycle; 213 | } 214 | 215 | @Override 216 | public int hashCode() { 217 | final int prime = 31; 218 | int result = 1; 219 | long temp; 220 | temp = Double.doubleToLongBits(this.activated); 221 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 222 | result = (prime * result) + this.bps; 223 | temp = Double.doubleToLongBits(this.cycle); 224 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 225 | result = (prime * result) + ((this.driver == null) ? 0 : this.driver.hashCode()); 226 | temp = Double.doubleToLongBits(this.mincycle); 227 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 228 | result = (prime * result) + (this.nativeMode ? 1231 : 1237); 229 | result = (prime * result) + ((this.parity == null) ? 0 : this.parity.hashCode()); 230 | result = (prime * result) + ((this.path == null) ? 0 : this.path.hashCode()); 231 | result = (prime * result) + this.stopbit; 232 | return result; 233 | } 234 | 235 | @Override 236 | public boolean equals(final Object obj) { 237 | if (this == obj) { 238 | return true; 239 | } 240 | if (obj == null) { 241 | return false; 242 | } 243 | if (this.getClass() != obj.getClass()) { 244 | return false; 245 | } 246 | final DeviceObject other = (DeviceObject) obj; 247 | if (Double.doubleToLongBits(this.activated) != Double.doubleToLongBits(other.activated)) { 248 | return false; 249 | } 250 | if (this.bps != other.bps) { 251 | return false; 252 | } 253 | if (Double.doubleToLongBits(this.cycle) != Double.doubleToLongBits(other.cycle)) { 254 | return false; 255 | } 256 | if (this.driver == null) { 257 | if (other.driver != null) { 258 | return false; 259 | } 260 | } else if (!this.driver.equals(other.driver)) { 261 | return false; 262 | } 263 | if (Double.doubleToLongBits(this.mincycle) != Double.doubleToLongBits(other.mincycle)) { 264 | return false; 265 | } 266 | if (this.nativeMode != other.nativeMode) { 267 | return false; 268 | } 269 | if (this.parity != other.parity) { 270 | return false; 271 | } 272 | if (this.path == null) { 273 | if (other.path != null) { 274 | return false; 275 | } 276 | } else if (!this.path.equals(other.path)) { 277 | return false; 278 | } 279 | if (this.stopbit != other.stopbit) { 280 | return false; 281 | } 282 | return true; 283 | } 284 | 285 | @Override 286 | public String toString() { 287 | final StringBuilder sb = new StringBuilder(); 288 | sb.append("DeviceObject{path="); 289 | sb.append(this.path); 290 | sb.append(", driver="); 291 | sb.append(this.driver); 292 | sb.append(", activated="); 293 | sb.append((long) this.activated); 294 | sb.append(", bps="); 295 | sb.append(this.bps); 296 | sb.append(", parity="); 297 | sb.append(this.parity); 298 | sb.append(", stopbit="); 299 | sb.append(this.stopbit); 300 | sb.append(", nativeMode="); 301 | sb.append(this.nativeMode); 302 | sb.append(", cycle="); 303 | sb.append(this.cycle); 304 | sb.append(", minCycle="); 305 | sb.append(this.mincycle); 306 | sb.append("}"); 307 | return sb.toString(); 308 | } 309 | } 310 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/DevicesObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * @author thoeger 27 | */ 28 | public class DevicesObject implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "DEVICES"; 32 | 33 | private List devices; 34 | 35 | /** 36 | * list of devices 37 | * 38 | * @return the devices 39 | */ 40 | public List getDevices() { 41 | return this.devices; 42 | } 43 | 44 | /** 45 | * list of devices 46 | * 47 | * @param devices the devices to set 48 | */ 49 | public void setDevices(final List devices) { 50 | this.devices = devices; 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | final int prime = 31; 56 | int result = 1; 57 | result = (prime * result) + ((this.devices == null) ? 0 : this.devices.hashCode()); 58 | return result; 59 | } 60 | 61 | @Override 62 | public boolean equals(final Object obj) { 63 | if (this == obj) { 64 | return true; 65 | } 66 | if (obj == null) { 67 | return false; 68 | } 69 | if (this.getClass() != obj.getClass()) { 70 | return false; 71 | } 72 | final DevicesObject other = (DevicesObject) obj; 73 | if (this.devices == null) { 74 | if (other.devices != null) { 75 | return false; 76 | } 77 | } else if (!this.devices.equals(other.devices)) { 78 | return false; 79 | } 80 | return true; 81 | } 82 | 83 | @Override 84 | public String toString() { 85 | return "DevicesObject{devices=" + ((this.devices == null) ? 0 : this.devices.size()) + "}"; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/ENMEAMode.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * NMEA Mode of GPSd response 25 | * 26 | * @author thoeger 27 | */ 28 | public enum ENMEAMode { 29 | 30 | /** no mode value yet seen */ 31 | NotSeen, 32 | /** No fix available */ 33 | NoFix, 34 | /** two dimensional fix */ 35 | TwoDimensional, 36 | /** three dimensional fix */ 37 | ThreeDimensional; 38 | 39 | /** 40 | * @param mode - mode integer 41 | * @return {@link ENMEAMode} 42 | */ 43 | public static ENMEAMode fromInt(final int mode) { 44 | switch (mode) { 45 | case 0: 46 | return NotSeen; 47 | case 1: 48 | return NoFix; 49 | case 2: 50 | return TwoDimensional; 51 | case 3: 52 | return ThreeDimensional; 53 | default: 54 | break; 55 | } 56 | return NotSeen; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/EParity.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * @author thoeger 25 | */ 26 | public enum EParity { 27 | 28 | /** */ 29 | NO, 30 | /** */ 31 | ODD, 32 | /** */ 33 | EVEN; 34 | 35 | /** 36 | * @param parity the parity string 37 | * @return {@link EParity} 38 | */ 39 | public static EParity fromString(final String parity) { 40 | if (parity == null) { 41 | return NO; 42 | } 43 | if (parity.equals("N")) { 44 | return NO; 45 | } 46 | if (parity.equals("O")) { 47 | return ODD; 48 | } 49 | if (parity.equals("E")) { 50 | return EVEN; 51 | } 52 | return NO; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/GSTObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * A GST object is a pseudorange noise report.
25 | * all getters for double values may return Double.NaN if value is not present
26 | * other getters may return null 27 | * 28 | * @author thoeger 29 | */ 30 | public class GSTObject implements IGPSObject { 31 | 32 | /** the GPSd internal name */ 33 | public static final String NAME = "GST"; 34 | 35 | private String tag = null; 36 | 37 | private String device = null; 38 | 39 | private double timestamp = Double.NaN; 40 | 41 | private double rms = Double.NaN; 42 | 43 | private double major = Double.NaN; 44 | 45 | private double minor = Double.NaN; 46 | 47 | private double orient = Double.NaN; 48 | 49 | private double lat = Double.NaN; 50 | 51 | private double lon = Double.NaN; 52 | 53 | private double alt = Double.NaN; 54 | 55 | /** 56 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 57 | * type. 58 | * 59 | * @return the tag 60 | */ 61 | public String getTag() { 62 | return this.tag; 63 | } 64 | 65 | /** 66 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 67 | * type. 68 | * 69 | * @param tag the tag to set 70 | */ 71 | public void setTag(final String tag) { 72 | this.tag = tag; 73 | } 74 | 75 | /** 76 | * Name of originating device 77 | * 78 | * @return the device 79 | */ 80 | public String getDevice() { 81 | return this.device; 82 | } 83 | 84 | /** 85 | * Name of originating device 86 | * 87 | * @param device the device to set 88 | */ 89 | public void setDevice(final String device) { 90 | this.device = device; 91 | } 92 | 93 | /** 94 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. 95 | * 96 | * @return the timestamp 97 | */ 98 | public double getTimestamp() { 99 | return this.timestamp; 100 | } 101 | 102 | /** 103 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. 104 | * 105 | * @param timestamp the timestamp to set 106 | */ 107 | public void setTimestamp(final double timestamp) { 108 | this.timestamp = timestamp; 109 | } 110 | 111 | /** 112 | * Value of the standard deviation of the range inputs to the navigation process (range inputs 113 | * include pseudoranges and DGPS corrections). 114 | * 115 | * @return the rms 116 | */ 117 | public double getRms() { 118 | return this.rms; 119 | } 120 | 121 | /** 122 | * Value of the standard deviation of the range inputs to the navigation process (range inputs 123 | * include pseudoranges and DGPS corrections). 124 | * 125 | * @param rms the rms to set 126 | */ 127 | public void setRms(final double rms) { 128 | this.rms = rms; 129 | } 130 | 131 | /** 132 | * Standard deviation of semi-major axis of error ellipse, in meters. 133 | * 134 | * @return the major 135 | */ 136 | public double getMajor() { 137 | return this.major; 138 | } 139 | 140 | /** 141 | * Standard deviation of semi-major axis of error ellipse, in meters. 142 | * 143 | * @param major the major to set 144 | */ 145 | public void setMajor(final double major) { 146 | this.major = major; 147 | } 148 | 149 | /** 150 | * Standard deviation of semi-minor axis of error ellipse, in meters. 151 | * 152 | * @return the minor 153 | */ 154 | public double getMinor() { 155 | return this.minor; 156 | } 157 | 158 | /** 159 | * Standard deviation of semi-minor axis of error ellipse, in meters. 160 | * 161 | * @param minor the minor to set 162 | */ 163 | public void setMinor(final double minor) { 164 | this.minor = minor; 165 | } 166 | 167 | /** 168 | * Orientation of semi-major axis of error ellipse, in degrees from true north. 169 | * 170 | * @return the orient 171 | */ 172 | public double getOrient() { 173 | return this.orient; 174 | } 175 | 176 | /** 177 | * Orientation of semi-major axis of error ellipse, in degrees from true north. 178 | * 179 | * @param orient the orient to set 180 | */ 181 | public void setOrient(final double orient) { 182 | this.orient = orient; 183 | } 184 | 185 | /** 186 | * Standard deviation of latitude error, in meters. 187 | * 188 | * @return the lat 189 | */ 190 | public double getLat() { 191 | return this.lat; 192 | } 193 | 194 | /** 195 | * Standard deviation of latitude error, in meters. 196 | * 197 | * @param lat the lat to set 198 | */ 199 | public void setLat(final double lat) { 200 | this.lat = lat; 201 | } 202 | 203 | /** 204 | * Standard deviation of longitude error, in meters. 205 | * 206 | * @return the lon 207 | */ 208 | public double getLon() { 209 | return this.lon; 210 | } 211 | 212 | /** 213 | * Standard deviation of longitude error, in meters. 214 | * 215 | * @param lon the lon to set 216 | */ 217 | public void setLon(final double lon) { 218 | this.lon = lon; 219 | } 220 | 221 | /** 222 | * Standard deviation of altitude error, in meters. 223 | * 224 | * @return the alt 225 | */ 226 | public double getAlt() { 227 | return this.alt; 228 | } 229 | 230 | /** 231 | * Standard deviation of altitude error, in meters. 232 | * 233 | * @param alt the alt to set 234 | */ 235 | public void setAlt(final double alt) { 236 | this.alt = alt; 237 | } 238 | 239 | @Override 240 | public int hashCode() { 241 | final int prime = 31; 242 | int result = 1; 243 | long temp; 244 | temp = Double.doubleToLongBits(this.alt); 245 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 246 | result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); 247 | temp = Double.doubleToLongBits(this.lat); 248 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 249 | temp = Double.doubleToLongBits(this.lon); 250 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 251 | temp = Double.doubleToLongBits(this.major); 252 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 253 | temp = Double.doubleToLongBits(this.minor); 254 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 255 | temp = Double.doubleToLongBits(this.orient); 256 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 257 | temp = Double.doubleToLongBits(this.rms); 258 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 259 | result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); 260 | temp = Double.doubleToLongBits(this.timestamp); 261 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 262 | return result; 263 | } 264 | 265 | @Override 266 | public boolean equals(final Object obj) { 267 | if (this == obj) { 268 | return true; 269 | } 270 | if (obj == null) { 271 | return false; 272 | } 273 | if (this.getClass() != obj.getClass()) { 274 | return false; 275 | } 276 | final GSTObject other = (GSTObject) obj; 277 | if (Double.doubleToLongBits(this.alt) != Double.doubleToLongBits(other.alt)) { 278 | return false; 279 | } 280 | if (this.device == null) { 281 | if (other.device != null) { 282 | return false; 283 | } 284 | } else if (!this.device.equals(other.device)) { 285 | return false; 286 | } 287 | if (Double.doubleToLongBits(this.lat) != Double.doubleToLongBits(other.lat)) { 288 | return false; 289 | } 290 | if (Double.doubleToLongBits(this.lon) != Double.doubleToLongBits(other.lon)) { 291 | return false; 292 | } 293 | if (Double.doubleToLongBits(this.major) != Double.doubleToLongBits(other.major)) { 294 | return false; 295 | } 296 | if (Double.doubleToLongBits(this.minor) != Double.doubleToLongBits(other.minor)) { 297 | return false; 298 | } 299 | if (Double.doubleToLongBits(this.orient) != Double.doubleToLongBits(other.orient)) { 300 | return false; 301 | } 302 | if (Double.doubleToLongBits(this.rms) != Double.doubleToLongBits(other.rms)) { 303 | return false; 304 | } 305 | if (this.tag == null) { 306 | if (other.tag != null) { 307 | return false; 308 | } 309 | } else if (!this.tag.equals(other.tag)) { 310 | return false; 311 | } 312 | if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { 313 | return false; 314 | } 315 | return true; 316 | } 317 | 318 | @Override 319 | public String toString() { 320 | final StringBuilder sb = new StringBuilder(); 321 | sb.append("GSTObject{tag="); 322 | sb.append(this.tag); 323 | sb.append(", device="); 324 | sb.append(this.device); 325 | sb.append(", timestamp="); 326 | sb.append(this.timestamp); 327 | sb.append(", rms="); 328 | sb.append(this.rms); 329 | sb.append(", major="); 330 | sb.append(this.major); 331 | sb.append(", minor="); 332 | sb.append(this.minor); 333 | sb.append(", orient="); 334 | sb.append(this.orient); 335 | sb.append(", lat="); 336 | sb.append(this.lat); 337 | sb.append(", lon="); 338 | sb.append(this.lon); 339 | sb.append(", alt="); 340 | sb.append(this.alt); 341 | sb.append("}"); 342 | return sb.toString(); 343 | } 344 | } 345 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/IGPSObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Interface for generic GPSd object 25 | * 26 | * @author thoeger 27 | */ 28 | public interface IGPSObject { 29 | 30 | // this is only a marker interface 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/ParseException.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * {@link Exception} indication an error while parsing the GPSd line 25 | * 26 | * @author thoeger 27 | */ 28 | public class ParseException extends Exception { 29 | 30 | private static final long serialVersionUID = 7747422116792199432L; 31 | 32 | /** */ 33 | public ParseException() { 34 | super(); 35 | } 36 | 37 | /** 38 | * @param message the message 39 | */ 40 | public ParseException(final String message) { 41 | super(message); 42 | } 43 | 44 | /** 45 | * @param message the message 46 | * @param cause the cause 47 | */ 48 | public ParseException(final String message, final Throwable cause) { 49 | super(message, cause); 50 | } 51 | 52 | /** 53 | * @param cause the cause 54 | */ 55 | public ParseException(final Throwable cause) { 56 | super(cause); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/PollObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * @author thoeger 27 | */ 28 | public class PollObject implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "POLL"; 32 | 33 | private double timestamp; 34 | 35 | private int active; 36 | 37 | private List fixes; 38 | 39 | private List skyviews; 40 | 41 | private List gst; 42 | 43 | /** 44 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. 45 | * 46 | * @return the timestamp 47 | */ 48 | public double getTimestamp() { 49 | return this.timestamp; 50 | } 51 | 52 | /** 53 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .001sec precision. 54 | * 55 | * @param timestamp the timestamp to set 56 | */ 57 | public void setTimestamp(final double timestamp) { 58 | this.timestamp = timestamp; 59 | } 60 | 61 | /** 62 | * Count of active devices. 63 | * 64 | * @return the active 65 | */ 66 | public int getActive() { 67 | return this.active; 68 | } 69 | 70 | /** 71 | * Count of active devices. 72 | * 73 | * @param active the active to set 74 | */ 75 | public void setActive(final int active) { 76 | this.active = active; 77 | } 78 | 79 | /** 80 | * list of TPV objects 81 | * 82 | * @return the fixes 83 | */ 84 | public List getFixes() { 85 | return this.fixes; 86 | } 87 | 88 | /** 89 | * list of TPV objects 90 | * 91 | * @param fixes the fixes to set 92 | */ 93 | public void setFixes(final List fixes) { 94 | this.fixes = fixes; 95 | } 96 | 97 | /** 98 | * list of SKY objects 99 | * 100 | * @return the skyviews 101 | */ 102 | public List getSkyviews() { 103 | return this.skyviews; 104 | } 105 | 106 | /** 107 | * list of SKY objects 108 | * 109 | * @param skyviews the skyviews to set 110 | */ 111 | public void setSkyviews(final List skyviews) { 112 | this.skyviews = skyviews; 113 | } 114 | 115 | /** 116 | * @return the gst 117 | */ 118 | public List getGst() { 119 | return this.gst; 120 | } 121 | 122 | /** 123 | * @param gst the gst to set 124 | */ 125 | public void setGst(final List gst) { 126 | this.gst = gst; 127 | } 128 | 129 | @Override 130 | public int hashCode() { 131 | final int prime = 31; 132 | int result = 1; 133 | result = (prime * result) + this.active; 134 | result = (prime * result) + ((this.fixes == null) ? 0 : this.fixes.hashCode()); 135 | result = (prime * result) + ((this.skyviews == null) ? 0 : this.skyviews.hashCode()); 136 | result = (prime * result) + ((this.gst == null) ? 0 : this.gst.hashCode()); 137 | long temp; 138 | temp = Double.doubleToLongBits(this.timestamp); 139 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 140 | return result; 141 | } 142 | 143 | @Override 144 | public boolean equals(final Object obj) { 145 | if (this == obj) { 146 | return true; 147 | } 148 | if (obj == null) { 149 | return false; 150 | } 151 | if (this.getClass() != obj.getClass()) { 152 | return false; 153 | } 154 | final PollObject other = (PollObject) obj; 155 | if (this.active != other.active) { 156 | return false; 157 | } 158 | if (this.fixes == null) { 159 | if (other.fixes != null) { 160 | return false; 161 | } 162 | } else if (!this.fixes.equals(other.fixes)) { 163 | return false; 164 | } 165 | if (this.skyviews == null) { 166 | if (other.skyviews != null) { 167 | return false; 168 | } 169 | } else if (!this.skyviews.equals(other.skyviews)) { 170 | return false; 171 | } 172 | if (this.gst == null) { 173 | if (other.gst != null) { 174 | return false; 175 | } 176 | } else if (!this.gst.equals(other.gst)) { 177 | return false; 178 | } 179 | if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { 180 | return false; 181 | } 182 | return true; 183 | } 184 | 185 | @Override 186 | public String toString() { 187 | final StringBuilder sb = new StringBuilder(); 188 | 189 | sb.append("PollObject{timestamp="); 190 | sb.append(this.timestamp); 191 | sb.append(", active="); 192 | sb.append(this.active); 193 | sb.append(", fixes="); 194 | sb.append(((this.fixes == null) ? 0 : this.fixes.size())); 195 | sb.append(", skyviews="); 196 | sb.append(((this.skyviews == null) ? 0 : this.skyviews.size())); 197 | sb.append(", gst="); 198 | sb.append(((this.gst == null) ? 0 : this.gst.size())); 199 | sb.append("}"); 200 | 201 | return sb.toString(); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/PpsObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /** 4 | * This message is emitted each time the daemon sees a valid PPS (Pulse Per Second) strobe from a 5 | * device. This message exactly mirrors the TOFF message except for two details. PPS emits the NTP 6 | * precision. See the NTP documentation for their definition of precision. The TOFF message reports 7 | * the GPS time as derived from the GPS serial data stream. The PPS message reports the GPS time as 8 | * derived from the GPS PPS pulse. 9 | * 10 | * @author dpishchukhin 11 | */ 12 | public class PpsObject implements IGPSObject { 13 | /** the PPS internal name */ 14 | public static final String NAME = "PPS"; 15 | 16 | private String device = null; 17 | 18 | private double realSec = Double.NaN; 19 | 20 | private double realNsec = Double.NaN; 21 | 22 | private double clockSec = Double.NaN; 23 | 24 | private double clockNsec = Double.NaN; 25 | 26 | private double precision = Double.NaN; 27 | 28 | /** 29 | * Name of originating device 30 | * 31 | * @return device 32 | */ 33 | public String getDevice() { 34 | return device; 35 | } 36 | 37 | /** 38 | * Name of originating device 39 | * 40 | * @param device device 41 | */ 42 | public void setDevice(String device) { 43 | this.device = device; 44 | } 45 | 46 | /** 47 | * seconds from the PPS source 48 | * 49 | * @return seconds 50 | */ 51 | public double getRealSec() { 52 | return realSec; 53 | } 54 | 55 | /** 56 | * seconds from the PPS source 57 | * 58 | * @param realSec seconds 59 | */ 60 | public void setRealSec(double realSec) { 61 | this.realSec = realSec; 62 | } 63 | 64 | /** 65 | * nanoseconds from the PPS source 66 | * 67 | * @return nanoseconds 68 | */ 69 | public double getRealNsec() { 70 | return realNsec; 71 | } 72 | 73 | /** 74 | * nanoseconds from the PPS source 75 | * 76 | * @param realNsec nanoseconds 77 | */ 78 | public void setRealNsec(double realNsec) { 79 | this.realNsec = realNsec; 80 | } 81 | 82 | /** 83 | * seconds from the system clock 84 | * 85 | * @return seconds 86 | */ 87 | public double getClockSec() { 88 | return clockSec; 89 | } 90 | 91 | /** 92 | * seconds from the system clock 93 | * 94 | * @param clockSec seconds 95 | */ 96 | public void setClockSec(double clockSec) { 97 | this.clockSec = clockSec; 98 | } 99 | 100 | /** 101 | * nanoseconds from the system clock 102 | * 103 | * @return nanoseconds 104 | */ 105 | public double getClockNsec() { 106 | return clockNsec; 107 | } 108 | 109 | /** 110 | * nanoseconds from the system clock 111 | * 112 | * @param clockNsec nanoseconds 113 | */ 114 | public void setClockNsec(double clockNsec) { 115 | this.clockNsec = clockNsec; 116 | } 117 | 118 | /** 119 | * NTP style estimate of PPS precision 120 | * 121 | * @return precision 122 | */ 123 | public double getPrecision() { 124 | return precision; 125 | } 126 | 127 | /** 128 | * NTP style estimate of PPS precision 129 | * 130 | * @param precision precision 131 | */ 132 | public void setPrecision(double precision) { 133 | this.precision = precision; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/SATObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * @author aevdokimov 25 | */ 26 | public class SATObject implements IGPSObject { 27 | 28 | /** the GPSd internal name */ 29 | public static final String NAME = "SAT"; 30 | 31 | private int PRN = -1; 32 | 33 | private int azimuth = -1; 34 | 35 | private int elevation = -1; 36 | 37 | private int signalStrength = -1; 38 | 39 | private int gnssId = -1; 40 | 41 | private boolean used = false; 42 | 43 | /** 44 | * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are 45 | * SBAS satellites 46 | * 47 | * @return PRN 48 | */ 49 | public int getPRN() { 50 | return this.PRN; 51 | } 52 | 53 | /** 54 | * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are 55 | * SBAS satellites 56 | * 57 | * @param PRN the PRN to set 58 | */ 59 | public void setPRN(final int PRN) { 60 | this.PRN = PRN; 61 | } 62 | 63 | /** 64 | * Azimuth, degrees from true north. 65 | * 66 | * @return azimuth 67 | */ 68 | public int getAzimuth() { 69 | return this.azimuth; 70 | } 71 | 72 | /** 73 | * Azimuth, degrees from true north. 74 | * 75 | * @param azimuth the azimuth to set 76 | */ 77 | public void setAzimuth(final int azimuth) { 78 | this.azimuth = azimuth; 79 | } 80 | 81 | /** 82 | * Elevation in degrees. 83 | * 84 | * @return elevation 85 | */ 86 | public int getElevation() { 87 | return this.elevation; 88 | } 89 | 90 | /** 91 | * Elevation in degrees. 92 | * 93 | * @param elevation the elevation to set 94 | */ 95 | public void setElevation(final int elevation) { 96 | this.elevation = elevation; 97 | } 98 | 99 | /** 100 | * Signal strength in dB. 101 | * 102 | * @return signal strength 103 | */ 104 | public int getSignalStrength() { 105 | return this.signalStrength; 106 | } 107 | 108 | /** 109 | * Signal strength in dB. 110 | * 111 | * @param signalStrength the signal strength to set 112 | */ 113 | public void setSignalStrength(final int signalStrength) { 114 | this.signalStrength = signalStrength; 115 | } 116 | 117 | /** 118 | * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has 119 | * corrections from them, but not all drivers make this information available.) 120 | * 121 | * @return used 122 | */ 123 | public boolean getUsed() { 124 | return this.used; 125 | } 126 | 127 | /** 128 | * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has 129 | * corrections from them, but not all drivers make this information available.) 130 | * 131 | * @param used the used flag to set 132 | */ 133 | public void setUsed(final boolean used) { 134 | this.used = used; 135 | } 136 | 137 | /** 138 | * The GNSSID field of the satellite, if available. 139 | * 140 | * @return gnssId 141 | */ 142 | public int getGnssId() { 143 | return gnssId; 144 | } 145 | 146 | /** 147 | * The GNSSID field of the satellite, if available. 148 | * 149 | * @param gnssId the GNSSID field to set 150 | */ 151 | public void setGnssId(final int gnssId) { 152 | this.gnssId = gnssId; 153 | } 154 | 155 | @Override 156 | public int hashCode() { 157 | final int prime = 31; 158 | int result = 1; 159 | long temp; 160 | temp = Double.doubleToLongBits(this.PRN); 161 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 162 | temp = Double.doubleToLongBits(this.azimuth); 163 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 164 | temp = Double.doubleToLongBits(this.elevation); 165 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 166 | temp = Double.doubleToLongBits(this.signalStrength); 167 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 168 | temp = Double.doubleToLongBits(this.gnssId); 169 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 170 | result = (prime * result) + ((this.used) ? 1 : 0); 171 | return result; 172 | } 173 | 174 | @Override 175 | public boolean equals(final Object obj) { 176 | if (this == obj) { 177 | return true; 178 | } 179 | if (obj == null) { 180 | return false; 181 | } 182 | if (this.getClass() != obj.getClass()) { 183 | return false; 184 | } 185 | final SATObject other = (SATObject) obj; 186 | if (Double.doubleToLongBits(this.PRN) != Double.doubleToLongBits(other.PRN)) { 187 | return false; 188 | } 189 | if (Double.doubleToLongBits(this.azimuth) != Double.doubleToLongBits(other.azimuth)) { 190 | return false; 191 | } 192 | if (Double.doubleToLongBits(this.elevation) != Double.doubleToLongBits(other.elevation)) { 193 | return false; 194 | } 195 | if (Double.doubleToLongBits(this.signalStrength) 196 | != Double.doubleToLongBits(other.signalStrength)) { 197 | return false; 198 | } 199 | if (this.used != other.used) { 200 | return false; 201 | } 202 | return true; 203 | } 204 | 205 | @Override 206 | public String toString() { 207 | final StringBuilder sb = new StringBuilder(); 208 | sb.append("SATObject{PRN="); 209 | sb.append(this.PRN); 210 | sb.append(", az="); 211 | sb.append(this.azimuth); 212 | sb.append(", el="); 213 | sb.append(this.elevation); 214 | sb.append(", ss="); 215 | sb.append(this.signalStrength); 216 | sb.append(", used="); 217 | sb.append(this.used ? "Y" : "N"); 218 | sb.append("}"); 219 | return sb.toString(); 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/SKYObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * @author thoeger 27 | * @author aevdokimov 28 | */ 29 | public class SKYObject implements IGPSObject { 30 | 31 | /** the GPSd internal name */ 32 | public static final String NAME = "SKY"; 33 | 34 | private String tag = null; 35 | 36 | private String device = null; 37 | 38 | private double timestamp = Double.NaN; 39 | 40 | private double longitudeDOP = Double.NaN; 41 | 42 | private double latitudeDOP = Double.NaN; 43 | 44 | private double altitudeDOP = Double.NaN; 45 | 46 | private double timestampDOP = Double.NaN; 47 | 48 | private double horizontalDOP = Double.NaN; 49 | 50 | private double sphericalDOP = Double.NaN; 51 | 52 | private double hypersphericalDOP = Double.NaN; 53 | 54 | private List satellites; 55 | 56 | /** 57 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 58 | * type. 59 | * 60 | * @return the tag 61 | */ 62 | public String getTag() { 63 | return this.tag; 64 | } 65 | 66 | /** 67 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 68 | * type. 69 | * 70 | * @param tag the tag to set 71 | */ 72 | public void setTag(final String tag) { 73 | this.tag = tag; 74 | } 75 | 76 | /** 77 | * Name of originating device 78 | * 79 | * @return the device 80 | */ 81 | public String getDevice() { 82 | return this.device; 83 | } 84 | 85 | /** 86 | * Name of originating device 87 | * 88 | * @param device the device to set 89 | */ 90 | public void setDevice(final String device) { 91 | this.device = device; 92 | } 93 | 94 | /** 95 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. 96 | * 97 | * @return the timestamp 98 | */ 99 | public double getTimestamp() { 100 | return this.timestamp; 101 | } 102 | 103 | /** 104 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. 105 | * 106 | * @param timestamp the timestamp to set 107 | */ 108 | public void setTimestamp(final double timestamp) { 109 | this.timestamp = timestamp; 110 | } 111 | 112 | /** 113 | * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base 114 | * UERE to get an error estimate. 115 | * 116 | * @return the longitude DOP 117 | */ 118 | public double getLongitudeDOP() { 119 | return this.longitudeDOP; 120 | } 121 | 122 | /** 123 | * Longitudinal dilution of precision, a dimensionless factor which should be multiplied by a base 124 | * UERE to get an error estimate. 125 | * 126 | * @param longitudeDOP the longitude DOP to set 127 | */ 128 | public void setLongitudeDOP(final double longitudeDOP) { 129 | this.longitudeDOP = longitudeDOP; 130 | } 131 | 132 | /** 133 | * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base 134 | * UERE to get an error estimate. 135 | * 136 | * @return the latitude DOP 137 | */ 138 | public double getLatitudeDOP() { 139 | return this.latitudeDOP; 140 | } 141 | 142 | /** 143 | * Latitudinal dilution of precision, a dimensionless factor which should be multiplied by a base 144 | * UERE to get an error estimate. 145 | * 146 | * @param latitudeDOP the latitude DOP to set 147 | */ 148 | public void setLatitudeDOP(final double latitudeDOP) { 149 | this.latitudeDOP = latitudeDOP; 150 | } 151 | 152 | /** 153 | * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base 154 | * UERE to get an error estimate. 155 | * 156 | * @return the altitude DOP 157 | */ 158 | public double getAltitudeDOP() { 159 | return this.altitudeDOP; 160 | } 161 | 162 | /** 163 | * Altitude dilution of precision, a dimensionless factor which should be multiplied by a base 164 | * UERE to get an error estimate. 165 | * 166 | * @param altitudeDOP the altitude DOP to set 167 | */ 168 | public void setAltitudeDOP(final double altitudeDOP) { 169 | this.altitudeDOP = altitudeDOP; 170 | } 171 | 172 | /** 173 | * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to 174 | * get an error estimate. 175 | * 176 | * @return the timestamp DOP 177 | */ 178 | public double getTimestampDOP() { 179 | return this.timestampDOP; 180 | } 181 | 182 | /** 183 | * Time dilution of precision, a dimensionless factor which should be multiplied by a base UERE to 184 | * get an error estimate. 185 | * 186 | * @param timestampDOP the timestamp DOP to set 187 | */ 188 | public void setTimestampDOP(final double timestampDOP) { 189 | this.timestampDOP = timestampDOP; 190 | } 191 | 192 | /** 193 | * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base 194 | * UERE to get a circular error estimate. 195 | * 196 | * @return the horizontal DOP 197 | */ 198 | public double getHorizontalDOP() { 199 | return this.horizontalDOP; 200 | } 201 | 202 | /** 203 | * Horizontal dilution of precision, a dimensionless factor which should be multiplied by a base 204 | * UERE to get a circular error estimate. 205 | * 206 | * @param horizontalDOP the horizontal DOP to set 207 | */ 208 | public void setHorizontalDOP(final double horizontalDOP) { 209 | this.horizontalDOP = horizontalDOP; 210 | } 211 | 212 | /** 213 | * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base 214 | * UERE to get an error estimate. 215 | * 216 | * @return the spherical DOP 217 | */ 218 | public double getSphericalDOP() { 219 | return this.sphericalDOP; 220 | } 221 | 222 | /** 223 | * Spherical dilution of precision, a dimensionless factor which should be multiplied by a base 224 | * UERE to get an error estimate. 225 | * 226 | * @param sphericalDOP the spherical DOP to set 227 | */ 228 | public void setSphericalDOP(final double sphericalDOP) { 229 | this.sphericalDOP = sphericalDOP; 230 | } 231 | 232 | /** 233 | * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a 234 | * base UERE to get an error estimate. 235 | * 236 | * @return the hyperspherical DOP 237 | */ 238 | public double getHypersphericalDOP() { 239 | return this.hypersphericalDOP; 240 | } 241 | 242 | /** 243 | * Hyperspherical dilution of precision, a dimensionless factor which should be multiplied by a 244 | * base UERE to get an error estimate. 245 | * 246 | * @param hypersphericalDOP the hyperspherical DOP to set 247 | */ 248 | public void setHypersphericalDOP(final double hypersphericalDOP) { 249 | this.hypersphericalDOP = hypersphericalDOP; 250 | } 251 | 252 | /** 253 | * list of Satellite objects 254 | * 255 | * @return the satellites 256 | */ 257 | public List getSatellites() { 258 | return this.satellites; 259 | } 260 | 261 | /** 262 | * list of Satellite objects 263 | * 264 | * @param satellites the satellites to set 265 | */ 266 | public void setSatellites(final List satellites) { 267 | this.satellites = satellites; 268 | } 269 | 270 | @Override 271 | public int hashCode() { 272 | final int prime = 31; 273 | int result = 1; 274 | long temp; 275 | temp = Double.doubleToLongBits(this.altitudeDOP); 276 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 277 | result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); 278 | temp = Double.doubleToLongBits(this.horizontalDOP); 279 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 280 | temp = Double.doubleToLongBits(this.hypersphericalDOP); 281 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 282 | temp = Double.doubleToLongBits(this.latitudeDOP); 283 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 284 | temp = Double.doubleToLongBits(this.longitudeDOP); 285 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 286 | temp = Double.doubleToLongBits(this.sphericalDOP); 287 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 288 | result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); 289 | temp = Double.doubleToLongBits(this.timestamp); 290 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 291 | temp = Double.doubleToLongBits(this.timestampDOP); 292 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 293 | return result; 294 | } 295 | 296 | @Override 297 | public boolean equals(final Object obj) { 298 | if (this == obj) { 299 | return true; 300 | } 301 | if (obj == null) { 302 | return false; 303 | } 304 | if (this.getClass() != obj.getClass()) { 305 | return false; 306 | } 307 | final SKYObject other = (SKYObject) obj; 308 | if (Double.doubleToLongBits(this.altitudeDOP) != Double.doubleToLongBits(other.altitudeDOP)) { 309 | return false; 310 | } 311 | if (this.device == null) { 312 | if (other.device != null) { 313 | return false; 314 | } 315 | } else if (!this.device.equals(other.device)) { 316 | return false; 317 | } 318 | if (Double.doubleToLongBits(this.horizontalDOP) 319 | != Double.doubleToLongBits(other.horizontalDOP)) { 320 | return false; 321 | } 322 | if (Double.doubleToLongBits(this.hypersphericalDOP) 323 | != Double.doubleToLongBits(other.hypersphericalDOP)) { 324 | return false; 325 | } 326 | if (Double.doubleToLongBits(this.latitudeDOP) != Double.doubleToLongBits(other.latitudeDOP)) { 327 | return false; 328 | } 329 | if (Double.doubleToLongBits(this.longitudeDOP) != Double.doubleToLongBits(other.longitudeDOP)) { 330 | return false; 331 | } 332 | if (Double.doubleToLongBits(this.sphericalDOP) != Double.doubleToLongBits(other.sphericalDOP)) { 333 | return false; 334 | } 335 | if (this.tag == null) { 336 | if (other.tag != null) { 337 | return false; 338 | } 339 | } else if (!this.tag.equals(other.tag)) { 340 | return false; 341 | } 342 | if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { 343 | return false; 344 | } 345 | if (Double.doubleToLongBits(this.timestampDOP) != Double.doubleToLongBits(other.timestampDOP)) { 346 | return false; 347 | } 348 | if (this.satellites.size() != other.satellites.size()) { 349 | return false; 350 | } 351 | try { 352 | for (int i = 0; i < this.satellites.size(); i++) { 353 | if (!this.satellites.get(i).equals(other.satellites.get(i))) { 354 | return false; 355 | } 356 | } 357 | } catch (final IndexOutOfBoundsException e) { 358 | return false; 359 | } 360 | 361 | return true; 362 | } 363 | 364 | @Override 365 | public String toString() { 366 | final StringBuilder sb = new StringBuilder(); 367 | sb.append("SKYObject{time="); 368 | sb.append(this.timestamp); 369 | sb.append(", xdop="); 370 | sb.append(this.longitudeDOP); 371 | sb.append(", ydop="); 372 | sb.append(this.latitudeDOP); 373 | sb.append(", vdop="); 374 | sb.append(this.altitudeDOP); 375 | sb.append(", tdop="); 376 | sb.append(this.timestampDOP); 377 | sb.append(", hdop="); 378 | sb.append(this.horizontalDOP); 379 | sb.append(", pdop="); 380 | sb.append(this.sphericalDOP); 381 | sb.append(", gdop="); 382 | sb.append(this.hypersphericalDOP); 383 | sb.append(", sat="); 384 | sb.append(this.satellites == null ? 0 : this.satellites.size()); 385 | sb.append("}"); 386 | 387 | return sb.toString(); 388 | } 389 | } 390 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/TPVObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Time-Position-Velocity Report Object
25 | *
26 | * all getters for double values may return Double.NaN if value is not present
27 | * other getters may return null 28 | * 29 | * @author thoeger 30 | */ 31 | public class TPVObject implements IGPSObject { 32 | 33 | /** the GPSd internal name */ 34 | public static final String NAME = "TPV"; 35 | 36 | private String tag = null; 37 | 38 | private String device = null; 39 | 40 | private double timestamp = Double.NaN; 41 | 42 | private double timestampError = Double.NaN; 43 | 44 | private double latitude = Double.NaN; 45 | 46 | private double longitude = Double.NaN; 47 | 48 | private double altitude = Double.NaN; 49 | 50 | private double latitudeError = Double.NaN; 51 | 52 | private double longitudeError = Double.NaN; 53 | 54 | private double altitudeError = Double.NaN; 55 | 56 | private double course = Double.NaN; 57 | 58 | private double speed = Double.NaN; 59 | 60 | private double climbRate = Double.NaN; 61 | 62 | private double courseError = Double.NaN; 63 | 64 | private double speedError = Double.NaN; 65 | 66 | private double climbRateError = Double.NaN; 67 | 68 | private ENMEAMode mode; 69 | 70 | /** 71 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 72 | * type. 73 | * 74 | * @return the tag 75 | */ 76 | public String getTag() { 77 | return this.tag; 78 | } 79 | 80 | /** 81 | * Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence 82 | * type. 83 | * 84 | * @param tag the tag to set 85 | */ 86 | public void setTag(final String tag) { 87 | this.tag = tag; 88 | } 89 | 90 | /** 91 | * Name of originating device 92 | * 93 | * @return the device 94 | */ 95 | public String getDevice() { 96 | return this.device; 97 | } 98 | 99 | /** 100 | * Name of originating device 101 | * 102 | * @param device the device to set 103 | */ 104 | public void setDevice(final String device) { 105 | this.device = device; 106 | } 107 | 108 | /** 109 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. 110 | * 111 | * @return the timestamp 112 | */ 113 | public double getTimestamp() { 114 | return this.timestamp; 115 | } 116 | 117 | /** 118 | * Seconds since the Unix epoch, UTC. May have a fractional part of up to .01sec precision. 119 | * 120 | * @param timestamp the timestamp to set 121 | */ 122 | public void setTimestamp(final double timestamp) { 123 | this.timestamp = timestamp; 124 | } 125 | 126 | /** 127 | * Estimated timestamp error (%f, seconds, 95% confidence). 128 | * 129 | * @return the timestampError 130 | */ 131 | public double getTimestampError() { 132 | return this.timestampError; 133 | } 134 | 135 | /** 136 | * Estimated timestamp error (%f, seconds, 95% confidence). 137 | * 138 | * @param timestampError the timestampError to set 139 | */ 140 | public void setTimestampError(final double timestampError) { 141 | this.timestampError = timestampError; 142 | } 143 | 144 | /** 145 | * Latitude in degrees: +/- signifies North/South 146 | * 147 | * @return the latitude 148 | */ 149 | public double getLatitude() { 150 | return this.latitude; 151 | } 152 | 153 | /** 154 | * Latitude in degrees: +/- signifies North/South 155 | * 156 | * @param latitude the latitude to set 157 | */ 158 | public void setLatitude(final double latitude) { 159 | this.latitude = latitude; 160 | } 161 | 162 | /** 163 | * Longitude in degrees: +/- signifies East/West 164 | * 165 | * @return the longitude 166 | */ 167 | public double getLongitude() { 168 | return this.longitude; 169 | } 170 | 171 | /** 172 | * Longitude in degrees: +/- signifies East/West 173 | * 174 | * @param longitude the longitude to set 175 | */ 176 | public void setLongitude(final double longitude) { 177 | this.longitude = longitude; 178 | } 179 | 180 | /** 181 | * Altitude in meters. 182 | * 183 | * @return the altitude 184 | */ 185 | public double getAltitude() { 186 | return this.altitude; 187 | } 188 | 189 | /** 190 | * Altitude in meters. 191 | * 192 | * @param altitude the altitude to set 193 | */ 194 | public void setAltitude(final double altitude) { 195 | this.altitude = altitude; 196 | } 197 | 198 | /** 199 | * Latitude error estimate in meters, 95% confidence. 200 | * 201 | * @return the latitudeError 202 | */ 203 | public double getLatitudeError() { 204 | return this.latitudeError; 205 | } 206 | 207 | /** 208 | * Latitude error estimate in meters, 95% confidence. 209 | * 210 | * @param latitudeError the latitudeError to set 211 | */ 212 | public void setLatitudeError(final double latitudeError) { 213 | this.latitudeError = latitudeError; 214 | } 215 | 216 | /** 217 | * Longitude error estimate in meters, 95% confidence. 218 | * 219 | * @return the longitudeError 220 | */ 221 | public double getLongitudeError() { 222 | return this.longitudeError; 223 | } 224 | 225 | /** 226 | * Longitude error estimate in meters, 95% confidence. 227 | * 228 | * @param longitudeError the longitudeError to set 229 | */ 230 | public void setLongitudeError(final double longitudeError) { 231 | this.longitudeError = longitudeError; 232 | } 233 | 234 | /** 235 | * Estimated vertical error in meters, 95% confidence. 236 | * 237 | * @return the altitudeError 238 | */ 239 | public double getAltitudeError() { 240 | return this.altitudeError; 241 | } 242 | 243 | /** 244 | * Estimated vertical error in meters, 95% confidence. 245 | * 246 | * @param altitudeError the altitudeError to set 247 | */ 248 | public void setAltitudeError(final double altitudeError) { 249 | this.altitudeError = altitudeError; 250 | } 251 | 252 | /** 253 | * Course over ground, degrees from true north. 254 | * 255 | * @return the course 256 | */ 257 | public double getCourse() { 258 | return this.course; 259 | } 260 | 261 | /** 262 | * Course over ground, degrees from true north. 263 | * 264 | * @param course the course to set 265 | */ 266 | public void setCourse(final double course) { 267 | this.course = course; 268 | } 269 | 270 | /** 271 | * Speed over ground, meters per second. 272 | * 273 | * @return the speed 274 | */ 275 | public double getSpeed() { 276 | return this.speed; 277 | } 278 | 279 | /** 280 | * Speed over ground, meters per second. 281 | * 282 | * @param speed the speed to set 283 | */ 284 | public void setSpeed(final double speed) { 285 | this.speed = speed; 286 | } 287 | 288 | /** 289 | * Climb (positive) or sink (negative) rate, meters per second. 290 | * 291 | * @return the climbRate 292 | */ 293 | public double getClimbRate() { 294 | return this.climbRate; 295 | } 296 | 297 | /** 298 | * Climb (positive) or sink (negative) rate, meters per second. 299 | * 300 | * @param climbRate the climbRate to set 301 | */ 302 | public void setClimbRate(final double climbRate) { 303 | this.climbRate = climbRate; 304 | } 305 | 306 | /** 307 | * Direction error estimate in degrees, 95% confidence. 308 | * 309 | * @return the courseError 310 | */ 311 | public double getCourseError() { 312 | return this.courseError; 313 | } 314 | 315 | /** 316 | * Direction error estimate in degrees, 95% confidence. 317 | * 318 | * @param courseError the courseError to set 319 | */ 320 | public void setCourseError(final double courseError) { 321 | this.courseError = courseError; 322 | } 323 | 324 | /** 325 | * Speed error estimate in meters/sec, 95% confidence. 326 | * 327 | * @return the speedError 328 | */ 329 | public double getSpeedError() { 330 | return this.speedError; 331 | } 332 | 333 | /** 334 | * Speed error estimate in meters/sec, 95% confidence. 335 | * 336 | * @param speedError the speedError to set 337 | */ 338 | public void setSpeedError(final double speedError) { 339 | this.speedError = speedError; 340 | } 341 | 342 | /** 343 | * Climb/sink error estimate in meters/sec, 95% confidence. 344 | * 345 | * @return the climbRateError 346 | */ 347 | public double getClimbRateError() { 348 | return this.climbRateError; 349 | } 350 | 351 | /** 352 | * Climb/sink error estimate in meters/sec, 95% confidence. 353 | * 354 | * @param climbRateError the climbRateError to set 355 | */ 356 | public void setClimbRateError(final double climbRateError) { 357 | this.climbRateError = climbRateError; 358 | } 359 | 360 | /** 361 | * NMEA mode 362 | * 363 | * @return the mode 364 | */ 365 | public ENMEAMode getMode() { 366 | return this.mode; 367 | } 368 | 369 | /** 370 | * NMEA mode 371 | * 372 | * @param mode the mode to set 373 | */ 374 | public void setMode(final ENMEAMode mode) { 375 | this.mode = mode; 376 | } 377 | 378 | @Override 379 | public int hashCode() { 380 | final int prime = 31; 381 | int result = 1; 382 | long temp; 383 | temp = Double.doubleToLongBits(this.altitude); 384 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 385 | temp = Double.doubleToLongBits(this.altitudeError); 386 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 387 | temp = Double.doubleToLongBits(this.climbRate); 388 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 389 | temp = Double.doubleToLongBits(this.climbRateError); 390 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 391 | temp = Double.doubleToLongBits(this.course); 392 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 393 | temp = Double.doubleToLongBits(this.courseError); 394 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 395 | result = (prime * result) + ((this.device == null) ? 0 : this.device.hashCode()); 396 | temp = Double.doubleToLongBits(this.latitude); 397 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 398 | temp = Double.doubleToLongBits(this.latitudeError); 399 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 400 | temp = Double.doubleToLongBits(this.longitude); 401 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 402 | temp = Double.doubleToLongBits(this.longitudeError); 403 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 404 | result = (prime * result) + ((this.mode == null) ? 0 : this.mode.hashCode()); 405 | temp = Double.doubleToLongBits(this.speed); 406 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 407 | temp = Double.doubleToLongBits(this.speedError); 408 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 409 | result = (prime * result) + ((this.tag == null) ? 0 : this.tag.hashCode()); 410 | temp = Double.doubleToLongBits(this.timestamp); 411 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 412 | temp = Double.doubleToLongBits(this.timestampError); 413 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 414 | return result; 415 | } 416 | 417 | @Override 418 | public boolean equals(final Object obj) { 419 | if (this == obj) { 420 | return true; 421 | } 422 | if (obj == null) { 423 | return false; 424 | } 425 | if (this.getClass() != obj.getClass()) { 426 | return false; 427 | } 428 | final TPVObject other = (TPVObject) obj; 429 | if (Double.doubleToLongBits(this.altitude) != Double.doubleToLongBits(other.altitude)) { 430 | return false; 431 | } 432 | if (Double.doubleToLongBits(this.altitudeError) 433 | != Double.doubleToLongBits(other.altitudeError)) { 434 | return false; 435 | } 436 | if (Double.doubleToLongBits(this.climbRate) != Double.doubleToLongBits(other.climbRate)) { 437 | return false; 438 | } 439 | if (Double.doubleToLongBits(this.climbRateError) 440 | != Double.doubleToLongBits(other.climbRateError)) { 441 | return false; 442 | } 443 | if (Double.doubleToLongBits(this.course) != Double.doubleToLongBits(other.course)) { 444 | return false; 445 | } 446 | if (Double.doubleToLongBits(this.courseError) != Double.doubleToLongBits(other.courseError)) { 447 | return false; 448 | } 449 | if (this.device == null) { 450 | if (other.device != null) { 451 | return false; 452 | } 453 | } else if (!this.device.equals(other.device)) { 454 | return false; 455 | } 456 | if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { 457 | return false; 458 | } 459 | if (Double.doubleToLongBits(this.latitudeError) 460 | != Double.doubleToLongBits(other.latitudeError)) { 461 | return false; 462 | } 463 | if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { 464 | return false; 465 | } 466 | if (Double.doubleToLongBits(this.longitudeError) 467 | != Double.doubleToLongBits(other.longitudeError)) { 468 | return false; 469 | } 470 | if (this.mode != other.mode) { 471 | return false; 472 | } 473 | if (Double.doubleToLongBits(this.speed) != Double.doubleToLongBits(other.speed)) { 474 | return false; 475 | } 476 | if (Double.doubleToLongBits(this.speedError) != Double.doubleToLongBits(other.speedError)) { 477 | return false; 478 | } 479 | if (this.tag == null) { 480 | if (other.tag != null) { 481 | return false; 482 | } 483 | } else if (!this.tag.equals(other.tag)) { 484 | return false; 485 | } 486 | if (Double.doubleToLongBits(this.timestamp) != Double.doubleToLongBits(other.timestamp)) { 487 | return false; 488 | } 489 | if (Double.doubleToLongBits(this.timestampError) 490 | != Double.doubleToLongBits(other.timestampError)) { 491 | return false; 492 | } 493 | return true; 494 | } 495 | 496 | @Override 497 | public String toString() { 498 | final StringBuilder sb = new StringBuilder(); 499 | sb.append("TPVObject{tag="); 500 | sb.append(this.tag); 501 | sb.append(", device="); 502 | sb.append(this.device); 503 | sb.append(", timestamp="); 504 | sb.append(this.timestamp); 505 | sb.append(", timestampError="); 506 | sb.append(this.timestampError); 507 | sb.append(", latitude="); 508 | sb.append(this.latitude); 509 | sb.append(", longitude="); 510 | sb.append(this.longitude); 511 | sb.append(", altitude="); 512 | sb.append(this.altitude); 513 | sb.append(", latitudeError="); 514 | sb.append(this.latitudeError); 515 | sb.append(", longitudeError="); 516 | sb.append(this.longitudeError); 517 | sb.append(", altitudeError="); 518 | sb.append(this.altitudeError); 519 | sb.append(", course="); 520 | sb.append(this.course); 521 | sb.append(", speed="); 522 | sb.append(this.speed); 523 | sb.append(", climbRate="); 524 | sb.append(this.climbRate); 525 | sb.append(", courseError="); 526 | sb.append(this.courseError); 527 | sb.append(", speedError="); 528 | sb.append(this.speedError); 529 | sb.append(", climbRateError="); 530 | sb.append(this.climbRateError); 531 | if (mode != null) { 532 | sb.append(", mode="); 533 | sb.append(this.mode.name()); 534 | } 535 | sb.append("}"); 536 | return sb.toString(); 537 | } 538 | } 539 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/ToffObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /** 4 | * This message is emitted on each cycle and reports the offset between the host's clock time and 5 | * the GPS time at top of second (actually, when the first data for the reporting cycle is 6 | * received). This message exactly mirrors the PPS message except for two details. TOFF emits no NTP 7 | * precision, this is assumed to be -2. See the NTP documentation for their definition of precision. 8 | * The TOFF message reports the GPS time as derived from the GPS serial data stream. The PPS message 9 | * reports the GPS time as derived from the GPS PPS pulse. 10 | * 11 | * @author dpishchukhin 12 | */ 13 | public class ToffObject implements IGPSObject { 14 | /** the TOFF internal name */ 15 | public static final String NAME = "TOFF"; 16 | 17 | private String device = null; 18 | 19 | private double realSec = Double.NaN; 20 | 21 | private double realNsec = Double.NaN; 22 | 23 | private double clockSec = Double.NaN; 24 | 25 | private double clockNsec = Double.NaN; 26 | 27 | /** 28 | * Name of originating device 29 | * 30 | * @return device 31 | */ 32 | public String getDevice() { 33 | return device; 34 | } 35 | 36 | /** 37 | * Name of originating device 38 | * 39 | * @param device device 40 | */ 41 | public void setDevice(String device) { 42 | this.device = device; 43 | } 44 | 45 | /** 46 | * seconds from the GPS clock 47 | * 48 | * @return seconds 49 | */ 50 | public double getRealSec() { 51 | return realSec; 52 | } 53 | 54 | /** 55 | * seconds from the GPS clock 56 | * 57 | * @param realSec seconds 58 | */ 59 | public void setRealSec(double realSec) { 60 | this.realSec = realSec; 61 | } 62 | 63 | /** 64 | * nanoseconds from the GPS clock 65 | * 66 | * @return nanoseconds 67 | */ 68 | public double getRealNsec() { 69 | return realNsec; 70 | } 71 | 72 | /** 73 | * nanoseconds from the GPS clock 74 | * 75 | * @param realNsec nanoseconds 76 | */ 77 | public void setRealNsec(double realNsec) { 78 | this.realNsec = realNsec; 79 | } 80 | 81 | /** 82 | * seconds from the system clock 83 | * 84 | * @return seconds 85 | */ 86 | public double getClockSec() { 87 | return clockSec; 88 | } 89 | 90 | /** 91 | * seconds from the system clock 92 | * 93 | * @param clockSec seconds 94 | */ 95 | public void setClockSec(double clockSec) { 96 | this.clockSec = clockSec; 97 | } 98 | 99 | /** 100 | * nanoseconds from the system clock 101 | * 102 | * @return nanoseconds 103 | */ 104 | public double getClockNsec() { 105 | return clockNsec; 106 | } 107 | 108 | /** 109 | * nanoseconds from the system clock 110 | * 111 | * @param clockNsec nanoseconds 112 | */ 113 | public void setClockNsec(double clockNsec) { 114 | this.clockNsec = clockNsec; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/VersionObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * @author thoeger 25 | */ 26 | public class VersionObject implements IGPSObject { 27 | 28 | /** the GPSd internal name */ 29 | public static final String NAME = "VERSION"; 30 | 31 | private String release; 32 | 33 | private String rev; 34 | 35 | private double protocolMajor; 36 | 37 | private double protocolMinor; 38 | 39 | /** 40 | * @return the release 41 | */ 42 | public String getRelease() { 43 | return this.release; 44 | } 45 | 46 | /** 47 | * @param release the release to set 48 | */ 49 | public void setRelease(final String release) { 50 | this.release = release; 51 | } 52 | 53 | /** 54 | * @return the rev 55 | */ 56 | public String getRev() { 57 | return this.rev; 58 | } 59 | 60 | /** 61 | * @param rev the rev to set 62 | */ 63 | public void setRev(final String rev) { 64 | this.rev = rev; 65 | } 66 | 67 | /** 68 | * @return the protocolMajor 69 | */ 70 | public double getProtocolMajor() { 71 | return this.protocolMajor; 72 | } 73 | 74 | /** 75 | * @param protocolMajor the protocolMajor to set 76 | */ 77 | public void setProtocolMajor(final double protocolMajor) { 78 | this.protocolMajor = protocolMajor; 79 | } 80 | 81 | /** 82 | * @return the protocolMinor 83 | */ 84 | public double getProtocolMinor() { 85 | return this.protocolMinor; 86 | } 87 | 88 | /** 89 | * @param protocolMinor the protocolMinor to set 90 | */ 91 | public void setProtocolMinor(final double protocolMinor) { 92 | this.protocolMinor = protocolMinor; 93 | } 94 | 95 | @Override 96 | public int hashCode() { 97 | final int prime = 31; 98 | int result = 1; 99 | long temp; 100 | temp = Double.doubleToLongBits(this.protocolMajor); 101 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 102 | temp = Double.doubleToLongBits(this.protocolMinor); 103 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 104 | result = (prime * result) + ((this.release == null) ? 0 : this.release.hashCode()); 105 | result = (prime * result) + ((this.rev == null) ? 0 : this.rev.hashCode()); 106 | return result; 107 | } 108 | 109 | @Override 110 | public boolean equals(final Object obj) { 111 | if (this == obj) { 112 | return true; 113 | } 114 | if (obj == null) { 115 | return false; 116 | } 117 | if (this.getClass() != obj.getClass()) { 118 | return false; 119 | } 120 | final VersionObject other = (VersionObject) obj; 121 | if (Double.doubleToLongBits(this.protocolMajor) 122 | != Double.doubleToLongBits(other.protocolMajor)) { 123 | return false; 124 | } 125 | if (Double.doubleToLongBits(this.protocolMinor) 126 | != Double.doubleToLongBits(other.protocolMinor)) { 127 | return false; 128 | } 129 | if (this.release == null) { 130 | if (other.release != null) { 131 | return false; 132 | } 133 | } else if (!this.release.equals(other.release)) { 134 | return false; 135 | } 136 | if (this.rev == null) { 137 | if (other.rev != null) { 138 | return false; 139 | } 140 | } else if (!this.rev.equals(other.rev)) { 141 | return false; 142 | } 143 | return true; 144 | } 145 | 146 | @Override 147 | public String toString() { 148 | final StringBuilder sb = new StringBuilder(); 149 | 150 | sb.append("VersionObject{release="); 151 | sb.append(this.release); 152 | sb.append(", rev="); 153 | sb.append(this.rev); 154 | sb.append(", protocolMajor="); 155 | sb.append(this.protocolMajor); 156 | sb.append(", protocolMinor="); 157 | sb.append(this.protocolMinor); 158 | sb.append("}"); 159 | return sb.toString(); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/WatchObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * @author thoeger 25 | */ 26 | public class WatchObject implements IGPSObject { 27 | 28 | /** the GPSd internal name */ 29 | public static final String NAME = "WATCH"; 30 | 31 | private boolean enable = true; 32 | 33 | private boolean dump = false; 34 | 35 | /** 36 | * Enable (true) or disable (false) watcher mode. Default is true. 37 | * 38 | * @return the enable 39 | */ 40 | public boolean isEnable() { 41 | return this.enable; 42 | } 43 | 44 | /** 45 | * Enable (true) or disable (false) watcher mode. Default is true. 46 | * 47 | * @param enable the enable to set 48 | */ 49 | public void setEnable(final boolean enable) { 50 | this.enable = enable; 51 | } 52 | 53 | /** 54 | * Enable (true) or disable (false) dumping of JSON reports. Default is false. 55 | * 56 | * @return the json 57 | */ 58 | public boolean isDump() { 59 | return this.dump; 60 | } 61 | 62 | /** 63 | * Enable (true) or disable (false) dumping of JSON reports. Default is false. 64 | * 65 | * @param dump the dump to set 66 | */ 67 | public void setDump(final boolean dump) { 68 | this.dump = dump; 69 | } 70 | 71 | @Override 72 | public int hashCode() { 73 | final int prime = 31; 74 | int result = 1; 75 | result = (prime * result) + (this.dump ? 1231 : 1237); 76 | result = (prime * result) + (this.enable ? 1231 : 1237); 77 | return result; 78 | } 79 | 80 | @Override 81 | public boolean equals(final Object obj) { 82 | if (this == obj) { 83 | return true; 84 | } 85 | if (obj == null) { 86 | return false; 87 | } 88 | if (this.getClass() != obj.getClass()) { 89 | return false; 90 | } 91 | final WatchObject other = (WatchObject) obj; 92 | if (this.dump != other.dump) { 93 | return false; 94 | } 95 | if (this.enable != other.enable) { 96 | return false; 97 | } 98 | return true; 99 | } 100 | 101 | @Override 102 | public String toString() { 103 | return "WatchObject{enable=" + this.enable + ", dump=" + this.dump + "}"; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/ALMANACObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | 25 | /** 26 | * @author aevdokimov 27 | */ 28 | public class ALMANACObject implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "ALMANAC"; 32 | 33 | private int ID = -1; 34 | 35 | private int Health = -1; 36 | 37 | private double e = Double.NaN; 38 | 39 | private int toa = -1; 40 | 41 | private double deltai = Double.NaN; 42 | 43 | private double Omegad = Double.NaN; 44 | 45 | private double sqrtA = Double.NaN; 46 | 47 | private double Omega0 = Double.NaN; 48 | 49 | private double omega = Double.NaN; 50 | 51 | private double M0 = Double.NaN; 52 | 53 | private double af0 = Double.NaN; 54 | 55 | private double af1 = Double.NaN; 56 | 57 | /** 58 | * @return the iD 59 | */ 60 | public int getID() { 61 | return this.ID; 62 | } 63 | 64 | /** 65 | * @param iD the iD to set 66 | */ 67 | public void setID(final int iD) { 68 | this.ID = iD; 69 | } 70 | 71 | /** 72 | * @return the health 73 | */ 74 | public int getHealth() { 75 | return this.Health; 76 | } 77 | 78 | /** 79 | * @param health the health to set 80 | */ 81 | public void setHealth(final int health) { 82 | this.Health = health; 83 | } 84 | 85 | /** 86 | * @return the e 87 | */ 88 | public double getE() { 89 | return this.e; 90 | } 91 | 92 | /** 93 | * @param e the e to set 94 | */ 95 | public void setE(final double e) { 96 | this.e = e; 97 | } 98 | 99 | /** 100 | * @return the toa 101 | */ 102 | public int getToa() { 103 | return this.toa; 104 | } 105 | 106 | /** 107 | * @param toa the toa to set 108 | */ 109 | public void setToa(final int toa) { 110 | this.toa = toa; 111 | } 112 | 113 | /** 114 | * @return the deltai 115 | */ 116 | public double getDeltai() { 117 | return this.deltai; 118 | } 119 | 120 | /** 121 | * @param deltai the deltai to set 122 | */ 123 | public void setDeltai(final double deltai) { 124 | this.deltai = deltai; 125 | } 126 | 127 | /** 128 | * @return the omegad 129 | */ 130 | public double getOmegad() { 131 | return this.Omegad; 132 | } 133 | 134 | /** 135 | * @param omegad the omegad to set 136 | */ 137 | public void setOmegad(final double omegad) { 138 | this.Omegad = omegad; 139 | } 140 | 141 | /** 142 | * @return the sqrtA 143 | */ 144 | public double getSqrtA() { 145 | return this.sqrtA; 146 | } 147 | 148 | /** 149 | * @param sqrtA the sqrtA to set 150 | */ 151 | public void setSqrtA(final double sqrtA) { 152 | this.sqrtA = sqrtA; 153 | } 154 | 155 | /** 156 | * @return the omega0 157 | */ 158 | public double getOmega0() { 159 | return this.Omega0; 160 | } 161 | 162 | /** 163 | * @param omega0 the omega0 to set 164 | */ 165 | public void setOmega0(final double omega0) { 166 | this.Omega0 = omega0; 167 | } 168 | 169 | /** 170 | * @return the omega 171 | */ 172 | public double getOmega() { 173 | return this.omega; 174 | } 175 | 176 | /** 177 | * @param omega the omega to set 178 | */ 179 | public void setOmega(final double omega) { 180 | this.omega = omega; 181 | } 182 | 183 | /** 184 | * @return the m0 185 | */ 186 | public double getM0() { 187 | return this.M0; 188 | } 189 | 190 | /** 191 | * @param m0 the m0 to set 192 | */ 193 | public void setM0(final double m0) { 194 | this.M0 = m0; 195 | } 196 | 197 | /** 198 | * @return the af0 199 | */ 200 | public double getAf0() { 201 | return this.af0; 202 | } 203 | 204 | /** 205 | * @param af0 the af0 to set 206 | */ 207 | public void setAf0(final double af0) { 208 | this.af0 = af0; 209 | } 210 | 211 | /** 212 | * @return the af1 213 | */ 214 | public double getAf1() { 215 | return this.af1; 216 | } 217 | 218 | /** 219 | * @param af1 the af1 to set 220 | */ 221 | public void setAf1(final double af1) { 222 | this.af1 = af1; 223 | } 224 | 225 | @Override 226 | public boolean equals(final Object o) { 227 | if (this == o) { 228 | return true; 229 | } 230 | if (!(o instanceof ALMANACObject)) { 231 | return false; 232 | } 233 | 234 | final ALMANACObject that = (ALMANACObject) o; 235 | 236 | if (this.Health != that.Health) { 237 | return false; 238 | } 239 | if (this.ID != that.ID) { 240 | return false; 241 | } 242 | if (Double.compare(that.M0, this.M0) != 0) { 243 | return false; 244 | } 245 | if (Double.compare(that.Omega0, this.Omega0) != 0) { 246 | return false; 247 | } 248 | if (Double.compare(that.Omegad, this.Omegad) != 0) { 249 | return false; 250 | } 251 | if (Double.compare(that.af0, this.af0) != 0) { 252 | return false; 253 | } 254 | if (Double.compare(that.af1, this.af1) != 0) { 255 | return false; 256 | } 257 | if (Double.compare(that.deltai, this.deltai) != 0) { 258 | return false; 259 | } 260 | if (Double.compare(that.e, this.e) != 0) { 261 | return false; 262 | } 263 | if (Double.compare(that.omega, this.omega) != 0) { 264 | return false; 265 | } 266 | if (Double.compare(that.sqrtA, this.sqrtA) != 0) { 267 | return false; 268 | } 269 | if (this.toa != that.toa) { 270 | return false; 271 | } 272 | 273 | return true; 274 | } 275 | 276 | @Override 277 | public int hashCode() { 278 | int result; 279 | long temp; 280 | result = this.ID; 281 | result = (31 * result) + this.Health; 282 | temp = this.e != +0.0d ? Double.doubleToLongBits(this.e) : 0L; 283 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 284 | result = (31 * result) + this.toa; 285 | temp = this.deltai != +0.0d ? Double.doubleToLongBits(this.deltai) : 0L; 286 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 287 | temp = this.Omegad != +0.0d ? Double.doubleToLongBits(this.Omegad) : 0L; 288 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 289 | temp = this.sqrtA != +0.0d ? Double.doubleToLongBits(this.sqrtA) : 0L; 290 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 291 | temp = this.Omega0 != +0.0d ? Double.doubleToLongBits(this.Omega0) : 0L; 292 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 293 | temp = this.omega != +0.0d ? Double.doubleToLongBits(this.omega) : 0L; 294 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 295 | temp = this.M0 != +0.0d ? Double.doubleToLongBits(this.M0) : 0L; 296 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 297 | temp = this.af0 != +0.0d ? Double.doubleToLongBits(this.af0) : 0L; 298 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 299 | temp = this.af1 != +0.0d ? Double.doubleToLongBits(this.af1) : 0L; 300 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 301 | return result; 302 | } 303 | 304 | @Override 305 | public String toString() { 306 | final StringBuilder sb = new StringBuilder(); 307 | sb.append("ALMANACObject{ID="); 308 | sb.append(this.ID); 309 | sb.append(", Health="); 310 | sb.append(this.Health); 311 | sb.append(", e="); 312 | sb.append(this.e); 313 | sb.append(", toa="); 314 | sb.append(this.toa); 315 | sb.append(", deltai="); 316 | sb.append(this.deltai); 317 | sb.append(", Omegad="); 318 | sb.append(this.Omegad); 319 | sb.append(", sqrtA="); 320 | sb.append(this.sqrtA); 321 | sb.append(", Omega0="); 322 | sb.append(this.Omega0); 323 | sb.append(", omega="); 324 | sb.append(this.omega); 325 | sb.append(", M0="); 326 | sb.append(this.M0); 327 | sb.append(", af0="); 328 | sb.append(this.af0); 329 | sb.append(", af1="); 330 | sb.append(this.af1); 331 | sb.append("}"); 332 | return sb.toString(); 333 | } 334 | } 335 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM1Object.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | 25 | /** 26 | * @author aevdokimov 27 | */ 28 | public class EPHEM1Object implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "EPHEM1"; 32 | 33 | private int WN = -1; 34 | 35 | private int IODC = -1; 36 | 37 | private int L2 = -1; 38 | 39 | private double ura = Double.NaN; 40 | 41 | private double hlth = Double.NaN; 42 | 43 | private int L2P = -1; 44 | 45 | private double Tgd = Double.NaN; 46 | 47 | private int toc = -1; 48 | 49 | private double af2 = Double.NaN; 50 | 51 | private double af1 = Double.NaN; 52 | 53 | private double af0 = Double.NaN; 54 | 55 | /** 56 | * @return the wN 57 | */ 58 | public int getWN() { 59 | return this.WN; 60 | } 61 | 62 | /** 63 | * @param wN the wN to set 64 | */ 65 | public void setWN(final int wN) { 66 | this.WN = wN; 67 | } 68 | 69 | /** 70 | * @return the iODC 71 | */ 72 | public int getIODC() { 73 | return this.IODC; 74 | } 75 | 76 | /** 77 | * @param iODC the iODC to set 78 | */ 79 | public void setIODC(final int iODC) { 80 | this.IODC = iODC; 81 | } 82 | 83 | /** 84 | * @return the l2 85 | */ 86 | public int getL2() { 87 | return this.L2; 88 | } 89 | 90 | /** 91 | * @param l2 the l2 to set 92 | */ 93 | public void setL2(final int l2) { 94 | this.L2 = l2; 95 | } 96 | 97 | /** 98 | * @return the ura 99 | */ 100 | public double getUra() { 101 | return this.ura; 102 | } 103 | 104 | /** 105 | * @param ura the ura to set 106 | */ 107 | public void setUra(final double ura) { 108 | this.ura = ura; 109 | } 110 | 111 | /** 112 | * @return the hlth 113 | */ 114 | public double getHlth() { 115 | return this.hlth; 116 | } 117 | 118 | /** 119 | * @param hlth the hlth to set 120 | */ 121 | public void setHlth(final double hlth) { 122 | this.hlth = hlth; 123 | } 124 | 125 | /** 126 | * @return the l2P 127 | */ 128 | public int getL2P() { 129 | return this.L2P; 130 | } 131 | 132 | /** 133 | * @param l2p the l2P to set 134 | */ 135 | public void setL2P(final int l2p) { 136 | this.L2P = l2p; 137 | } 138 | 139 | /** 140 | * @return the tgd 141 | */ 142 | public double getTgd() { 143 | return this.Tgd; 144 | } 145 | 146 | /** 147 | * @param tgd the tgd to set 148 | */ 149 | public void setTgd(final double tgd) { 150 | this.Tgd = tgd; 151 | } 152 | 153 | /** 154 | * @return the toc 155 | */ 156 | public int getToc() { 157 | return this.toc; 158 | } 159 | 160 | /** 161 | * @param toc the toc to set 162 | */ 163 | public void setToc(final int toc) { 164 | this.toc = toc; 165 | } 166 | 167 | /** 168 | * @return the af2 169 | */ 170 | public double getAf2() { 171 | return this.af2; 172 | } 173 | 174 | /** 175 | * @param af2 the af2 to set 176 | */ 177 | public void setAf2(final double af2) { 178 | this.af2 = af2; 179 | } 180 | 181 | /** 182 | * @return the af1 183 | */ 184 | public double getAf1() { 185 | return this.af1; 186 | } 187 | 188 | /** 189 | * @param af1 the af1 to set 190 | */ 191 | public void setAf1(final double af1) { 192 | this.af1 = af1; 193 | } 194 | 195 | /** 196 | * @return the af0 197 | */ 198 | public double getAf0() { 199 | return this.af0; 200 | } 201 | 202 | /** 203 | * @param af0 the af0 to set 204 | */ 205 | public void setAf0(final double af0) { 206 | this.af0 = af0; 207 | } 208 | 209 | @Override 210 | public boolean equals(final Object o) { 211 | if (this == o) { 212 | return true; 213 | } 214 | if ((o == null) || (this.getClass() != o.getClass())) { 215 | return false; 216 | } 217 | 218 | final EPHEM1Object that = (EPHEM1Object) o; 219 | 220 | if (this.IODC != that.IODC) { 221 | return false; 222 | } 223 | if (this.L2 != that.L2) { 224 | return false; 225 | } 226 | if (this.L2P != that.L2P) { 227 | return false; 228 | } 229 | if (Double.compare(that.Tgd, this.Tgd) != 0) { 230 | return false; 231 | } 232 | if (this.WN != that.WN) { 233 | return false; 234 | } 235 | if (Double.compare(that.af0, this.af0) != 0) { 236 | return false; 237 | } 238 | if (Double.compare(that.af1, this.af1) != 0) { 239 | return false; 240 | } 241 | if (Double.compare(that.af2, this.af2) != 0) { 242 | return false; 243 | } 244 | if (Double.compare(that.hlth, this.hlth) != 0) { 245 | return false; 246 | } 247 | if (this.toc != that.toc) { 248 | return false; 249 | } 250 | if (Double.compare(that.ura, this.ura) != 0) { 251 | return false; 252 | } 253 | 254 | return true; 255 | } 256 | 257 | @Override 258 | public int hashCode() { 259 | int result; 260 | long temp; 261 | result = this.WN; 262 | result = (31 * result) + this.IODC; 263 | result = (31 * result) + this.L2; 264 | temp = this.ura != +0.0d ? Double.doubleToLongBits(this.ura) : 0L; 265 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 266 | temp = this.hlth != +0.0d ? Double.doubleToLongBits(this.hlth) : 0L; 267 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 268 | result = (31 * result) + this.L2P; 269 | temp = this.Tgd != +0.0d ? Double.doubleToLongBits(this.Tgd) : 0L; 270 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 271 | result = (31 * result) + this.toc; 272 | temp = this.af2 != +0.0d ? Double.doubleToLongBits(this.af2) : 0L; 273 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 274 | temp = this.af1 != +0.0d ? Double.doubleToLongBits(this.af1) : 0L; 275 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 276 | temp = this.af0 != +0.0d ? Double.doubleToLongBits(this.af0) : 0L; 277 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 278 | return result; 279 | } 280 | 281 | @Override 282 | public String toString() { 283 | final StringBuilder sb = new StringBuilder(); 284 | sb.append("EPHEM1Object{WN="); 285 | sb.append(this.WN); 286 | sb.append(", IODC="); 287 | sb.append(this.IODC); 288 | sb.append(", ura="); 289 | sb.append(this.ura); 290 | sb.append(", L2="); 291 | sb.append(this.L2); 292 | sb.append(", hlth="); 293 | sb.append(this.hlth); 294 | sb.append(", L2P="); 295 | sb.append(this.L2P); 296 | sb.append(", Tgd="); 297 | sb.append(this.Tgd); 298 | sb.append(", toc="); 299 | sb.append(this.toc); 300 | sb.append(", af2="); 301 | sb.append(this.af2); 302 | sb.append(", af0="); 303 | sb.append(this.af0); 304 | sb.append(", af1="); 305 | sb.append(this.af1); 306 | sb.append("}"); 307 | return sb.toString(); 308 | } 309 | } 310 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM2Object.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | 25 | /** 26 | * @author aevdokimov 27 | */ 28 | public class EPHEM2Object implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "EPHEM2"; 32 | 33 | private int IODE = -1; 34 | 35 | private double Crs = Double.NaN; 36 | 37 | private double deltan = Double.NaN; 38 | 39 | private double M0 = Double.NaN; 40 | 41 | private double Cuc = Double.NaN; 42 | 43 | private double e = Double.NaN; 44 | 45 | private double Cus = Double.NaN; 46 | 47 | private double sqrtA = Double.NaN; 48 | 49 | private int toe = -1; 50 | 51 | private int FIT = -1; 52 | 53 | private int AODO = -1; 54 | 55 | /** 56 | * @return the iODE 57 | */ 58 | public int getIODE() { 59 | return this.IODE; 60 | } 61 | 62 | /** 63 | * @param iODE the iODE to set 64 | */ 65 | public void setIODE(final int iODE) { 66 | this.IODE = iODE; 67 | } 68 | 69 | /** 70 | * @return the crs 71 | */ 72 | public double getCrs() { 73 | return this.Crs; 74 | } 75 | 76 | /** 77 | * @param crs the crs to set 78 | */ 79 | public void setCrs(final double crs) { 80 | this.Crs = crs; 81 | } 82 | 83 | /** 84 | * @return the deltan 85 | */ 86 | public double getDeltan() { 87 | return this.deltan; 88 | } 89 | 90 | /** 91 | * @param deltan the deltan to set 92 | */ 93 | public void setDeltan(final double deltan) { 94 | this.deltan = deltan; 95 | } 96 | 97 | /** 98 | * @return the m0 99 | */ 100 | public double getM0() { 101 | return this.M0; 102 | } 103 | 104 | /** 105 | * @param m0 the m0 to set 106 | */ 107 | public void setM0(final double m0) { 108 | this.M0 = m0; 109 | } 110 | 111 | /** 112 | * @return the cuc 113 | */ 114 | public double getCuc() { 115 | return this.Cuc; 116 | } 117 | 118 | /** 119 | * @param cuc the cuc to set 120 | */ 121 | public void setCuc(final double cuc) { 122 | this.Cuc = cuc; 123 | } 124 | 125 | /** 126 | * @return the e 127 | */ 128 | public double getE() { 129 | return this.e; 130 | } 131 | 132 | /** 133 | * @param e the e to set 134 | */ 135 | public void setE(final double e) { 136 | this.e = e; 137 | } 138 | 139 | /** 140 | * @return the cus 141 | */ 142 | public double getCus() { 143 | return this.Cus; 144 | } 145 | 146 | /** 147 | * @param cus the cus to set 148 | */ 149 | public void setCus(final double cus) { 150 | this.Cus = cus; 151 | } 152 | 153 | /** 154 | * @return the sqrtA 155 | */ 156 | public double getSqrtA() { 157 | return this.sqrtA; 158 | } 159 | 160 | /** 161 | * @param sqrtA the sqrtA to set 162 | */ 163 | public void setSqrtA(final double sqrtA) { 164 | this.sqrtA = sqrtA; 165 | } 166 | 167 | /** 168 | * @return the toe 169 | */ 170 | public int getToe() { 171 | return this.toe; 172 | } 173 | 174 | /** 175 | * @param toe the toe to set 176 | */ 177 | public void setToe(final int toe) { 178 | this.toe = toe; 179 | } 180 | 181 | /** 182 | * @return the fIT 183 | */ 184 | public int getFIT() { 185 | return this.FIT; 186 | } 187 | 188 | /** 189 | * @param fIT the fIT to set 190 | */ 191 | public void setFIT(final int fIT) { 192 | this.FIT = fIT; 193 | } 194 | 195 | /** 196 | * @return the aODO 197 | */ 198 | public int getAODO() { 199 | return this.AODO; 200 | } 201 | 202 | /** 203 | * @param aODO the aODO to set 204 | */ 205 | public void setAODO(final int aODO) { 206 | this.AODO = aODO; 207 | } 208 | 209 | @Override 210 | public boolean equals(final Object o) { 211 | if (this == o) { 212 | return true; 213 | } 214 | if ((o == null) || (this.getClass() != o.getClass())) { 215 | return false; 216 | } 217 | 218 | final EPHEM2Object that = (EPHEM2Object) o; 219 | 220 | if (this.AODO != that.AODO) { 221 | return false; 222 | } 223 | if (Double.compare(that.Crs, this.Crs) != 0) { 224 | return false; 225 | } 226 | if (Double.compare(that.Cuc, this.Cuc) != 0) { 227 | return false; 228 | } 229 | if (Double.compare(that.Cus, this.Cus) != 0) { 230 | return false; 231 | } 232 | if (this.FIT != that.FIT) { 233 | return false; 234 | } 235 | if (this.IODE != that.IODE) { 236 | return false; 237 | } 238 | if (Double.compare(that.M0, this.M0) != 0) { 239 | return false; 240 | } 241 | if (Double.compare(that.deltan, this.deltan) != 0) { 242 | return false; 243 | } 244 | if (Double.compare(that.e, this.e) != 0) { 245 | return false; 246 | } 247 | if (Double.compare(that.sqrtA, this.sqrtA) != 0) { 248 | return false; 249 | } 250 | if (this.toe != that.toe) { 251 | return false; 252 | } 253 | 254 | return true; 255 | } 256 | 257 | @Override 258 | public int hashCode() { 259 | int result; 260 | long temp; 261 | result = this.IODE; 262 | temp = this.Crs != +0.0d ? Double.doubleToLongBits(this.Crs) : 0L; 263 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 264 | temp = this.deltan != +0.0d ? Double.doubleToLongBits(this.deltan) : 0L; 265 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 266 | temp = this.M0 != +0.0d ? Double.doubleToLongBits(this.M0) : 0L; 267 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 268 | temp = this.Cuc != +0.0d ? Double.doubleToLongBits(this.Cuc) : 0L; 269 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 270 | temp = this.e != +0.0d ? Double.doubleToLongBits(this.e) : 0L; 271 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 272 | temp = this.Cus != +0.0d ? Double.doubleToLongBits(this.Cus) : 0L; 273 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 274 | temp = this.sqrtA != +0.0d ? Double.doubleToLongBits(this.sqrtA) : 0L; 275 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 276 | result = (31 * result) + this.toe; 277 | result = (31 * result) + this.FIT; 278 | result = (31 * result) + this.AODO; 279 | return result; 280 | } 281 | 282 | @Override 283 | public String toString() { 284 | final StringBuilder sb = new StringBuilder(); 285 | sb.append("EPHEM2Object{IODE="); 286 | sb.append(this.IODE); 287 | sb.append(", Crs="); 288 | sb.append(this.Crs); 289 | sb.append(", deltan="); 290 | sb.append(this.deltan); 291 | sb.append(", M0="); 292 | sb.append(this.M0); 293 | sb.append(", Cuc="); 294 | sb.append(this.Cuc); 295 | sb.append(", e="); 296 | sb.append(this.e); 297 | sb.append(", Cus="); 298 | sb.append(this.Cus); 299 | sb.append(", sqrtA="); 300 | sb.append(this.sqrtA); 301 | sb.append(", toe="); 302 | sb.append(this.toe); 303 | sb.append(", FIT="); 304 | sb.append(this.FIT); 305 | sb.append(", AODO="); 306 | sb.append(this.AODO); 307 | sb.append("}"); 308 | return sb.toString(); 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/EPHEM3Object.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | 25 | /** 26 | * @author aevdokimov 27 | */ 28 | public class EPHEM3Object implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "EPHEM3"; 32 | 33 | private int IODE = -1; 34 | 35 | private double IDOT = Double.NaN; 36 | 37 | private double Cic = Double.NaN; 38 | 39 | private double Omega0 = Double.NaN; 40 | 41 | private double Cis = Double.NaN; 42 | 43 | private double i0 = Double.NaN; 44 | 45 | private double Crc = Double.NaN; 46 | 47 | private double omega = Double.NaN; 48 | 49 | private double Omegad = Double.NaN; 50 | 51 | /** 52 | * @return the iODE 53 | */ 54 | public int getIODE() { 55 | return this.IODE; 56 | } 57 | 58 | /** 59 | * @param iODE the iODE to set 60 | */ 61 | public void setIODE(final int iODE) { 62 | this.IODE = iODE; 63 | } 64 | 65 | /** 66 | * @return the iDOT 67 | */ 68 | public double getIDOT() { 69 | return this.IDOT; 70 | } 71 | 72 | /** 73 | * @param iDOT the iDOT to set 74 | */ 75 | public void setIDOT(final double iDOT) { 76 | this.IDOT = iDOT; 77 | } 78 | 79 | /** 80 | * @return the cic 81 | */ 82 | public double getCic() { 83 | return this.Cic; 84 | } 85 | 86 | /** 87 | * @param cic the cic to set 88 | */ 89 | public void setCic(final double cic) { 90 | this.Cic = cic; 91 | } 92 | 93 | /** 94 | * @return the omega0 95 | */ 96 | public double getOmega0() { 97 | return this.Omega0; 98 | } 99 | 100 | /** 101 | * @param omega0 the omega0 to set 102 | */ 103 | public void setOmega0(final double omega0) { 104 | this.Omega0 = omega0; 105 | } 106 | 107 | /** 108 | * @return the cis 109 | */ 110 | public double getCis() { 111 | return this.Cis; 112 | } 113 | 114 | /** 115 | * @param cis the cis to set 116 | */ 117 | public void setCis(final double cis) { 118 | this.Cis = cis; 119 | } 120 | 121 | /** 122 | * @return the i0 123 | */ 124 | public double getI0() { 125 | return this.i0; 126 | } 127 | 128 | /** 129 | * @param i0 the i0 to set 130 | */ 131 | public void setI0(final double i0) { 132 | this.i0 = i0; 133 | } 134 | 135 | /** 136 | * @return the crc 137 | */ 138 | public double getCrc() { 139 | return this.Crc; 140 | } 141 | 142 | /** 143 | * @param crc the crc to set 144 | */ 145 | public void setCrc(final double crc) { 146 | this.Crc = crc; 147 | } 148 | 149 | /** 150 | * @return the omega 151 | */ 152 | public double getOmega() { 153 | return this.omega; 154 | } 155 | 156 | /** 157 | * @param omega the omega to set 158 | */ 159 | public void setOmega(final double omega) { 160 | this.omega = omega; 161 | } 162 | 163 | /** 164 | * @return the omegad 165 | */ 166 | public double getOmegad() { 167 | return this.Omegad; 168 | } 169 | 170 | /** 171 | * @param omegad the omegad to set 172 | */ 173 | public void setOmegad(final double omegad) { 174 | this.Omegad = omegad; 175 | } 176 | 177 | @Override 178 | public boolean equals(final Object o) { 179 | if (this == o) { 180 | return true; 181 | } 182 | if (!(o instanceof EPHEM3Object)) { 183 | return false; 184 | } 185 | 186 | final EPHEM3Object that = (EPHEM3Object) o; 187 | 188 | if (Double.compare(that.Cic, this.Cic) != 0) { 189 | return false; 190 | } 191 | if (Double.compare(that.Cis, this.Cis) != 0) { 192 | return false; 193 | } 194 | if (Double.compare(that.Crc, this.Crc) != 0) { 195 | return false; 196 | } 197 | if (Double.compare(that.IDOT, this.IDOT) != 0) { 198 | return false; 199 | } 200 | if (this.IODE != that.IODE) { 201 | return false; 202 | } 203 | if (Double.compare(that.Omega0, this.Omega0) != 0) { 204 | return false; 205 | } 206 | if (Double.compare(that.Omegad, this.Omegad) != 0) { 207 | return false; 208 | } 209 | if (Double.compare(that.i0, this.i0) != 0) { 210 | return false; 211 | } 212 | if (Double.compare(that.omega, this.omega) != 0) { 213 | return false; 214 | } 215 | 216 | return true; 217 | } 218 | 219 | @Override 220 | public int hashCode() { 221 | int result; 222 | long temp; 223 | result = this.IODE; 224 | temp = this.IDOT != +0.0d ? Double.doubleToLongBits(this.IDOT) : 0L; 225 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 226 | temp = this.Cic != +0.0d ? Double.doubleToLongBits(this.Cic) : 0L; 227 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 228 | temp = this.Omega0 != +0.0d ? Double.doubleToLongBits(this.Omega0) : 0L; 229 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 230 | temp = this.Cis != +0.0d ? Double.doubleToLongBits(this.Cis) : 0L; 231 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 232 | temp = this.i0 != +0.0d ? Double.doubleToLongBits(this.i0) : 0L; 233 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 234 | temp = this.Crc != +0.0d ? Double.doubleToLongBits(this.Crc) : 0L; 235 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 236 | temp = this.omega != +0.0d ? Double.doubleToLongBits(this.omega) : 0L; 237 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 238 | temp = this.Omegad != +0.0d ? Double.doubleToLongBits(this.Omegad) : 0L; 239 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 240 | return result; 241 | } 242 | 243 | @Override 244 | public String toString() { 245 | final StringBuilder sb = new StringBuilder(); 246 | sb.append("EPHEM3Object{IODE="); 247 | sb.append(this.IODE); 248 | sb.append(", IDOT="); 249 | sb.append(this.IDOT); 250 | sb.append(", Cic="); 251 | sb.append(this.Cic); 252 | sb.append(", Omega0="); 253 | sb.append(this.Omega0); 254 | sb.append(", Cis="); 255 | sb.append(this.Cis); 256 | sb.append(", i0="); 257 | sb.append(this.i0); 258 | sb.append(", Crc="); 259 | sb.append(this.Crc); 260 | sb.append(", omega="); 261 | sb.append(this.omega); 262 | sb.append(", Omegad="); 263 | sb.append(this.Omegad); 264 | sb.append("}"); 265 | return sb.toString(); 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/ERDObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | import java.util.Arrays; 25 | 26 | /** 27 | * @author aevdokimov 28 | */ 29 | public class ERDObject implements IGPSObject { 30 | 31 | /** the GPSd internal name */ 32 | public static final String NAME = "ERD"; 33 | 34 | private int[] ERD = new int[30]; 35 | 36 | private int ai = -1; 37 | 38 | /** 39 | * @return the eRD 40 | */ 41 | public int[] getERD() { 42 | return this.ERD; 43 | } 44 | 45 | /** 46 | * @param eRD the eRD to set 47 | */ 48 | public void setERD(final int[] eRD) { 49 | this.ERD = eRD; 50 | } 51 | 52 | /** 53 | * @return the ai 54 | */ 55 | public int getAi() { 56 | return this.ai; 57 | } 58 | 59 | /** 60 | * @param ai the ai to set 61 | */ 62 | public void setAi(final int ai) { 63 | this.ai = ai; 64 | } 65 | 66 | /** 67 | * @param index 68 | * @return the ERD 69 | */ 70 | public int getERDbyIndex(final int index) { 71 | return this.ERD[index]; 72 | } 73 | 74 | /** 75 | * @param index the index 76 | * @param ERDvalue the ERD 77 | */ 78 | public void setERDbyIndex(final int index, final int ERDvalue) { 79 | this.ERD[index] = ERDvalue; 80 | } 81 | 82 | @Override 83 | public boolean equals(final Object o) { 84 | if (this == o) { 85 | return true; 86 | } 87 | if (!(o instanceof ERDObject)) { 88 | return false; 89 | } 90 | 91 | final ERDObject erdObject = (ERDObject) o; 92 | 93 | if (this.ai != erdObject.ai) { 94 | return false; 95 | } 96 | if (!Arrays.equals(this.ERD, erdObject.ERD)) { 97 | return false; 98 | } 99 | 100 | return true; 101 | } 102 | 103 | @Override 104 | public int hashCode() { 105 | int result = this.ERD != null ? Arrays.hashCode(this.ERD) : 0; 106 | result = (31 * result) + this.ai; 107 | return result; 108 | } 109 | 110 | @Override 111 | public String toString() { 112 | final StringBuilder sb = new StringBuilder(); 113 | sb.append("ERDObject{ai="); 114 | sb.append(this.ai); 115 | for (int index = 1; index <= 30; index++) { 116 | sb.append(", ERD"); 117 | sb.append(index); 118 | sb.append("="); 119 | sb.append(this.ERD[index - 1]); 120 | } 121 | sb.append("}"); 122 | return sb.toString(); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/HEALTH2Object.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | import java.util.Arrays; 25 | 26 | /** 27 | * @author aevdokimov 28 | */ 29 | public class HEALTH2Object implements IGPSObject { 30 | 31 | /** the GPSd internal name */ 32 | public static final String NAME = "HEALTH2"; 33 | 34 | private final int[] SV = new int[24]; 35 | 36 | private int toa = -1; 37 | 38 | private int WNa = -1; 39 | 40 | /** 41 | * @return the toa 42 | */ 43 | public int getToa() { 44 | return this.toa; 45 | } 46 | 47 | /** 48 | * @param toa the toa to set 49 | */ 50 | public void setToa(final int toa) { 51 | this.toa = toa; 52 | } 53 | 54 | /** 55 | * @return the wNa 56 | */ 57 | public int getWNa() { 58 | return this.WNa; 59 | } 60 | 61 | /** 62 | * @param wNa the wNa to set 63 | */ 64 | public void setWNa(final int wNa) { 65 | this.WNa = wNa; 66 | } 67 | 68 | /** 69 | * @param index the index 70 | * @return the SV 71 | */ 72 | public int getSVbyIndex(final int index) { 73 | return this.SV[index]; 74 | } 75 | 76 | /** 77 | * @param index the index 78 | * @param SVvalue the SV 79 | */ 80 | public void setSVbyIndex(final int index, final int SVvalue) { 81 | this.SV[index] = SVvalue; 82 | } 83 | 84 | @Override 85 | public boolean equals(final Object o) { 86 | if (this == o) { 87 | return true; 88 | } 89 | if (!(o instanceof HEALTH2Object)) { 90 | return false; 91 | } 92 | 93 | final HEALTH2Object that = (HEALTH2Object) o; 94 | 95 | if (this.WNa != that.WNa) { 96 | return false; 97 | } 98 | if (this.toa != that.toa) { 99 | return false; 100 | } 101 | if (!Arrays.equals(this.SV, that.SV)) { 102 | return false; 103 | } 104 | 105 | return true; 106 | } 107 | 108 | @Override 109 | public int hashCode() { 110 | int result = this.SV != null ? Arrays.hashCode(this.SV) : 0; 111 | result = (31 * result) + this.toa; 112 | result = (31 * result) + this.WNa; 113 | return result; 114 | } 115 | 116 | @Override 117 | public String toString() { 118 | final StringBuilder sb = new StringBuilder(); 119 | sb.append("HEALTH2Object{toa="); 120 | sb.append(this.toa); 121 | sb.append(", WNa="); 122 | sb.append(this.WNa); 123 | for (int index = 1; index <= 24; index++) { 124 | sb.append(", SV"); 125 | sb.append(index); 126 | sb.append("="); 127 | sb.append(this.SV[index - 1]); 128 | } 129 | sb.append("}"); 130 | return sb.toString(); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/HEALTHObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | import java.util.Arrays; 25 | 26 | /** 27 | * @author aevdokimov 28 | */ 29 | public class HEALTHObject implements IGPSObject { 30 | 31 | /** the GPSd internal name */ 32 | public static final String NAME = "HEALTH"; 33 | 34 | private final int[] SV = new int[32]; 35 | 36 | private final int[] SVH = new int[8]; 37 | 38 | private int data_id = -1; 39 | 40 | /** 41 | * @return the data_id 42 | */ 43 | public int getData_id() { 44 | return this.data_id; 45 | } 46 | 47 | /** 48 | * @param data_id the data_id to set 49 | */ 50 | public void setData_id(final int data_id) { 51 | this.data_id = data_id; 52 | } 53 | 54 | /** 55 | * @param index the index 56 | * @return the SV 57 | */ 58 | public int getSVbyIndex(final int index) { 59 | return this.SV[index]; 60 | } 61 | 62 | /** 63 | * @param index the index 64 | * @param SVvalue the SV 65 | */ 66 | public void setSVbyIndex(final int index, final int SVvalue) { 67 | this.SV[index] = SVvalue; 68 | } 69 | 70 | /** 71 | * @param index the index 72 | * @return the SVH 73 | */ 74 | public int getSVHbyIndex(final int index) { 75 | return this.SVH[index]; 76 | } 77 | 78 | /** 79 | * @param index the index 80 | * @param SVHvalue the SVH 81 | */ 82 | public void setSVHbyIndex(final int index, final int SVHvalue) { 83 | this.SVH[index] = SVHvalue; 84 | } 85 | 86 | @Override 87 | public boolean equals(final Object o) { 88 | if (this == o) { 89 | return true; 90 | } 91 | if (!(o instanceof HEALTHObject)) { 92 | return false; 93 | } 94 | 95 | final HEALTHObject that = (HEALTHObject) o; 96 | 97 | if (this.data_id != that.data_id) { 98 | return false; 99 | } 100 | if (!Arrays.equals(this.SV, that.SV)) { 101 | return false; 102 | } 103 | if (!Arrays.equals(this.SVH, that.SVH)) { 104 | return false; 105 | } 106 | 107 | return true; 108 | } 109 | 110 | @Override 111 | public int hashCode() { 112 | int result = this.SV != null ? Arrays.hashCode(this.SV) : 0; 113 | result = (31 * result) + (this.SVH != null ? Arrays.hashCode(this.SVH) : 0); 114 | result = (31 * result) + this.data_id; 115 | return result; 116 | } 117 | 118 | @Override 119 | public String toString() { 120 | final StringBuilder sb = new StringBuilder(); 121 | sb.append("HEALTHObject{data_id="); 122 | sb.append(this.data_id); 123 | for (int index = 1; index <= 32; index++) { 124 | sb.append(", SV"); 125 | sb.append(index); 126 | sb.append("="); 127 | sb.append(this.SV[index - 1]); 128 | } 129 | for (int index = 0; index <= 7; index++) { 130 | sb.append(", SVH"); 131 | sb.append(index + 25); 132 | sb.append("="); 133 | sb.append(this.SVH[index]); 134 | } 135 | sb.append("}"); 136 | return sb.toString(); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/IONOObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | 25 | /** 26 | * @author aevdokimov 27 | */ 28 | public class IONOObject implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "IONO"; 32 | 33 | private double alpha0 = Double.NaN; 34 | 35 | private double alpha1 = Double.NaN; 36 | 37 | private double alpha2 = Double.NaN; 38 | 39 | private double alpha3 = Double.NaN; 40 | 41 | private double beta0 = Double.NaN; 42 | 43 | private double beta1 = Double.NaN; 44 | 45 | private double beta2 = Double.NaN; 46 | 47 | private double beta3 = Double.NaN; 48 | 49 | private double A0 = Double.NaN; 50 | 51 | private double A1 = Double.NaN; 52 | 53 | private double tot = Double.NaN; 54 | 55 | private int WNt = -1; 56 | 57 | private int leap = -1; 58 | 59 | private int WNlsf = -1; 60 | 61 | private int DN = -1; 62 | 63 | private int lsf = -1; 64 | 65 | /** 66 | * @return the alpha0 67 | */ 68 | public double getAlpha0() { 69 | return this.alpha0; 70 | } 71 | 72 | /** 73 | * @param alpha0 the alpha0 to set 74 | */ 75 | public void setAlpha0(final double alpha0) { 76 | this.alpha0 = alpha0; 77 | } 78 | 79 | /** 80 | * @return the alpha1 81 | */ 82 | public double getAlpha1() { 83 | return this.alpha1; 84 | } 85 | 86 | /** 87 | * @param alpha1 the alpha1 to set 88 | */ 89 | public void setAlpha1(final double alpha1) { 90 | this.alpha1 = alpha1; 91 | } 92 | 93 | /** 94 | * @return the alpha2 95 | */ 96 | public double getAlpha2() { 97 | return this.alpha2; 98 | } 99 | 100 | /** 101 | * @param alpha2 the alpha2 to set 102 | */ 103 | public void setAlpha2(final double alpha2) { 104 | this.alpha2 = alpha2; 105 | } 106 | 107 | /** 108 | * @return the alpha3 109 | */ 110 | public double getAlpha3() { 111 | return this.alpha3; 112 | } 113 | 114 | /** 115 | * @param alpha3 the alpha3 to set 116 | */ 117 | public void setAlpha3(final double alpha3) { 118 | this.alpha3 = alpha3; 119 | } 120 | 121 | /** 122 | * @return the beta0 123 | */ 124 | public double getBeta0() { 125 | return this.beta0; 126 | } 127 | 128 | /** 129 | * @param beta0 the beta0 to set 130 | */ 131 | public void setBeta0(final double beta0) { 132 | this.beta0 = beta0; 133 | } 134 | 135 | /** 136 | * @return the beta1 137 | */ 138 | public double getBeta1() { 139 | return this.beta1; 140 | } 141 | 142 | /** 143 | * @param beta1 the beta1 to set 144 | */ 145 | public void setBeta1(final double beta1) { 146 | this.beta1 = beta1; 147 | } 148 | 149 | /** 150 | * @return the beta2 151 | */ 152 | public double getBeta2() { 153 | return this.beta2; 154 | } 155 | 156 | /** 157 | * @param beta2 the beta2 to set 158 | */ 159 | public void setBeta2(final double beta2) { 160 | this.beta2 = beta2; 161 | } 162 | 163 | /** 164 | * @return the beta3 165 | */ 166 | public double getBeta3() { 167 | return this.beta3; 168 | } 169 | 170 | /** 171 | * @param beta3 the beta3 to set 172 | */ 173 | public void setBeta3(final double beta3) { 174 | this.beta3 = beta3; 175 | } 176 | 177 | /** 178 | * @return the a0 179 | */ 180 | public double getA0() { 181 | return this.A0; 182 | } 183 | 184 | /** 185 | * @param a0 the a0 to set 186 | */ 187 | public void setA0(final double a0) { 188 | this.A0 = a0; 189 | } 190 | 191 | /** 192 | * @return the a1 193 | */ 194 | public double getA1() { 195 | return this.A1; 196 | } 197 | 198 | /** 199 | * @param a1 the a1 to set 200 | */ 201 | public void setA1(final double a1) { 202 | this.A1 = a1; 203 | } 204 | 205 | /** 206 | * @return the tot 207 | */ 208 | public double getTot() { 209 | return this.tot; 210 | } 211 | 212 | /** 213 | * @param tot the tot to set 214 | */ 215 | public void setTot(final double tot) { 216 | this.tot = tot; 217 | } 218 | 219 | /** 220 | * @return the wNt 221 | */ 222 | public int getWNt() { 223 | return this.WNt; 224 | } 225 | 226 | /** 227 | * @param wNt the wNt to set 228 | */ 229 | public void setWNt(final int wNt) { 230 | this.WNt = wNt; 231 | } 232 | 233 | /** 234 | * @return the leap 235 | */ 236 | public int getLeap() { 237 | return this.leap; 238 | } 239 | 240 | /** 241 | * @param leap the leap to set 242 | */ 243 | public void setLeap(final int leap) { 244 | this.leap = leap; 245 | } 246 | 247 | /** 248 | * @return the wNlsf 249 | */ 250 | public int getWNlsf() { 251 | return this.WNlsf; 252 | } 253 | 254 | /** 255 | * @param wNlsf the wNlsf to set 256 | */ 257 | public void setWNlsf(final int wNlsf) { 258 | this.WNlsf = wNlsf; 259 | } 260 | 261 | /** 262 | * @return the dN 263 | */ 264 | public int getDN() { 265 | return this.DN; 266 | } 267 | 268 | /** 269 | * @param dN the dN to set 270 | */ 271 | public void setDN(final int dN) { 272 | this.DN = dN; 273 | } 274 | 275 | /** 276 | * @return the lsf 277 | */ 278 | public int getLsf() { 279 | return this.lsf; 280 | } 281 | 282 | /** 283 | * @param lsf the lsf to set 284 | */ 285 | public void setLsf(final int lsf) { 286 | this.lsf = lsf; 287 | } 288 | 289 | @Override 290 | public boolean equals(final Object o) { 291 | if (this == o) { 292 | return true; 293 | } 294 | if (!(o instanceof IONOObject)) { 295 | return false; 296 | } 297 | 298 | final IONOObject that = (IONOObject) o; 299 | 300 | if (Double.compare(that.A0, this.A0) != 0) { 301 | return false; 302 | } 303 | if (Double.compare(that.A1, this.A1) != 0) { 304 | return false; 305 | } 306 | if (this.DN != that.DN) { 307 | return false; 308 | } 309 | if (this.WNlsf != that.WNlsf) { 310 | return false; 311 | } 312 | if (this.WNt != that.WNt) { 313 | return false; 314 | } 315 | if (Double.compare(that.alpha0, this.alpha0) != 0) { 316 | return false; 317 | } 318 | if (Double.compare(that.alpha1, this.alpha1) != 0) { 319 | return false; 320 | } 321 | if (Double.compare(that.alpha2, this.alpha2) != 0) { 322 | return false; 323 | } 324 | if (Double.compare(that.alpha3, this.alpha3) != 0) { 325 | return false; 326 | } 327 | if (Double.compare(that.beta0, this.beta0) != 0) { 328 | return false; 329 | } 330 | if (Double.compare(that.beta1, this.beta1) != 0) { 331 | return false; 332 | } 333 | if (Double.compare(that.beta2, this.beta2) != 0) { 334 | return false; 335 | } 336 | if (Double.compare(that.beta3, this.beta3) != 0) { 337 | return false; 338 | } 339 | if (this.leap != that.leap) { 340 | return false; 341 | } 342 | if (this.lsf != that.lsf) { 343 | return false; 344 | } 345 | if (Double.compare(that.tot, this.tot) != 0) { 346 | return false; 347 | } 348 | 349 | return true; 350 | } 351 | 352 | @Override 353 | public int hashCode() { 354 | int result; 355 | long temp; 356 | temp = this.alpha0 != +0.0d ? Double.doubleToLongBits(this.alpha0) : 0L; 357 | result = (int) (temp ^ (temp >>> 32)); 358 | temp = this.alpha1 != +0.0d ? Double.doubleToLongBits(this.alpha1) : 0L; 359 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 360 | temp = this.alpha2 != +0.0d ? Double.doubleToLongBits(this.alpha2) : 0L; 361 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 362 | temp = this.alpha3 != +0.0d ? Double.doubleToLongBits(this.alpha3) : 0L; 363 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 364 | temp = this.beta0 != +0.0d ? Double.doubleToLongBits(this.beta0) : 0L; 365 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 366 | temp = this.beta1 != +0.0d ? Double.doubleToLongBits(this.beta1) : 0L; 367 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 368 | temp = this.beta2 != +0.0d ? Double.doubleToLongBits(this.beta2) : 0L; 369 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 370 | temp = this.beta3 != +0.0d ? Double.doubleToLongBits(this.beta3) : 0L; 371 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 372 | temp = this.A0 != +0.0d ? Double.doubleToLongBits(this.A0) : 0L; 373 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 374 | temp = this.A1 != +0.0d ? Double.doubleToLongBits(this.A1) : 0L; 375 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 376 | temp = this.tot != +0.0d ? Double.doubleToLongBits(this.tot) : 0L; 377 | result = (31 * result) + (int) (temp ^ (temp >>> 32)); 378 | result = (31 * result) + this.WNt; 379 | result = (31 * result) + this.leap; 380 | result = (31 * result) + this.WNlsf; 381 | result = (31 * result) + this.DN; 382 | result = (31 * result) + this.lsf; 383 | return result; 384 | } 385 | 386 | @Override 387 | public String toString() { 388 | final StringBuilder sb = new StringBuilder(); 389 | sb.append("IONOObject{alpha0="); 390 | sb.append(this.alpha0); 391 | sb.append(", alpha1="); 392 | sb.append(this.alpha1); 393 | sb.append(", alpha2="); 394 | sb.append(this.alpha2); 395 | sb.append(", alpha3="); 396 | sb.append(this.alpha3); 397 | sb.append(", beta0="); 398 | sb.append(this.beta0); 399 | sb.append(", beta1="); 400 | sb.append(this.beta1); 401 | sb.append(", beta2="); 402 | sb.append(this.beta2); 403 | sb.append(", beta3="); 404 | sb.append(this.beta3); 405 | sb.append(", A0="); 406 | sb.append(this.A0); 407 | sb.append(", A1="); 408 | sb.append(this.A1); 409 | sb.append(", tot="); 410 | sb.append(this.tot); 411 | sb.append(", WNt="); 412 | sb.append(this.WNt); 413 | sb.append(", leap="); 414 | sb.append(this.leap); 415 | sb.append(", WNlsf="); 416 | sb.append(this.WNlsf); 417 | sb.append(", DN="); 418 | sb.append(this.DN); 419 | sb.append(", lsf="); 420 | sb.append(this.lsf); 421 | sb.append("}"); 422 | return sb.toString(); 423 | } 424 | } 425 | -------------------------------------------------------------------------------- /src/main/java/de/taimos/gpsd4java/types/subframes/SUBFRAMEObject.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.types.subframes; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.types.IGPSObject; 24 | 25 | /** 26 | * @author aevdokimov 27 | */ 28 | public class SUBFRAMEObject implements IGPSObject { 29 | 30 | /** the GPSd internal name */ 31 | public static final String NAME = "SUBFRAME"; 32 | 33 | private String device = null; 34 | 35 | private int subframeNumber = -1; 36 | 37 | private int satelliteNumber = -1; 38 | 39 | private int MSBs = -1; 40 | 41 | private boolean scaled = false; 42 | 43 | private int pageid = -1; 44 | 45 | private String systemMessage = null; 46 | 47 | private ALMANACObject almanac; 48 | 49 | private EPHEM1Object ephem1; 50 | 51 | private EPHEM2Object ephem2; 52 | 53 | private EPHEM3Object ephem3; 54 | 55 | private ERDObject erd; 56 | 57 | private HEALTHObject health; 58 | 59 | private HEALTH2Object health2; 60 | 61 | private IONOObject iono; 62 | 63 | /** 64 | * Name of originating device 65 | * 66 | * @return the device 67 | */ 68 | public String getDevice() { 69 | return this.device; 70 | } 71 | 72 | /** 73 | * Name of originating device 74 | * 75 | * @param device the device to set 76 | */ 77 | public void setDevice(final String device) { 78 | this.device = device; 79 | } 80 | 81 | /** 82 | * Subframe number 83 | * 84 | * @return the subframe number 85 | */ 86 | public int getSubFrameNumber() { 87 | return this.subframeNumber; 88 | } 89 | 90 | /** 91 | * Subframe number 92 | * 93 | * @param subframeNumber to set 94 | */ 95 | public void setSubframeNumber(final int subframeNumber) { 96 | this.subframeNumber = subframeNumber; 97 | } 98 | 99 | /** 100 | * Satellite number 101 | * 102 | * @return the satellite number 103 | */ 104 | public int getSatelliteNumber() { 105 | return this.satelliteNumber; 106 | } 107 | 108 | /** 109 | * Satellite number 110 | * 111 | * @param satelliteNumber satellite number to set 112 | */ 113 | public void setSatelliteNumber(final int satelliteNumber) { 114 | this.satelliteNumber = satelliteNumber; 115 | } 116 | 117 | /** 118 | * TOW17 field containing the 17 MSBs of the start of the next 12-second message 119 | * 120 | * @return TOW17 121 | */ 122 | public int getMSBs() { 123 | return this.MSBs; 124 | } 125 | 126 | /** 127 | * TOW17 field containing the 17 MSBs of the start of the next 12-second message 128 | * 129 | * @param MSBs TOW17 to set 130 | */ 131 | public void setMSBs(final int MSBs) { 132 | this.MSBs = MSBs; 133 | } 134 | 135 | /** 136 | * field telling whether the remainder of the fields are dumped in scaled or unscaled form 137 | * 138 | * @return scaled 139 | */ 140 | public boolean getScaled() { 141 | return this.scaled; 142 | } 143 | 144 | /** 145 | * field telling whether the remainder of the fields are dumped in scaled or unscaled form 146 | * 147 | * @param scaled scaled to set 148 | */ 149 | public void setScaled(final boolean scaled) { 150 | this.scaled = scaled; 151 | } 152 | 153 | /** 154 | * optional pageid for ERD, IONO, HEALTH and system message 155 | * 156 | * @return pageid 157 | */ 158 | public int getPageid() { 159 | return this.pageid; 160 | } 161 | 162 | /** 163 | * optional pageid for ERD, IONO, HEALTH and system message 164 | * 165 | * @param pageid page id to set 166 | */ 167 | public void setPageid(final int pageid) { 168 | this.pageid = pageid; 169 | } 170 | 171 | /** 172 | * optional system message 173 | * 174 | * @return system message 175 | */ 176 | public String getSystemMessage() { 177 | return this.systemMessage; 178 | } 179 | 180 | /** 181 | * optional system message 182 | * 183 | * @param systemMessage system message to set 184 | */ 185 | public void setSystemMessage(final String systemMessage) { 186 | this.systemMessage = systemMessage; 187 | } 188 | 189 | /** 190 | * Optional ALMANAC object 191 | * 192 | * @return ALMANAC 193 | */ 194 | public ALMANACObject getAlmanac() { 195 | return this.almanac; 196 | } 197 | 198 | /** 199 | * Optional ALMANAC object 200 | * 201 | * @param almanac ALMANAC to set 202 | */ 203 | public void setAlmanac(final ALMANACObject almanac) { 204 | this.almanac = almanac; 205 | } 206 | 207 | /** 208 | * Optional EPHEM1 object 209 | * 210 | * @return EPHEM1 211 | */ 212 | public EPHEM1Object getEphem1() { 213 | return this.ephem1; 214 | } 215 | 216 | /** 217 | * Optional EPHEM1 object 218 | * 219 | * @param ephem1 EPHEM1 to set 220 | */ 221 | public void setEphem1(final EPHEM1Object ephem1) { 222 | this.ephem1 = ephem1; 223 | } 224 | 225 | /** 226 | * Optional EPHEM2 object 227 | * 228 | * @return EPHEM2 229 | */ 230 | public EPHEM2Object getEphem2() { 231 | return this.ephem2; 232 | } 233 | 234 | /** 235 | * Optional EPHEM2 object 236 | * 237 | * @param ephem2 EPHEM2 to set 238 | */ 239 | public void setEphem2(final EPHEM2Object ephem2) { 240 | this.ephem2 = ephem2; 241 | } 242 | 243 | /** 244 | * Optional EPHEM3 object 245 | * 246 | * @return EPHEM3 247 | */ 248 | public EPHEM3Object getEphem3() { 249 | return this.ephem3; 250 | } 251 | 252 | /** 253 | * Optional EPHEM3 object 254 | * 255 | * @param ephem3 EPHEM3 to set 256 | */ 257 | public void setEphem3(final EPHEM3Object ephem3) { 258 | this.ephem3 = ephem3; 259 | } 260 | 261 | /** 262 | * Optional ERD object 263 | * 264 | * @return ERD 265 | */ 266 | public ERDObject getErd() { 267 | return this.erd; 268 | } 269 | 270 | /** 271 | * Optional ERD object 272 | * 273 | * @param erd ERD to set 274 | */ 275 | public void setErd(final ERDObject erd) { 276 | this.erd = erd; 277 | } 278 | 279 | /** 280 | * Optional HEALTH object 281 | * 282 | * @return HEALTH 283 | */ 284 | public HEALTHObject getHealth() { 285 | return this.health; 286 | } 287 | 288 | /** 289 | * Optional HEALTH object 290 | * 291 | * @param health HEALTH to set 292 | */ 293 | public void setHealth(final HEALTHObject health) { 294 | this.health = health; 295 | } 296 | 297 | /** 298 | * Optional HEALTH2 object 299 | * 300 | * @return HEALTH2 301 | */ 302 | public HEALTH2Object getHealth2() { 303 | return this.health2; 304 | } 305 | 306 | /** 307 | * Optional HEALTH2 object 308 | * 309 | * @param health2 HEALTH2 to set 310 | */ 311 | public void setHealth2(final HEALTH2Object health2) { 312 | this.health2 = health2; 313 | } 314 | 315 | /** 316 | * Optional IONO object 317 | * 318 | * @return IONO 319 | */ 320 | public IONOObject getIono() { 321 | return this.iono; 322 | } 323 | 324 | /** 325 | * Optional IONO object 326 | * 327 | * @param iono IONO to set 328 | */ 329 | public void setIono(final IONOObject iono) { 330 | this.iono = iono; 331 | } 332 | 333 | @Override 334 | public boolean equals(final Object o) { 335 | if (this == o) { 336 | return true; 337 | } 338 | if (!(o instanceof SUBFRAMEObject)) { 339 | return false; 340 | } 341 | 342 | final SUBFRAMEObject that = (SUBFRAMEObject) o; 343 | 344 | if (this.MSBs != that.MSBs) { 345 | return false; 346 | } 347 | if (this.pageid != that.pageid) { 348 | return false; 349 | } 350 | if (this.satelliteNumber != that.satelliteNumber) { 351 | return false; 352 | } 353 | if (this.scaled != that.scaled) { 354 | return false; 355 | } 356 | if (this.subframeNumber != that.subframeNumber) { 357 | return false; 358 | } 359 | if (this.almanac != null ? !this.almanac.equals(that.almanac) : that.almanac != null) { 360 | return false; 361 | } 362 | if (this.device != null ? !this.device.equals(that.device) : that.device != null) { 363 | return false; 364 | } 365 | if (this.ephem1 != null ? !this.ephem1.equals(that.ephem1) : that.ephem1 != null) { 366 | return false; 367 | } 368 | if (this.ephem2 != null ? !this.ephem2.equals(that.ephem2) : that.ephem2 != null) { 369 | return false; 370 | } 371 | if (this.ephem3 != null ? !this.ephem3.equals(that.ephem3) : that.ephem3 != null) { 372 | return false; 373 | } 374 | if (this.erd != null ? !this.erd.equals(that.erd) : that.erd != null) { 375 | return false; 376 | } 377 | if (this.health != null ? !this.health.equals(that.health) : that.health != null) { 378 | return false; 379 | } 380 | if (this.health2 != null ? !this.health2.equals(that.health2) : that.health2 != null) { 381 | return false; 382 | } 383 | if (this.iono != null ? !this.iono.equals(that.iono) : that.iono != null) { 384 | return false; 385 | } 386 | if (this.systemMessage != null 387 | ? !this.systemMessage.equals(that.systemMessage) 388 | : that.systemMessage != null) { 389 | return false; 390 | } 391 | 392 | return true; 393 | } 394 | 395 | @Override 396 | public int hashCode() { 397 | int result = this.device != null ? this.device.hashCode() : 0; 398 | result = (31 * result) + this.subframeNumber; 399 | result = (31 * result) + this.satelliteNumber; 400 | result = (31 * result) + this.MSBs; 401 | result = (31 * result) + (this.scaled ? 1 : 0); 402 | result = (31 * result) + this.pageid; 403 | result = (31 * result) + (this.systemMessage != null ? this.systemMessage.hashCode() : 0); 404 | result = (31 * result) + (this.almanac != null ? this.almanac.hashCode() : 0); 405 | result = (31 * result) + (this.ephem1 != null ? this.ephem1.hashCode() : 0); 406 | result = (31 * result) + (this.ephem2 != null ? this.ephem2.hashCode() : 0); 407 | result = (31 * result) + (this.ephem3 != null ? this.ephem3.hashCode() : 0); 408 | result = (31 * result) + (this.erd != null ? this.erd.hashCode() : 0); 409 | result = (31 * result) + (this.health != null ? this.health.hashCode() : 0); 410 | result = (31 * result) + (this.health2 != null ? this.health2.hashCode() : 0); 411 | result = (31 * result) + (this.iono != null ? this.iono.hashCode() : 0); 412 | return result; 413 | } 414 | 415 | @Override 416 | public String toString() { 417 | final StringBuilder sb = new StringBuilder(); 418 | sb.append("SUBFRAMEObject{device="); 419 | sb.append(this.device); 420 | sb.append(", subframeNumber="); 421 | sb.append(this.subframeNumber); 422 | sb.append(", satelliteNumber="); 423 | sb.append(this.satelliteNumber); 424 | sb.append(", TOW17="); 425 | sb.append(this.MSBs); 426 | sb.append(", scaled="); 427 | sb.append(this.scaled); 428 | sb.append(", pageid="); 429 | sb.append(this.pageid); 430 | if (this.almanac != null) { 431 | sb.append(", almanac={"); 432 | sb.append(this.almanac.toString()); 433 | sb.append("}"); 434 | } else if (this.ephem1 != null) { 435 | sb.append(", ephem1={"); 436 | sb.append(this.ephem1.toString()); 437 | sb.append("}"); 438 | } else if (this.ephem2 != null) { 439 | sb.append(", ephem2={"); 440 | sb.append(this.ephem2.toString()); 441 | sb.append("}"); 442 | } else if (this.ephem3 != null) { 443 | sb.append(", ephem3={"); 444 | sb.append(this.ephem3.toString()); 445 | sb.append("}"); 446 | } else if (this.erd != null) { 447 | sb.append(", erd={"); 448 | sb.append(this.erd.toString()); 449 | sb.append("}"); 450 | } else if (this.health != null) { 451 | sb.append(", health={"); 452 | sb.append(this.health.toString()); 453 | sb.append("}"); 454 | } else if (this.health2 != null) { 455 | sb.append(", health2={"); 456 | sb.append(this.health2.toString()); 457 | sb.append("}"); 458 | } else if (this.systemMessage != null) { 459 | sb.append(", systemMessage="); 460 | sb.append(this.systemMessage); 461 | } else if (this.iono != null) { 462 | sb.append(", iono={"); 463 | sb.append(this.iono.toString()); 464 | sb.append("}"); 465 | } 466 | sb.append("}"); 467 | return sb.toString(); 468 | } 469 | } 470 | -------------------------------------------------------------------------------- /src/test/java/de/taimos/gpsd4java/backend/ResultParserTest.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.backend; 2 | 3 | import de.taimos.gpsd4java.types.ENMEAMode; 4 | import de.taimos.gpsd4java.types.SATObject; 5 | import de.taimos.gpsd4java.types.SKYObject; 6 | import de.taimos.gpsd4java.types.TPVObject; 7 | import de.taimos.gpsd4java.types.subframes.IONOObject; 8 | import org.json.JSONArray; 9 | import org.json.JSONObject; 10 | import org.junit.Assert; 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | 14 | public class ResultParserTest { 15 | 16 | private ResultParser resultParser; 17 | 18 | @Before 19 | public void before() { 20 | this.resultParser = new ResultParser(); 21 | } 22 | 23 | @Test 24 | public void testSatObject() { 25 | final JSONObject json = new JSONObject(); 26 | json.put("PRN", 12); 27 | json.put("gnssid", 44); 28 | json.put("svid", 12); 29 | json.put("az", 229); 30 | json.put("el", 24); 31 | json.put("prRes", 22.9); 32 | json.put("qual", 1); 33 | json.put("ss", 0); 34 | json.put("used", false); 35 | json.put("health", 1); 36 | final SATObject satObject = (SATObject) this.resultParser.parsePRN(json); 37 | Assert.assertEquals(12, satObject.getPRN()); 38 | Assert.assertEquals(44, satObject.getGnssId()); 39 | Assert.assertEquals(229, satObject.getAzimuth()); 40 | Assert.assertEquals(24, satObject.getElevation()); 41 | Assert.assertFalse(satObject.getUsed()); 42 | Assert.assertEquals(0, satObject.getSignalStrength()); 43 | } 44 | 45 | @Test 46 | public void testIonoObject() { 47 | final JSONObject json = new JSONObject(); 48 | json.put("a0", 1.0); 49 | json.put("a1", 2.0); 50 | json.put("a2", 3.0); 51 | json.put("b0", 11.0); 52 | json.put("b1", 12.0); 53 | json.put("b2", 13.0); 54 | json.put("b3", 14.0); 55 | json.put("A0", 21.0); 56 | json.put("A1", 22.0); 57 | json.put("tot", 31.0); 58 | json.put("WNt", 100); 59 | json.put("ls", 101); 60 | json.put("WNlsf", 102); 61 | json.put("DN", 103); 62 | json.put("lsf", 104); 63 | final IONOObject ionoObject = (IONOObject) this.resultParser.parseIONO(json); 64 | Assert.assertEquals(1.0, ionoObject.getAlpha0(), 0); 65 | Assert.assertEquals(2.0, ionoObject.getAlpha1(), 0); 66 | Assert.assertEquals(3.0, ionoObject.getAlpha2(), 0); 67 | Assert.assertEquals(11.0, ionoObject.getBeta0(), 0); 68 | Assert.assertEquals(12.0, ionoObject.getBeta1(), 0); 69 | Assert.assertEquals(13.0, ionoObject.getBeta2(), 0); 70 | Assert.assertEquals(14.0, ionoObject.getBeta3(), 0); 71 | Assert.assertEquals(21.0, ionoObject.getA0(), 0); 72 | Assert.assertEquals(22.0, ionoObject.getA1(), 0); 73 | Assert.assertEquals(31.0, ionoObject.getTot(), 0); 74 | Assert.assertEquals(100, ionoObject.getWNt()); 75 | Assert.assertEquals(101, ionoObject.getLeap()); 76 | Assert.assertEquals(102, ionoObject.getWNlsf()); 77 | Assert.assertEquals(103, ionoObject.getDN()); 78 | Assert.assertEquals(104, ionoObject.getLsf()); 79 | } 80 | 81 | @Test 82 | public void testSkyObject() throws Exception { 83 | 84 | final JSONObject json = new JSONObject(); 85 | json.put("device", "/dev/ttyUSB0"); 86 | json.put("time", "2025-02-11T08:39:29.000Z"); 87 | json.put("gdop", 1.29); 88 | json.put("hdop", 0.61); 89 | json.put("pdop", 1.16); 90 | json.put("tdop", 0.56); 91 | json.put("xdop", 0.38); 92 | json.put("ydop", 0.49); 93 | json.put("vdop", 0.99); 94 | json.put("nSat", 2); 95 | 96 | final JSONArray satellites = new JSONArray(); 97 | json.put("satellites", satellites); 98 | 99 | final JSONObject sat1 = new JSONObject(); 100 | sat1.put("PRN", 6); 101 | sat1.put("gnssid", 0); 102 | sat1.put("svid", 6); 103 | sat1.put("az", 110.0); 104 | sat1.put("el", 2.0); 105 | sat1.put("prRes", 11.0); 106 | sat1.put("qual", 1); 107 | sat1.put("ss", 0.0); 108 | sat1.put("used", false); 109 | sat1.put("health", 1); 110 | 111 | final JSONObject sat2 = new JSONObject(); 112 | sat2.put("PRN", 10); 113 | sat2.put("gnssid", 0); 114 | sat2.put("svid", 10); 115 | sat2.put("az", 303.0); 116 | sat2.put("el", 14.0); 117 | sat2.put("prRes", 30.3); 118 | sat2.put("qual", 7); 119 | sat2.put("ss", 48.0); 120 | sat2.put("used", true); 121 | sat2.put("health", 1); 122 | 123 | satellites.put(sat1); 124 | satellites.put(sat2); 125 | 126 | final SKYObject skyObject = (SKYObject) this.resultParser.parseSKY(json); 127 | 128 | Assert.assertEquals("/dev/ttyUSB0", skyObject.getDevice()); 129 | Assert.assertEquals(1739263169.0, skyObject.getTimestamp(), 0.0); 130 | Assert.assertEquals(1.29, skyObject.getHypersphericalDOP(), 0.0); 131 | Assert.assertEquals(0.61, skyObject.getHorizontalDOP(), 0.0); 132 | Assert.assertEquals(1.16, skyObject.getSphericalDOP(), 0.0); 133 | Assert.assertEquals(0.56, skyObject.getTimestampDOP(), 0.0); 134 | Assert.assertEquals(0.38, skyObject.getLongitudeDOP(), 0.0); 135 | Assert.assertEquals(0.49, skyObject.getLatitudeDOP(), 0.0); 136 | Assert.assertEquals(0.99, skyObject.getAltitudeDOP(), 0.0); 137 | Assert.assertEquals(2, skyObject.getSatellites().size()); 138 | 139 | final SATObject satObject1 = skyObject.getSatellites().get(0); 140 | Assert.assertEquals(6, satObject1.getPRN()); 141 | Assert.assertEquals(0, satObject1.getGnssId()); 142 | Assert.assertEquals(110.0, satObject1.getAzimuth(), 0.0); 143 | Assert.assertEquals(2.0, satObject1.getElevation(), 0.0); 144 | Assert.assertEquals(0.0, satObject1.getSignalStrength(), 0.0); 145 | Assert.assertFalse(satObject1.getUsed()); 146 | 147 | final SATObject satObject2 = skyObject.getSatellites().get(1); 148 | Assert.assertEquals(10, satObject2.getPRN()); 149 | Assert.assertEquals(0, satObject2.getGnssId()); 150 | Assert.assertEquals(303.0, satObject2.getAzimuth(), 0.0); 151 | Assert.assertEquals(14.0, satObject2.getElevation(), 0.0); 152 | Assert.assertEquals(48.0, satObject2.getSignalStrength(), 0.0); 153 | Assert.assertTrue(satObject2.getUsed()); 154 | } 155 | 156 | @Test 157 | public void testTpvObject() { 158 | 159 | final JSONObject json = new JSONObject(); 160 | json.put("tag", "tag"); 161 | json.put("alt", 136.054); 162 | json.put("epv", 0.835); 163 | json.put("device", "/dev/ttyUSB0"); 164 | json.put("time", "2025-02-11T08:39:29.000Z"); 165 | json.put("ept", 0.005); 166 | json.put("lat", 42.7045841); 167 | json.put("lon", 12.1588884); 168 | json.put("alt", 136.054); 169 | json.put("epx", 1.411); 170 | json.put("epy", 1.822); 171 | json.put("epv", 0.835); 172 | json.put("track", 144.6175); 173 | json.put("speed", 22.693); 174 | json.put("climb", 0.023); 175 | json.put("epd", 9.1852); 176 | json.put("eps", 3.51); 177 | json.put("epc", 1.68); 178 | json.put("mode", 3); 179 | 180 | final TPVObject tpvObject = (TPVObject) this.resultParser.parseTPV(json); 181 | Assert.assertEquals(136.054, tpvObject.getAltitude(), 0); 182 | Assert.assertEquals(0.835, tpvObject.getAltitudeError(), 0); 183 | Assert.assertEquals(0.023, tpvObject.getClimbRate(), 0); 184 | Assert.assertEquals(1.68, tpvObject.getClimbRateError(), 0); 185 | Assert.assertEquals(144.6175, tpvObject.getCourse(), 0); 186 | Assert.assertEquals(9.1852, tpvObject.getCourseError(), 0); 187 | Assert.assertEquals("/dev/ttyUSB0", tpvObject.getDevice()); 188 | Assert.assertEquals(42.7045841, tpvObject.getLatitude(), 0); 189 | Assert.assertEquals(1.822, tpvObject.getLatitudeError(), 0); 190 | Assert.assertEquals(12.1588884, tpvObject.getLongitude(), 0); 191 | Assert.assertEquals(1.411, tpvObject.getLongitudeError(), 0); 192 | Assert.assertEquals(ENMEAMode.ThreeDimensional, tpvObject.getMode()); 193 | Assert.assertEquals(22.693, tpvObject.getSpeed(), 0); 194 | Assert.assertEquals(3.51, tpvObject.getSpeedError(), 0); 195 | Assert.assertEquals("tag", tpvObject.getTag()); 196 | Assert.assertEquals(1739263169.0, tpvObject.getTimestamp(), 0); 197 | Assert.assertEquals(0.005, tpvObject.getTimestampError(), 0); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /src/test/java/de/taimos/gpsd4java/test/Tester.java: -------------------------------------------------------------------------------- 1 | package de.taimos.gpsd4java.test; 2 | 3 | /* 4 | * #%L 5 | * GPSd4Java 6 | * %% 7 | * Copyright (C) 2011 - 2012 Taimos GmbH 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import de.taimos.gpsd4java.api.ObjectListener; 24 | import de.taimos.gpsd4java.backend.GPSdEndpoint; 25 | import de.taimos.gpsd4java.backend.ResultParser; 26 | import de.taimos.gpsd4java.types.ATTObject; 27 | import de.taimos.gpsd4java.types.DeviceObject; 28 | import de.taimos.gpsd4java.types.DevicesObject; 29 | import de.taimos.gpsd4java.types.SATObject; 30 | import de.taimos.gpsd4java.types.SKYObject; 31 | import de.taimos.gpsd4java.types.TPVObject; 32 | import de.taimos.gpsd4java.types.subframes.SUBFRAMEObject; 33 | import org.slf4j.Logger; 34 | import org.slf4j.LoggerFactory; 35 | 36 | /** 37 | * This class provides tests during the startup phase of GPSd4Java
38 | * It will later be replaced by JUnit Tests 39 | * 40 | *

created: 17.01.2011 41 | */ 42 | public class Tester { 43 | 44 | static final Logger log = LoggerFactory.getLogger(Tester.class); 45 | 46 | private Tester() {} 47 | 48 | /** 49 | * @param args the args 50 | */ 51 | public static void main(final String[] args) { 52 | try { 53 | String host = "localhost"; 54 | int port = 2947; 55 | 56 | switch (args.length) { 57 | case 0: 58 | // Nothing to do, use default 59 | break; 60 | case 1: 61 | // only server specified 62 | host = args[0]; 63 | break; 64 | case 2: 65 | // Server and port specified 66 | host = args[0]; 67 | if (args[1].matches("\\d+")) { 68 | port = Integer.parseInt(args[1]); 69 | } 70 | break; 71 | default: 72 | break; 73 | } 74 | 75 | final GPSdEndpoint ep = new GPSdEndpoint(host, port, new ResultParser()); 76 | 77 | ep.addListener( 78 | new ObjectListener() { 79 | 80 | @Override 81 | public void handleTPV(final TPVObject tpv) { 82 | Tester.log.info("TPV: {}", tpv); 83 | } 84 | 85 | @Override 86 | public void handleSKY(final SKYObject sky) { 87 | Tester.log.info("SKY: {}", sky); 88 | for (final SATObject sat : sky.getSatellites()) { 89 | Tester.log.info(" SAT: {}", sat); 90 | } 91 | } 92 | 93 | @Override 94 | public void handleSUBFRAME(final SUBFRAMEObject subframe) { 95 | Tester.log.info("SUBFRAME: {}", subframe); 96 | } 97 | 98 | @Override 99 | public void handleATT(final ATTObject att) { 100 | Tester.log.info("ATT: {}", att); 101 | } 102 | 103 | @Override 104 | public void handleDevice(final DeviceObject device) { 105 | Tester.log.info("Device: {}", device); 106 | } 107 | 108 | @Override 109 | public void handleDevices(final DevicesObject devices) { 110 | for (final DeviceObject d : devices.getDevices()) { 111 | Tester.log.info("Device: {}", d); 112 | } 113 | } 114 | }); 115 | 116 | ep.start(); 117 | 118 | Tester.log.info("Version: {}", ep.version()); 119 | 120 | Tester.log.info("Watch: {}", ep.watch(true, true)); 121 | 122 | Tester.log.info("Poll: {}", ep.poll()); 123 | 124 | Thread.sleep(60000); 125 | } catch (final Exception e) { 126 | Tester.log.error("Problem encountered", e); 127 | } 128 | } 129 | } 130 | --------------------------------------------------------------------------------