Browse Source

Different beeps at different times

Kenneth van Ewijk 10 years ago
parent
commit
0ded1cb132

+ 2 - 3
ErgometerIPR/ErgometerApplication/ClientApplicatie.cs

@@ -31,7 +31,7 @@ namespace ErgometerApplication
 
         private void updateBeep(object sender, EventArgs e)
         {
-            Console.Beep(1000,5);
+            MainClient.RPMBeatAudio();
         }
         private void updateTimer_Tick(object sender, EventArgs e)
         {
@@ -103,7 +103,6 @@ namespace ErgometerApplication
         public void updateStepsText(string text)
         {
             steps.setText(text);
-            Console.Beep(1200, 500);
         }
 
         public void CreateNewTest(char geslacht, int leeftijd, int gewicht, int lengte)
@@ -118,7 +117,7 @@ namespace ErgometerApplication
             MainClient.ComPort.Read();
             ergotest = new ErgometerTest(gewicht, lengte, leeftijd, geslacht, this);
             updateTimer.Start();
-            
+            beeptimer.Start();
         }
 
         private void buttonLogOff_Click(object sender, EventArgs e)

+ 8 - 4
ErgometerIPR/ErgometerApplication/ErgometerTest.cs

@@ -29,11 +29,12 @@ namespace ErgometerApplication
             this.gender = gender;
             currentstate = state.WARMUP;
 
+            MainClient.SwitchTestModeAudio();
+
             this.client = client;
             client.updateStepsText("U begint nu aan een warmup, probeer een tempo van 50 rpm aan te houden. De test gaat automatisch verder.");
 			workloads = new List<Workload>();
             MainClient.ComPort.Write("PW 25");
-            MainClient.Client.beeptimer.Start();
         }
 
         public void timerTick()
@@ -44,8 +45,8 @@ namespace ErgometerApplication
                     if (MainClient.GetLastMeting().Seconds > 30)
                     {
                         List<ErgometerLibrary.Meting> last10 = MainClient.Metingen.GetRange(MainClient.Metingen.Count - 10, 10);
-                        int max = FindMaxValue(MainClient.Metingen, x => x.HeartBeat);
-                        int min = FindMinValue(MainClient.Metingen, x => x.HeartBeat);
+                        int max = FindMaxValue(last10, x => x.HeartBeat);
+                        int min = FindMinValue(last10, x => x.HeartBeat);
                         Console.WriteLine(max);
                         Console.WriteLine(min);
                         if(max - min > 10) //Hartslag niet stabiel
@@ -56,6 +57,7 @@ namespace ErgometerApplication
                         else
                         {
                             currentstate = state.WORKLOAD;
+                            MainClient.SwitchTestModeAudio();
                             workloadStarted = MainClient.GetLastMeting().Seconds;
                             client.updateStepsText("De warmup is voltooid. U begint nu aan de " + NumToText(GetCurrentWorkload()) + " workload.");
                         }
@@ -69,6 +71,7 @@ namespace ErgometerApplication
                         {
                             workloadStarted = MainClient.GetLastMeting().Seconds;
                             currentstate = state.COOLINGDOWN;
+                            MainClient.SwitchTestModeAudio();
                             client.updateStepsText("Uw hartslag heeft het kritieke punt bereikt, we beginnen nu aan de cooldown.");
                         }
 
@@ -77,7 +80,7 @@ namespace ErgometerApplication
                         MainClient.ComPort.Write("PW " + pw);
 
                         client.updateStepsText("U heeft de workload afgerond, u begint nu aan de " + NumToText(GetCurrentWorkload()) + " workload. Uw nieuwe weerstand is " + pw + " Watt.");
-
+                        MainClient.SwitchWorkloadAudio();
 
                         workloadStarted = MainClient.GetLastMeting().Seconds;
                         workloadHearthbeat = 0;
@@ -100,6 +103,7 @@ namespace ErgometerApplication
                     if(MainClient.GetLastMeting().Seconds - workloadStarted > 360)
                     {
                         currentstate = state.STOP;
+                        MainClient.SwitchTestModeAudio();
                         client.updateStepsText("De test is afgelopen.");
                     }
                     else if(MainClient.GetLastMeting().Seconds - workloadStarted > 8 && MainClient.GetLastMeting().Seconds - workloadStarted < 10)

+ 19 - 0
ErgometerIPR/ErgometerApplication/MainClient.cs

@@ -47,6 +47,25 @@ namespace ErgometerApplication
             Client = client;
         }
 
+        public static void RPMBeatAudio()
+        {
+            Console.Beep(1000, 5);
+        }
+
+        public static void SwitchWorkloadAudio()
+        {
+            Console.Beep(1000, 200);
+            Console.Beep(1100, 200);
+            Console.Beep(1200, 100);
+        }
+
+        public static void SwitchTestModeAudio()
+        {
+            Console.Beep(1000, 200);
+            Console.Beep(900, 200);
+            Console.Beep(800, 100);
+        }
+
         public static bool Connect(string comport, string name, string password, out string error)
         {
             error = "Succes";