diff --git a/ErgometerIPR/ErgometerApplication/ErgometerApplication.csproj b/ErgometerIPR/ErgometerApplication/ErgometerApplication.csproj
index 1903322..c53b71f 100644
--- a/ErgometerIPR/ErgometerApplication/ErgometerApplication.csproj
+++ b/ErgometerIPR/ErgometerApplication/ErgometerApplication.csproj
@@ -87,6 +87,7 @@
+
ClientApplicatie.cs
diff --git a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs
index 019d5a7..6fcb0b6 100644
--- a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs
+++ b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs
@@ -13,11 +13,11 @@ namespace ErgometerApplication
private int age;
private char gender;
- private enum state {WARMUP, WORKLOAD, COOLINGDOWN};
+ private enum state {WARMUP, WORKLOAD, COOLINGDOWN, STOP};
private state currentstate;
private int workloadStarted;
private int workloadHearthbeat;
- private int workloadnumber;
+ private List workloads;
public ErgometerTest(int weight, int length , int age, char gender)
{
@@ -26,8 +26,10 @@ namespace ErgometerApplication
this.age = age;
this.gender = gender;
currentstate = state.WARMUP;
- workloadnumber = 1;
+ workloads = new List();
MainClient.ComPort.Write("SET PW 25");
+
+ Console.WriteLine(CalculateVOMaxTest());
}
public void timerTick()
@@ -58,15 +60,15 @@ namespace ErgometerApplication
//Checken of de heartrate niet groter is dan 75%, anders stoppen
if (workloadHearthbeat > CalculateMaximumHeartRate())
{
+ workloadStarted = MainClient.GetLastMeting().Seconds;
currentstate = state.COOLINGDOWN;
}
-
- MainClient.ComPort.Write("PW " + GetWorkloadPower(workloadnumber));
+ workloads.Add(new Workload(MainClient.GetLastMeting().Power, workloadHearthbeat));
+ MainClient.ComPort.Write("PW " + GetWorkloadPower(workloads.Count-1));
workloadStarted = MainClient.GetLastMeting().Seconds;
workloadHearthbeat = 0;
- workloadnumber++;
- Console.WriteLine("3:00 gefietst, workload" + workloadnumber + " af, nieuwe waardes maken");
+ Console.WriteLine("3:00 gefietst, workload" + (workloads.Count - 1) + " af, nieuwe waardes maken");
}
else if (MainClient.GetLastMeting().Seconds - workloadStarted > 160 && workloadHearthbeat == 0)
{
@@ -75,19 +77,23 @@ namespace ErgometerApplication
Console.WriteLine("2:40 gefiets, gemiddelde harstslag berekenen:" + workloadHearthbeat);
}
break;
- case state.COOLINGDOWN:
+ case state.COOLINGDOWN:
+ MainClient.ComPort.Write("SET PW 25");
+ if(MainClient.GetLastMeting().Seconds - workloadStarted > 360)
+ {
+ currentstate = state.STOP;
+ }
break;
}
}
// WORKLOAD //
-
private int GetWorkloadPower(int workload)
{
if (gender == 'V')
{
- if (workloadnumber == 1)
+ if (workload == 1)
{
if (workloadHearthbeat < 80)
return 125;
@@ -105,7 +111,7 @@ namespace ErgometerApplication
}
else if(gender == 'M')
{
- if(workloadnumber == 1)
+ if(workload == 1)
{
if (workloadHearthbeat < 90)
return 150;
@@ -114,7 +120,7 @@ namespace ErgometerApplication
else
return 100;
}
- else if(workloadnumber == 2)
+ else if(workload == 2)
{
if(workloadHearthbeat < 120)
{
@@ -153,6 +159,16 @@ namespace ErgometerApplication
return 25;
}
+ // CALCULATOR FUNCTIONS //
+
+ public double CalculateVOMax()
+ {
+ Workload wa = workloads[workloads.Count - 2];
+ Workload wb = workloads.Last();
+
+ var LmA = 0.32643 + 0.55275 * wa.getKiloponds() + 0.014429 * Math.Pow(wa.getKiloponds(), 2) + 0.00025271 * Math.Pow(wa.getKiloponds(), 3);
var LmB = 0.32643 + 0.55275 * wb.getKiloponds() + 0.014429 * Math.Pow(wb.getKiloponds(), 2) + 0.00025271 * Math.Pow(wb.getKiloponds(), 3);
var VOABS = LmB + ((LmB - LmA) / (wb.heartrate - wa.heartrate)) * (220 - age - wb.heartrate);
return VOABS * 1000 / weight;
+ }
+
// HELPER FUNCTIONS //
diff --git a/ErgometerIPR/ErgometerApplication/Workload.cs b/ErgometerIPR/ErgometerApplication/Workload.cs
new file mode 100644
index 0000000..9b72f34
--- /dev/null
+++ b/ErgometerIPR/ErgometerApplication/Workload.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ErgometerApplication
+{
+ class Workload
+ {
+ public double watt{private set; get; }
+ public double heartrate { private set; get; }
+
+ public Workload(int watt, int heartrate)
+ {
+ this.watt = watt;
+ this.heartrate = heartrate;
+ }
+
+ public double getKiloponds()
+ {
+ return watt / 50;
+ }
+ }
+}