Ejemplo n.º 1
0
 /**
  * Athlete
  * @return \Runalyze\Athlete
  */
 public static function Athlete()
 {
     if (!isset(self::$Objects['athlete'])) {
         self::$Objects['athlete'] = new Athlete(Configuration::General()->gender(), Configuration::Data()->HRmax(), Configuration::Data()->HRrest(), null, null, Configuration::Data()->vdot());
     }
     return self::$Objects['athlete'];
 }
Ejemplo n.º 2
0
 /**
  * Set manipulation facotr
  */
 protected function setManipulationFactor()
 {
     $this->Factor = 1;
     $this->HRmax = Configuration::Data()->HRmax();
     $this->HRrest = Configuration::Data()->HRrest();
     if (\Runalyze\Context::Athlete()->knowsMaximalHeartRate() && !Configuration::General()->heartRateUnit()->isBPM()) {
         if (\Runalyze\Context::Athlete()->knowsRestingHeartRate() && Configuration::General()->heartRateUnit()->isHRreserve()) {
             $this->Factor = false;
         } else {
             $this->Factor = 100 / Configuration::Data()->HRmax();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Set direction
  * @param float $vdotValue
  * @param float $currentShape
  */
 protected function setDirectionBasedOn($vdotValue, $currentShape)
 {
     // TODO
     if (is_null($currentShape)) {
         $currentShape = Configuration::Data()->vdot();
     }
     $diff = $vdotValue - $currentShape;
     if ($diff > 3) {
         $this->setUp();
     } elseif ($diff > 1) {
         $this->setUpHalf();
     } elseif ($diff > -1) {
         $this->setRight();
     } elseif ($diff > -3) {
         $this->setDownHalf();
     } else {
         $this->setDown();
     }
 }
    /**
     * Get fieldset for paces
     * @return \FormularFieldset
     */
    public function getFieldsetPaces()
    {
        $Table = '<table class="fullwidth zebra-style">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th class="small">' . __('Pace') . '</th>
						<th class="small">' . __('Description') . '</th>
					</tr>
				</thead>
				<tbody>';
        $VDOT = new VDOT(Configuration::Data()->vdot());
        foreach ($this->getArrayForPaces() as $Pace) {
            $Table .= '<tr>
						<td class="b">' . $Pace['short'] . '</td>
						<td class=""><em>' . Duration::format($VDOT->paceAt($Pace['limit-low'] / 100)) . '</em>&nbsp;-&nbsp;<em>' . Duration::format($VDOT->paceAt($Pace['limit-high'] / 100)) . '</em>/km</td>
						<td class="">' . $Pace['description'] . '</td>
					</tr>';
        }
        $Table .= '
				</tbody>
			</table>';
        $Fieldset = new FormularFieldset(__('Training paces'));
        $Fieldset->addBlock($Table);
        $Fieldset->addInfo(__('These paces are based on Jack Daniels\' recommendation.'));
        return $Fieldset;
    }
Ejemplo n.º 5
0
        $index = Plot::dayOfYearToJStime($StartYear, $d - $AddDays + $StartDayInYear + 1);
        $ATLs[$index] = 100 * $TSBModel->fatigueAt($d - 1) / $maxATL;
        $CTLs[$index] = 100 * $TSBModel->fitnessAt($d - 1) / $maxCTL;
        $TRIMPs[$index] = $Trimps_raw[$d];
        if ($maxTrimp < $Trimps_raw[$d]) {
            $maxTrimp = $Trimps_raw[$d];
        }
        $VDOT_slice = array_slice($VDOTs_raw, $d - $VDOTdays, $VDOTdays);
        $Durations_slice = array_slice($Durations_raw, $d - $VDOTdays, $VDOTdays);
        $VDOT_sum = array_sum($VDOT_slice);
        $Durations_sum = array_sum($Durations_slice);
        if (count($VDOT_slice) != 0 && $Durations_sum != 0) {
            $VDOTs[$index] = Configuration::Data()->vdotFactor() * ($VDOT_sum / $Durations_sum);
        }
        if ($VDOTs_raw[$d]) {
            $VDOTsday[$index] = Configuration::Data()->vdotFactor() * ($VDOTs_raw[$d] / $Durations_raw[$d]);
        }
    }
} else {
    $DataFailed = true;
}
$Plot = new Plot("form" . $_GET['y'], 800, 450);
$Plot->Data[] = array('label' => __('Fitness (CTL)'), 'color' => '#008800', 'data' => $CTLs);
//if (count($ATLs) < $MaxATLPoints)
$Plot->Data[] = array('label' => __('Fatigue (ATL)'), 'color' => '#CC2222', 'data' => $ATLs);
$Plot->Data[] = array('label' => __('avg VDOT'), 'color' => '#000000', 'data' => $VDOTs, 'yaxis' => 2);
$Plot->Data[] = array('label' => 'TRIMP', 'color' => '#5555FF', 'data' => $TRIMPs, 'yaxis' => 3);
$Plot->Data[] = array('label' => __('day VDOT'), 'color' => '#444444', 'data' => $VDOTsday, 'yaxis' => 2);
$Plot->setMarginForGrid(5);
$Plot->setLinesFilled(array(0));
$Plot->setLinesFilled(array(1), 0.3);
Ejemplo n.º 6
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.º 7
0
 /**
  * Get array for exemplary training data
  * @return array 
  */
 protected function getExampleTraining()
 {
     $ClothesID = $this->getRandIdFor('clothes');
     $ShoeID = $this->getRandIdFor('shoe');
     $Data = array('id' => DataObject::$DEFAULT_ID, 'sportid' => Configuration::General()->runningSport(), 'typeid' => Configuration::General()->competitionType(), 'time' => time(), 'created' => time(), 'edited' => time(), 'is_public' => 1, 'is_track' => 1, 'distance' => 10, 's' => 51 * 60 + 27, 'elevation' => 57, 'kcal' => 691, 'pulse_avg' => 186, 'pulse_max' => 193, 'vdot_with_elevation' => Configuration::Data()->vdot() + 1, 'vdot' => Configuration::Data()->vdot() + 2, 'use_vdot' => 0, 'jd_intensity' => 27, 'trimp' => 121, 'cadence' => 90, 'stride_length' => 108, 'groundcontact' => 220, 'vertical_oscillation' => 76, 'power' => 520, 'temperature' => 17, 'weatherid' => 5, 'clothes' => $ClothesID, 'splits' => '5|26:51-5|24:36', 'comment' => str_replace(' ', '&nbsp;', __('Test activity')), 'partner' => 'Peter', 'abc' => 1, 'shoeid' => $ShoeID, 'notes' => str_replace(' ', '&nbsp;', __('Great run!')), 'accountid' => SessionAccountHandler::getId(), 'creator' => '', 'creator_details' => '', 'activity_id' => '', 'elevation_corrected' => 1);
     return $Data;
 }
Ejemplo n.º 8
0
        $withElevation = Configuration::Vdot()->useElevationCorrection();
        $Data = DB::getInstance()->query('
			SELECT
				YEAR(FROM_UNIXTIME(`time`)) as `y`,
				MONTH(FROM_UNIXTIME(`time`)) as `m`,
				SUM(' . JD\Shape::mysqlVDOTsum($withElevation) . ')/SUM(' . JD\Shape::mysqlVDOTsumTime($withElevation) . ') as `vdot`
			FROM `' . PREFIX . 'training`
			WHERE
				`vdot`>0 AND use_vdot<>0
			GROUP BY `y`, `m`
			ORDER BY `y` ASC, `m` ASC')->fetchAll();
        Cache::set('prognosePlotData', $Data, '300');
    }
    foreach ($Data as $dat) {
        // TODO: use correct GA
        $Strategy->setVDOT(Configuration::Data()->vdotFactor() * $dat['vdot']);
        $index = mktime(1, 0, 0, $dat['m'], 15, $dat['y']);
        $Prognosis[$index . '000'] = $PrognosisObj->inSeconds($distance) * 1000;
    }
    $ResultsData = Cache::get('prognosePlotDistanceData' . $distance);
    if (is_null($ResultsData)) {
        $ResultsData = DB::getInstance()->query('
			SELECT
				`time`,
				`id`,
				`s`
			FROM `' . PREFIX . 'training`
			WHERE
				`typeid`="' . Configuration::General()->competitionType() . '"
				AND `distance`="' . $distance . '"
			ORDER BY
Ejemplo n.º 9
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();
         }
     }
 }
    /**
     * Get fieldset for paces
     * @return \FormularFieldset
     */
    public function getFieldsetPaces()
    {
        $Table = '<table class="fullwidth zebra-style">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th class="small">' . __('Pace') . '</th>
						<th class="small">' . __('Description') . '</th>
					</tr>
				</thead>
				<tbody>';
        $VDOT = new VDOT(Configuration::Data()->vdot());
        $PaceObject = new Runalyze\Activity\Pace(0, 1, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport()));
        foreach ($this->getArrayForPaces() as $Pace) {
            $Table .= '<tr>
						<td class="b">' . $Pace['short'] . '</td>
						<td class=""><em>' . $PaceObject->setTime($VDOT->paceAt($Pace['limit-high'] / 100))->value() . '</em> - <em>' . $PaceObject->setTime($VDOT->paceAt($Pace['limit-low'] / 100))->value() . '</em>' . $PaceObject->appendix() . '</td>
						<td class="">' . $Pace['description'] . '</td>
					</tr>';
        }
        $Table .= '
				</tbody>
			</table>';
        $Fieldset = new FormularFieldset(__('Training paces'));
        $Fieldset->addBlock($Table);
        $Fieldset->addInfo(__('These paces are based on Jack Daniels\' recommendation.'));
        return $Fieldset;
    }
