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

com.github.pires.obd.commands.control.ModuleVoltageCommand Maven / Gradle / Ivy

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

import com.github.pires.obd.commands.ObdCommand;
import com.github.pires.obd.enums.AvailableCommandNames;

/**
 * 

ModuleVoltageCommand class.

* * @author pires * @version $Id: $Id */ public class ModuleVoltageCommand extends ObdCommand { // Equivalent ratio (V) private double voltage = 0.00; /** * Default ctor. */ public ModuleVoltageCommand() { super("01 42"); } /** * Copy ctor. * * @param other a {@link com.github.pires.obd.commands.control.ModuleVoltageCommand} object. */ public ModuleVoltageCommand(ModuleVoltageCommand other) { super(other); } /** {@inheritDoc} */ @Override protected void performCalculations() { // ignore first two bytes [hh hh] of the response int a = buffer.get(2); int b = buffer.get(3); voltage = (a * 256 + b) / 1000; } /** {@inheritDoc} */ @Override public String getFormattedResult() { return String.format("%.1f%s", voltage, getResultUnit()); } /** {@inheritDoc} */ @Override public String getResultUnit() { return "V"; } /** {@inheritDoc} */ @Override public String getCalculatedResult() { return String.valueOf(voltage); } /** *

Getter for the field voltage.

* * @return a double. */ public double getVoltage() { return voltage; } /** {@inheritDoc} */ @Override public String getName() { return AvailableCommandNames.CONTROL_MODULE_VOLTAGE.getValue(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy