Пример #1
0
  public static void writeParameters(MavLinkDrone drone, Parameters parameters) {
    if (drone == null || parameters == null) return;

    List<Parameter> parametersList = parameters.getParameters();
    if (parametersList.isEmpty()) return;

    org.droidplanner.services.android.core.drone.profiles.Parameters droneParams =
        drone.getParameters();
    for (Parameter proxyParam : parametersList) {
      droneParams.sendParameter(
          new org.droidplanner.services.android.core.parameters.Parameter(
              proxyParam.getName(), proxyParam.getValue(), proxyParam.getType()));
    }
  }
Пример #2
0
  public static Parameters getParameters(
      MavLinkDrone drone, Context context, Map<String, Parameter> cachedParameters) {
    if (drone == null) return new Parameters();

    final Map<String, Parameter> incompleteParams = new HashMap<>();
    final List<Parameter> parametersList = new ArrayList<>();

    Map<String, org.droidplanner.services.android.core.parameters.Parameter> droneParameters =
        drone.getParameters().getParameters();
    if (!droneParameters.isEmpty()) {
      for (org.droidplanner.services.android.core.parameters.Parameter param :
          droneParameters.values()) {
        if (param.name != null) {
          Parameter cachedParam = cachedParameters.get(param.name);
          if (cachedParam == null) {
            cachedParam = new Parameter(param.name, param.value, param.type);
            incompleteParams.put(param.name, cachedParam);
            cachedParameters.put(param.name, cachedParam);
          } else {
            cachedParam.setValue(param.value);
            cachedParam.setType(param.type);
          }

          parametersList.add(cachedParam);
        }
      }

      final VehicleProfile profile = drone.getVehicleProfile();
      if (!incompleteParams.isEmpty() && profile != null) {
        try {
          String metadataType = profile.getParameterMetadataType();
          if (metadataType != null) {
            ParameterMetadataLoader.load(context, metadataType, incompleteParams);
          }
        } catch (IOException | XmlPullParserException e) {
          Timber.e(e, e.getMessage());
        }
      }
    }

    return new Parameters(new ArrayList<>(parametersList));
  }
Пример #3
0
 public static void refreshParameters(MavLinkDrone drone) {
   if (drone == null) return;
   drone.getParameters().refreshParameters();
 }