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

namespace Assets.Scripts.Devices
{
    static class DeviceValueFilter
    {
        public const int MaxCadence = 255;
        public const int MaxHeartRate = 254;
        public const int MaxPower = 2000;
        public const double MaxSpeed = 150.0;

        public static int Cadence(int? value)
        {
            if (value.HasValue)
            {
                if (value.GetValueOrDefault(0) < MaxCadence)
                {
                    return value.Value;
                }
            }
            return -1;
        }

        public static int HeartRate(int? value)
        {
            if (value.HasValue)
            {
                if (value.GetValueOrDefault(0) < MaxHeartRate && value.GetValueOrDefault(0) >= 0)
                {
                    return value.Value;
                }
            }
            return -1;
        }

        public static int Power(int? value)
        {
            if (value.HasValue)
            {
                if (value.GetValueOrDefault(0) < MaxPower && value.GetValueOrDefault(0) >= 0)
                {
                    return value.Value;
                }
            }
            return -1;
        }
    }
}
