Beispiel #1
0
// IMO Circ 289 - Clearance time to enter port
Ais6_1_18::Ais6_1_18(const char *nmea_payload, const size_t pad)
    : Ais6(nmea_payload, pad), link_id(0), utc_month(0), utc_day(0),
      utc_hour(0), utc_min(0), spare2() {
  assert(dac == 1);
  assert(fi == 18);

  if (num_bits != 360) {
    status = AIS_ERR_BAD_BIT_COUNT;
    return;
  }

  AisBitset bs;
  const AIS_STATUS r = bs.ParseNmeaPayload(nmea_payload, pad);
  if (r != AIS_OK) {
    status = r;
    return;
  }

  link_id = bs.ToUnsignedInt(88, 10);
  utc_month = bs.ToUnsignedInt(98, 4);
  utc_day = bs.ToUnsignedInt(102, 5);
  utc_hour = bs.ToUnsignedInt(107, 5);
  utc_min = bs.ToUnsignedInt(112, 6);
  port_berth = bs.ToString(118, 120);
  dest = bs.ToString(238, 30);
  position = bs.ToAisPoint(268, 49);
  spare2[0] = bs.ToUnsignedInt(317, 32);
  spare2[1] = bs.ToUnsignedInt(349, 11);

  assert(bs.GetRemaining() == 0);
  status = AIS_OK;
}
Beispiel #2
0
Ais6_1_0::Ais6_1_0(const char *nmea_payload, const size_t pad)
    : Ais6(nmea_payload, pad), ack_required(false), msg_seq(0),
      spare2(0) {

  assert(dac == 1);
  assert(fi == 0);

  if (num_bits < 88 || num_bits > 936) {
    status = AIS_ERR_BAD_BIT_COUNT;
    return;
  }

  AisBitset bs;  // TODO(schwehr): what is the real max size?
  const AIS_STATUS r = bs.ParseNmeaPayload(nmea_payload, pad);
  if (r != AIS_OK) {
    status = r;
    return;
  }

  bs.SeekTo(88);
  ack_required = bs[88];
  msg_seq = bs.ToUnsignedInt(89, 11);

  const size_t text_size = 6 * ((num_bits - 100) / 6);
  const size_t spare2_size = num_bits - 100 - text_size;
  text = bs.ToString(100, text_size);

  if (!spare2_size)
    spare2 = 0;
  else
    spare2 = bs.ToUnsignedInt(100 + text_size, spare2_size);

  assert(bs.GetRemaining() == 0);
  status = AIS_OK;
}
Beispiel #3
0
// IMO Circ 289 - Dangerous cargo
// See also Circ 236
Ais6_1_12::Ais6_1_12(const char *nmea_payload, const size_t pad)
    : Ais6(nmea_payload, pad), utc_month_dep(0), utc_day_dep(0),
      utc_hour_dep(0), utc_min_dep(0), utc_month_next(0),
      utc_day_next(0), utc_hour_next(0), utc_min_next(0),
      un(0), value(0), value_unit(0), spare2(0) {
  assert(dac == 1);
  assert(fi == 12);

  if (num_bits != 360) {
    status = AIS_ERR_BAD_BIT_COUNT;
    return;
  }

  AisBitset bs;
  const AIS_STATUS r = bs.ParseNmeaPayload(nmea_payload, pad);
  if (r != AIS_OK) {
    status = r;
    return;
  }

  // TODO(schwehr): add in the offset of the dest mmsi

#if 0
  bs.SeekTo(56);
  last_port = bs.ToString(56, 30);
  utc_month_dep = bs.ToUnsignedInt(86, 4);
  utc_day_dep = bs.ToUnsignedInt(90, 5);
  utc_hour_dep = bs.ToUnsignedInt(95, 5);
  utc_min_dep = bs.ToUnsignedInt(100, 6);
  next_port = bs.ToString(106, 30);
  utc_month_next = bs.ToUnsignedInt(136, 4);  // estimated arrival
  utc_day_next = bs.ToUnsignedInt(140, 5);
  utc_hour_next = bs.ToUnsignedInt(145, 5);
  utc_min_next = bs.ToUnsignedInt(150, 6);
  main_danger = bs.ToString(156, 120);
  imo_cat = bs.ToString(276, 24);
  un = bs.ToUnsignedInt(300, 13);
  value = bs.ToUnsignedInt(313, 10);  // TODO(schwehr): units
  value_unit = bs.ToUnsignedInt(323, 2);
  spare = bs.ToUnsignedInt(325, 3);
  // 360
#endif

  // TODO(schwehr): Add assert(bs.GetRemaining() == 0);
  status = AIS_OK;
}
Beispiel #4
0
// IMO Circ 289 - Berthing data
Ais6_1_20::Ais6_1_20(const char *nmea_payload, const size_t pad)
    : Ais6(nmea_payload, pad), link_id(0), length(0), depth(0.0),
      mooring_position(0), utc_month(0), utc_day(0), utc_hour(0), utc_min(0),
      services_known(false), services() {
  assert(dac == 1);
  assert(fi == 20);

  if (num_bits != 360) {
    status = AIS_ERR_BAD_BIT_COUNT;
    return;
  }

  AisBitset bs;
  const AIS_STATUS r = bs.ParseNmeaPayload(nmea_payload, pad);
  if (r != AIS_OK) {
    status = r;
    return;
  }

  bs.SeekTo(88);
  link_id = bs.ToUnsignedInt(88, 10);
  length = bs.ToUnsignedInt(98, 9);
  depth = bs.ToUnsignedInt(107, 8);
  mooring_position = bs.ToUnsignedInt(115, 3);
  utc_month = bs.ToUnsignedInt(118, 4);
  utc_day = bs.ToUnsignedInt(122, 5);
  utc_hour = bs.ToUnsignedInt(127, 5);
  utc_min = bs.ToUnsignedInt(132, 6);
  services_known = bs[138];
  for (size_t serv_num = 0; serv_num < 26; serv_num++) {
    // TODO(schwehr): const int val = bs.ToUnsignedInt(139 + 2*serv_num, 2);
    services[serv_num]
        = static_cast<int>(bs.ToUnsignedInt(139 + 2*serv_num, 2));
  }
  name = bs.ToString(191, 120);
  position = bs.ToAisPoint(311, 49);

  assert(bs.GetRemaining() == 0);
  status = AIS_OK;
}
Beispiel #5
0
Ais8_366_22_Text::Ais8_366_22_Text(const AisBitset &bits,
                                   const size_t offset) {
  text = string(bits.ToString(offset + 3, 84));
  spare = bits.ToUnsignedInt(offset + 87, 3);
}
Beispiel #6
0
Ais8_1_26_Station::Ais8_1_26_Station(const AisBitset &bits,
                                     const size_t offset) {
  name = bits.ToString(offset, 84);
  spare = bits.ToUnsignedInt(offset + 84, 1);
}