/** * 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(); }
/** * Show values */ protected function showValues() { $ModelQuery = new Performance\ModelQuery(); $ModelQuery->execute(DB::getInstance()); $TSBmodel = new Performance\TSB($ModelQuery->data(), Configuration::Trimp()->daysForCTL(), Configuration::Trimp()->daysForATL()); $TSBmodel->calculate(); $MonotonyQuery = new Performance\ModelQuery(); $MonotonyQuery->setRange(time() - (Monotony::DAYS - 1) * DAY_IN_S, time()); $MonotonyQuery->execute(DB::getInstance()); $Monotony = new Monotony($MonotonyQuery->data()); $Monotony->calculate(); $VDOT = Configuration::Data()->vdot(); $ATLmax = Configuration::Data()->maxATL(); $CTLmax = Configuration::Data()->maxCTL(); $ModelATLmax = $TSBmodel->maxFatigue(); $ModelCTLmax = $TSBmodel->maxFitness(); if ($ModelATLmax > $ATLmax) { Configuration::Data()->updateMaxATL($ModelATLmax); $ATLmax = $ModelATLmax; } if ($ModelCTLmax > $CTLmax) { Configuration::Data()->updateMaxCTL($ModelCTLmax); $CTLmax = $ModelCTLmax; } $ATLabsolute = $TSBmodel->fatigueAt(0); $CTLabsolute = $TSBmodel->fitnessAt(0); $TSBabsolute = $TSBmodel->performanceAt(0); $TrimpValues = array('ATL' => round(100 * $ATLabsolute / $ATLmax), 'ATLstring' => Configuration::Trimp()->showInPercent() ? round(100 * $ATLabsolute / $ATLmax) . ' %' : $ATLabsolute, 'CTL' => round(100 * $CTLabsolute / $CTLmax), 'CTLstring' => Configuration::Trimp()->showInPercent() ? round(100 * $CTLabsolute / $CTLmax) . ' %' : $CTLabsolute, 'TSB' => round(100 * $TSBabsolute / max($ATLabsolute, $CTLabsolute, 1)), 'TSBstring' => Configuration::Trimp()->showTSBinPercent() ? sprintf("%+d", round(100 * $TSBabsolute / max($ATLabsolute, $CTLabsolute))) . ' %' : sprintf("%+d", $TSBabsolute)); $TSBisPositive = $TrimpValues['TSB'] > 0; $maxTrimpToBalanced = ceil($TSBmodel->maxTrimpToBalanced($CTLabsolute, $ATLabsolute)); $restDays = ceil($TSBmodel->restDays($CTLabsolute, $ATLabsolute)); $JDQuery = Cache::get(self::CACHE_KEY_JD_POINTS); if (is_null($JDQuery)) { $JDQueryLastWeek = DB::getInstance()->query('SELECT SUM(`jd_intensity`) FROM `' . PREFIX . 'training` WHERE `time`>=' . Time::Weekstart(time() - 7 * DAY_IN_S) . ' AND `time`<' . Time::Weekend(time() - 7 * DAY_IN_S) . ' AND accountid = ' . SessionAccountHandler::getId()); $JDQueryThisWeek = DB::getInstance()->query('SELECT SUM(`jd_intensity`) FROM `' . PREFIX . 'training` WHERE `time`>=' . Time::Weekstart(time()) . ' AND `time`<' . Time::Weekend(time()) . ' AND accountid = ' . SessionAccountHandler::getId()); $JDQuery['LastWeek'] = Helper::Unknown($JDQueryLastWeek->fetchColumn(), 0); $JDQuery['ThisWeek'] = Helper::Unknown($JDQueryThisWeek->fetchColumn(), 0); Cache::set(self::CACHE_KEY_JD_POINTS, $JDQuery, '600'); } $JDPointsLastWeek = $JDQuery['LastWeek']; $JDPointsThisWeek = $JDQuery['ThisWeek']; $JDPointsPrognosis = round($JDPointsThisWeek / (7 - (Time::Weekend(time()) - time()) / DAY_IN_S) * 7); $Values = array(array('show' => $this->Configuration()->value('show_vdot'), 'bars' => array(new ProgressBarSingle(2 * round($VDOT - 30), ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => number_format($VDOT, 2), 'title' => __('VDOT'), 'small' => '', 'tooltip' => __('Current average VDOT')), array('show' => $this->Configuration()->value('show_basicendurance'), 'bars' => array(new ProgressBarSingle(BasicEndurance::getConst(), ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => BasicEndurance::getConst() . ' %', 'title' => __('Basic endurance'), 'small' => '', 'tooltip' => __('<em>Experimental value!</em><br>100 % means: you had enough long runs and kilometers per week to run a good marathon, based on your current VDOT.')), array('show' => $this->Configuration()->value('show_trimpvalues'), 'bars' => array(new ProgressBarSingle($TrimpValues['ATL'], ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => sprintf(__('Current value: %s<br>Maximal value: %s<br>as percentage: %s %'), $ATLabsolute, $ATLmax, $TrimpValues['ATL']), 'value' => $TrimpValues['ATLstring'], 'title' => __('Fatigue'), 'small' => '(ATL)', 'tooltip' => __('Actual Training Load<br><small>Average training impulse of the last weeks in relation to your maximal value.</small>')), array('show' => $this->Configuration()->value('show_trimpvalues'), 'bars' => array(new ProgressBarSingle($TrimpValues['CTL'], ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => sprintf(__('Current value: %s<br>Maximal value: %s<br>as percentage: %s %'), $CTLabsolute, $CTLmax, $TrimpValues['CTL']), 'value' => $TrimpValues['CTLstring'], 'title' => __('Fitness level'), 'small' => '(CTL)', 'tooltip' => __('Chronical Training Load<br><small>Average training impulse of the last months in relation to your maximal value.</small>')), array('show' => $this->Configuration()->value('show_trimpvalues'), 'bars' => array(new ProgressBarSingle(abs($TrimpValues['TSB']) / 2, $TSBisPositive ? ProgressBarSingle::$COLOR_GREEN : ProgressBarSingle::$COLOR_RED, $TSBisPositive ? 'right' : 'left')), 'bar-tooltip' => 'TSB = CTL - ATL<br>' . sprintf(__('absolute: %s<br>as percentage: %s %'), $CTLabsolute . ' - ' . $ATLabsolute . ' = ' . sprintf("%+d", $TSBabsolute), $TrimpValues['TSB']), 'value' => $TrimpValues['TSBstring'], 'title' => __('Stress Balance'), 'small' => '(TSB)', 'tooltip' => __('Training Stress Balance (= CTL - ATL)<br>> 0: You are relaxing.<br>' . '< 0: You are training hard.')), array('show' => $this->Configuration()->value('show_trimpvalues') && !$TSBisPositive, 'bars' => array(new ProgressBarSingle(100 * $restDays / 7, ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => $restDays, 'title' => __('Rest days'), 'small' => '', 'tooltip' => __('Rest days needed to reach TSB = 0')), array('show' => $this->Configuration()->value('show_trimpvalues') && $TSBisPositive, 'bars' => array(new ProgressBarSingle(100 * $maxTrimpToBalanced / 1000, ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => $maxTrimpToBalanced, 'title' => __('Easy TRIMP'), 'small' => '', 'tooltip' => __('Max TRIMP that will still keep you at TSB = 0')), array('show' => $this->Configuration()->value('show_trimpvalues_extra'), 'bars' => array(new ProgressBarSingle($Monotony->valueAsPercentage(), $Monotony->value() > Monotony::CRITICAL ? ProgressBarSingle::$COLOR_RED : $Monotony->value() > Monotony::WARNING ? ProgressBarSingle::$COLOR_ORANGE : ProgressBarSingle::$COLOR_GREEN)), 'bar-tooltip' => 'Monotony = avg(Trimp)/stddev(Trimp)', 'value' => number_format($Monotony->value(), 2), 'title' => __('Monotony'), 'small' => '', 'tooltip' => __('Monotony<br><small>Monotony of your last seven days.<br>Values below 1.5 are preferable.</small>')), array('show' => $this->Configuration()->value('show_trimpvalues_extra'), 'bars' => array(new ProgressBarSingle($Monotony->trainingStrainAsPercentage(), $Monotony->trainingStrainAsPercentage() >= 75 ? ProgressBarSingle::$COLOR_RED : ($Monotony->trainingStrainAsPercentage() >= 50 ? ProgressBarSingle::$COLOR_ORANGE : ProgressBarSingle::$COLOR_GREEN))), 'bar-tooltip' => 'Training strain = sum(Trimp)*Monotony', 'value' => round($Monotony->trainingStrain()), 'title' => __('Training strain'), 'small' => '', 'tooltip' => __('Training strain<br><small>of your last seven days</small>')), array('show' => $this->Configuration()->value('show_jd_intensity'), 'bars' => array(new ProgressBarSingle($JDPointsPrognosis / 2, ProgressBarSingle::$COLOR_LIGHT), new ProgressBarSingle($JDPointsThisWeek / 2, ProgressBarSingle::$COLOR_RED)), 'bar-goal' => $JDPointsLastWeek / 2, 'bar-tooltip' => sprintf(__('This week: %s training points<br>Prognosis: ca. %s training points<br>Last week: %s training points'), $JDPointsThisWeek, $JDPointsPrognosis, $JDPointsLastWeek), 'value' => $JDPointsThisWeek, 'title' => __('Training points'), 'small' => '', 'tooltip' => __('Training intensity by Jack Daniels.<br>' . 'Jack Daniels considers the following levels:<br>' . '50 points: Beginner<br>' . '100 points: Advanced Runner<br>' . '200 points: Pro Runner'))); $this->showTableForValues($Values); }