Ejemplo n.º 11
0
 /**
  * Recalculate HF_REST
  */
 public static function recalculateHFrest()
 {
     $HF_REST = self::calculateHFrest();
     Configuration::Data()->updateHRrest($HF_REST);
     return $HF_REST;
 }
Ejemplo n.º 12
0
</td>
		<?php 
        }
        ?>
		<?php 
    }
    ?>
		</tr>
<?php 
}
?>
	</tbody>
</table>

<?php 
echo Ajax::wrapJS('$("#jd-tables-prognosis td.b").each(function(){ if ($(this).text() == \'' . round(Configuration::Data()->vdot()) . '\') $(this).parent().addClass("highlight"); });');
?>

<p class="info">
	<?php 
_e('This table is computed by some formulas, derived from the tables in Jack Daniels\' Running formula.');
?>
	<?php 
_e('These values do not fit the original table one hundred percent.');
?>
</p>

<p class="info">
	<?php 
_e('This table does <strong>not</strong> use a correction based on your current basic endurance.');
?>
Ejemplo n.º 13
0
 /**
  * Running setup from database
  */
 public function setupFromDatabase()
 {
     $this->setVDOT(Configuration::Data()->vdot());
     $this->adjustVDOT(true);
     $this->setBasicEnduranceForAdjustment(BasicEndurance::getConst());
 }
 /**
  * Initialize line-data-array for 'VDOT'
  * @param array $dat
  */
 private function initVDOTData($dat)
 {
     $VDOT = isset($dat['vdot']) ? Configuration::Data()->vdotFactor() * $dat['vdot'] : 0;
     $text = $VDOT == 0 ? NBSP : number_format($VDOT, 1);
     $this->VDOTData[] = array('i' => $dat['i'], 'text' => $text);
 }
