From 9bf99a6f3803feee4aa64d955dbc39b135d4c4f3 Mon Sep 17 00:00:00 2001 From: Janco Kock Date: Sun, 1 Nov 2015 16:21:57 +0100 Subject: [PATCH] Added start of ergometer test --- .../ErgometerApplication/ErgometerTest.cs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 ErgometerIPR/ErgometerApplication/ErgometerTest.cs diff --git a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs new file mode 100644 index 0000000..016a9a2 --- /dev/null +++ b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ErgometerApplication +{ + class ErgometerTest + { + private int weight; + private int length; + private int age; + + private enum state {WARMUP, WORKLOAD1, WORKLOAD2, WORKLOAD3, WORKLOAD4, COOLINGDOWN}; + private state currentstate; + private int stateStarted; + + public ErgometerTest(int weight, int length , int age) + { + this.weight = weight; + this.length = length; + this.age = age; + this.currentstate = state.WARMUP; + stateStarted = 0; + } + + private double CalculateMaximumHeartRate() + { + return 208 - (0.7 * age); + } + + public void timerTick() + { + if(currentstate == state.WARMUP) + { + if (MainClient.Metingen.Last().Seconds > 30) + { + List last10 = MainClient.Metingen.GetRange(MainClient.Metingen.Count - 10, 10); + int max = FindMaxValue(MainClient.Metingen, x => x.HeartBeat); + int min = FindMaxValue(MainClient.Metingen, x => x.HeartBeat); + }; + } + } + + public int FindMaxValue(List list, Converter projection) + { + if (list.Count == 0) + { + throw new InvalidOperationException("Empty list"); + } + int maxValue = int.MinValue; + foreach (T item in list) + { + int value = projection(item); + if (value > maxValue) + { + maxValue = value; + } + } + return maxValue; + } + + public int FindMinValue(List list, Converter projection) + { + if (list.Count == 0) + { + throw new InvalidOperationException("Empty list"); + } + int minValue = int.MaxValue; + foreach (T item in list) + { + int value = projection(item); + if (value < minValue) + { + minValue = value; + } + } + return minValue; + } + } +}