nmea_plus 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/nmea_plus.rb +11 -7
- data/lib/nmea_plus/message/ais/vdm.rb +9 -4
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg1.rb +1 -68
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg11.rb +16 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg13.rb +16 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg18.rb +1 -37
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg19.rb +32 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg2.rb +12 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg3.rb +12 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg4.rb +1 -30
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg5.rb +3 -2
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg7.rb +1 -22
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg8d1f22.rb +1 -1
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg8d1f31.rb +2 -2
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg_binary_acknowledgement.rb +26 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg_class_b_cs_position.rb +24 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg_cnb.rb +70 -0
- data/lib/nmea_plus/message/ais/vdm_payload/vdm_msg_station_report.rb +36 -0
- data/lib/nmea_plus/message/base.rb +3 -3
- data/lib/nmea_plus/message_factory.rb +1 -1
- data/lib/nmea_plus/version.rb +1 -1
- metadata +15 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d63a8c026e77ab29e6e6f71ce7fcb0602d7bca0a
|
4
|
+
data.tar.gz: 33155818b755bb4d9d0648bccd0b320c0f15cd55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0114101601c7af5c05d516ecb1b1ced1e3c69bf1cdb5ccfa58faf81f216fb51311f712375005d7d1e83ce3706d57a94ee5df2d59194ef0d0540138cfc7d62fa2
|
7
|
+
data.tar.gz: 895f5c9fcbbc4fac5ab48426816b2201ad774d11ac0043686465351940c8fc53874cf7f95fe52f9a9f894fe7b27c664165d0b2d0272d217deffc636b1d3f4417
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# NMEA (GPS) and AIS Parser / Decoder for Ruby (nmea_plus)
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/nmea_plus.
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/nmea_plus.svg)](https://rubygems.org/gems/nmea_plus)
|
4
4
|
[![Build Status](https://travis-ci.org/ifreecarve/nmea_plus.svg)](https://travis-ci.org/ifreecarve/nmea_plus)
|
5
|
-
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/nmea_plus/1.0.
|
5
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/nmea_plus/1.0.12)
|
6
6
|
|
7
7
|
[NMEA Plus](https://github.com/ifreecarve/nmea_plus) is a Ruby gem for parsing and decoding "GPS" messages: NMEA, AIS, and any other similar formats of short messaging typically used by marine equipment. It provides convenient access (by name) to the fields of each message type, and a stream reader designed for use with Ruby Blocks.
|
8
8
|
|
data/lib/nmea_plus.rb
CHANGED
@@ -14,18 +14,14 @@ module NMEAPlus
|
|
14
14
|
# to {#each_message} and/or {#each_complete_message},
|
15
15
|
# which yield {NMEAPlus::Message} objects representing the parsed data.
|
16
16
|
class SourceDecoder
|
17
|
-
# False by default.
|
17
|
+
# Whether to raise an exception when lines don't parse. False by default -- ignore such errors.
|
18
18
|
# @return [bool] whether to throw an exception on lines that don't properly parse
|
19
19
|
attr_accessor :throw_on_parse_fail
|
20
20
|
|
21
|
-
# False by default. Typically for development.
|
22
|
-
# @return [bool] whether to throw an exception on message types that aren't supported
|
23
|
-
attr_accessor :throw_on_unrecognized_type
|
24
|
-
|
25
21
|
# @param line_reader [IO] The source stream for messages
|
26
22
|
def initialize(line_reader)
|
27
23
|
unless line_reader.respond_to? :each_line
|
28
|
-
|
24
|
+
raise ArgumentError, "line_reader must inherit from type IO (or implement each_line)"
|
29
25
|
end
|
30
26
|
@throw_on_parse_fail = false
|
31
27
|
@source = line_reader
|
@@ -63,6 +59,8 @@ module NMEAPlus
|
|
63
59
|
end
|
64
60
|
|
65
61
|
# Attempts to group multipart NMEA messages into chains, and executes the block once for every complete chain.
|
62
|
+
# To limit memory use (and be realistic about our ability to match up messages), only 1 message of chain of
|
63
|
+
# each NMEA message type can be in progress at any one time.
|
66
64
|
#
|
67
65
|
# @yield [NMEAPlus::Message] A parsed message that may contain subsequent parts
|
68
66
|
# @return [void]
|
@@ -81,8 +79,14 @@ module NMEAPlus
|
|
81
79
|
def each_complete_message
|
82
80
|
partials = {} # hash of message type to message-chain-in-progress
|
83
81
|
each_message do |msg|
|
84
|
-
|
82
|
+
# don't clutter things up if the message arrives already complete
|
83
|
+
if msg.all_messages_received?
|
84
|
+
yield msg
|
85
|
+
next
|
86
|
+
end
|
85
87
|
|
88
|
+
# put message into partials slot (merge if necessary) based on its data type
|
89
|
+
slot = msg.data_type
|
86
90
|
if partials[slot].nil? # no message in there
|
87
91
|
partials[slot] = msg
|
88
92
|
elsif 1 != (msg.message_number - partials[slot].message_number) # broken sequence
|
@@ -17,16 +17,21 @@ end
|
|
17
17
|
|
18
18
|
=end
|
19
19
|
|
20
|
-
require_relative "vdm_payload/vdm_msg1"
|
21
|
-
require_relative "vdm_payload/
|
20
|
+
require_relative "vdm_payload/vdm_msg1"
|
21
|
+
require_relative "vdm_payload/vdm_msg2"
|
22
|
+
require_relative "vdm_payload/vdm_msg3"
|
23
|
+
require_relative "vdm_payload/vdm_msg4"
|
22
24
|
require_relative "vdm_payload/vdm_msg5"
|
23
25
|
require_relative "vdm_payload/vdm_msg6"
|
24
|
-
require_relative "vdm_payload/vdm_msg7"
|
26
|
+
require_relative "vdm_payload/vdm_msg7"
|
25
27
|
require_relative "vdm_payload/vdm_msg8"
|
26
28
|
require_relative "vdm_payload/vdm_msg9"
|
29
|
+
require_relative "vdm_payload/vdm_msg11"
|
27
30
|
require_relative "vdm_payload/vdm_msg12"
|
31
|
+
require_relative "vdm_payload/vdm_msg13"
|
28
32
|
require_relative "vdm_payload/vdm_msg14"
|
29
|
-
require_relative "vdm_payload/vdm_msg18"
|
33
|
+
require_relative "vdm_payload/vdm_msg18"
|
34
|
+
require_relative "vdm_payload/vdm_msg19"
|
30
35
|
require_relative "vdm_payload/vdm_msg20"
|
31
36
|
require_relative "vdm_payload/vdm_msg21"
|
32
37
|
require_relative "vdm_payload/vdm_msg24"
|
@@ -1,78 +1,11 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'vdm_msg_cnb'
|
2
2
|
|
3
3
|
module NMEAPlus
|
4
4
|
module Message
|
5
5
|
module AIS
|
6
6
|
module VDMPayload
|
7
|
-
# CNB - The Common Navigation Block, transmitted by AIS messages 1, 2, and 3.
|
8
|
-
class VDMMsgCNB < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
9
|
-
|
10
|
-
payload_reader :navigational_status, 38, 4, :_u
|
11
|
-
|
12
|
-
# @!parse attr_reader :navigational_status_description
|
13
|
-
# @return [String] the human-readable description of navigational status
|
14
|
-
def navigational_status_description
|
15
|
-
get_navigational_status_description(navigational_status)
|
16
|
-
end
|
17
|
-
|
18
|
-
# The rate of turn in degrees per minute
|
19
|
-
# @!parse attr_reader :rate_of_turn
|
20
|
-
# @return [Float]
|
21
|
-
def rate_of_turn
|
22
|
-
ret = _i(42, 8) # spec is wrong, we don't use I3
|
23
|
-
return nil if ret == -128
|
24
|
-
negative = ret < 0
|
25
|
-
(ret / 4.733)**2 * (negative ? -1 : 1)
|
26
|
-
end
|
27
|
-
|
28
|
-
payload_reader :speed_over_ground, 50, 10, :_U, 10
|
29
|
-
payload_reader :position_10m_accuracy?, 60, 1, :_b
|
30
|
-
payload_reader :longitude, 61, 28, :_I, 60 * 10**4, 181
|
31
|
-
payload_reader :latitude, 89, 27, :_I, 60 * 10**4, 91
|
32
|
-
payload_reader :course_over_ground, 116, 12, :_U, 10, 3600
|
33
|
-
payload_reader :true_heading, 128, 9, :_u, 511
|
34
|
-
|
35
|
-
# @!visibility private
|
36
|
-
payload_reader :_time_stamp, 137, 6, :_u
|
37
|
-
|
38
|
-
# @!parse attr_reader :time_stamp
|
39
|
-
# @return [Integer]
|
40
|
-
def time_stamp
|
41
|
-
ret = _time_stamp
|
42
|
-
59 < ret ? nil : ret
|
43
|
-
end
|
44
|
-
|
45
|
-
# @!parse attr_reader :position_manual_input?
|
46
|
-
# @return [bool]
|
47
|
-
def position_manual_input?
|
48
|
-
61 == _time_stamp
|
49
|
-
end
|
50
|
-
|
51
|
-
# @!parse attr_reader :position_estimated?
|
52
|
-
# @return [bool]
|
53
|
-
def position_estimated?
|
54
|
-
62 == _time_stamp
|
55
|
-
end
|
56
|
-
|
57
|
-
# @!parse attr_reader :position_inoperative?
|
58
|
-
# @return [bool]
|
59
|
-
def position_inoperative?
|
60
|
-
63 == _time_stamp
|
61
|
-
end
|
62
|
-
|
63
|
-
payload_reader :special_manoeuvre, 143, 2, :_e
|
64
|
-
payload_reader :raim?, 148, 1, :_b
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
7
|
# AIS Type 1: Position report class A, which is really {VDMMsgCNB}
|
69
8
|
class VDMMsg1 < VDMMsgCNB; end
|
70
|
-
|
71
|
-
# AIS Type 2: Position report class A, which is really {VDMMsgCNB}
|
72
|
-
class VDMMsg2 < VDMMsgCNB; end
|
73
|
-
|
74
|
-
# AIS Type 3: Position report class A, which is really {VDMMsgCNB}
|
75
|
-
class VDMMsg3 < VDMMsgCNB; end
|
76
9
|
end
|
77
10
|
end
|
78
11
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'vdm_msg_station_report'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
|
8
|
+
# AIS Type 11: UTC/Date Response
|
9
|
+
# According to the unoffical spec: "Identical to message 4, with the semantics of a response to inquiry."
|
10
|
+
# @see VDMMsgStationReport
|
11
|
+
class VDMMsg11 < VDMMsgStationReport; end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'vdm_msg_binary_acknowledgement'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
|
8
|
+
# AIS Type 13: Safety-Related Acknowledgement
|
9
|
+
# According to the unoffical spec: "The message layout is identical to a type 7 Binary Acknowledge."
|
10
|
+
# @see VDMMsgBinaryAcknowledgement
|
11
|
+
class VDMMsg13 < VDMMsgBinaryAcknowledgement; end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,25 +1,10 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'vdm_msg_class_b_cs_position'
|
2
2
|
|
3
3
|
module NMEAPlus
|
4
4
|
module Message
|
5
5
|
module AIS
|
6
6
|
module VDMPayload
|
7
7
|
|
8
|
-
# Base class for "Class B CS Position Report" messages (18 and 19)
|
9
|
-
# @see NMEAPlus::Message::AIS::VDMPayload::VDMMsg18
|
10
|
-
# @see NMEAPlus::Message::AIS::VDMPayload::VDMMsg19
|
11
|
-
class VDMMsgClassBCSPosition < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
12
|
-
|
13
|
-
payload_reader :speed_over_ground, 46, 10, :_U, 10
|
14
|
-
payload_reader :position_10m_accuracy?, 56, 1, :_b
|
15
|
-
payload_reader :longitude, 57, 28, :_I, 60 * 10**4, 181
|
16
|
-
payload_reader :latitude, 85, 27, :_I, 60 * 10**4, 91
|
17
|
-
payload_reader :course_over_ground, 112, 12, :_U, 10
|
18
|
-
payload_reader :true_heading, 124, 9, :_u, 511
|
19
|
-
payload_reader :time_stamp, 133, 6, :_u
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
8
|
# AIS Type 18: Standard Class B CS Position Report
|
24
9
|
class VDMMsg18 < VDMMsgClassBCSPosition
|
25
10
|
payload_reader :cs_unit?, 141, 1, :_b
|
@@ -31,27 +16,6 @@ module NMEAPlus
|
|
31
16
|
payload_reader :raim?, 147, 1, :_b
|
32
17
|
end
|
33
18
|
|
34
|
-
# AIS Type 19: Extended Class B CS Position Report
|
35
|
-
class VDMMsg19 < VDMMsgClassBCSPosition
|
36
|
-
payload_reader :name, 143, 120, :_t
|
37
|
-
payload_reader :ship_cargo_type, 263, 8, :_e
|
38
|
-
payload_reader :ship_dimension_to_bow, 271, 9, :_u
|
39
|
-
payload_reader :ship_dimension_to_stern, 280, 9, :_u
|
40
|
-
payload_reader :ship_dimension_to_port, 289, 6, :_u
|
41
|
-
payload_reader :ship_dimension_to_starboard, 295, 6, :_u
|
42
|
-
payload_reader :epfd_type, 301, 4, :_e
|
43
|
-
payload_reader :raim?, 305, 1, :_b
|
44
|
-
payload_reader :dte_ready?, 306, 1, :_nb
|
45
|
-
payload_reader :assigned?, 307, 1, :_b
|
46
|
-
|
47
|
-
# @!parse attr_reader :ship_cargo_type_description
|
48
|
-
# @return [String] Cargo type description
|
49
|
-
def ship_cargo_type_description
|
50
|
-
get_ship_cargo_type_description(ship_cargo_type)
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
19
|
end
|
56
20
|
end
|
57
21
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'vdm_msg_class_b_cs_position'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
|
8
|
+
# AIS Type 19: Extended Class B CS Position Report
|
9
|
+
class VDMMsg19 < VDMMsgClassBCSPosition
|
10
|
+
payload_reader :name, 143, 120, :_t
|
11
|
+
payload_reader :ship_cargo_type, 263, 8, :_e
|
12
|
+
payload_reader :ship_dimension_to_bow, 271, 9, :_u
|
13
|
+
payload_reader :ship_dimension_to_stern, 280, 9, :_u
|
14
|
+
payload_reader :ship_dimension_to_port, 289, 6, :_u
|
15
|
+
payload_reader :ship_dimension_to_starboard, 295, 6, :_u
|
16
|
+
payload_reader :epfd_type, 301, 4, :_e
|
17
|
+
payload_reader :raim?, 305, 1, :_b
|
18
|
+
payload_reader :dte_ready?, 306, 1, :_nb
|
19
|
+
payload_reader :assigned?, 307, 1, :_b
|
20
|
+
|
21
|
+
# @!parse attr_reader :ship_cargo_type_description
|
22
|
+
# @return [String] Cargo type description
|
23
|
+
def ship_cargo_type_description
|
24
|
+
get_ship_cargo_type_description(ship_cargo_type)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,43 +1,14 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'vdm_msg_station_report'
|
2
2
|
|
3
3
|
module NMEAPlus
|
4
4
|
module Message
|
5
5
|
module AIS
|
6
6
|
module VDMPayload
|
7
7
|
|
8
|
-
# Base class for station reports
|
9
|
-
# @see VDMMsg4
|
10
|
-
# @see VDMMsg11
|
11
|
-
class VDMMsgStationReport < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
12
|
-
|
13
|
-
# @!parse attr_reader :current_time
|
14
|
-
# @return [Time] current time
|
15
|
-
def current_time
|
16
|
-
Time.new(_u(38, 14),
|
17
|
-
_u(52, 4),
|
18
|
-
_u(56, 5),
|
19
|
-
_u(61, 5),
|
20
|
-
_u(66, 6),
|
21
|
-
_u(72, 6))
|
22
|
-
end
|
23
|
-
|
24
|
-
payload_reader :position_10m_accuracy?, 78, 1, :_b
|
25
|
-
payload_reader :longitude, 79, 28, :_I, 60 * 10**4, 181
|
26
|
-
payload_reader :latitude, 107, 27, :_I, 60 * 10**4, 91
|
27
|
-
payload_reader :epfd_type, 134, 4, :_e
|
28
|
-
payload_reader :raim?, 148, 1, :_b
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
8
|
# AIS Type 4: Base Station Report
|
33
9
|
# @see VDMMsgStationReport
|
34
10
|
class VDMMsg4 < VDMMsgStationReport; end
|
35
11
|
|
36
|
-
# AIS Type 11: UTC/Date Response
|
37
|
-
# According to the unoffical spec: "Identical to message 4, with the semantics of a response to inquiry."
|
38
|
-
# @see VDMMsgStationReport
|
39
|
-
class VDMMsg11 < VDMMsgStationReport; end
|
40
|
-
|
41
12
|
end
|
42
13
|
end
|
43
14
|
end
|
@@ -20,7 +20,7 @@ module NMEAPlus
|
|
20
20
|
payload_reader :epfd_type, 270, 4, :_e
|
21
21
|
|
22
22
|
# @!parse attr_reader :eta
|
23
|
-
# @return [Time]
|
23
|
+
# @return [Time] Estimated Time of Arrival, in UTC
|
24
24
|
def eta
|
25
25
|
now = Time.now
|
26
26
|
Time.new(now.year,
|
@@ -28,7 +28,8 @@ module NMEAPlus
|
|
28
28
|
_u(278, 5),
|
29
29
|
_u(283, 5),
|
30
30
|
_u(288, 6),
|
31
|
-
0
|
31
|
+
0,
|
32
|
+
'+00:00')
|
32
33
|
end
|
33
34
|
|
34
35
|
payload_reader :static_draught, 294, 8, :_U, 10
|
@@ -1,35 +1,14 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'vdm_msg_binary_acknowledgement'
|
2
2
|
|
3
3
|
module NMEAPlus
|
4
4
|
module Message
|
5
5
|
module AIS
|
6
6
|
module VDMPayload
|
7
7
|
|
8
|
-
# Base class for binary acknowledgement messages
|
9
|
-
# @see VDMMsg7
|
10
|
-
# @see VDMMsg13
|
11
|
-
class VDMMsgBinaryAcknowledgement < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
12
|
-
|
13
|
-
payload_reader :ack1_mmsi, 40, 30, :_u
|
14
|
-
payload_reader :ack1_sequence_number, 70, 2, :_u
|
15
|
-
payload_reader :ack2_mmsi, 72, 30, :_u
|
16
|
-
payload_reader :ack2_sequence_number, 102, 2, :_u
|
17
|
-
payload_reader :ack3_mmsi, 104, 30, :_u
|
18
|
-
payload_reader :ack3_sequence_number, 134, 2, :_u
|
19
|
-
payload_reader :ack4_mmsi, 136, 30, :_u
|
20
|
-
payload_reader :ack4_sequence_number, 166, 2, :_u
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
8
|
# AIS Type 7: Binary Acknowledge
|
25
9
|
# @see VDMMsgBinaryAcknowledgement
|
26
10
|
class VDMMsg7 < VDMMsgBinaryAcknowledgement; end
|
27
11
|
|
28
|
-
# AIS Type 13: Safety-Related Acknowledgement
|
29
|
-
# According to the unoffical spec: "The message layout is identical to a type 7 Binary Acknowledge."
|
30
|
-
# @see VDMMsgBinaryAcknowledgement
|
31
|
-
class VDMMsg13 < VDMMsgBinaryAcknowledgement; end
|
32
|
-
|
33
12
|
end
|
34
13
|
end
|
35
14
|
end
|
@@ -186,7 +186,7 @@ module NMEAPlus
|
|
186
186
|
return nil if 0 == month
|
187
187
|
return nil if 24 == hour
|
188
188
|
return nil if 60 == minute
|
189
|
-
Time.new(now.year, month, day, hour, minute, 0)
|
189
|
+
Time.new(now.year, month, day, hour, minute, 0, "+00:00")
|
190
190
|
end
|
191
191
|
|
192
192
|
payload_reader :duration, 93, 18, :_u, 262_143
|
@@ -12,7 +12,7 @@ module NMEAPlus
|
|
12
12
|
payload_reader :position_10m_accuracy?, 105, 1, :_b
|
13
13
|
|
14
14
|
# @!parse attr_reader :current_time
|
15
|
-
# @return [Time] current time
|
15
|
+
# @return [Time] current time, assumed to be in UTC
|
16
16
|
def current_time
|
17
17
|
now = Time.now
|
18
18
|
day = _u(106, 5)
|
@@ -21,7 +21,7 @@ module NMEAPlus
|
|
21
21
|
return nil if 0 == day
|
22
22
|
return nil if 24 == hour
|
23
23
|
return nil if 60 == minute
|
24
|
-
Time.new(now.year, now.month, day, hour, minute, 0)
|
24
|
+
Time.new(now.year, now.month, day, hour, minute, 0, "+00:00")
|
25
25
|
end
|
26
26
|
|
27
27
|
payload_reader :wind_speed_average, 122, 7, :_u, 127
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'vdm_msg'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
|
8
|
+
# Base class for binary acknowledgement messages
|
9
|
+
# @see VDMMsg7
|
10
|
+
# @see VDMMsg13
|
11
|
+
class VDMMsgBinaryAcknowledgement < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
12
|
+
|
13
|
+
payload_reader :ack1_mmsi, 40, 30, :_u
|
14
|
+
payload_reader :ack1_sequence_number, 70, 2, :_u
|
15
|
+
payload_reader :ack2_mmsi, 72, 30, :_u
|
16
|
+
payload_reader :ack2_sequence_number, 102, 2, :_u
|
17
|
+
payload_reader :ack3_mmsi, 104, 30, :_u
|
18
|
+
payload_reader :ack3_sequence_number, 134, 2, :_u
|
19
|
+
payload_reader :ack4_mmsi, 136, 30, :_u
|
20
|
+
payload_reader :ack4_sequence_number, 166, 2, :_u
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'vdm_msg'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
|
8
|
+
# Base class for "Class B CS Position Report" messages (18 and 19)
|
9
|
+
# @see NMEAPlus::Message::AIS::VDMPayload::VDMMsg18
|
10
|
+
# @see NMEAPlus::Message::AIS::VDMPayload::VDMMsg19
|
11
|
+
class VDMMsgClassBCSPosition < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
12
|
+
payload_reader :speed_over_ground, 46, 10, :_U, 10
|
13
|
+
payload_reader :position_10m_accuracy?, 56, 1, :_b
|
14
|
+
payload_reader :longitude, 57, 28, :_I, 60 * 10**4, 181
|
15
|
+
payload_reader :latitude, 85, 27, :_I, 60 * 10**4, 91
|
16
|
+
payload_reader :course_over_ground, 112, 12, :_U, 10
|
17
|
+
payload_reader :true_heading, 124, 9, :_u, 511
|
18
|
+
payload_reader :time_stamp, 133, 6, :_u
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative 'vdm_msg'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
# CNB - The Common Navigation Block, transmitted by AIS messages 1, 2, and 3.
|
8
|
+
class VDMMsgCNB < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
9
|
+
|
10
|
+
payload_reader :navigational_status, 38, 4, :_u
|
11
|
+
|
12
|
+
# @!parse attr_reader :navigational_status_description
|
13
|
+
# @return [String] the human-readable description of navigational status
|
14
|
+
def navigational_status_description
|
15
|
+
get_navigational_status_description(navigational_status)
|
16
|
+
end
|
17
|
+
|
18
|
+
# The rate of turn in degrees per minute
|
19
|
+
# @!parse attr_reader :rate_of_turn
|
20
|
+
# @return [Float]
|
21
|
+
def rate_of_turn
|
22
|
+
ret = _i(42, 8) # spec is wrong, we don't use I3
|
23
|
+
return nil if ret == -128
|
24
|
+
negative = ret < 0
|
25
|
+
(ret / 4.733)**2 * (negative ? -1 : 1)
|
26
|
+
end
|
27
|
+
|
28
|
+
payload_reader :speed_over_ground, 50, 10, :_U, 10
|
29
|
+
payload_reader :position_10m_accuracy?, 60, 1, :_b
|
30
|
+
payload_reader :longitude, 61, 28, :_I, 60 * 10**4, 181
|
31
|
+
payload_reader :latitude, 89, 27, :_I, 60 * 10**4, 91
|
32
|
+
payload_reader :course_over_ground, 116, 12, :_U, 10, 3600
|
33
|
+
payload_reader :true_heading, 128, 9, :_u, 511
|
34
|
+
|
35
|
+
# @!visibility private
|
36
|
+
payload_reader :_time_stamp, 137, 6, :_u
|
37
|
+
|
38
|
+
# @!parse attr_reader :time_stamp
|
39
|
+
# @return [Integer]
|
40
|
+
def time_stamp
|
41
|
+
ret = _time_stamp
|
42
|
+
59 < ret ? nil : ret
|
43
|
+
end
|
44
|
+
|
45
|
+
# @!parse attr_reader :position_manual_input?
|
46
|
+
# @return [bool]
|
47
|
+
def position_manual_input?
|
48
|
+
61 == _time_stamp
|
49
|
+
end
|
50
|
+
|
51
|
+
# @!parse attr_reader :position_estimated?
|
52
|
+
# @return [bool]
|
53
|
+
def position_estimated?
|
54
|
+
62 == _time_stamp
|
55
|
+
end
|
56
|
+
|
57
|
+
# @!parse attr_reader :position_inoperative?
|
58
|
+
# @return [bool]
|
59
|
+
def position_inoperative?
|
60
|
+
63 == _time_stamp
|
61
|
+
end
|
62
|
+
|
63
|
+
payload_reader :special_manoeuvre, 143, 2, :_e
|
64
|
+
payload_reader :raim?, 148, 1, :_b
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'vdm_msg'
|
2
|
+
|
3
|
+
module NMEAPlus
|
4
|
+
module Message
|
5
|
+
module AIS
|
6
|
+
module VDMPayload
|
7
|
+
|
8
|
+
# Base class for "base station reports"
|
9
|
+
# @see VDMMsg4
|
10
|
+
# @see VDMMsg11
|
11
|
+
class VDMMsgStationReport < NMEAPlus::Message::AIS::VDMPayload::VDMMsg
|
12
|
+
|
13
|
+
# @!parse attr_reader :current_time
|
14
|
+
# @return [Time] current time in UTC
|
15
|
+
def current_time
|
16
|
+
Time.new(_u(38, 14),
|
17
|
+
_u(52, 4),
|
18
|
+
_u(56, 5),
|
19
|
+
_u(61, 5),
|
20
|
+
_u(66, 6),
|
21
|
+
_u(72, 6),
|
22
|
+
'+00:00')
|
23
|
+
end
|
24
|
+
|
25
|
+
payload_reader :position_10m_accuracy?, 78, 1, :_b
|
26
|
+
payload_reader :longitude, 79, 28, :_I, 60 * 10**4, 181
|
27
|
+
payload_reader :latitude, 107, 27, :_I, 60 * 10**4, 91
|
28
|
+
payload_reader :epfd_type, 134, 4, :_e
|
29
|
+
payload_reader :raim?, 148, 1, :_b
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -200,7 +200,7 @@ module NMEAPlus
|
|
200
200
|
now = Time.now
|
201
201
|
begin
|
202
202
|
hms = re_format.match(field)
|
203
|
-
Time.new(now.year, now.month, now.day, hms[1].to_i, hms[2].to_i, hms[3].to_f)
|
203
|
+
Time.new(now.year, now.month, now.day, hms[1].to_i, hms[2].to_i, hms[3].to_f, '+00:00')
|
204
204
|
rescue
|
205
205
|
nil
|
206
206
|
end
|
@@ -215,7 +215,7 @@ module NMEAPlus
|
|
215
215
|
re_format = /(\d{2})(\d{2})(\d{2}(\.\d+)?)/
|
216
216
|
begin
|
217
217
|
hms = re_format.match(field)
|
218
|
-
Time.new(0, 0, 0, hms[1].to_i, hms[2].to_i, hms[3].to_f)
|
218
|
+
Time.new(0, 0, 0, hms[1].to_i, hms[2].to_i, hms[3].to_f, '+00:00')
|
219
219
|
rescue
|
220
220
|
nil
|
221
221
|
end
|
@@ -237,7 +237,7 @@ module NMEAPlus
|
|
237
237
|
begin
|
238
238
|
dmy = date_format.match(d_field)
|
239
239
|
hms = time_format.match(t_field)
|
240
|
-
Time.new(2000 + dmy[3].to_i, dmy[2].to_i, dmy[1].to_i, hms[1].to_i, hms[2].to_i, hms[3].to_f)
|
240
|
+
Time.new(2000 + dmy[3].to_i, dmy[2].to_i, dmy[1].to_i, hms[1].to_i, hms[2].to_i, hms[3].to_f, '+00:00')
|
241
241
|
rescue
|
242
242
|
nil
|
243
243
|
end
|
@@ -76,7 +76,7 @@ module NMEAPlus
|
|
76
76
|
# create message and make sure it's the right type
|
77
77
|
message = self.dynamically_get_message_object(class_name)
|
78
78
|
unless message.is_a? NMEAPlus::Message::Base
|
79
|
-
|
79
|
+
raise ArgumentError, "Undefined message type #{data_type} (classname #{class_name})"
|
80
80
|
end
|
81
81
|
|
82
82
|
# assign its data and return it
|
data/lib/nmea_plus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nmea_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Katz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: racc
|
@@ -70,20 +70,20 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ~>
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0
|
73
|
+
version: '0'
|
74
74
|
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
76
|
+
version: 0.37.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0
|
83
|
+
version: '0'
|
84
84
|
- - '>='
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.
|
86
|
+
version: 0.37.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: rspec
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,13 +201,18 @@ files:
|
|
201
201
|
- lib/nmea_plus/message/ais/vdm_payload/sub_area.rb
|
202
202
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg.rb
|
203
203
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg1.rb
|
204
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg11.rb
|
204
205
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg12.rb
|
206
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg13.rb
|
205
207
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg14.rb
|
206
208
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg18.rb
|
209
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg19.rb
|
210
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg2.rb
|
207
211
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg20.rb
|
208
212
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg21.rb
|
209
213
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg24.rb
|
210
214
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg27.rb
|
215
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg3.rb
|
211
216
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg4.rb
|
212
217
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg5.rb
|
213
218
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg6.rb
|
@@ -227,6 +232,10 @@ files:
|
|
227
232
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg8d1f31.rb
|
228
233
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg8d366f56.rb
|
229
234
|
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg9.rb
|
235
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg_binary_acknowledgement.rb
|
236
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg_class_b_cs_position.rb
|
237
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg_cnb.rb
|
238
|
+
- lib/nmea_plus/message/ais/vdm_payload/vdm_msg_station_report.rb
|
230
239
|
- lib/nmea_plus/message/base.rb
|
231
240
|
- lib/nmea_plus/message/nmea/aam.rb
|
232
241
|
- lib/nmea_plus/message/nmea/alm.rb
|