Ejemplo n.º 15
0
 /**
  * Init constants
  */
 private function defineConsts()
 {
     require_once FRONTEND_PATH . 'system/define.consts.php';
     Configuration::loadAll();
     \Runalyze\Calculation\JD\VDOTCorrector::setGlobalFactor(Configuration::Data()->vdotFactor());
     require_once FRONTEND_PATH . 'class.Helper.php';
 }
Ejemplo n.º 16
0
 public function testVDOTstatisticsUpdate()
 {
     $current = time();
     $timeago = mktime(0, 0, 0, 1, 1, 2000);
     $running = Configuration::General()->runningSport();
     $raceid = Configuration::General()->competitionType();
     Configuration::Data()->updateVdotShape(0);
     Configuration::Data()->updateVdotCorrector(1);
     $this->insert(array(Object::TIMESTAMP => $timeago, Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 30 * 60, Object::HR_AVG => 150, Object::SPORTID => $running, Object::TYPEID => $raceid + 1, Object::USE_VDOT => true));
     $this->insert(array(Object::TIMESTAMP => $current, Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 30 * 60, Object::HR_AVG => 150, Object::SPORTID => $running + 1, Object::USE_VDOT => true));
     $this->insert(array(Object::TIMESTAMP => $current, Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 30 * 60, Object::SPORTID => $running, Object::USE_VDOT => true));
     $this->assertEquals(0, Configuration::Data()->vdotShape());
     $this->assertEquals(1, Configuration::Data()->vdotFactor());
     $this->insert(array(Object::TIMESTAMP => $current, Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 30 * 60, Object::HR_AVG => 150, Object::SPORTID => $running, Object::TYPEID => $raceid + 1, Object::USE_VDOT => true));
     $this->assertNotEquals(0, Configuration::Data()->vdotShape());
     $this->assertEquals(1, Configuration::Data()->vdotFactor());
     $this->insert(array(Object::TIMESTAMP => $current, Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 30 * 60, Object::HR_AVG => 150, Object::SPORTID => $running, Object::TYPEID => $raceid, Object::USE_VDOT => true));
     $this->assertNotEquals(0, Configuration::Data()->vdotShape());
     $this->assertNotEquals(1, Configuration::Data()->vdotFactor());
 }
