/// <summary> /// Read the equivalent CO2 in ppm and equivalent Total Volatile Compound in ppb /// </summary> /// <param name="equivalentCO2">The equivalent CO2 (eCO2) output range for CCS811 is from /// 400ppm up to 29206ppm.</param> /// <param name="equivalentTotalVolatileOrganicCompound">The equivalent Total Volatile Organic Compound (eTVOC) /// output range for CCS811 is from 0ppb up to 32768ppb</param> /// <param name="rawCurrentSelected">Raw data containing the value of the /// current through the sensor(0μA to 63μA)</param> /// <param name="rawAdcReading">Raw data containing the /// readings of the voltage across the sensor with the selected /// current(1023 = 1.65V) where 1023 is the maximum value</param> /// <returns>True if success</returns> public bool TryReadGasData(out VolumeConcentration equivalentCO2, out VolumeConcentration equivalentTotalVolatileOrganicCompound, out ElectricCurrent rawCurrentSelected, out int rawAdcReading) { int equivalentCO2InPpm = -1; int equivalentTotalVolatileOrganicCompoundInPpb = -1; int rawCurrent = -1; rawAdcReading = -1; Span <byte> toRead = stackalloc byte[8]; ReadRegister(Register.ALG_RESULT_DATA, toRead); if (toRead[5] != (byte)Error.NoError) { equivalentCO2 = VolumeConcentration.Zero; equivalentTotalVolatileOrganicCompound = VolumeConcentration.Zero; rawCurrentSelected = ElectricCurrent.Zero; return(false); } equivalentCO2InPpm = BinaryPrimitives.ReadInt16BigEndian(toRead.Slice(0, 2)); equivalentTotalVolatileOrganicCompoundInPpb = BinaryPrimitives.ReadInt16BigEndian(toRead.Slice(2, 2)); rawCurrent = toRead[6] >> 2; rawAdcReading = ((toRead[6] & 0b0000_0011) << 2) + toRead[7]; equivalentCO2 = VolumeConcentration.FromPartsPerMillion(equivalentCO2InPpm); equivalentTotalVolatileOrganicCompound = VolumeConcentration.FromPartsPerBillion(equivalentTotalVolatileOrganicCompoundInPpb); rawCurrentSelected = ElectricCurrent.FromMicroamperes(rawCurrent); return((equivalentCO2InPpm >= 400) && (equivalentCO2InPpm <= 29206) && (equivalentTotalVolatileOrganicCompoundInPpb >= 0) && (equivalentTotalVolatileOrganicCompoundInPpb <= 32768)); }
public void ConversionRoundTrip() { ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); Assert.AreEqual(1, ElectricCurrent.FromAmperes(ampere.Amperes).Amperes, AmperesTolerance); Assert.AreEqual(1, ElectricCurrent.FromKiloamperes(ampere.Kiloamperes).Amperes, KiloamperesTolerance); Assert.AreEqual(1, ElectricCurrent.FromMegaamperes(ampere.Megaamperes).Amperes, MegaamperesTolerance); Assert.AreEqual(1, ElectricCurrent.FromMicroamperes(ampere.Microamperes).Amperes, MicroamperesTolerance); Assert.AreEqual(1, ElectricCurrent.FromMilliamperes(ampere.Milliamperes).Amperes, MilliamperesTolerance); Assert.AreEqual(1, ElectricCurrent.FromNanoamperes(ampere.Nanoamperes).Amperes, NanoamperesTolerance); }
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.FromDecaamperes(ampere.Decaamperes).Amperes, DecaamperesTolerance); AssertEx.EqualTolerance(1, ElectricCurrent.FromDeciamperes(ampere.Deciamperes).Amperes, DeciamperesTolerance); 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); }
public void NumberToMicroamperesTest() => Assert.Equal(ElectricCurrent.FromMicroamperes(2), 2.Microamperes());
/// <inheritdoc cref="ElectricCurrent.FromMicroamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Microamperes <T>(this T value) => ElectricCurrent.FromMicroamperes(Convert.ToDouble(value));
/// <inheritdoc cref="ElectricCurrent.FromMicroamperes(double?)"/> public static ElectricCurrent?Microamperes(this decimal?value) => ElectricCurrent.FromMicroamperes(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="ElectricCurrent.FromMicroamperes(double?)"/> public static ElectricCurrent?Microamperes(this float?value) => ElectricCurrent.FromMicroamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromMicroamperes(double)"/> public static ElectricCurrent Microamperes(this double value) => ElectricCurrent.FromMicroamperes(value);
public static ElectricCurrent?Microamperes <T>(this T?value) where T : struct => ElectricCurrent.FromMicroamperes(value == null ? (double?)null : Convert.ToDouble(value.Value));