nmea_plus 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f71c1e2ce5125ec0729070d9bc7955bf0e764ff
|
4
|
+
data.tar.gz: 8058c722fb35884334c9b87e750948791bd9c441
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e49686ab20cf85f0d91743e026af130d2e372be651e3410ae60570a8efa2d33c8df63b14bfce7a499cb31e073fe34cf88da508db181fd6825d8081aa749b7a0
|
7
|
+
data.tar.gz: 33c30c99d96467c453c1c8046efa321af8c60c3ca971e877db1adad3d49193a2a326e26b94264a4bc7f80e01a41c8699950b0c9aa3aaed65ea7ee0c796dd52ae
|
data/gem/lib/nmea_plus.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# DO NOT MODIFY!!!!
|
3
3
|
# This file is automatically generated by rex 1.0.5
|
4
|
-
# from lexical definition file "/Users/iakatz/Code Base/nmea_plus/parser/tokenizer.rex".
|
4
|
+
# from lexical definition file "/Users/iakatz/Code Base/ship_spotter/nmea_plus/parser/tokenizer.rex".
|
5
5
|
#++
|
6
6
|
|
7
7
|
|
@@ -26,6 +26,14 @@ module NMEAPlus
|
|
26
26
|
'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !"#$%&\'()*+,-./0123456789:;<=>?'[ord]
|
27
27
|
end
|
28
28
|
|
29
|
+
# access part of the payload. if there aren't bytes, there, return nil
|
30
|
+
# else execute a block
|
31
|
+
def _access(start, length)
|
32
|
+
part = @payload_bitstring[start, length]
|
33
|
+
return nil if part.nil? || part.empty?
|
34
|
+
yield part
|
35
|
+
end
|
36
|
+
|
29
37
|
# convert an entire string from the payload
|
30
38
|
def _6b_string(start, length)
|
31
39
|
# pull out 6b chunks from the string, use their value as a lookup into the ascii array
|
@@ -37,7 +45,7 @@ module NMEAPlus
|
|
37
45
|
end
|
38
46
|
|
39
47
|
def _bit_slices(start, length, chunk_size)
|
40
|
-
|
48
|
+
_access(start, length) { |bits| bits.chars.each_slice(chunk_size) }
|
41
49
|
end
|
42
50
|
|
43
51
|
# convert a string but trim off the 0s ('@')
|
@@ -47,18 +55,19 @@ module NMEAPlus
|
|
47
55
|
|
48
56
|
# directly convert a string to a binary number as you'd read it
|
49
57
|
def _6b_unsigned_integer(start, length)
|
50
|
-
|
58
|
+
_access(start, length) { |bits| bits.to_i(2) }
|
51
59
|
end
|
52
60
|
|
53
61
|
# perform a twos complement operation on part of the payload
|
54
62
|
def _6b_twoscomplement(start, length)
|
55
63
|
# two's complement: flip bits, then add 1
|
56
|
-
|
64
|
+
_access(start, length) { |bits| bits.tr("01", "10").to_i(2) + 1 }
|
57
65
|
end
|
58
66
|
|
59
67
|
def _6b_integer(start, length)
|
60
68
|
# MSB is 1 for negative
|
61
|
-
_6b_twoscomplement(start, length)
|
69
|
+
twoc = _6b_twoscomplement(start, length)
|
70
|
+
twoc && twoc * (@payload_bitstring[start] == 0 ? 1 : -1)
|
62
71
|
end
|
63
72
|
|
64
73
|
# scale an integer by dividing it by 10^decimal_places
|
@@ -72,11 +81,11 @@ module NMEAPlus
|
|
72
81
|
end
|
73
82
|
|
74
83
|
def _6b_boolean(start, _)
|
75
|
-
|
84
|
+
_access(start, 1) { |bits| bits.to_i == 1 }
|
76
85
|
end
|
77
86
|
|
78
87
|
def _2b_data_string(start, length)
|
79
|
-
|
88
|
+
_access(start, length)
|
80
89
|
end
|
81
90
|
|
82
91
|
# use shorthand for data types as defined in http://catb.org/gpsd/AIVDM.html
|
@@ -31,6 +31,72 @@ module NMEAPlus
|
|
31
31
|
payload_reader :destination, 302, 120, :_t
|
32
32
|
payload_reader :dte?, 422, 1, :_b
|
33
33
|
|
34
|
+
def ship_cargo_type_description
|
35
|
+
case ship_cargo_type
|
36
|
+
when 0 then return nil
|
37
|
+
when 1...19 then return "(future use)"
|
38
|
+
when 20 then return "WIG (any)"
|
39
|
+
when 21 then return "WIG Hazardous category A"
|
40
|
+
when 22 then return "WIG Hazardous category B"
|
41
|
+
when 23 then return "WIG Hazardous category C"
|
42
|
+
when 24 then return "WIG Hazardous category D"
|
43
|
+
when 25...29 then return "WIG (future use)"
|
44
|
+
when 30 then return "Fishing"
|
45
|
+
when 31 then return "Towing"
|
46
|
+
when 32 then return "Towing (large)"
|
47
|
+
when 33 then return "Dredging/underwater ops"
|
48
|
+
when 34 then return "Diving ops"
|
49
|
+
when 35 then return "Military ops"
|
50
|
+
when 36 then return "Sailing"
|
51
|
+
when 37 then return "Pleasure craft"
|
52
|
+
when 38, 39 then return "Reserved"
|
53
|
+
when 40 then return "High Speed Craft"
|
54
|
+
when 41 then return "HSC Hazardous category A"
|
55
|
+
when 42 then return "HSC Hazardous category B"
|
56
|
+
when 43 then return "HSC Hazardous category C"
|
57
|
+
when 44 then return "HSC Hazardous category D"
|
58
|
+
when 45...48 then return "HSC (reserved)"
|
59
|
+
when 49 then return "HSC (no additional information)"
|
60
|
+
when 50 then return "Pilot Vessel"
|
61
|
+
when 51 then return "Search and Rescue Vessel"
|
62
|
+
when 52 then return "Tug"
|
63
|
+
when 53 then return "Port Tender"
|
64
|
+
when 54 then return "Anti-pollution equipment"
|
65
|
+
when 55 then return "Law Enforcement"
|
66
|
+
when 56, 57 then return "Spare - Local Vessel"
|
67
|
+
when 58 then return "Medical Transport"
|
68
|
+
when 59 then return "Noncombatant ship according to RR Resolution No. 18"
|
69
|
+
when 60 then return "Passenger"
|
70
|
+
when 61 then return "Passenger, Hazardous category A"
|
71
|
+
when 62 then return "Passenger, Hazardous category B"
|
72
|
+
when 63 then return "Passenger, Hazardous category C"
|
73
|
+
when 64 then return "Passenger, Hazardous category D"
|
74
|
+
when 65..68 then return "Passenger, Reserved for future use"
|
75
|
+
when 69 then return "Passenger, No additional information"
|
76
|
+
when 70 then return "Cargo"
|
77
|
+
when 71 then return "Cargo, Hazardous category A"
|
78
|
+
when 72 then return "Cargo, Hazardous category B"
|
79
|
+
when 73 then return "Cargo, Hazardous category C"
|
80
|
+
when 74 then return "Cargo, Hazardous category D"
|
81
|
+
when 75..78 then return "Cargo, Reserved for future use"
|
82
|
+
when 79 then return "Cargo, No additional information"
|
83
|
+
when 80 then return "Tanker"
|
84
|
+
when 81 then return "Tanker, Hazardous category A"
|
85
|
+
when 82 then return "Tanker, Hazardous category B"
|
86
|
+
when 83 then return "Tanker, Hazardous category C"
|
87
|
+
when 84 then return "Tanker, Hazardous category D"
|
88
|
+
when 85.88 then return "Tanker, Reserved for future use"
|
89
|
+
when 89 then return "Tanker, No additional information"
|
90
|
+
when 90 then return "Other Type"
|
91
|
+
when 91 then return "Other Type, Hazardous category A"
|
92
|
+
when 92 then return "Other Type, Hazardous category B"
|
93
|
+
when 93 then return "Other Type, Hazardous category C"
|
94
|
+
when 94 then return "Other Type, Hazardous category D"
|
95
|
+
when 95..98 then return "Other Type, Reserved for future use"
|
96
|
+
when 99 then return "Other Type, no additional information"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
34
100
|
end
|
35
101
|
end
|
36
102
|
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Katz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: racc
|