Ejemplo n.º 17
0
 /**
  * Trigger recalculation
  */
 public static function triggerRecalculation()
 {
     if (!self::$TRIGGERED) {
         self::$TRIGGERED = true;
         $Data = \Runalyze\Configuration::Data();
         $oldCTL = $Data->maxCTL();
         $oldATL = $Data->maxATL();
         $Data->recalculateMaxValues();
         $newCTL = $Data->maxCTL();
         $newATL = $Data->maxATL();
         Messages::addValueRecalculated(__('Maximal CTL'), $newCTL, $oldCTL);
         Messages::addValueRecalculated(__('Maximal ATL'), $newATL, $oldATL);
     }
 }
 /**
  * Set default values
  */
 protected function setDefaultValues()
 {
     $Strategy = new Prognosis\Bock();
     $TopResults = $Strategy->getTopResults(2);
     $CurrentShape = Configuration::Data()->vdotShape();
     if (empty($_POST)) {
         $Factory = new PluginFactory();
         $Plugin = $Factory->newInstance('RunalyzePluginPanel_Prognose');
         $_POST['model'] = 'jack-daniels';
         $_POST['distances'] = implode(', ', $Plugin->getDistances());
         $_POST['vdot'] = $CurrentShape;
         $_POST['endurance'] = true;
         $_POST['endurance-value'] = BasicEndurance::getConst();
         $_POST['best-result-km'] = !empty($TopResults) ? $TopResults[0]['distance'] : '5.0';
         $_POST['best-result-time'] = !empty($TopResults) ? Duration::format($TopResults[0]['s']) : '0:26:00';
         $_POST['second-best-result-km'] = !empty($TopResults) ? $TopResults[1]['distance'] : '10.0';
         $_POST['second-best-result-time'] = !empty($TopResults) ? Duration::format($TopResults[1]['s']) : '1:00:00';
     }
     $this->InfoLines['jack-daniels'] = __('Your current VDOT:') . ' ' . $CurrentShape . '. ';
     $this->InfoLines['jack-daniels'] .= __('Your current basic endurance:') . ' ' . BasicEndurance::getConst() . '.';
     $ResultLine = empty($TopResults) ? __('none') : sprintf(__('%s in %s <small>(%s)</small> and %s in %s <small>(%s)</small>'), Distance::format($TopResults[0]['distance']), Duration::format($TopResults[0]['s']), date('d.m.Y', $TopResults[0]['time']), Distance::format($TopResults[1]['distance']), Duration::format($TopResults[1]['s']), date('d.m.Y', $TopResults[1]['time']));
     $this->InfoLines['robert-bock'] = __('Your two best results:') . ' ' . $ResultLine;
     $this->setupJackDanielsStrategy();
     $this->setupBockStrategy();
     $this->setupSteffnyStrategy();
     $this->setupCameronStrategy();
 }
