|
@@ -13,11 +13,11 @@ namespace ErgometerApplication
|
|
|
private int age;
|
|
private int age;
|
|
|
private char gender;
|
|
private char gender;
|
|
|
|
|
|
|
|
- private enum state {WARMUP, WORKLOAD, COOLINGDOWN};
|
|
|
|
|
|
|
+ private enum state {WARMUP, WORKLOAD, COOLINGDOWN, STOP};
|
|
|
private state currentstate;
|
|
private state currentstate;
|
|
|
private int workloadStarted;
|
|
private int workloadStarted;
|
|
|
private int workloadHearthbeat;
|
|
private int workloadHearthbeat;
|
|
|
- private int workloadnumber;
|
|
|
|
|
|
|
+ private List<Workload> workloads;
|
|
|
|
|
|
|
|
public ErgometerTest(int weight, int length , int age, char gender)
|
|
public ErgometerTest(int weight, int length , int age, char gender)
|
|
|
{
|
|
{
|
|
@@ -26,8 +26,10 @@ namespace ErgometerApplication
|
|
|
this.age = age;
|
|
this.age = age;
|
|
|
this.gender = gender;
|
|
this.gender = gender;
|
|
|
currentstate = state.WARMUP;
|
|
currentstate = state.WARMUP;
|
|
|
- workloadnumber = 1;
|
|
|
|
|
|
|
+ workloads = new List<Workload>();
|
|
|
MainClient.ComPort.Write("SET PW 25");
|
|
MainClient.ComPort.Write("SET PW 25");
|
|
|
|
|
+
|
|
|
|
|
+ Console.WriteLine(CalculateVOMaxTest());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void timerTick()
|
|
public void timerTick()
|
|
@@ -58,15 +60,15 @@ namespace ErgometerApplication
|
|
|
//Checken of de heartrate niet groter is dan 75%, anders stoppen
|
|
//Checken of de heartrate niet groter is dan 75%, anders stoppen
|
|
|
if (workloadHearthbeat > CalculateMaximumHeartRate())
|
|
if (workloadHearthbeat > CalculateMaximumHeartRate())
|
|
|
{
|
|
{
|
|
|
|
|
+ workloadStarted = MainClient.GetLastMeting().Seconds;
|
|
|
currentstate = state.COOLINGDOWN;
|
|
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;
|
|
workloadStarted = MainClient.GetLastMeting().Seconds;
|
|
|
workloadHearthbeat = 0;
|
|
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)
|
|
else if (MainClient.GetLastMeting().Seconds - workloadStarted > 160 && workloadHearthbeat == 0)
|
|
|
{
|
|
{
|
|
@@ -75,19 +77,23 @@ namespace ErgometerApplication
|
|
|
Console.WriteLine("2:40 gefiets, gemiddelde harstslag berekenen:" + workloadHearthbeat);
|
|
Console.WriteLine("2:40 gefiets, gemiddelde harstslag berekenen:" + workloadHearthbeat);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
- case state.COOLINGDOWN:
|
|
|
|
|
|
|
+ case state.COOLINGDOWN:
|
|
|
|
|
+ MainClient.ComPort.Write("SET PW 25");
|
|
|
|
|
+ if(MainClient.GetLastMeting().Seconds - workloadStarted > 360)
|
|
|
|
|
+ {
|
|
|
|
|
+ currentstate = state.STOP;
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// WORKLOAD //
|
|
// WORKLOAD //
|
|
|
|
|
|
|
|
-
|
|
|
|
|
private int GetWorkloadPower(int workload)
|
|
private int GetWorkloadPower(int workload)
|
|
|
{
|
|
{
|
|
|
if (gender == 'V')
|
|
if (gender == 'V')
|
|
|
{
|
|
{
|
|
|
- if (workloadnumber == 1)
|
|
|
|
|
|
|
+ if (workload == 1)
|
|
|
{
|
|
{
|
|
|
if (workloadHearthbeat < 80)
|
|
if (workloadHearthbeat < 80)
|
|
|
return 125;
|
|
return 125;
|
|
@@ -105,7 +111,7 @@ namespace ErgometerApplication
|
|
|
}
|
|
}
|
|
|
else if(gender == 'M')
|
|
else if(gender == 'M')
|
|
|
{
|
|
{
|
|
|
- if(workloadnumber == 1)
|
|
|
|
|
|
|
+ if(workload == 1)
|
|
|
{
|
|
{
|
|
|
if (workloadHearthbeat < 90)
|
|
if (workloadHearthbeat < 90)
|
|
|
return 150;
|
|
return 150;
|
|
@@ -114,7 +120,7 @@ namespace ErgometerApplication
|
|
|
else
|
|
else
|
|
|
return 100;
|
|
return 100;
|
|
|
}
|
|
}
|
|
|
- else if(workloadnumber == 2)
|
|
|
|
|
|
|
+ else if(workload == 2)
|
|
|
{
|
|
{
|
|
|
if(workloadHearthbeat < 120)
|
|
if(workloadHearthbeat < 120)
|
|
|
{
|
|
{
|
|
@@ -153,6 +159,16 @@ namespace ErgometerApplication
|
|
|
return 25;
|
|
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 //
|
|
// HELPER FUNCTIONS //
|
|
|
|
|
|