From 5ec521c2a5184e5bf4dd0fe0544a682138250587 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 3 Nov 2015 16:08:55 +0100 Subject: [PATCH] Bugfixes --- .../ErgometerApplication/ClientApplicatie.cs | 1 + .../ErgometerApplication/ErgometerTest.cs | 22 +++++++++---------- .../Client/ClientThread.cs | 9 +++++--- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs b/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs index c6098b8..cfc33ae 100644 --- a/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs +++ b/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs @@ -120,6 +120,7 @@ namespace ErgometerApplication MainClient.ComPort.Read(); ergotest = new ErgometerTest(gewicht, lengte, leeftijd, geslacht, this); updateTimer.Start(); + beeptimer.Start(); } diff --git a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs index c18558d..a5f954d 100644 --- a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs +++ b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs @@ -75,16 +75,6 @@ namespace ErgometerApplication case state.WORKLOAD: 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()); workloads.Add(new Workload(MainClient.GetLastMeting().Power, workloadHearthbeat)); MainClient.ComPort.Write("PW " + pw); @@ -95,6 +85,16 @@ namespace ErgometerApplication workloadStarted = MainClient.GetLastMeting().Seconds; workloadHearthbeat = 0; 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) { @@ -130,7 +130,7 @@ namespace ErgometerApplication } 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; } diff --git a/ErgometerIPR/ErgometerDoctorApplication/Client/ClientThread.cs b/ErgometerIPR/ErgometerDoctorApplication/Client/ClientThread.cs index 68a4c40..7999e5a 100644 --- a/ErgometerIPR/ErgometerDoctorApplication/Client/ClientThread.cs +++ b/ErgometerIPR/ErgometerDoctorApplication/Client/ClientThread.cs @@ -43,11 +43,14 @@ namespace ErgometerDoctorApplication switch (command.Type) { 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; case NetCommand.CommandType.CHAT: ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, command.IsDoctor);