public void ConversionRoundTrip()
        {
            ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);

            AssertEx.EqualTolerance(1, ElectricCharge.FromAmpereHours(coulomb.AmpereHours).Coulombs, AmpereHoursTolerance);
            AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance);
            AssertEx.EqualTolerance(1, ElectricCharge.FromKiloampereHours(coulomb.KiloampereHours).Coulombs, KiloampereHoursTolerance);
            AssertEx.EqualTolerance(1, ElectricCharge.FromMegaampereHours(coulomb.MegaampereHours).Coulombs, MegaampereHoursTolerance);
            AssertEx.EqualTolerance(1, ElectricCharge.FromMilliampereHours(coulomb.MilliampereHours).Coulombs, MilliampereHoursTolerance);
        }
Ejemplo n.º 2
0
 /// <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)));
 }
 public static ElectricCharge MilliampereHours <T>(this T value) =>
 ElectricCharge.FromMilliampereHours(Convert.ToDouble(value));
 public void NumberToMilliampereHoursTest() =>
 Assert.Equal(ElectricCharge.FromMilliampereHours(2), 2.MilliampereHours());