Beispiel #1
0
 public void setParameter(String command) throws NumberFormatException {
   ParameterProfile parameter = commands.get(command);
   commands.remove(command);
   int value = getValue(command);
   parameter.setValue(value);
   commands.put(parameter.getCommand(), parameter);
 }
Beispiel #2
0
  public void setValue(String command, int value) {
    // Toast.makeText(ctx,command +" = " +value,Toast.LENGTH_SHORT).show();
    writeWord(command + "=" + Integer.toString(value));

    ParameterProfile parameter = commands.get(command);
    commands.remove(command);
    parameter.setValue(value);
    commands.put(parameter.getCommand(), parameter);
  }
Beispiel #3
0
  private void initCommands() {
    commands = new HashMap<String, ParameterProfile>();

    ParameterProfile parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.aimed_frequency_min),
            ctx.getResources().getInteger(R.integer.aimed_frequency_max),
            ctx.getResources().getString(R.string.aimed_frequency_unit),
            ctx.getResources().getString(R.string.aimed_frequency_command),
            ctx.getResources().getInteger(R.integer.aimed_frequency_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.max_speed_assist_min),
            ctx.getResources().getInteger(R.integer.max_speed_assist_max),
            ctx.getResources().getString(R.string.max_speed_assist_unit),
            ctx.getResources().getString(R.string.max_speed_assist_command),
            ctx.getResources().getInteger(R.integer.max_speed_assist_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.deltaU_min),
            ctx.getResources().getInteger(R.integer.deltaU_max),
            ctx.getResources().getString(R.string.deltaU_unit),
            ctx.getResources().getString(R.string.deltaU_command),
            ctx.getResources().getInteger(R.integer.deltaU_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.empty_voltage_min),
            ctx.getResources().getInteger(R.integer.empty_voltage_max),
            ctx.getResources().getString(R.string.empty_voltage_unit),
            ctx.getResources().getString(R.string.empty_voltage_command),
            ctx.getResources().getInteger(R.integer.empty_voltage_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.Kmotor_min),
            ctx.getResources().getInteger(R.integer.Kmotor_max),
            ctx.getResources().getString(R.string.Kmotor_unit),
            ctx.getResources().getString(R.string.Kmotor_command),
            ctx.getResources().getInteger(R.integer.Kmotor_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.Rvar_min),
            ctx.getResources().getInteger(R.integer.Rvar_max),
            ctx.getResources().getString(R.string.Rvar_unit),
            ctx.getResources().getString(R.string.Rvar_command),
            ctx.getResources().getInteger(R.integer.Rvar_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.max_temp_min),
            ctx.getResources().getInteger(R.integer.max_temp_max),
            ctx.getResources().getString(R.string.max_temp_unit),
            ctx.getResources().getString(R.string.max_temp_command),
            ctx.getResources().getInteger(R.integer.max_temp_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.maxV_min),
            ctx.getResources().getInteger(R.integer.maxV_max),
            ctx.getResources().getString(R.string.maxV_unit),
            ctx.getResources().getString(R.string.maxV_command),
            ctx.getResources().getInteger(R.integer.maxV_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.minV_min),
            ctx.getResources().getInteger(R.integer.minV_max),
            ctx.getResources().getString(R.string.minV_unit),
            ctx.getResources().getString(R.string.minV_command),
            ctx.getResources().getInteger(R.integer.minV_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.command_min),
            ctx.getResources().getInteger(R.integer.command_max),
            ctx.getResources().getString(R.string.command_unit),
            ctx.getResources().getString(R.string.command_command),
            ctx.getResources().getInteger(R.integer.command_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.shuntR_min),
            ctx.getResources().getInteger(R.integer.shuntR_max),
            ctx.getResources().getString(R.string.shuntR_unit),
            ctx.getResources().getString(R.string.shuntR_command),
            ctx.getResources().getInteger(R.integer.shuntR_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.OCV_min),
            ctx.getResources().getInteger(R.integer.OCV_max),
            ctx.getResources().getString(R.string.OCV_unit),
            ctx.getResources().getString(R.string.OCV_command),
            ctx.getResources().getInteger(R.integer.OCV_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.nbTeeth_min),
            ctx.getResources().getInteger(R.integer.nbTeeth_max),
            ctx.getResources().getString(R.string.nbTeeth_unit),
            ctx.getResources().getString(R.string.nbTeeth_command),
            ctx.getResources().getInteger(R.integer.nbTeeth_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.max_latency_min),
            ctx.getResources().getInteger(R.integer.max_latency_max),
            ctx.getResources().getString(R.string.max_latency_unit),
            ctx.getResources().getString(R.string.max_latency_command),
            ctx.getResources().getInteger(R.integer.max_latency_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.error_detection_min),
            ctx.getResources().getInteger(R.integer.error_detection_max),
            ctx.getResources().getString(R.string.error_detection_unit),
            ctx.getResources().getString(R.string.error_detection_command),
            ctx.getResources().getInteger(R.integer.error_detection_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.braking_speed_min),
            ctx.getResources().getInteger(R.integer.braking_speed_max),
            ctx.getResources().getString(R.string.braking_speed_unit),
            ctx.getResources().getString(R.string.braking_speed_command),
            ctx.getResources().getInteger(R.integer.braking_speed_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.max_speed_regen_min),
            ctx.getResources().getInteger(R.integer.max_speed_regen_max),
            ctx.getResources().getString(R.string.max_speed_regen_unit),
            ctx.getResources().getString(R.string.max_speed_regen_command),
            ctx.getResources().getInteger(R.integer.max_speed_regen_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getInteger(R.integer.output_voltage_min),
            ctx.getResources().getInteger(R.integer.output_voltage_max),
            ctx.getResources().getString(R.string.output_voltage_unit),
            ctx.getResources().getString(R.string.output_voltage_command),
            ctx.getResources().getInteger(R.integer.output_voltage_increment));

    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile = new ParameterProfile(ctx.getResources().getString(R.string.MR_flag_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile = new ParameterProfile(ctx.getResources().getString(R.string.ES_flag_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile = new ParameterProfile(ctx.getResources().getString(R.string.BB_flag_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile = new ParameterProfile(ctx.getResources().getString(R.string.DC_flag_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(ctx.getResources().getString(R.string.USB_flag_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(ctx.getResources().getString(R.string.total_capacity_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(ctx.getResources().getString(R.string.full_voltage_command));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getString(R.string.number_picker_command),
            ctx.getResources().getInteger(R.integer.number_picker_max));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getString(R.string.nb_parallele_command),
            ctx.getResources().getInteger(R.integer.nb_parallele_max));
    commands.put(parameterProfile.getCommand(), parameterProfile);

    parameterProfile =
        new ParameterProfile(
            ctx.getResources().getString(R.string.nb_serie_command),
            ctx.getResources().getInteger(R.integer.nb_serie_max));
    commands.put(parameterProfile.getCommand(), parameterProfile);
  }