Ejemplo n.º 1
0
 /**
  * Value of used VDOT (uncorrected)
  * @return float
  */
 public function usedVdot()
 {
     if (Configuration::Vdot()->useElevationCorrection()) {
         if ($this->Activity->vdotWithElevation() > 0) {
             return $this->Activity->vdotWithElevation();
         }
     }
     return $this->Activity->vdotByHeartRate();
 }
Ejemplo n.º 2
0
 /**
  * Update vdot shape and corrector
  */
 protected function updateVDOTshapeAndCorrector()
 {
     $timestampLimit = time() - Configuration::Vdot()->days() * DAY_IN_S;
     if ($this->Object->usesVDOT() && $this->Object->vdotByHeartRate() > 0 && $this->Object->timestamp() > $timestampLimit) {
         Configuration::Data()->recalculateVDOTshape();
         if ($this->Object->typeid() == Configuration::General()->competitionType()) {
             Configuration::Data()->recalculateVDOTcorrector();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Prognosis time by heart rate after correction
  * @return string
  */
 public function prognosisByHRafterCorrection()
 {
     if (Configuration::Vdot()->useCorrectionFactor()) {
         $Prognosis = new Daniels();
         $Prognosis->adjustVDOT(false);
         $Prognosis->setVDOT(Configuration::Data()->vdotFactor() * $this->Activity->vdotByHeartRate());
         return $this->formatTime($Prognosis->inSeconds($this->Activity->distance()));
     }
     return '-';
 }
Ejemplo n.º 4
0
 /**
  * Calculate factor from activity
  * 
  * Simply calculates the ratio of vdot by time and by heart rate.
  * This method does not regard any other correction (e.g. elevation, ...).
  * 
  * @param \Runalyze\Model\Activity\Object $activity
  */
 public function fromActivity(Activity\Object $activity)
 {
     if ($activity->vdotByHeartRate() > 0) {
         $this->Factor = $activity->vdotByTime() / $activity->vdotByHeartRate();
     } else {
         $this->Factor = 1;
     }
 }
Ejemplo n.º 5
0
 /**
  * Get content for a given dataset
  * @param string $name
  * @return string
  */
 public function getDataset($name)
 {
     switch ($name) {
         case 'sportid':
             if (!is_null($this->Sport)) {
                 return $this->Sport->icon()->code();
             }
             return '';
         case 'typeid':
             if (!is_null($this->Type)) {
                 if ($this->Type->isQualitySession()) {
                     return '<strong>' . $this->Type->abbreviation() . '</strong>';
                 }
                 return $this->Type->abbreviation();
             }
             return '';
         case 'time':
             return $this->Dataview->daytime();
         case 'distance':
             return $this->Dataview->distance() . $this->distanceComparison();
         case 's':
             return $this->Dataview->duration()->string();
         case 'pace':
             if ($this->Activity->distance() > 0) {
                 if (isset($this->ActivityData['s_sum_with_distance'])) {
                     if ($this->ActivityData['s_sum_with_distance'] > 0) {
                         $Pace = new Pace($this->ActivityData['s_sum_with_distance'], $this->Activity->distance(), SportFactory::getSpeedUnitFor($this->Activity->sportid()));
                         return $Pace->valueWithAppendix();
                     }
                     return '';
                 }
                 return $this->Dataview->pace()->valueWithAppendix();
             }
             return '';
         case 'elevation':
             if ($this->Activity->elevation() > 0) {
                 return $this->Dataview->elevation()->string();
             }
             return '';
         case 'kcal':
             return $this->Dataview->calories();
         case 'pulse_avg':
             if ($this->Activity->hrAvg() > 0) {
                 return $this->Dataview->hrAvg()->string();
             }
             return '';
         case 'pulse_max':
             if ($this->Activity->hrMax() > 0) {
                 return $this->Dataview->hrMax()->string();
             }
             return '';
         case 'trimp':
             return $this->Dataview->trimp();
         case 'cadence':
             if ($this->Dataview->cadence()->value() > 0) {
                 return $this->Dataview->cadence()->asString();
             }
             return '';
         case 'stride_length':
             if ($this->Dataview->strideLength()->value() > 0) {
                 return $this->Dataview->strideLength()->string();
             }
             return '';
         case 'groundcontact':
             return $this->Dataview->groundcontact();
         case 'vertical_oscillation':
             return $this->Dataview->verticalOscillation();
         case 'power':
             return $this->Dataview->power();
         case 'temperature':
             if (!$this->Activity->weather()->temperature()->isUnknown() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return Temperature::format($this->Activity->weather()->temperature()->value(), true, false);
             }
             return '';
         case 'weatherid':
             if (!$this->Activity->weather()->isEmpty() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return $this->Activity->weather()->condition()->icon()->code();
             }
             return '';
         case 'routeid':
             if ($this->Activity->get(Activity\Object::ROUTEID) > 0) {
                 return $this->cut($this->Factory->route($this->Activity->get(Activity\Object::ROUTEID))->name());
             }
             return '';
         case 'splits':
             if (!$this->Activity->splits()->isEmpty()) {
                 if ($this->Activity->splits()->hasActiveAndInactiveLaps() || round($this->Activity->splits()->totalDistance()) != round($this->Activity->distance()) || !is_null($this->Type) && $this->Type->id() == Configuration::General()->competitionType()) {
                     // TODO: Icon with tooltip?
                     $Icon = new Icon(Icon::CLOCK);
                     return $Icon->code();
                 }
             }
             return '';
         case 'comment':
             return $this->cut($this->Activity->comment());
         case 'partner':
             return $this->cut($this->Activity->partner()->asString());
         case 'abc':
             return $this->Dataview->abcIcon();
         case 'vdoticon':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->vdotIcon();
             }
             return '';
         case 'vdot':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport() && $this->Activity->vdotByHeartRate() > 0) {
                 if (!$this->Activity->usesVDOT()) {
                     return '<span class="unimportant">' . $this->Dataview->vdot()->value() . '</span>';
                 }
                 return $this->Dataview->vdot()->value();
             }
             return '';
         case 'jd_intensity':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->jdIntensityWithStresscolor();
             }
             return '';
         case 'fit_vdot_estimate':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->fitVdotEstimate();
             }
             return '';
         case 'fit_recovery_time':
             return $this->Dataview->fitRecoveryTime();
         case 'fit_hrv_analysis':
             return $this->Dataview->fitHRVscore();
     }
     return '';
 }
