SetMeasurementCollection

Coordinator
Apr 11, 2012 at 11:30 PM

void SetMeasurementCollection(double measurement, ObservableCollection<byte?> collection)
{
    if (collection == null) return;
    var x = Convert.ToInt32(100 * (Math.Round(measurement, 2)));
    if (x <= 100) return;
    collection[0] = MathUtility.GetDigitInNumber(x, 1);
    collection[1] = MathUtility.GetDigitInNumber(x, 2);

    x = Convert.ToInt32(MathUtility.TruncateNumber(measurement));
    if (x <= 1e0) return;
    collection[2] = MathUtility.GetDigitInNumber(x, 1);

    if (x <= 1e1) return;
    collection[3] = MathUtility.GetDigitInNumber(x, 2);

    if (x <= 1e2) return;
    collection[4] = MathUtility.GetDigitInNumber(x, 3);

    if (x <= 1e3) return;
    collection[5] = MathUtility.GetDigitInNumber(x, 4);

    if (x <= 1e4) return;
    collection[6] = MathUtility.GetDigitInNumber(x, 5);

    if (x <= 1e5) return;
    collection[7] = MathUtility.GetDigitInNumber(x, 6);
}