Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to remove hardcoded data points and improve compatibility with Garmin kit #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 176 additions & 56 deletions conversions/gps.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,23 @@
const _ = require('lodash')

module.exports = (app, plugin) => {
var lastUpdate = null

return {
title: 'Location (129025,129029)',
optionKey: 'GPS_LOCATIONv2',
return [{
pgn: 129025,
title: 'Position (129025)',
optionKey: 'position',
keys: ["navigation.position"],
callback: (position) => {
//app.debug(`position: ${JSON.stringify(position)}`)
var res = [
return [
{
pgn: 129025,
Latitude: position.latitude,
Longitude: position.longitude
}
]


if (
lastUpdate == null ||
(new Date().getTime() - lastUpdate.getTime()) > 1000
) {
lastUpdate = new Date()

var dateObj = new Date();
var date = Math.trunc(dateObj.getTime() / 86400 / 1000);
var time =
dateObj.getUTCHours() * (60 * 60) +
dateObj.getUTCMinutes() * 60 +
dateObj.getUTCSeconds();

res.push({
pgn: 129029,
Date: date,
Time: time,
Latitude: position.latitude,
Longitude: position.longitude,
'GNSS type': 'GPS+SBAS/WAAS',
Method: 'DGNSS fix',
Integrity: 'No integrity checking',
'Number of SVs': 16,
HDOP:0.64,
'Geoidal Separation': -0.01,
'Reference Stations': 1,
list: [{
'Reference Station Type': 'GPS+SBAS/WAAS',
'Reference Station ID': 7
}]
//'Age of DGNSS Corrections':
})
}
return res
},
tests: [{
input: [ { longitude: -75.487264,
latitude: 32.0631296 } ],
input: [{
longitude: -75.487264,
latitude: 32.0631296
}],
expected: [{
"prio": 2,
"pgn": 129025,
Expand All @@ -64,7 +26,52 @@ module.exports = (app, plugin) => {
"Latitude": 32.0631296,
"Longitude": -75.487264
}
},{
}]
}]
},
{
pgn: 129029,
title: 'GNSS position data (129029)',
optionKey: 'gnssPositionData',
keys: [
"navigation.datetime",
'navigation.position',
'navigation.gnss.antennaAltitude',
'navigation.gnss.type',
"navigation.gnss.methodQuality",
'navigation.gnss.integrity',
"navigation.gnss.satellites",
'navigation.gnss.horizontalDilution',
'navigation.gnss.positionDilution',
'navigation.gnss.geoidalSeparation',
// 'navigation.gnss.differentialAge',
// 'navigation.gnss.differentialReference'
],
callback: (datetime, position, altitude, gnss_type, quality, integrity, satellites, hdop, pdop, separation) => {
var dateObj = new Date(datetime);
var date = Math.trunc(dateObj.getTime() / 86400 / 1000);
var time = dateObj.getUTCHours() * (60 * 60) +
dateObj.getUTCMinutes() * 60 +
dateObj.getUTCSeconds();
return [{
pgn: 129029,
Date: date,
Time: time,
Latitude: position.latitude,
Longitude: position.longitude,
Altitude: altitude,
'GNSS type': typeMap[gnss_type] || gnss_type,
Method: methodQualityMap[quality] || quality,
Integrity: integrityMap[integrity] || integrity,
'Number of SVs': satellites,
HDOP: hdop,
PDOP: pdop,
'Geoidal Separation': separation,
}]
},
tests: [{
input: [new Date('2017-04-15T14:59:53.123Z'), { longitude: -75.487264, latitude: 32.0631296 }, 0, 'GPS+SBAS/WAAS', "GNSS Fix", 'No integrity checking', 12, 0.46, 0.1, -0.01],
expected: [{
"__preprocess__": (testResult) => {
//these change every time
delete testResult.fields.Date
Expand All @@ -76,21 +83,134 @@ module.exports = (app, plugin) => {
"fields": {
"Latitude": 32.0631296,
"Longitude": -75.487264,
"GNSS type": "GPS+SBAS/WAAS",
"Method": "DGNSS fix",
"Altitude": 0,
"GNSS type": 'GPS+SBAS/WAAS',
"Method": "GNSS fix",
"Integrity": "No integrity checking",
"Number of SVs": 16,
"HDOP": 0.64,
"Number of SVs": 12,
"HDOP": 0.46,
"PDOP": 0.1,
"Geoidal Separation": -0.01,
"Reference Stations": 1,
list: []
}
}]
}]
}, {
pgn: 129539,
title: 'GNSS DOPs (129539)',
optionKey: 'gnssDops',
keys: ["navigation.gnss.horizontalDilution", "navigation.gnss.verticalDilution", "navigation.gnss.timeDilution"],
callback: (hdop, vdop, tdop) => {
return [
{
pgn: 129539,
"Desired Mode": "3D",
"Actual Mode": "Auto",
"HDOP": hdop,
"VDOP": vdop,
"TDOP": tdop
}
]
},
tests: [{
input: [0.77, 1.38, 0.89],
expected: [{
"prio": 2,
"pgn": 129539,
"dst": 255,
"fields": {
"Desired Mode": "3D",
"Actual Mode": "Auto",
"HDOP": 0.77,
"VDOP": 1.38,
"TDOP": 0.89
}
}]
}]
}, {
pgn: 129540,
title: 'GNSS Sats in View (129539)',
optionKey: 'satsInView',
keys: ["navigation.gnss.satellitesInView"],
callback: (sats) => {
return [
{
pgn: 129540,
"Sats in View": sats.count,
"Actual Mode": "Auto",
list: sats.satellites.reduce((acc, satInfo) => {
if (Object.keys(satInfo).length >= 4) {
acc.push({
PRN: satInfo.id,
Elevation: satInfo.elevation,
Azimuth: satInfo.azimuth,
SNR: satInfo.SNR,
Status: "Used"
})
}
return acc
}, [])
}
]
},
tests: [{
input: [{
"count": 2,
"satellites": [
{
"id": 15,
"elevation": 1.0,
"azimuth": 2.0,
"SNR": 30.00
},
{
"id": 88,
"elevation": 1.0,
"azimuth": 2.0,
"SNR": 30.00
}]
}],
expected: [{
"prio": 2,
"pgn": 129540,
"dst": 255,
"fields": {
"Sats in View": 2,
"list": [
{
"Reference Station Type": "GPS+SBAS/WAAS",
"Reference Station ID": 7
"PRN": 15,
"Elevation": 1.0,
"Azimuth": 2.0,
"SNR": 30.00,
"Status": "Used"
},
{
"PRN": 88,
"Elevation": 1.0,
"Azimuth": 2.0,
"SNR": 30.00,
"Status": "Used"
}
]
}
}]
}]
}
}]
}

var typeMap = {
'Combined GPS/GLONASS': 'GPS+GLONASS',
'Integrated navigation system': 'integrated',
'Surveyed': 'surveyed'
}

var methodQualityMap = {
'no GPS': 'no GNSS',
'GNSS Fix': 'GNSS fix',
'RTK fixed integer': 'RTK Fixed Integer',
'Simulator mode': 'Simulate mode'
}

var integrityMap = {
'no Integrity checking': 'No integrity checking'
}
65 changes: 28 additions & 37 deletions conversions/navigationdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = (app, plugin) => {
"Navigation Terminated": "No"
}],
tests: [{
input: [ 0.12 ],
input: [0.12],
expected: [{
"prio": 2,
"pgn": 129283,
Expand All @@ -31,48 +31,41 @@ module.exports = (app, plugin) => {
title: 'Navigation Data (129284)',
optionKey: 'navigationdata',
keys: [
'navigation.courseRhumbline.nextPoint.distance',
'navigation.courseRhumbline.bearingToDestinationTrue',
'navigation.courseRhumbline.bearingOriginToDestinationTrue',
'navigation.courseRhumbline.nextPoint',
'navigation.courseRhumbline.nextPoint.velocityMadeGood',
'notifications.arrivalCircleEntered',
'notifications.perpendicularPassed',
'navigation.courseRhumbline.nextPoint.ID'
'navigation.course.calcValues.distance',
'navigation.course.calcValues.bearingTrue',
'navigation.course.calcValues.bearingTrackTrue',
'navigation.course.nextPoint',
'navigation.course.calcValues.timeToGo',
'navigation.course.calcValues.velocityMadeGood',
'navigation.course.arrivalCircleEntered',
'navigation.course.perpendicularPassed',
],
timeouts: [
10000, 10000, 10000, 10000, 10000, undefined, undefined, 10000
],
callback: (distToDest, bearingToDest, bearingOriginToDest, dest, WCV, ace, pp, wpid) => {
callback: (distToDest, bearingToDest, bearingOriginToDest, dest, secondsToGo, vmg, ace, pp) => {
var dateObj = new Date();
var secondsToGo = Math.trunc(distToDest / WCV);
var etaDate = Math.trunc((dateObj.getTime() / 1000 + secondsToGo) / 86400);
var etaTime = (dateObj.getUTCHours() * (60 * 60) +
dateObj.getUTCMinutes() * 60 +
dateObj.getUTCSeconds() +
secondsToGo) % 86400;
dateObj.getUTCMinutes() * 60 +
dateObj.getUTCSeconds() +
secondsToGo) % 86400;

return [{
pgn: 129284,
"SID" : 0x88,
"Distance to Waypoint" : distToDest,
"Course/Bearing reference" : 0,
"Perpendicular Crossed" : pp != null,
"Arrival Circle Entered" : ace != null,
"Calculation Type" : 1,
"ETA Time" : (WCV > 0) ? etaTime : undefined,
"ETA Date": (WCV > 0) ? etaDate : undefined,
"Bearing, Origin to Destination Waypoint" : bearingOriginToDest,
"Bearing, Position to Destination Waypoint" : bearingToDest,
"Origin Waypoint Number" : undefined,
"Destination Waypoint Number" : parseInt(wpid),
"Destination Latitude" : dest.latitude,
"Destination Longitude" : dest.longitude,
"Waypoint Closing Velocity" : WCV,
"Distance to Waypoint": distToDest,
"Course/Bearing reference": "True",
"Perpendicular Crossed": pp != null,
"Arrival Circle Entered": ace != null,
"Calculation Type": "Great Circle",
"ETA Time": (vmg > 0) ? etaTime : undefined,
"ETA Date": (vmg > 0) ? etaDate : undefined,
"Bearing, Origin to Destination Waypoint": bearingOriginToDest,
"Bearing, Position to Destination Waypoint": bearingToDest,
"Destination Latitude": dest.latitude,
"Destination Longitude": dest.longitude,
"Waypoint Closing Velocity": vmg,
}]
},
tests: [{
input: [ 12, 1.23, 3.1, { longitude: -75.487264, latitude: 32.0631296 } , 4.0, null, 1, 5 ],
input: [12, 1.23, 3.1, { longitude: -75.487264, latitude: 32.0631296 }, 60, 4.0, null, null],
expected: [{
"__preprocess__": (testResult) => {
//these change every time
Expand All @@ -83,15 +76,13 @@ module.exports = (app, plugin) => {
"pgn": 129284,
"dst": 255,
"fields": {
"SID": 136,
"Distance to Waypoint": 12,
"Course/Bearing reference": "True",
"Perpendicular Crossed": "Yes",
"Perpendicular Crossed": "No",
"Arrival Circle Entered": "No",
"Calculation Type": "Rhumbline",
"Calculation Type": "Great Circle",
"Bearing, Origin to Destination Waypoint": 3.1,
"Bearing, Position to Destination Waypoint": 1.23,
"Destination Waypoint Number": 5,
"Destination Latitude": 32.0631296,
"Destination Longitude": -75.487264,
"Waypoint Closing Velocity": 4
Expand Down