Exemple #1
0
 /**
  * @param \Runalyze\View\Activity\Context $context
  * @return array
  */
 protected function computeRounds(Activity\Context $context)
 {
     $Loop = new Trackdata\Loop($context->trackdata());
     $Rounds = array();
     do {
         $Loop->nextDistance();
         $Rounds[] = array('km' => $Loop->difference(Trackdata\Object::DISTANCE), 's' => $Loop->difference(Trackdata\Object::TIME));
     } while (!$Loop->isAtEnd());
     return $Rounds;
 }
 /**
  * Display data
  */
 protected function setDataToCode()
 {
     $this->Code .= '<table class="fullwidth zebra-style">';
     $this->Code .= '<thead><tr>';
     $this->Code .= '<th></th>';
     $this->Code .= '<th>' . __('Distance') . '</th>';
     $this->Code .= '<th>' . __('Time') . '</th>';
     $this->Code .= '<th>' . __('Swolf') . '</th>';
     $this->Code .= '<th>' . __('Strokes') . '</th>';
     $this->Code .= '<th>' . __('Type') . '</th>';
     $this->Code .= '</tr></thead>';
     $this->Code .= '<tbody>';
     $Loop = new Swimdata\Loop($this->Context->swimdata());
     $TrackLoop = new Trackdata\Loop($this->Context->trackdata());
     $Stroketype = new Stroketype(Stroketype::FREESTYLE);
     $Distance = new Distance(0);
     $max = $Loop->num();
     for ($i = 1; $i <= $max; ++$i) {
         $Stroketype->set($Loop->stroketype());
         $Distance->set($TrackLoop->distance());
         $this->Code .= '<tr class="r">';
         $this->Code .= '<td>' . $i . '.</td>';
         $this->Code .= '<td>' . $Distance->stringMeter() . '</td>';
         $this->Code .= '<td>' . Duration::format($TrackLoop->difference(Trackdata\Object::TIME)) . '</td>';
         $this->Code .= '<td>' . $Loop->swolf() . '</td>';
         $this->Code .= '<td>' . $Loop->stroke() . '</td>';
         $this->Code .= '<td>' . $Stroketype->shortstring() . '</td>';
         $this->Code .= '</tr>';
         $TrackLoop->nextStep();
         $Loop->nextStep();
     }
     $this->Code .= '</tbody>';
     $this->Code .= '</table>';
 }
Exemple #3
0
 /**
  * Read lap
  */
 protected function readLap()
 {
     $Lap = new Lap($this->TrackdataLoop->difference(Trackdata\Object::TIME), $this->TrackdataLoop->difference(Trackdata\Object::DISTANCE));
     $Lap->setTrackDuration($this->TrackdataLoop->time());
     $Lap->setTrackDistance($this->TrackdataLoop->distance());
     $Lap->setHR($this->TrackdataLoop->average(Trackdata\Object::HEARTRATE), $this->TrackdataLoop->max(Trackdata\Object::HEARTRATE));
     $this->addElevationFor($Lap);
     $this->Laps->add($Lap);
 }
 /**
  * Add all laps to xml 
  */
 protected function setLaps()
 {
     $Starttime = $this->Context->activity()->timestamp();
     $Loop = new Trackdata\Loop($this->Context->trackdata());
     while (!$Loop->isAtEnd()) {
         $Loop->nextKilometer();
         $TimeInSeconds = $Loop->difference(Trackdata\Object::TIME);
         $Lap = $this->Activity->addChild('Lap');
         $Lap->addAttribute('StartTime', $this->timeToString($Starttime + $Loop->time() - $TimeInSeconds));
         $Lap->addChild('TotalTimeSeconds', $TimeInSeconds);
         $Lap->addChild('DistanceMeters', 1000 * $Loop->difference(Trackdata\Object::DISTANCE));
         if ($this->Context->trackdata()->has(Trackdata\Object::HEARTRATE)) {
             $AvgBpm = $Lap->addChild('AverageHeartRateBpm');
             $AvgBpm->addChild('Value', $Loop->average(Trackdata\Object::HEARTRATE));
             $MaxBpm = $Lap->addChild('MaximumHeartRateBpm');
             $MaxBpm->addChild('Value', $Loop->max(Trackdata\Object::HEARTRATE));
         }
         $Lap->addChild('Intensity', 'Active');
         $Lap->addChild('TriggerMethod', 'Distance');
         $Lap->addChild('Track');
         // TODO: Calories?
     }
     $this->setTrack();
 }
Exemple #5
0
 /**
  * @param string $key Object key to move
  */
 protected function runFastSmoothingForKey($key)
 {
     $started = false;
     while (!$this->Loop->isAtEnd()) {
         $this->Loop->move($key, $this->StepSize);
         $dist = $this->Loop->difference(Trackdata\Object::DISTANCE);
         $pace = $dist > 0 ? round($this->Loop->difference(Trackdata\Object::TIME) / $dist) : 0;
         if ($this->KeepArraySize) {
             $steps = $this->Loop->currentStepSize();
             if (!$started) {
                 $steps += 1;
                 $started = true;
             }
             for ($i = 0; $i < $steps; ++$i) {
                 $this->Smoothed[] = $pace;
             }
         } else {
             $this->Smoothed[] = $pace;
         }
     }
 }
Exemple #6
0
 public function fillSwolfArray(Trackdata\Entity &$trackdata)
 {
     if ($this->stroke() && $trackdata->has(Trackdata\Entity::TIME)) {
         $TrackLoop = new Trackdata\Loop($trackdata);
         $Loop = new Loop($this);
         $max = $Loop->num();
         $swolf = array();
         $swolfcycles = array();
         for ($i = 1; $i <= $max; ++$i) {
             $duration = $TrackLoop->difference(Trackdata\Entity::TIME);
             $swolf[] = $duration + $Loop->stroke();
             $swolfcycles[] = $duration + $Loop->stroke() / 2;
             $Loop->nextStep();
             $TrackLoop->nextStep();
         }
         $this->set(Entity::SWOLF, $swolf);
         $this->set(Entity::SWOLFCYCLES, $swolfcycles);
     }
 }
Exemple #7
0
 /**
  * @param \Runalyze\Model\Trackdata\Loop $Loop
  * @return array
  */
 protected function halfFromLoop(Trackdata\Loop $Loop)
 {
     return array('s' => $Loop->difference(Trackdata\Entity::TIME), 'km' => $Loop->difference(Trackdata\Entity::DISTANCE));
 }