public void ConversionRoundTrip() { ElectricResistance ohm = ElectricResistance.FromOhms(1); AssertEx.EqualTolerance(1, ElectricResistance.FromKiloohms(ohm.Kiloohms).Ohms, KiloohmsTolerance); AssertEx.EqualTolerance(1, ElectricResistance.FromMegaohms(ohm.Megaohms).Ohms, MegaohmsTolerance); AssertEx.EqualTolerance(1, ElectricResistance.FromMilliohms(ohm.Milliohms).Ohms, MilliohmsTolerance); AssertEx.EqualTolerance(1, ElectricResistance.FromOhms(ohm.Ohms).Ohms, OhmsTolerance); }
/// <summary> /// Get Battery extended profile /// </summary> /// <returns>Battery extended profile</returns> public BatteryExtendedProfile GetBatteryExtProfile() { byte[] response = _piJuice.ReadCommand(PiJuiceCommand.BatteryExtendedProfile, 17); BatteryChemistry chemistry; if (response[0] < 2) { chemistry = (BatteryChemistry)response[0]; } else { chemistry = BatteryChemistry.Unknown; } return(new BatteryExtendedProfile( chemistry, ElectricPotential.FromMillivolts((response[2] << 8) | response[1]), ElectricPotential.FromMillivolts((response[4] << 8) | response[3]), ElectricPotential.FromMillivolts((response[6] << 8) | response[5]), ElectricResistance.FromMilliohms(((response[8] << 8) | response[7]) / 100.0), ElectricResistance.FromMilliohms(((response[10] << 8) | response[9]) / 100.0), ElectricResistance.FromMilliohms(((response[12] << 8) | response[11]) / 100.0))); }
/// <inheritdoc cref="ElectricResistance.FromMilliohms(double)"/> public static ElectricResistance Milliohms(this decimal value) => ElectricResistance.FromMilliohms(Convert.ToDouble(value));
/// <inheritdoc cref="ElectricResistance.FromMilliohms(double?)"/> public static ElectricResistance?Milliohms(this decimal?value) => ElectricResistance.FromMilliohms(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="ElectricResistance.FromMilliohms(double?)"/> public static ElectricResistance?Milliohms(this float?value) => ElectricResistance.FromMilliohms(value);
/// <inheritdoc cref="ElectricResistance.FromMilliohms(double)"/> public static ElectricResistance Milliohms(this double value) => ElectricResistance.FromMilliohms(value);
public void NumberToMilliohmsTest() => Assert.Equal(ElectricResistance.FromMilliohms(2), 2.Milliohms());
public static ElectricResistance?Milliohms <T>(this T?value) where T : struct => ElectricResistance.FromMilliohms(value == null ? (double?)null : Convert.ToDouble(value.Value));
public static ElectricResistance Milliohms <T>(this T value) => ElectricResistance.FromMilliohms(Convert.ToDecimal(value));