/** * Set activity * @param \Runalyze\Model\Activity\Entity $object activity object */ public function setActivity(Model\Activity\Entity $object) { $this->Activity = $object; $this->Dataview = new Dataview($object); $this->Linker = new Linker($object); $this->Sport = $this->Activity->sportid() > 0 ? $this->Factory->sport($this->Activity->sportid()) : null; $this->Type = $this->Activity->typeid() > 0 ? $this->Factory->type($this->Activity->typeid()) : null; $this->ActivityData = $this->Activity->completeData(); $this->IsRunning = $this->hasSport() && $this->Sport->id() == \Runalyze\Configuration::General()->runningSport(); }
/** * Title for this training: type or sport name * @return string */ public function titleByTypeOrSport() { $Factory = new Factory(SessionAccountHandler::getId()); if ($this->Activity->typeid() != 0) { return $Factory->type($this->Activity->typeid())->name(); } return $Factory->sport($this->Activity->sportid())->name(); }
/** * Update vdot shape and corrector */ protected function updateVDOTshapeAndCorrector() { $timestampLimit = time() - Configuration::Vdot()->days() * DAY_IN_S; if ($this->hasChanged(Entity::USE_VDOT) && ($this->NewObject->timestamp() >= $timestampLimit || $this->knowsOldObject() && $this->OldObject->timestamp() > $timestampLimit) || $this->NewObject->usesVDOT() && ($this->hasChanged(Entity::VDOT) || $this->hasChanged(Entity::VDOT_WITH_ELEVATION) || $this->hasChanged(Entity::TIMESTAMP) && $this->knowsOldObject() && ($this->NewObject->timestamp() >= $timestampLimit && $this->OldObject->timestamp() < $timestampLimit || $this->NewObject->timestamp() < $timestampLimit && $this->OldObject->timestamp() >= $timestampLimit))) { Configuration::Data()->recalculateVDOTshape(); } if (($this->NewObject->usesVDOT() || $this->hasChanged(Entity::USE_VDOT)) && ($this->NewObject->typeid() == Configuration::General()->competitionType() || $this->knowsOldObject() && $this->OldObject->typeid() == Configuration::General()->competitionType())) { Configuration::Data()->recalculateVDOTcorrector(); } }
/** * 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(); } } }
/** * Calculate trimp * @return int */ public function calculateTrimp() { if ($this->knowsTrackdata() && $this->Trackdata->has(Model\Trackdata\Entity::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()); }