Class: NMEAPlus::Message::AIS::VDMPayload::VDMMsg6d1022f61

Inherits:
VDMMsg6DynamicPayload show all
Defined in:
lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb

Overview

Type 6: Binary Addressed Message Subtype: Sealite SL125 Lantern or 155 Apollo Lantern This message has an ascii CSV payload wrapped in an armored AIS payload, wrapped in the NMEA CSV payload.

Instance Attribute Summary collapse

Attributes inherited from Payload

#fill_bits, #payload_bitstring

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Payload

#_2b_data_string, #_6b_ascii, #_6b_boolean, #_6b_integer, #_6b_integer_scaled, #_6b_integer_scaled_shifted, #_6b_negated_boolean, #_6b_string, #_6b_string_nullterminated, #_6b_unsigned_integer, #_6b_unsigned_integer_scaled, #_6b_unsigned_integer_scaled_shifted, #_8b_data_string, #_access, #_bit_slices, #_get_date_mdhm, #_object_by_name, payload_reader

Constructor Details

#initializeVDMMsg6d1022f61



12
13
14
15
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 12

def initialize
  super
  @fields = []
end

Instance Attribute Details

#application_dataString (readonly)

The raw payload: comma separated ascii fields



19
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 19

payload_reader :application_data, 88, 384, :_T

#battery_flat?bool (readonly)



55
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 55

bit_reader :battery_flat?, 6

#battery_low?bool (readonly)



56
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 56

bit_reader :battery_low?, 7

#battery_voltageFloat (readonly)

The battery voltage in volts



100
101
102
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 100

def battery_voltage
  @fields[3].nil? ? nil : @fields[3].to_f
end

#flash_codeString (readonly)

A vendor-specific code



93
94
95
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 93

def flash_code
  @fields[2].nil? ? nil : @fields[2].hex
end

#gps_off_station?bool (readonly)



50
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 50

bit_reader :gps_off_station?, 1

#gps_sync_valid?bool (readonly)



52
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 52

bit_reader :gps_sync_valid?, 3

#gps_valid?bool (readonly)



53
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 53

bit_reader :gps_valid?, 4

#intensity_percentFloat (readonly)

This field seems to be a 0-100% value encoded as 6-bit. The test cases seem to indicate that it is offset by +1.5625, which may mean that “3F” is a special case. But I have no data on that.



84
85
86
87
88
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 84

def intensity_percent
  return nil if @fields[1].nil?

  (1 + (@fields[1].hex & "3F".hex)) * (100.0 / (2**6))
end

#latitudeFloat (readonly)

Latitude



107
108
109
110
111
112
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 107

def latitude
  parts = @fields[4]
  return nil if parts.nil?

  NMEAPlus::Message::Base.degrees_minutes_to_decimal(parts[0..-1], parts[-1])
end

#light_sensor_dark?bool (readonly)



51
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 51

bit_reader :light_sensor_dark?, 2

#longitudeFloat (readonly)

Longitude



117
118
119
120
121
122
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 117

def longitude
  parts = @fields[5]
  return nil if parts.nil?

  NMEAPlus::Message::Base.degrees_minutes_to_decimal(parts[0..-1], parts[-1])
end

#operation_modeInteger (readonly)

Operation mode (integer code)



61
62
63
64
65
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 61

def operation_mode
  return nil if @fields[1].nil?

  @fields[1].hex >> 6
end

#operation_mode_descriptionString (readonly)

A human-readable description of the operation mode



70
71
72
73
74
75
76
77
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 70

def operation_mode_description
  case operation_mode
  when 1 then "Standby"
  when 2 then "Always on"
  else
    "description n/a" # TODO
  end
end

#supply_fail?bool (readonly)



49
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 49

bit_reader :supply_fail?, 0

#temperature_sensor_hot?bool (readonly)



54
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 54

bit_reader :temperature_sensor_hot?, 5

Class Method Details

.bit_reader(name, position) ⇒ void

This method returns an undefined value.

Enable a shortcut syntax for bit field attributes, in the style of ‘attr_accessor` metaprogramming. This is used to create a named field pointing to a specific bit in the first field of the payload



45
46
47
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 45

def self.bit_reader(name, position)
  define_method(name) { self.send(:_field0_bit, position) }
end

Instance Method Details

#_field0_bit(position) ⇒ bool

Return a bit from the 8 bits in field 0



30
31
32
33
34
35
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 30

def _field0_bit(position)
  return nil if @fields[1].nil?

  mask = 1 << (7 - position)
  @fields[0].hex & mask == mask
end

#payload_bitstring=(val) ⇒ Object

Override default bitstring setting to automatically load up a fields array for easier access



22
23
24
25
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg6d1022f61.rb', line 22

def payload_bitstring=(val)
  super
  @fields = application_data.split(",")
end