From 2f85ba0a4fad2caf29f0afc66b309c7512b673e5 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Wed, 4 Nov 2015 10:39:41 +0100 Subject: [PATCH] Bugfixes --- ErgometerIPR/ErgometerApplication/ClientApplicatie.cs | 2 +- ErgometerIPR/ErgometerApplication/ErgometerTest.cs | 4 ++-- ErgometerIPR/ErgometerApplication/MainClient.cs | 3 ++- ErgometerIPR/ErgometerServer/DoctorThread.cs | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs b/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs index b7a9b18..d4e7f32 100644 --- a/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs +++ b/ErgometerIPR/ErgometerApplication/ClientApplicatie.cs @@ -75,7 +75,7 @@ namespace ErgometerApplication { string error = ""; bool connect = false; - foreach(string comport in SerialPort.GetPortNames()) + foreach(string comport in SerialPort.GetPortNames().Reverse()) { connect = MainClient.Connect(comport, username, password, out error); if (connect) diff --git a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs index 8e186f7..8942e64 100644 --- a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs +++ b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs @@ -62,7 +62,7 @@ namespace ErgometerApplication else deviation = Math.Max(deviation-1, 0); - if(deviation >= 60 && !failed) + if(deviation >= 80 && !failed) { workloadStarted = MainClient.GetLastMeting().Seconds; currentstate = state.COOLINGDOWN; @@ -127,6 +127,7 @@ namespace ErgometerApplication workloadStarted = MainClient.GetLastMeting().Seconds; currentstate = state.COOLINGDOWN; MainClient.SwitchTestModeAudio(); + MainClient.SendNetCommand(new ErgometerLibrary.NetCommand(CalculateVOMax(), CalculateMET(), CalculatePopulationAverage(), CalculateZScore(), CalculateRating(), MainClient.Session)); client.updateStepsText("Uw hartslag heeft het kritieke punt bereikt, we beginnen nu aan de cooldown."); MainClient.ComPort.Write("PW 25"); MainClient.ComPort.Read(); @@ -170,7 +171,6 @@ namespace ErgometerApplication else if (workloads.Count > 1) { MainClient.Client.updateStepsText(String.Format("De test is afgelopen. Uw test resultaten zijn: \n VO2MAX: {0:0.00} MET: {1:0.00} Gemiddelde: {2:0.00} \n {3} ", CalculateVOMax(), CalculateMET(), CalculatePopulationAverage(), CalculateRating())); - MainClient.SendNetCommand(new ErgometerLibrary.NetCommand(CalculateVOMax(), CalculateMET(), CalculatePopulationAverage(), CalculateZScore(), CalculateRating(), MainClient.Session)); } else { diff --git a/ErgometerIPR/ErgometerApplication/MainClient.cs b/ErgometerIPR/ErgometerApplication/MainClient.cs index 45ddc21..5368f14 100644 --- a/ErgometerIPR/ErgometerApplication/MainClient.cs +++ b/ErgometerIPR/ErgometerApplication/MainClient.cs @@ -80,7 +80,8 @@ namespace ErgometerApplication if (ComPort.Connect(comport)) { ComPort.Write("RS"); - string temp = ComPort.Read(); + string temp = ComPort.Read().Replace("\r", "").Replace("\n", ""); + Console.WriteLine(temp); if (temp.ToLower() != "ack") { ComPort.Disconnect(); diff --git a/ErgometerIPR/ErgometerServer/DoctorThread.cs b/ErgometerIPR/ErgometerServer/DoctorThread.cs index 6916910..20fd804 100644 --- a/ErgometerIPR/ErgometerServer/DoctorThread.cs +++ b/ErgometerIPR/ErgometerServer/DoctorThread.cs @@ -77,6 +77,8 @@ namespace ErgometerServer Thread.Sleep(10); sendToDoctor(new NetCommand(meting, input.Session)); } + + break; case NetCommand.RequestType.ALLSESSIONS: List> sessions = FileHandler.GetAllSessions();