001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.units;
006
007import static edu.wpi.first.units.Units.Watts;
008
009/**
010 * Unit of electric voltage dimension.
011 *
012 * <p>This is the base type for units of voltage dimension. It is also used to specify the dimension
013 * for {@link Measure}: <code>Measure&lt;Voltage&gt;</code>.
014 *
015 * <p>Actual units (such as {@link Units#Volts} and {@link Units#Millivolts}) can be found in the
016 * {@link Units} class.
017 */
018public class Voltage extends Unit<Voltage> {
019  Voltage(Voltage baseUnit, double baseUnitEquivalent, String name, String symbol) {
020    super(baseUnit, baseUnitEquivalent, name, symbol);
021  }
022
023  Voltage(
024      Voltage baseUnit,
025      UnaryFunction toBaseConverter,
026      UnaryFunction fromBaseConverter,
027      String name,
028      String symbol) {
029    super(baseUnit, toBaseConverter, fromBaseConverter, name, symbol);
030  }
031
032  /**
033   * Constructs a unit of power equivalent to this unit of voltage multiplied by another unit of
034   * electrical current. For example, {@code Volts.times(Amps)} will return a unit of power
035   * equivalent to one Watt; {@code Volts.times(Milliams)} will return a unit of power equivalent to
036   * a milliwatt, and so on.
037   *
038   * @param current the current unit to multiply by
039   * @param name the name of the resulting unit of power
040   * @param symbol the symbol used to represent the unit of power
041   * @return the power unit
042   */
043  public Power times(Unit<Current> current, String name, String symbol) {
044    return new Power(Watts, toBaseUnits(1) * current.toBaseUnits(1), name, symbol);
045  }
046}