Janco Kock 10 lat temu
rodzic
commit
78404b2295
1 zmienionych plików z 34 dodań i 15 usunięć
  1. 34 15
      ErgometerIPR/ErgometerApplication/ErgometerTest.cs

+ 34 - 15
ErgometerIPR/ErgometerApplication/ErgometerTest.cs

@@ -11,38 +11,57 @@ namespace ErgometerApplication
         private int weight;
         private int length;
         private int age;
+        private char gender;
 
-        private enum state {WARMUP, WORKLOAD1, WORKLOAD2, WORKLOAD3, WORKLOAD4, COOLINGDOWN};
+        private enum state {WARMUP, WORKLOAD, COOLINGDOWN};
         private state currentstate;
         private int stateStarted;
 
-        public ErgometerTest(int weight, int length , int age)
+        public ErgometerTest(int weight, int length , int age, char gender)
         {
             this.weight = weight;
             this.length = length;
             this.age = age;
-            this.currentstate = state.WARMUP;
+            this.gender = gender;
+            currentstate = state.WARMUP;
             stateStarted = 0;
         }
 
-        private double CalculateMaximumHeartRate()
-        {
-            return 208 - (0.7 * age);
-        }
-
         public void timerTick()
         {
-            if(currentstate == state.WARMUP)
+            switch(currentstate)
             {
-                if (MainClient.Metingen.Last().Seconds > 30)
-                {
-                    List<ErgometerLibrary.Meting> 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);
-                };
+                case state.WARMUP:
+                    if (MainClient.Metingen.Last().Seconds > 30)
+                    {
+                        List<ErgometerLibrary.Meting> 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);
+                        if(max - min > 20) //Hartslag niet stabiel
+                        {
+                            return;
+                        }
+                        else
+                        {
+                            currentstate = state.WORKLOAD;
+                        }
+                    }
+                    break;
+                case state.WORKLOAD:
+                    break;
+                case state.COOLINGDOWN:
+                    break;
             }
         }
 
+
+        //          HELPER FUNCTIONS         //
+
+        private double CalculateMaximumHeartRate()
+        {
+            return 208 - (0.7 * age);
+        }
+
         public int FindMaxValue<T>(List<T> list, Converter<T, int> projection)
         {
             if (list.Count == 0)