Method: NMEAPlus::Message::AIS::VDMPayload::VDMMsg24#payload_bitstring=

Defined in:
lib/nmea_plus/message/ais/vdm_payload/vdm_msg24.rb

#payload_bitstring=(val) ⇒ Object

Override default bitstring setting to dynamically calculate what fields belong in this message which can be either part A or part B dpeending on the #part_number field


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/nmea_plus/message/ais/vdm_payload/vdm_msg24.rb', line 15

def payload_bitstring=(val)
  super

  case part_number
  when 0
    self.class.payload_reader :name, 40, 120, :_t
  when 1
    self.class.payload_reader :ship_cargo_type, 40, 8, :_e
    self.class.payload_reader :vendor_id, 48, 18, :_t
    self.class.payload_reader :model_code, 66, 4, :_u
    self.class.payload_reader :serial_number, 70, 20, :_u
    self.class.payload_reader :callsign, 90, 42, :_t

    # If the MMSI is that of an auxiliary craft, these 30 bits are read as the MMSI of the mother ship.
    # otherwise they are the vessel dimensions
    if auxiliary_craft?
      self.class.payload_reader :mothership_mmsi, 132, 30, :_u
    else
      self.class.payload_reader :ship_dimension_to_bow, 132, 9, :_u
      self.class.payload_reader :ship_dimension_to_stern, 141, 9, :_u
      self.class.payload_reader :ship_dimension_to_port, 150, 6, :_u
      self.class.payload_reader :ship_dimension_to_starboard, 156, 6, :_u
    end
  end
end