Ejemplo n.º 19
0
 /**
  * Get array for exemplary training data
  * @return array 
  */
 protected function getExampleTraining()
 {
     return array('id' => DataObject::$DEFAULT_ID, 'sportid' => Configuration::General()->runningSport(), 'typeid' => Configuration::General()->competitionType(), 'time' => time(), 'created' => time(), 'edited' => time(), 'is_public' => 1, 'is_track' => 1, 'distance' => 10, 's' => 51 * 60 + 27, 'elevation' => 57, 'kcal' => 691, 'pulse_avg' => 186, 'pulse_max' => 193, 'vdot_with_elevation' => Configuration::Data()->vdot() + 1, 'vdot' => Configuration::Data()->vdot() + 2, 'use_vdot' => 0, 'fit_vdot_estimate' => round(Configuration::Data()->vdot()), 'fit_recovery_time' => 800, 'fit_hrv_analysis' => 800, 'jd_intensity' => 27, 'trimp' => 121, 'cadence' => 90, 'stride_length' => 108, 'groundcontact' => 220, 'vertical_oscillation' => 76, 'power' => 520, 'temperature' => 17, 'weatherid' => 5, 'splits' => '5|26:51-5|24:36', 'comment' => str_replace(' ', '&nbsp;', __('Test activity')), 'partner' => 'Peter', 'notes' => str_replace(' ', '&nbsp;', __('Great run!')), 'accountid' => SessionAccountHandler::getId(), 'creator' => '', 'creator_details' => '', 'activity_id' => '', 'elevation_corrected' => 1, 'swolf' => 29, 'total_strokes' => 1250, 'vertical_ratio' => 79, 'groundcontact_balance' => 4980, Dataset\Keys\Tags::CONCAT_TAGIDS_KEY => $this->exampleTagID(), Dataset\Keys\CompleteEquipment::CONCAT_EQUIPMENT_KEY => $this->exampleEquipmentIDs(2));
 }
Ejemplo n.º 20
0
 /**
  * Add condition for single value
  * @param string $key
  * @param array $conditions
  */
 protected function addConditionFor($key, array &$conditions)
 {
     $sign = isset($_POST['opt'][$key]) ? $this->signFor($_POST['opt'][$key]) : '=';
     if ($sign == ' LIKE ') {
         $conditions[] = '`t`.`' . $key . '` ' . $sign . ' "%' . DB::getInstance()->escape($_POST[$key], false) . '%"';
     } else {
         if (in_array($key, array('distance', 'vertical_oscillation', 'stride_length'))) {
             $_POST[$key] = (double) str_replace(',', '.', $_POST[$key]);
         }
         if ($key == 'elevation') {
             $value = (new Elevation())->setInPreferredUnit($_POST[$key])->meter();
         } elseif ($key == 'distance') {
             $value = (new Distance())->setInPreferredUnit($_POST[$key])->kilometer();
         } elseif ($key == 'vertical_oscillation') {
             $value = 10 * $_POST[$key];
         } elseif ($key == 'vertical_ratio') {
             $value = 10 * $_POST[$key];
         } elseif ($key == 'groundcontact_balance') {
             $value = 100 * $_POST[$key];
         } elseif ($key == 'stride_length') {
             $value = (new StrideLength())->setInPreferredUnit($_POST[$key])->cm();
         } elseif ($key == 'temperature') {
             $value = (new Temperature())->setInPreferredUnit($_POST[$key])->celsius();
         } elseif ($key == 'wind_speed') {
             $value = (new WindSpeed())->setInPreferredUnit($_POST[$key])->value();
         } elseif ($key == 'vdot' || $key == 'vdot_with_elevation') {
             if (!Configuration::Vdot()->useCorrectionFactor()) {
                 $value = $_POST[$key];
             } else {
                 $value = $_POST[$key] * Configuration::Data()->vdotFactor();
             }
         } else {
             $value = $_POST[$key];
         }
         $conditions[] = '`t`.`' . $key . '` ' . $sign . ' ' . DB::getInstance()->escape($value);
         if (($sign == '<' || $sign == '<=') && in_array($key, array('distance', 'pulse_avg', 'pulse_max', 'cadence', 'groundcontact', 'vertical_oscillation', 'vertical_ratio', 'groundcontact_balance', 'stride_length'))) {
             $conditions[] = '`t`.`' . $key . '` != 0';
         }
     }
 }
