コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
ファイル: Calculator.php プロジェクト: n0rthface/Runalyze
 /**
  * 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());
 }
コード例 #3
0
ファイル: CalculatorTest.php プロジェクト: n0rthface/Runalyze
 /**
  * @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);
 }