public IActionResult Estimate([FromBody] int[] zones, Guid fileId)
        {
            try{
                var zonesInt = new List <int>();
                foreach (int z in zones)
                {
                    zonesInt.Add(Convert.ToInt32(z));
                }
                var tss = TSSEstimator.FromHeartRate(zonesInt, HeartRateLogger.Instance.HeartRates);
                var averagePowerMissingFTP = tss * 36 / ElapsedTimeLogger.Instance.ElapsedTime; //need to multiply by FTP^2 and then take the square root of that
                var FilePath = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot", "Uploads",
                    fileId.ToString());
                // //now that we've estimated it, we can delete it
                // //this may be removed in the future if we need it for othe things
                // System.IO.File.Delete(FilePath);
                return(Ok((new { tss, averagePowerMissingFTP })));
            }
            catch (Exception ex) {
                var originalMessage = ex.Message;

                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                return(BadRequest($"{originalMessage} | {ex.Message}"));
            }
        }
Exemplo n.º 2
0
        public void TestTSSEstimator()
        {
            IList <int> Zones = new List <int>(new int[] { 162, 176, 188, 200, 215 });

            IList <int> HeartRates = new List <int>(new int[] { 100, 100, 100, 100, 100 });

            Assert.Equal((20.0 / 3600) * 5, TSSEstimator.FromHeartRate(Zones, HeartRates), 4);

            HeartRates = new List <int>(new int[] { 214, 214, 214, 214, 214 });
            Assert.Equal((140.0 / 3600) * 5, TSSEstimator.FromHeartRate(Zones, HeartRates), 4);
        }
        public async Task <IActionResult> Estimate()
        {
            try{
                var form = await Request.ReadFormAsync();

                Console.WriteLine("In the estimates controller, recieved objects #:" + form.Count);
                var zonesInt = new List <int>();
                foreach (string z in form.ToDictionary(x => x.Key, x => x.Value).Values.ToArray())
                {
                    zonesInt.Add(Convert.ToInt32(z));
                }
                var tss = TSSEstimator.FromHeartRate(zonesInt, HeartRateLogger.Instance.HeartRates);
                return(Ok((new { tss })));
            }
            catch (Exception ex) {
                var originalMessage = ex.Message;

                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                return(BadRequest($"{originalMessage} | {ex.Message}"));
            }
        }