Example #1
0
 /**
  * Calculate power
  */
 protected function calculatePower()
 {
     if (\Runalyze\Context::Factory()->sport($this->Object->sportid())->hasPower() && Configuration::ActivityForm()->computePower() && NULL !== $this->Trackdata) {
         $Calculator = new \Runalyze\Calculation\Power\Calculator($this->Trackdata, $this->Route);
         $Calculator->calculate();
         $this->Trackdata->set(Model\Trackdata\Object::POWER, $Calculator->powerData());
         $this->Object->set(Object::POWER, $Calculator->average());
     }
 }
Example #2
0
 /**
  * Update power
  */
 protected function updatePower()
 {
     if ($this->hasChanged(Entity::SPORTID)) {
         if (\Runalyze\Context::Factory()->sport($this->NewObject->sportid())->hasPower() && null !== $this->Trackdata && $this->Trackdata->has(Model\Trackdata\Entity::TIME) && $this->Trackdata->has(Model\Trackdata\Entity::DISTANCE)) {
             $Calculator = new \Runalyze\Calculation\Power\Calculator($this->Trackdata, $this->Route);
             $Calculator->calculate();
             $this->updatePowerForTrackdata($Calculator->powerData());
             $this->NewObject->set(Entity::POWER, $Calculator->average());
         } else {
             $this->updatePowerForTrackdata(array());
             $this->NewObject->set(Entity::POWER, 0);
         }
     }
 }
Example #3
0
 /**
  * Update power
  */
 protected function updatePower()
 {
     if ($this->hasChanged(Object::SPORTID)) {
         if (\Runalyze\Context::Factory()->sport($this->NewObject->sportid())->hasPower()) {
             $Calculator = new \Runalyze\Calculation\Power\Calculator($this->Trackdata, $this->Route);
             $Calculator->calculate();
             $this->updatePowerForTrackdata($Calculator->powerData());
             $this->NewObject->set(Object::POWER, $Calculator->average());
         } else {
             $this->updatePowerForTrackdata(array());
             $this->NewObject->set(Object::POWER, 0);
         }
     }
 }