forked from snaewe/node-nmea-1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b034e5
commit b2b1e33
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var Helper = require("../Helper.js"); | ||
|
||
/* | ||
=== HDG - Heading, Deviation and Variation === | ||
------------------------------------------------------------------------------ | ||
******* 1 2 3 4 5 6 | ||
******* | | | | | | | ||
$--HDG,x.x,x.x,x,x*hh<CR><LF> | ||
------------------------------------------------------------------------------ | ||
Field Number: | ||
1. Magnetic sensor heading, degrees, to the nearest 0.1 degree. | ||
2. Magnetic deviation, degrees east or west, to the nearest 0.1 degree. | ||
3. E if field 2 is degrees East W if field 2 is degrees West | ||
4. Magnetic variation, degrees east or west, to the nearest 0.1 degree. | ||
5. E if field 4 is degrees East W if field 4 is degrees West | ||
6. Checksum | ||
*/ | ||
|
||
exports.Decoder = function (id) { | ||
this.id = id; | ||
this.talker_type_id = "HDG"; | ||
this.talker_type_desc = "Heading, Deviation and Variation"; | ||
|
||
this.parse = function (tokens) { | ||
if (tokens.length < 6) { | ||
throw new Error('DBT : not enough tokens'); | ||
} | ||
return { | ||
id: tokens[0].substr(1), | ||
talker_type_id: this.talker_type_id, | ||
talker_type_desc: this.talker_type_desc, | ||
heading: Helper.parseFloatX(tokens[1]), | ||
deviation: Helper.parseFloatX(tokens[2]), | ||
deviation_direction: tokens[3], | ||
variation: Helper.parseFloatX(tokens[4]), | ||
variation_direction: tokens[5] | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
var Helper = require("../Helper.js"); | ||
|
||
/* | ||
=== VHW – Water Speed and Heading === | ||
The compass heading to which the vessel is currently pointing, and the speed of the vessel through the water. | ||
------------------------------------------------------------------------------ | ||
*******1 2 3 4 5 6 7 | ||
*******| | | | | | | | ||
$--VHW,x.x,M,x.x,T,x.x,x.x*hh<CR><LF> | ||
------------------------------------------------------------------------------ | ||
Field Number: | ||
1. Heading degrees true | ||
2. M = magnetic, T = true | ||
3. Heading degrees magnetic | ||
4. M = magnetic, T = true | ||
5. Speed, Knots | ||
6. Speed KMH | ||
7. checksum | ||
*/ | ||
|
||
exports.Decoder = function (id) { | ||
this.id = id; | ||
this.talker_type_id = "VHW"; | ||
this.talker_type_desc = "Water, Speed and Heading"; | ||
this._reference = function(char){ | ||
switch(char){ | ||
case "T" : return "true" | ||
case "M" : return "magnetic" | ||
} | ||
}; | ||
|
||
this.parse = function (tokens) { | ||
if (tokens.length < 7) { | ||
throw new Error('VHW : not enough tokens'); | ||
} | ||
|
||
return { | ||
id: tokens[0].substr(1), | ||
talker_type_id: this.talker_type_id, | ||
talker_type_desc: this.talker_type_desc, | ||
heading1: Helper.parseFloatX(tokens[1]), | ||
reference1:this._reference(tokens[2]), | ||
heading2: Helper.parseFloatX(tokens[3]), | ||
reference2:this._reference(tokens[4]), | ||
speed_knots: Helper.parseFloatX(tokens[5]), | ||
speek_kph: Helper.parseFloatX(tokens[6]) | ||
} | ||
}; | ||
}; |