Пример #1
0
$uts_l_t = $uts_now;
$query = "SELECT * FROM records WHERE `uts` > " . $uts_l_b . " AND `uts` < " . $uts_l_t . " ORDER BY uts ASC";
$result = mysql_query($query) or die("Query 2 failed with error: " . mysql_error());
if (mysql_num_rows($result) == 0) {
    die;
}
$row2 = mysql_fetch_array($result) or die(mysql_error());
db_disconnect();
$press_data = array();
$uts_data = array();
while ($row2 = mysql_fetch_array($result)) {
    array_push($press_data, $row2['pressure']);
    array_push($uts_data, $row2['uts']);
}
//if (count($press_data) > 0){
$g = 1000 * calculateRegression($uts_data, $press_data);
$r = calculatePMCC($uts_data, $press_data);
$lpress = number_format($row['pressure'], 0, ".", "");
$fast = $c_pressure_change_fast;
$slow = $c_pressure_change_slow;
if ($g >= $fast) {
    $img_str = "pressure_imgs/pressure_rise_2.gif";
    $image1 = imagecreatefromgif($img_str);
    $txt_color = ImageColorAllocate($image1, 255, 0, 0);
} else {
    if ($g >= $slow) {
        $img_str = "pressure_imgs/pressure_rise_1.gif";
        $image1 = imagecreatefromgif($img_str);
        $txt_color = ImageColorAllocate($image1, 255, 0, 0);
    } else {
        if ($g >= -$slow) {
Пример #2
0
    }
}
$trended = getAllProjectsInTrend();
if ($trended == null) {
    exit;
}
foreach ($trended as $project) {
    $cycle = getTrendCycle($project['project_id']);
    $hr = '';
    $dt = time();
    $times = new DateTime("@{$dt}");
    $time = $times->format('Y-m-d H:i:s');
    //echo gettype($time);
    $trend_value = calculateTrendForProject($project['project_id']);
    echo 'trend.value=' . $trend_value;
    $regression = @calculateRegression($project['project_id'], $time, $trend_value);
    echo 'regression' . $regression . '</br>';
    if ($cycle == 0) {
        $hr = ' `h1` = ' . $trend_value . ', `h1_time = ' . "{$time}" . ', `r1` = ' . $regression;
        $c = 1;
        $query = 'UPDATE `trend` SET `h1`=' . $trend_value . ',`h1_time`=' . '\'' . $time . '\'' . ',`r1`=' . $regression . ',`cycle`=' . $c . ' WHERE `project_id` = ' . $project['project_id'];
    } else {
        if ($cycle == 1) {
            $hr = ' `h2` = ' . $trend_value . ', `h2_time` = ' . " {$time}" . ', `r2` = ' . $regression;
            $c = 2;
            $query = 'UPDATE `trend` SET `h2`=' . $trend_value . ',`h2_time`=' . '\'' . $time . '\'' . ',`r2`=' . $regression . ',`cycle`=' . $c . ' WHERE `project_id` = ' . $project['project_id'];
        } else {
            if ($cycle == 2) {
                $hr = ' `h3` = ' . $trend_value . ', `h3_time` = ' . "{$time}" . ', `r3` = ' . $regression;
                $c = 3;
                $query = 'UPDATE `trend` SET `h3`=' . $trend_value . ',`h3_time`=' . '\'' . $time . '\'' . ',`r3`=' . $regression . ',`cycle`=' . $c . ' WHERE `project_id` = ' . $project['project_id'];
Пример #3
0
<?php

define("IN_MODULE", true);
require_once "../includes/config.inc.php";
require_once "../includes/functions.inc.php";
$x_data[0] = 1;
$x_data[1] = 2;
$x_data[2] = 3;
$x_data[3] = 4;
$x_data[4] = 5;
$y_data[0] = 1;
$y_data[1] = 3;
$y_data[2] = 5;
$y_data[3] = 7;
$y_data[4] = 9;
echo calculateRegression($x_data, $y_data) . "   " . calculatePMCC($x_data, $y_data);