All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.pires.obd.commands.fuel.FuelTrimCommand Maven / Gradle / Ivy

There is a newer version: 1.0
Show newest version
package com.github.pires.obd.commands.fuel;

import com.github.pires.obd.commands.PercentageObdCommand;
import com.github.pires.obd.enums.FuelTrim;

/**
 * Fuel Trim.
 *
 * @author pires
 * @version $Id: $Id
 */
public class FuelTrimCommand extends PercentageObdCommand {

    private final FuelTrim bank;

    /**
     * Default ctor.
     * 

* Will read the bank from parameters and construct the command accordingly. * Please, see FuelTrim enum for more details. * * @param bank a {@link com.github.pires.obd.enums.FuelTrim} object. */ public FuelTrimCommand(final FuelTrim bank) { super(bank.buildObdCommand()); this.bank = bank; } /** *

Constructor for FuelTrimCommand.

*/ public FuelTrimCommand() { this(FuelTrim.SHORT_TERM_BANK_1); } /** * @param value * @return */ private float prepareTempValue(final int value) { return (value - 128) * (100.0F / 128); } /** *

performCalculations.

*/ protected void performCalculations() { // ignore first two bytes [hh hh] of the response percentage = prepareTempValue(buffer.get(2)); } /** *

getValue.

* * @return the readed Fuel Trim percentage value. * @deprecated use #getCalculatedResult() */ public final float getValue() { return percentage; } /** *

Getter for the field bank.

* * @return the name of the bank in string representation. */ public final String getBank() { return bank.getBank(); } /** {@inheritDoc} */ @Override public String getName() { return bank.getBank(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy