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 electic current dimension.
011 *
012 * <p>This is the base type for units of current dimension. It is also used to specify the dimension
013 * for {@link Measure}: <code>Measure&lt;Current&gt;</code>.
014 *
015 * <p>Actual units (such as {@link Units#Amps} and {@link Units#Milliamps}) can be found in the
016 * {@link Units} class.
017 */
018public class Current extends Unit<Current> {
019  Current(Current baseUnit, double baseUnitEquivalent, String name, String symbol) {
020    super(baseUnit, baseUnitEquivalent, name, symbol);
021  }
022
023  Current(
024      Current 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 electrical current multiplied by another
034   * unit of voltage. For example, {@code Amps.times(Volts)} will return a unit of power equivalent
035   * to one Watt; {@code Amps.times(Millivolts)} will return a unit of power equivalent to a
036   * milliwatt, and so on.
037   *
038   * @param voltage the voltage 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<Voltage> voltage, String name, String symbol) {
044    return new Power(Watts, this.toBaseUnits(1) * voltage.toBaseUnits(1), name, symbol);
045  }
046}