public void ConversionRoundTrip() { ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); AssertEx.EqualTolerance(1, ElectricCurrent.FromAmperes(ampere.Amperes).Amperes, AmperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromCentiamperes(ampere.Centiamperes).Amperes, CentiamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromKiloamperes(ampere.Kiloamperes).Amperes, KiloamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromMegaamperes(ampere.Megaamperes).Amperes, MegaamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromMicroamperes(ampere.Microamperes).Amperes, MicroamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromMilliamperes(ampere.Milliamperes).Amperes, MilliamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromNanoamperes(ampere.Nanoamperes).Amperes, NanoamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromPicoamperes(ampere.Picoamperes).Amperes, PicoamperesTolerance); }
/// <summary> /// Get battery profile /// </summary> /// <returns>Battery profile</returns> public BatteryProfile GetBatteryProfile() { byte[] response = _piJuice.ReadCommand(PiJuiceCommand.BatteryProfile, 14); return(new BatteryProfile( ElectricCharge.FromMilliampereHours(BinaryPrimitives.ReadInt16LittleEndian(response)), ElectricCurrent.FromMilliamperes(response[2] * 75 + 550), ElectricCurrent.FromMilliamperes(response[3] * 50 + 50), ElectricPotential.FromMillivolts(response[4] * 20 + 3500), ElectricPotential.FromMillivolts(response[5] * 20), Temperature.FromDegreesCelsius(response[6]), Temperature.FromDegreesCelsius(response[7]), Temperature.FromDegreesCelsius(response[8]), Temperature.FromDegreesCelsius(response[9]), (response[11] << 8) | response[10], ElectricResistance.FromOhms(((response[13] << 8) | response[12]) * 10))); }
/// <summary> /// Get supplied current in milliamps /// </summary> /// <returns>Current supplied from the GPIO power output from the PiJuice or when charging, current supplied in milliamps</returns> public ElectricCurrent GetIOCurrent() { var response = _piJuice.ReadCommand(PiJuiceCommand.IOCurrent, 2); return(ElectricCurrent.FromMilliamperes(BinaryPrimitives.ReadInt16LittleEndian(response))); }
public void NumberToMilliamperesTest() => Assert.Equal(ElectricCurrent.FromMilliamperes(2), 2.Milliamperes());
/// <inheritdoc cref="ElectricCurrent.FromMilliamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Milliamperes <T>(this T value) => ElectricCurrent.FromMilliamperes(Convert.ToDouble(value));
/// <inheritdoc cref="ElectricCurrent.FromMilliamperes(double?)"/> public static ElectricCurrent?Milliamperes(this decimal?value) => ElectricCurrent.FromMilliamperes(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="ElectricCurrent.FromMilliamperes(double?)"/> public static ElectricCurrent?Milliamperes(this float?value) => ElectricCurrent.FromMilliamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromMilliamperes(double)"/> public static ElectricCurrent Milliamperes(this double value) => ElectricCurrent.FromMilliamperes(value);
public static ElectricCurrent?Milliamperes <T>(this T?value) where T : struct => ElectricCurrent.FromMilliamperes(value == null ? (double?)null : Convert.ToDouble(value.Value));