Ejemplo n.º 21
0
 /**
  * Trigger recalculation
  */
 public static function triggerRecalculation()
 {
     if (!self::$TRIGGERED) {
         self::$TRIGGERED = true;
         $Data = \Runalyze\Configuration::Data();
         $oldValue = $Data->vdotShape();
         $newValue = $Data->recalculateVDOTshape();
         Messages::addValueRecalculated(__('VDOT shape'), number_format($newValue, 1), number_format($oldValue, 1));
     }
 }
Ejemplo n.º 22
0
 /**
  * Recalculate maximal performance values
  */
 protected function recalculateMaximalPerformanceValues()
 {
     $Data = Configuration::Data();
     $oldCTL = $Data->maxCTL();
     $oldATL = $Data->maxATL();
     $oldTRIMP = $Data->maxTrimp();
     $Data->recalculateMaxValues();
     $newCTL = $Data->maxCTL();
     $newATL = $Data->maxATL();
     $newTRIMP = $Data->maxTrimp();
     $this->addSuccessMessage(__('Maximal CTL'), $oldCTL, $newCTL);
     $this->addSuccessMessage(__('Maximal ATL'), $oldATL, $newATL);
     $this->addSuccessMessage(__('Maximal TRIMP'), $oldTRIMP, $newTRIMP);
 }
Ejemplo n.º 23
0
 /**
  * Get VDOT with elevation corrected
  * @return double vdot with elevation influence
  */
 public function getVdotWithElevationCorrected()
 {
     return round(Configuration::Data()->vdotFactor() * $this->getVdotWithElevation(), 2);
 }
Ejemplo n.º 24
0
 /**
  * Recalculate value
  */
 public static function recalculateValue()
 {
     $Object = new self();
     $Object->readSettingsFromConfiguration();
     $BASIC_ENDURANCE = $Object->value();
     Configuration::Data()->updateBasicEndurance($BASIC_ENDURANCE);
     self::$CONST_VALUE = $BASIC_ENDURANCE;
 }
Ejemplo n.º 25
0
 /**
  * Calculate JD intensity
  * @return int
  */
 public function calculateJDintensity()
 {
     JD\Intensity::setVDOTshape(Configuration::Data()->vdot());
     JD\Intensity::setHRmax(Configuration::Data()->HRmax());
     $Intensity = new JD\Intensity();
     if ($this->knowsTrackdata() && $this->Trackdata->has(Model\Trackdata\Object::HEARTRATE) && $this->Trackdata->has(Model\Trackdata\Object::TIME)) {
         return $Intensity->calculateByHeartrate(new TimeSeries($this->Trackdata->heartRate(), $this->Trackdata->time()));
     } elseif ($this->Activity->hrAvg() > 0) {
         return $Intensity->calculateByHeartrateAverage($this->Activity->hrAvg(), $this->Activity->duration());
     } else {
         return $Intensity->calculateByPace($this->Activity->distance(), $this->Activity->duration());
     }
 }
