public function testViaTrimp()
 {
     $Athlete = new Athlete(null, 205, 45);
     for ($i = 0; $i < 10; ++$i) {
         $hr = mt_rand(45, 205);
         $t = mt_rand(60, 3600);
         $Trimp = new Calculator($Athlete, array($hr => $t));
         if ($Trimp->value() > 0) {
             $Inverse = new InverseCalculator($Athlete, $hr, $Trimp->value());
             $this->assertEquals($t, $Inverse->value(), sprintf('Inverse check failed for %us at %ubpm.', $t, $hr), 0.01 * $t);
         }
     }
 }
Esempio n. 2
0
 /**
  * Calculate trimp
  * @return int
  */
 public function calculateTrimp()
 {
     if ($this->knowsTrackdata() && $this->Trackdata->has(Model\Trackdata\Object::HEARTRATE)) {
         $Collector = new Trimp\DataCollector($this->Trackdata->heartRate(), $this->Trackdata->time());
         $data = $Collector->result();
     } elseif ($this->Activity->hrAvg() > 0) {
         $data = array($this->Activity->hrAvg() => $this->Activity->duration());
     } else {
         $Factory = Context::Factory();
         if ($this->Activity->typeid() > 0) {
             $data = array($Factory->type($this->Activity->typeid())->hrAvg() => $this->Activity->duration());
         } else {
             $data = array($Factory->sport($this->Activity->sportid())->avgHR() => $this->Activity->duration());
         }
     }
     $Athlete = Context::Athlete();
     $Calculator = new Trimp\Calculator($Athlete, $data);
     return round($Calculator->value());
 }
Esempio n. 3
0
 /**
  * @see http://fellrnr.com/wiki/TRIMP#Worked_Example
  */
 public function testReferenceExample()
 {
     $Male = new Gender();
     $Male->set(Gender::MALE);
     $Trimp = new Calculator(new Athlete($Male, 200, 40), array(130 => 30 * 60));
     $this->assertEquals(32, $Trimp->value(), '', 0.01 * 32);
 }