Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see pt.up.fe.dceg.neptus.plugins.update.IPeriodicUpdates#update()
   */
  @Override
  public boolean update() {
    location = MyState.getLocation();
    headingDegrees = MyState.getAxisAnglesDegrees()[2];
    lastCalcPosTimeMillis = MyState.getLastLocationUpdateTimeMillis();
    length = MyState.getLength();
    width = MyState.getWidth();

    // update pos if following system
    if (followingPositionOf != null && followingPositionOf.length() != 0) {
      ImcSystem sys = ImcSystemsHolder.lookupSystemByName(followingPositionOf);
      LocationType loc = null;
      long locTime = -1;
      double headingDegrees = 0;
      long headingDegreesTime = -1;
      if (sys != null) {
        loc = sys.getLocation();
        locTime = sys.getLocationTimeMillis();
        headingDegrees = sys.getYawDegrees();
        headingDegreesTime = sys.getAttitudeTimeMillis();
      } else {
        ExternalSystem ext = ExternalSystemsHolder.lookupSystem(followingPositionOf);
        if (ext != null) {
          loc = ext.getLocation();
          locTime = ext.getLocationTimeMillis();
          headingDegreesTime = ext.getAttitudeTimeMillis();
        }
      }
      if (loc != null) {
        if (locTime - lastCalcPosTimeMillis > 0) {
          if (headingDegreesTime - lastCalcPosTimeMillis > 0)
            MyState.setLocationAndAxis(loc, headingDegrees);
          else MyState.setLocation(loc);
        }
      }
    }

    if (useSystemToDeriveHeadingOf != null && useSystemToDeriveHeadingOf.length() != 0) {
      ImcSystem sys = ImcSystemsHolder.lookupSystemByName(useSystemToDeriveHeadingOf);
      LocationType loc = null;
      // long locTime = -1;
      if (sys != null) {
        loc = sys.getLocation();
        // locTime = sys.getLocationTimeMillis();
      } else {
        ExternalSystem ext = ExternalSystemsHolder.lookupSystem(useSystemToDeriveHeadingOf);
        if (ext != null) {
          loc = ext.getLocation();
          // locTime = ext.getLocationTimeMillis();
        }
      }
      if (loc != null) {
        double[] bearingRange = CoordinateUtil.getNEBearingDegreesAndRange(location, loc);
        bearingRange[0] += -useHeadingAngleToDerivedHeading + useHeadingOffsetFromDerivedHeading;
        // if (Math.abs(locTime - lastCalcPosTimeMillis) < DateTimeUtil.MINUTE * 5) {
        MyState.setHeadingInDegrees(AngleCalc.nomalizeAngleDegrees360(bearingRange[0]));
        // }
      }
    }

    return true;
  }