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
007/**
008 * Unit of electric voltage dimension.
009 *
010 * <p>This is the base type for units of voltage dimension. It is also used to specify the dimension
011 * for {@link Measure}: <code>Measure&lt;Voltage&gt;</code>.
012 *
013 * <p>Actual units (such as {@link Units#Volts} and {@link Units#Millivolts}) can be found in the
014 * {@link Units} class.
015 */
016public class Voltage extends Unit<Voltage> {
017  Voltage(double baseUnitEquivalent, String name, String symbol) {
018    super(Voltage.class, baseUnitEquivalent, name, symbol);
019  }
020
021  Voltage(
022      UnaryFunction toBaseConverter, UnaryFunction fromBaseConverter, String name, String symbol) {
023    super(Voltage.class, toBaseConverter, fromBaseConverter, name, symbol);
024  }
025
026  /**
027   * Constructs a unit of power equivalent to this unit of voltage multiplied by another unit of
028   * electrical current. For example, {@code Volts.times(Amps)} will return a unit of power
029   * equivalent to one Watt; {@code Volts.times(Milliams)} will return a unit of power equivalent to
030   * a milliwatt, and so on.
031   *
032   * @param current the current unit to multiply by
033   * @param name the name of the resulting unit of power
034   * @param symbol the symbol used to represent the unit of power
035   * @return the power unit
036   */
037  public Power times(Unit<Current> current, String name, String symbol) {
038    return new Power(toBaseUnits(1) * current.toBaseUnits(1), name, symbol);
039  }
040}