Ejemplo n.º 26
0
    /**
     * Display with corrector
     */
    protected function displayWithElevation()
    {
        if ($this->Context->hasRoute() && ($this->Context->route()->elevationUp() > 0 || $this->Context->route()->elevationDown())) {
            $up = $this->Context->route()->elevationUp();
            $down = $this->Context->route()->elevationDown();
        } else {
            $up = $this->Context->activity()->elevation();
            $down = $up;
        }
        $Modifier = new Elevation\DistanceModifier($this->Context->activity()->distance(), $up, $down, Configuration::Vdot());
        $VDOT = new JD\VDOT(0, new JD\VDOTCorrector(Configuration::Data()->vdotFactor()));
        $VDOT->fromPaceAndHR($Modifier->correctedDistance(), $this->Context->activity()->duration(), $this->Context->activity()->hrAvg() / Configuration::Data()->HRmax());
        $Fieldset = new FormularFieldset(__('Correction: considering elevation'));
        $Fieldset->setHtmlCode('
			<p class="warning small ' . (Configuration::Vdot()->useElevationCorrection() ? 'hide' : '') . '">
				' . __('This correction method is currently unused.') . '
			</p>

			<div class="w50">
				<label>' . __('Up/Down') . '</label>
				<span class="as-input">+' . $up . '/-' . $down . '&nbsp;m</span>
			</div>
			<div class="w50 double-height-right">
				<label>&rArr; ' . __('VDOT') . '</label>
				<span class="as-input ' . (!Configuration::Vdot()->useElevationCorrection() ? '' : 'highlight') . '">' . $VDOT->value() . '</span>
			</div>
			<div class="w50">
				<label>' . __('Influence') . '</label>
				<span class="as-input">' . sprintf("%+d", 1000 * $Modifier->additionalDistance()) . 'm = ' . Distance::format($Modifier->correctedDistance(), false, 3) . '</span>
			</div>
		');
        $Fieldset->display();
    }
Ejemplo n.º 27
0
 /**
  * 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();
     }
 }
Ejemplo n.º 28
0
 /**
  * VDOT icon
  * @return string
  */
 public function vdotIcon()
 {
     $value = $this->usedVdot() * Configuration::Data()->vdotFactor();
     if ($value > 0) {
         $Icon = new VdotIcon($value);
         if (!$this->Activity->usesVDOT()) {
             $Icon->setTransparent();
         }
         return $Icon->code();
     }
     return '';
 }
Ejemplo n.º 29
0
 public function testUpdatingBasicEndurance()
 {
     $ignoredId1 = $this->insert(array(Object::TIMESTAMP => time() - 365 * DAY_IN_S, Object::DISTANCE => 30, Object::TIME_IN_SECONDS => 30 * 60 * 3, Object::SPORTID => Configuration::General()->runningSport()));
     $ignoredId2 = $this->insert(array(Object::TIMESTAMP => time(), Object::DISTANCE => 30, Object::TIME_IN_SECONDS => 30 * 60 * 3, Object::SPORTID => Configuration::General()->runningSport() + 1));
     $relevantId = $this->insert(array(Object::TIMESTAMP => time(), Object::DISTANCE => 30, Object::TIME_IN_SECONDS => 30 * 60 * 3, Object::SPORTID => Configuration::General()->runningSport()));
     $this->assertNotEquals(0, Configuration::Data()->basicEndurance());
     $this->delete($ignoredId1);
     $this->assertNotEquals(0, Configuration::Data()->basicEndurance());
     $this->delete($ignoredId2);
     $this->assertNotEquals(0, Configuration::Data()->basicEndurance());
     $this->delete($relevantId);
     $this->assertEquals(0, Configuration::Data()->basicEndurance());
 }
Ejemplo n.º 30
0
 /**
  * Scale value for percentage
  * @return int
  */
 public function trainingStrainAsPercentage()
 {
     // TODO: Use another maximum?
     $max = 2 * Configuration::Data()->maxATL() * static::DAYS;
     $Scale = new Scale\Percental();
     $Scale->setMaximum($max);
     return $Scale->transform($this->trainingStrain());
 }