Ejemplo n.º 6
0
 /**
  * Get content for a given dataset
  * @param string $name
  * @return string
  */
 public function getDataset($name)
 {
     switch ($name) {
         case 'sportid':
             if (!is_null($this->Sport)) {
                 return $this->Sport->icon()->code();
             }
             return '';
         case 'typeid':
             if (!is_null($this->Type)) {
                 if ($this->Type->isQualitySession()) {
                     return '<strong>' . $this->Type->abbreviation() . '</strong>';
                 }
                 return $this->Type->abbreviation();
             }
             return '';
         case 'time':
             return $this->Dataview->daytime();
         case 'distance':
             return $this->Dataview->distance() . $this->distanceComparison();
         case 's':
             return $this->Dataview->duration()->string();
         case 'pace':
             if ($this->Activity->distance() > 0) {
                 // TODO: 's_sum_with_distance'
                 //return $this->TrainingObject->DataView()->getSpeedStringForTime( $this->TrainingObject->getTimeInSecondsSumWithDistance() );
                 return $this->Dataview->pace()->valueWithAppendix();
             }
             return '';
         case 'elevation':
             return $this->Dataview->elevation();
         case 'kcal':
             return $this->Dataview->calories();
         case 'pulse_avg':
             if ($this->Activity->hrAvg() > 0) {
                 return $this->Dataview->hrAvg()->string();
             }
             return '';
         case 'pulse_max':
             if ($this->Activity->hrMax() > 0) {
                 return $this->Dataview->hrMax()->string();
             }
             return '';
         case 'trimp':
             return $this->Dataview->trimp();
         case 'cadence':
             if ($this->Dataview->cadence()->value() > 0) {
                 return $this->Dataview->cadence()->asString();
             }
             return '';
         case 'stride_length':
             if ($this->Dataview->strideLength()->inCM() > 0) {
                 return $this->Dataview->strideLength()->string();
             }
             return '';
         case 'groundcontact':
             return $this->Dataview->groundcontact();
         case 'vertical_oscillation':
             return $this->Dataview->verticalOscillation();
         case 'power':
             return $this->Dataview->power();
         case 'temperature':
             if (!$this->Activity->weather()->temperature()->isUnknown() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return $this->Activity->weather()->temperature()->asString();
             }
             return '';
         case 'weatherid':
             if (!$this->Activity->weather()->isEmpty() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return $this->Activity->weather()->condition()->icon()->code();
             }
             return '';
         case 'routeid':
             if ($this->Activity->get(Activity\Object::ROUTEID) > 0) {
                 return $this->cut($this->Factory->route($this->Activity->get(Activity\Object::ROUTEID))->name());
             }
             return '';
         case 'clothes':
             return $this->cut($this->Dataview->clothes());
         case 'splits':
             if (!$this->Activity->splits()->isEmpty()) {
                 if ($this->Activity->splits()->hasActiveAndInactiveLaps() || round($this->Activity->splits()->totalDistance()) != round($this->Activity->distance()) || !is_null($this->Type) && $this->Type->id() == Configuration::General()->competitionType()) {
                     // TODO: Icon with tooltip?
                     $Icon = new Icon(Icon::CLOCK);
                     return $Icon->code();
                 }
             }
             return '';
         case 'comment':
             return $this->cut($this->Activity->comment());
         case 'partner':
             return $this->cut($this->Activity->partner()->asString());
         case 'abc':
             return $this->Dataview->abcIcon();
         case 'shoeid':
             if ($this->Activity->shoeID() > 0) {
                 return ShoeFactory::NameOf($this->Activity->shoeID());
             }
             return '';
         case 'vdoticon':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->vdotIcon();
             }
             return '';
         case 'vdot':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport() && $this->Activity->vdotByHeartRate() > 0) {
                 if (!$this->Activity->usesVDOT()) {
                     return '<span class="unimportant">' . $this->Dataview->vdot()->value() . '</span>';
                 }
                 return $this->Dataview->vdot()->value();
             }
             return '';
         case 'jd_intensity':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->jdIntensityWithStresscolor();
             }
             return '';
     }
     return '';
 }