Exemple #1
0
  @Override
  public void parseIMCMessage(IMCMessage message) {
    if (!DEFAULT_ROOT_ELEMENT.equalsIgnoreCase(message.getAbbrev())) return;
    pt.lsts.imc.Elevator elev = null;
    try {
      elev = pt.lsts.imc.Elevator.clone(message);
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    setMaxTime(elev.getTimeout());
    ManeuverLocation loc = new ManeuverLocation();
    loc.setLatitudeRads(elev.getLat());
    loc.setLongitudeRads(elev.getLon());
    loc.setZ(elev.getEndZ());
    NeptusLog.pub().info("<###> " + elev.getEndZUnits());
    //
    // loc.setZUnits(pt.lsts.neptus.mp.ManeuverLocation.Z_UNITS.valueOf(elev.getEndZUnits().toString()));
    loc.setZUnits(ManeuverLocation.Z_UNITS.valueOf(message.getString("end_z_units").toString()));
    setManeuverLocation(loc);
    startZ = (float) elev.getStartZ();
    startZUnits = ManeuverLocation.Z_UNITS.valueOf(message.getString("start_z_units").toString());
    setRadius((float) elev.getRadius());
    setSpeed(elev.getSpeed());
    setStartFromCurrentPosition((elev.getFlags() & pt.lsts.imc.Elevator.FLG_CURR_POS) != 0);
    setCustomSettings(elev.getCustom());

    switch (elev.getSpeedUnits()) {
      case RPM:
        speedUnits = "RPM";
        break;
      case METERS_PS:
        speedUnits = "m/s";
        break;
      case PERCENTAGE:
        speedUnits = "%";
        break;
      default:
        break;
    }
  }
Exemple #2
0
  @Override
  public IMCMessage serializeToIMC() {
    getManeuverLocation().convertToAbsoluteLatLonDepth();

    pt.lsts.imc.Elevator elevator = new pt.lsts.imc.Elevator();

    elevator.setTimeout(getMaxTime());
    elevator.setLat(getManeuverLocation().getLatitudeRads());
    elevator.setLon(getManeuverLocation().getLongitudeRads());
    elevator.setStartZ(startZ);
    elevator.setStartZUnits(startZUnits.toString());
    elevator.setEndZ(getManeuverLocation().getZ());
    elevator.setEndZUnits(getManeuverLocation().getZUnits().toString());
    elevator.setRadius(getRadius());
    elevator.setSpeed(getSpeed());
    elevator.setCustom(getCustomSettings());

    switch (getSpeedUnits()) {
      case "m/s":
        elevator.setSpeedUnits(pt.lsts.imc.Elevator.SPEED_UNITS.METERS_PS);
        break;
      case "RPM":
        elevator.setSpeedUnits(pt.lsts.imc.Elevator.SPEED_UNITS.RPM);
        break;
      default:
        elevator.setSpeedUnits(pt.lsts.imc.Elevator.SPEED_UNITS.PERCENTAGE);
        break;
    }

    if (isStartFromCurrentPosition()) elevator.setFlags(pt.lsts.imc.Elevator.FLG_CURR_POS);
    else elevator.setFlags((short) 0);

    return elevator;
  }