Kenneth van Ewijk 10 年之前
父节点
当前提交
5ec521c2a5

+ 1 - 0
ErgometerIPR/ErgometerApplication/ClientApplicatie.cs

@@ -120,6 +120,7 @@ namespace ErgometerApplication
             MainClient.ComPort.Read();
             MainClient.ComPort.Read();
             ergotest = new ErgometerTest(gewicht, lengte, leeftijd, geslacht, this);
             ergotest = new ErgometerTest(gewicht, lengte, leeftijd, geslacht, this);
             updateTimer.Start();
             updateTimer.Start();
+            beeptimer.Start();
             
             
         }
         }
 
 

+ 11 - 11
ErgometerIPR/ErgometerApplication/ErgometerTest.cs

@@ -75,16 +75,6 @@ namespace ErgometerApplication
                 case state.WORKLOAD:
                 case state.WORKLOAD:
                     if (MainClient.GetLastMeting().Seconds - workloadStarted > 180)
                     if (MainClient.GetLastMeting().Seconds - workloadStarted > 180)
                     {
                     {
-                        //Checken of de heartrate niet groter is dan 75%, anders stoppen
-                        if (workloadHearthbeat > (CalculateMaximumHeartRate() * 0.80))
-                        {
-                            workloadStarted = MainClient.GetLastMeting().Seconds;
-                            currentstate = state.COOLINGDOWN;
-                            MainClient.SwitchTestModeAudio();
-                            client.updateStepsText("Uw hartslag heeft het kritieke punt bereikt, we beginnen nu aan de cooldown.");
-                            MainClient.ComPort.Write("PW 25");
-                        }
-
                         int pw = GetWorkloadPower(GetCurrentWorkload());
                         int pw = GetWorkloadPower(GetCurrentWorkload());
                         workloads.Add(new Workload(MainClient.GetLastMeting().Power, workloadHearthbeat));
                         workloads.Add(new Workload(MainClient.GetLastMeting().Power, workloadHearthbeat));
                         MainClient.ComPort.Write("PW " + pw);
                         MainClient.ComPort.Write("PW " + pw);
@@ -95,6 +85,16 @@ namespace ErgometerApplication
                         workloadStarted = MainClient.GetLastMeting().Seconds;
                         workloadStarted = MainClient.GetLastMeting().Seconds;
                         workloadHearthbeat = 0;
                         workloadHearthbeat = 0;
                         Console.WriteLine("3:00 gefietst, workload" + (GetCurrentWorkload()) + " af, nieuwe waardes maken");
                         Console.WriteLine("3:00 gefietst, workload" + (GetCurrentWorkload()) + " af, nieuwe waardes maken");
+
+                        //Checken of de heartrate niet groter is dan 75%, anders stoppen
+                        if (workloadHearthbeat > (CalculateMaximumHeartRate() * 0.80))
+                        {
+                            workloadStarted = MainClient.GetLastMeting().Seconds;
+                            currentstate = state.COOLINGDOWN;
+                            MainClient.SwitchTestModeAudio();
+                            client.updateStepsText("Uw hartslag heeft het kritieke punt bereikt, we beginnen nu aan de cooldown.");
+                            MainClient.ComPort.Write("PW 25");
+                        }
                     }
                     }
                     else if (MainClient.GetLastMeting().Seconds - workloadStarted > 160 && workloadHearthbeat == 0)
                     else if (MainClient.GetLastMeting().Seconds - workloadStarted > 160 && workloadHearthbeat == 0)
                     {
                     {
@@ -130,7 +130,7 @@ namespace ErgometerApplication
                     }
                     }
                     else
                     else
                     {
                     {
-                        MainClient.Client.updateStepsText("Er zijn teweinig workload tests afgenomen om een resultaat te maken. Onze excuses voor het ongemak.");
+                        MainClient.Client.updateStepsText("Er zijn te weinig workload tests afgenomen om een resultaat te maken. Onze excuses voor het ongemak.");
                     }
                     }
                     break;
                     break;
             }
             }

+ 6 - 3
ErgometerIPR/ErgometerDoctorApplication/Client/ClientThread.cs

@@ -43,11 +43,14 @@ namespace ErgometerDoctorApplication
             switch (command.Type)
             switch (command.Type)
             {
             {
                 case NetCommand.CommandType.DATA:
                 case NetCommand.CommandType.DATA:
-                    lock (Metingen)
+                    if (command != null && command.Meting != null)
                     {
                     {
-                        Metingen.Add(command.Meting);
+                        lock (Metingen)
+                        {
+                            Metingen.Add(command.Meting);
+                        }
+                        window.Invoke(window.updateMetingen, new Object[] { command.Meting });
                     }
                     }
-                    window.Invoke(window.updateMetingen, new Object[] { command.Meting });
                     break;
                     break;
                 case NetCommand.CommandType.CHAT:
                 case NetCommand.CommandType.CHAT:
                     ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, command.IsDoctor);
                     ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, command.IsDoctor);