using MwFramework.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MainShell.Common.Extension
{
    public static class DeviceExtension
    {
        private static readonly int _taskNum = 3;
        public static void GetLastSamples(this IDiastimeter diastimeter, out double distance)
        {
            var doubles = new List<double>();
            for (int i = 0; i < _taskNum; i++)
            {
                diastimeter.GetLastSample(out double val);
                if (val != double.NaN)
                    doubles.Add(val);
            }
            distance = doubles.Average();
        }
    }
}
