Changeset 6


Ignore:
Timestamp:
Oct 16, 2007, 10:12:26 PM (17 years ago)
Author:
george
Message:

Přepracovaná vývojová verze s oddělenými datovými tabulkami a různými datovými typy.

Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • admin.php

    r4 r6  
    2727  );
    2828
    29   $Result = $Database->select('measure', '*');
     29  $Result = $Database->select('measure', '*', '1 ORDER BY Description');
    3030  while($Measure = $Result->fetch_array())
    3131  {
    32     array_push($Table['Rows'], array($Measure['Name'], Link('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.Link('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit')));
     32    array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit')));
    3333  }
    34   $Output = '<h3>Seznam mìøení</h3>'.Table($Table).Link('?Operation=Add', 'Pøidat');
     34  $Output = '<h3>Seznam mìøení</h3>'.Table($Table).MakeLink('?Operation=Add', 'Pøidat');
    3535  return($Output);
    3636}
  • config.sample.php

    r1 r6  
    22
    33$Config = array(
    4   'database' => array(
    5     'host' => 'localhost',
    6     'user' => 'stat',
    7     'password' => 'serepes',
    8     'database' => 'statistic',
    9     'prefix' => '',
    10     'charset' => 'latin2',
     4  'Database' => array(
     5    'Host' => 'localhost',
     6    'User' => 'root',
     7    'Password' => '',
     8    'Database' => 'statistic',
     9    'Prefix' => '',
     10    'Charset' => 'latin2',
    1111  ),
    12   'add_url' => 'http://localhost/statistic/new/add.php',
     12  'AddNewValueUrl' => 'http://localhost/dev/statistic/add.php',
     13  'Debug' => 0,
     14  'Web' => array(
     15    'Title' => 'Statistika',
     16    'Charset' => 'iso-8859-2',
     17  ),
     18  'DivisionCount' => 500,
     19  'LevelReducing' => 5,
     20  'MaxLevel' => 4,
     21  'ReferenceTime' => 0,
     22  'ImageWidth' => 750,
     23  'ImageHeight' => 200,
     24  'ValueToImageHeigthCoefficient' => 0.9,
     25  'FontFileName' => 'arial.ttf',
     26  'FontSize' => 10,
     27  'DefaultVariables' => array(
     28    'TimeStart' => time() - 3600*24,
     29    'TimeEnd' => time(),
     30    'Measure' => 1,
     31    'Period' => 'day',
     32    'TimeSpecify' => 5,
     33  ),
    1334);
    1435
     36// For back compatibility during development
     37$DivisionCount = $Config['DivisionCount'];
     38$ReferenceTime = $Config['ReferenceTime'];
     39$LevelReducing = $Config['LevelReducing'];
     40$MaxLevel = $Config['MaxLevel'];
     41$DefaultWidth = $Config['ImageWidth'];
     42$DefaultHeight = $Config['ImageHeight'];
     43$K = $Config['ValueToImageHeigthCoefficient'];
     44$FontFile = $Config['FontFileName'];
     45$FontSize = $Config['FontSize'];
     46
    1547?>
  • global.php

    r4 r6  
    22
    33session_start();
    4 include('config.php');
    5 include('database.php');
    6 include('code.php');
    7 include('types.php');
    8 include('classes.php');
    9 include('stat_functions.php');
     4include_once('config.php');
     5include_once('database.php');
     6include_once('code.php');
     7include_once('types.php');
     8include_once('classes.php');
     9include_once('stat_functions.php');
    1010$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    1111$Database->Prefix = $Config['Database']['Prefix'];
     
    2929
    3030
    31 function Link($Target, $Title)
     31function MakeLink($Target, $Title)
    3232{
    3333  return('<a href="'.$Target.'">'.$Title.'</a>');
     
    5757  $Class = $Classes[$ClassName];
    5858  $Table = array(
    59     'Header' => array('Polo¾ka', 'Hodnota'),
     59    'Header' => array('Položka', 'Hodnota'),
    6060    'Rows' => array(),
    6161  );
  • graph.php

    r3 r6  
    55  else $Debug = 0;
    66 
    7 $DefaultWidth = 750;
    8 $DefaultHeight = 200;
    9 $K = 0.9;   // Coeficient for decreasing graph height
    10 $FontFile = 'arial.ttf';
    11 $FontSize = 10;
    12 
    137if(!array_key_exists('From',$_GET)) die('Musíte zadat èas poèátku');
    148$StartTime = addslashes($_GET['From']);
     
    4741foreach($Points as $Index => $Item)
    4842{
    49   $Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['display_divider'];
    50   $Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['display_divider'];
    51   $Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['display_divider'];
     43  $Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
     44  $Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
     45  $Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
    5246  if($Points[$Index]['avg'] > $MaxValue) $MaxValue = $Points[$Index]['avg'];
    5347  if($Points[$Index]['avg'] < $MinValue) $MinValue = $Points[$Index]['avg'];
     
    5650  $AvgValue = $AvgValue + $Points[$Index]['avg'];
    5751}
    58 $MinValue = round($MinValue * $Measure['display_divider']) / $Measure['display_divider'];
    59 $MaxValue = round($MaxValue * $Measure['display_divider']) / $Measure['display_divider'];
    60 $AvgValue = round($AvgValue / count($Points) * $Measure['display_divider']) / $Measure['display_divider'];
     52$MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider'];
     53$MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider'];
     54$AvgValue = round($AvgValue / count($Points) * $Measure['Divider']) / $Measure['Divider'];
    6155
    6256// Generate polygon and recalculate y values to fit graph height
     
    9185
    9286
    93 array_unshift($Points, $Height - 1);
    94 array_unshift($Points, 0);
    95 $Points[] = $Width - 1;
    96 $Points[] = $Height - 1;
     87//array_unshift($Points, $Height - 1);
     88//array_unshift($Points, 0);
     89//$Points[] = $Width - 1;
     90//$Points[] = $Height - 1;
     91
     92//print_r($PointsMax);
    9793
    9894// Generate image
     
    182178  $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    183179
    184   imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ".$MaxValue.' '.$Measure['unit']);
    185   imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg.  ".$AvgValue.' '.$Measure['unit']);
    186   imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min.  ".$MinValue.' '.$Measure['unit']);
     180  imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ".$MaxValue.' '.$Measure['Unit']);
     181  imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg.  ".$AvgValue.' '.$Measure['Unit']);
     182  imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min.  ".$MinValue.' '.$Measure['Unit']);
    187183  imagestring($Image, 2, 50, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black);
    188184  //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black);
    189185
    190   imagettftext($Image, $FontSize, 0, 50, 14, $Black, $FontFile, to_utf8($Measure['description']));
     186  imagettftext($Image, $FontSize, 0, 50, 14, $Black, $FontFile, to_utf8($Measure['Description']));
    191187  imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black);   // Frame border
    192188  imagepng($Image);
  • index.php

    r3 r6  
    9898);
    9999
    100 $Variables = array(
    101   'TimeStart' => time() - 3600*24,
    102   'TimeEnd' => time(),
    103   'Measure' => 1,
    104   'Period' => 'day',
    105   'TimeSpecify' => 0,
    106 );
    107 
    108 foreach($Variables as $Index => $Variable)
     100foreach($Config['DefaultVariables'] as $Index => $Variable)
    109101{
    110102  if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
     
    182174
    183175$Output .= '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">';
    184 $Output .= '<tr><th>Mìøená velièina</th><th>Èas posledního mìøení</th><th>Poslední hodnota</th><th>Interpolace</th><th>Poznámky</th></tr>';
     176$Output .= '<tr><th>Mìøená velièina</th><th>Èas posledního mìøení</th><th>Poslední hodnota</th><th>Interpolace</th><th>Poznámky</th>';
     177if(array_key_exists('Debug', $_GET)) $Output .= '<th>Poèet polo¾ek</th><th>Èas vykonání</th>';
     178$Output .= '</tr>';
    185179$Database->select_db('measure');
    186180$Result = $Database->select('measure', '*', 'Enabled=1 AND PermissionView="all" OR PermissionView="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'" ORDER BY Description');
     
    190184{
    191185  $StopWatchStart = GetMicrotime();
    192 //  DB_Select('stat_data', 'COUNT(*)', 'measure='.$Measure['id']);
    193 //  $RowCount = DB_Row();
    194 //  $RowCount = $RowCount[0];
    195 //  $RowCount = 0;
    196   $Result2 = $Database->select('stat_data', 'time, avg', 'measure='.$Measure['id'].' ORDER BY time DESC LIMIT 1');
     186  if(array_key_exists('Debug', $_GET))
     187  { 
     188    $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'measure='.$Measure['Id']);
     189    $RowCount = $DbResult->fetch_array();
     190    $RowCount = $RowCount[0];
     191  }
     192  $Result2 = $Database->select($Measure['DataTable'], 'time, avg', 'measure='.$Measure['Id'].' ORDER BY time DESC LIMIT 1');
    197193  if($Result2->num_rows > 0)
    198194  {
    199195    $Row = $Result2->fetch_array();
    200196    $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['time']));
    201     $LastMeasureValue = round($Row['avg'] / $Measure['display_divider']);
     197    $LastMeasureValue = round($Row['avg'] / $Measure['Divider']);
    202198  } else {
    203199    $LastMeasureTime = '&nbsp;';
    204200    $LastMeasureValue = '&nbsp;';
    205201  }
    206   if($Measure['continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
    207   if($Measure['info'] == '') $Measure['info'] = '&nbsp;';
     202  if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
     203  if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    208204  $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    209   $Output .= '<tr><td><a href="?Measure='.$Measure['id'].'">'.$Measure['description'].'</a></td><td align="center">'.$LastMeasureValue.' '.$Measure['display_unit'].'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['info'].'</td>';
    210   //<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td></tr>');
    211   flush();
     205  $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.' '.$Measure['Unit'].'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>';
     206  if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
     207  $Output .= '</tr>';
    212208}
    213209$Output .= '</table>';
  • stat_functions.php

    r2 r6  
    11<?php
    2 
    3 $DivisionCount = 500;
    4 $ReferenceTime = 0;
    5 $LevelReducing = 5;
    6 $MaxLevel = 4;
    72
    83$ValueTypes = array('min', 'avg', 'max');
     
    3631function StatTableName($Level)
    3732{
    38   if($Level == 0) return('stat_data');
    39     else return('stat_data_cache');
     33  if($Level == 0) return('data');
     34    else return('data_cache');
    4035}
    4136
     
    4944{
    5045  global $Database;
    51   $Result = $Database->select('stat_measure', '*', 'id='.$Id);
     46  $Result = $Database->select('measure', '*', 'Id='.$Id);
    5247  if($Result->num_rows > 0)
    5348  {
    5449    $Measure = $Result->fetch_array();
    55     if($Measure['continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
     50    if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
    5651      else $Measure['ContinuityEnabled'] = 2;    // continuous graph 
    5752  } else die('Mìøená velièina nenalezena');
     
    6459 
    6560  $Time = time();
    66   $Value = round($Measure['divider']*$Value);
    67 
    68   $Result = $Databse->select('stat_data', '*', 'measure='.$Measure['id'].' AND level=0 ORDER BY time DESC LIMIT 2');
    69   if($Result->num_rows == 0) $Database->insert('stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['id'], 'time' => TimeToMysqlDateTime($Time),
     61  //$Value = round($Measure['divider'] * $Value);
     62
     63  $Result = $Databse->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level=0 ORDER BY time DESC LIMIT 2');
     64  if($Result->num_rows == 0) $Database->insert('stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time),
    7065    'continuity' => 0));
    71   else if($Result->num_rows == 1) $Database->insert('stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['id'], 'time' => TimeToMysqlDateTime($Time),
     66  else if($Result->num_rows == 1) $Database->insert($Measure['DataTable'], array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time),
    7267    'continuity' => 1));
    7368  else {
     
    8580      {
    8681        echo('s');
    87         $Database->update('stat_data', 'time="'.$LastValue['time'].'" AND level=0 AND measure='.$Measure['id'], array('time' => 'NOW()'));
     82        $Database->update($Measure['DataTable'], 'time="'.$LastValue['time'].'" AND level=0 AND measure='.$Measure['Id'], array('time' => 'NOW()'));
    8883      } else
    8984      {
    90         $Database->insert('stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['id'], 'time' => TimeToMysqlDateTime($Time),
     85        $Database->insert($Measure['DataTable'], array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time),
    9186          'continuity' => $Continuity));       
    9287      }
     
    109104      // Load values in time range
    110105      $Values = array();
    111       $Result = $Database->select(StatTableName($Level-1), '*', 'time > "'.TimeToMysqlDateTime($StartTime).'" AND time < "'.
    112         TimeToMysqlDateTime($EndTime).'" AND measure='.$Measure['id'].' AND level='.($Level-1).' ORDER BY time');
     106      $Result = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime).'" AND time < "'.
     107        TimeToMysqlDateTime($EndTime).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time');
    113108      while($Row = $Result->fetch_array())
    114109      {
     
    126121      //print_r($Point);
    127122     
    128       $Database->delete(StatTableName($Level), '(time > "'.TimeToMysqlDateTime($StartTime).'") AND
    129         (time < "'.TimeToMysqlDateTime($EndTime).'") AND measure='.$Measure['id'].' AND level='.$Level);
     123      $Database->delete($Measure['DataTable'], '(time > "'.TimeToMysqlDateTime($StartTime).'") AND
     124        (time < "'.TimeToMysqlDateTime($EndTime).'") AND measure='.$Measure['Id'].' AND level='.$Level);
    130125      $Continuity = $Values[1]['continuity'];   
    131       $Database->insert(StatTableName($Level), array('level' => $Level, 'measure' => $Measure['id'], 'min' => $Point['min'],
     126      $Database->insert($DataTable, array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
    132127        'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime+($EndTime-$StartTime)/2)));
    133128
     
    203198  }
    204199  //if(($RightTime - $LeftTime) > 0)
    205   if($Measure['cumulative'] == 0) $NewValue['avg'] = $NewValue['avg'] / ($RightTime - $LeftTime); 
     200  if($Measure['Cumulative'] == 0) $NewValue['avg'] = $NewValue['avg'] / ($RightTime - $LeftTime); 
    206201  return($NewValue);
    207202  //echo($NewValue['avg'].'<br>');
     
    214209 
    215210  // Get first and last time
    216   echo($Measure['id'].','.$Level.','.StatTableName($Level)."\n");
    217   $Result = $Database->select(StatTableName($Level), '*', 'measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time LIMIT 1');
     211  echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
     212  $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time LIMIT 1');
    218213  if($Result->num_rows > 0)
    219214  {
     
    222217  } else $AbsoluteLeftTime = 0;
    223218
    224   $Result = $Database->select(StatTableName($Level), '*', 'measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');
     219  $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');
    225220  if($Result->num_rows > 0)
    226221  {
     
    239234function LoadRightSideValue($Level, $Measure, $Time)
    240235{
    241   global $Debug;
     236  global $Debug, $Database;
    242237  $Result = array();
    243   $Result = $Database->select(StatTableName($Level), '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');
    244   if($Result->num_rows > 0)
    245   {
    246     $Row = $Result->fetch_array();
     238  $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');
     239  if($DbResult->num_rows > 0)
     240  {
     241    $Row = $DbResult->fetch_array();
    247242    $Row['time'] = MysqlDateTimeToTime($Row['time']);
    248243    return(array($Row));
     
    253248    //array_push($Values, array('time' => $Time, 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0));
    254249    $Result[] = array('time' => ($Time + TimeSegment($Level)), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0);
    255     $Result = $Database->select(StatTableName($Level), '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');
    256     if($Result->num_rows > 0)
    257     {
    258       $Row = $Result->fetch_array();
     250    $DbResult = $Database->select($Measure['DataTable'], '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');
     251    if($DbResult->num_rows > 0)
     252    {
     253      $Row = $DbResult->fetch_array();
    259254      array_unshift($Result, array('time' => (MysqlDateTimeToTime($Row['time'])+10), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0));
    260255    }
     
    266261function LoadLeftSideValue($Level, $Measure, $Time)
    267262{
    268   global $Debug;
     263  global $Debug, $Database;
    269264  $Result = array();
    270   //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'."<br>\n");
    271   $Result = $Database->select(StatTableName($Level), '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');
    272   if($Result->num_rows > 0)
    273   {
    274     $Row = $Result->fetch_array();
     265  //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'."<br>\n");
     266  $DbResult = $Database->select($Measure['DataTable'], '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');
     267  if($DbResult->num_rows > 0)
     268  {
     269    $Row = $DbResult->fetch_array();
    275270    $Row['time'] = MysqlDateTimeToTime($Row['time']);
    276271    return(array($Row));
     
    282277    $Result[] = array('time' => ($Time - TimeSegment($Level)), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0);
    283278   
    284     $Result = $Database->select(StatTableName($Level), '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');
    285     if($Result->num_rows > 0)
    286     {
    287       $Row = $Result->fetch_array();
     279    $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');
     280    if($DbResult->num_rows > 0)
     281    {
     282      $Row = $DbResult->fetch_array();
    288283      array_push($Result, array('time' => (MysqlDateTimeToTime($Row['time'])-10), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0));
    289284    }
     
    295290function GetValues($Measure, $TimeFrom, $TimeTo, $Level)
    296291{
    297   global $DivisionCount, $Debug;
     292  global $DivisionCount, $Debug, $Database;
    298293 
    299294  if($Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>');
     
    307302
    308303  // Load values in time range
    309   $Result = $Database->select(StatTableName($Level), 'time, min, avg, max, continuity', 'time > "'.TimeToMysqlDateTime($TimeFrom).'" AND time < "'.
    310     TimeToMysqlDateTime($TimeTo).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time');
     304  $Result = $Database->select($Measure['DataTable'], 'time, min, avg, max, continuity', 'time > "'.TimeToMysqlDateTime($TimeFrom).'" AND time < "'.
     305    TimeToMysqlDateTime($TimeTo).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time');
    311306//  echo($Level.' '.TimeToMysqlDateTime($TimeFrom).' '.TimeToMysqlDateTime($TimeTo));
    312307  $Values = array();
     
    334329    $StartIndex = 0;
    335330    $Points = array();
     331    //echo($DivisionCount.'<br>');
    336332    for($I = 0; $I < $DivisionCount; $I++)
    337333    {
     
    358354  global $MaxLevel, $LevelReducing;
    359355
    360   echo('Velicina '.$Measure['name']."\n");
    361   if($Measure['continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
     356  echo('Velicina '.$Measure['Name']."\n");
     357  if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
    362358    else $Measure['ContinuityEnabled'] = 2;    // continuous graph
    363359
    364360  // Clear previous items
    365   $Result = $Database->select('stat_data_cache', 'COUNT(*)', 'level>0 AND measure='.$Measure['id']);
     361  $Result = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level>0 AND measure='.$Measure['Id']);
    366362  $Row = $Result->fetch_array();
    367363  echo("Mazu starou cache (".$Row[0]." polozek)...");
    368   $Database->delete('stat_data_cache', 'level>0 AND measure='.$Measure['id']);
     364  $Database->delete($Measure['DataTable'], 'level>0 AND measure='.$Measure['Id']);
    369365  echo("\n");
    370366
     
    373369    echo('Uroven '.$Level."\n");
    374370    $TimeRange = GetTimeRange($Measure, $Level-1);
    375     //echo($Measure['id'].','.($Level-1)."\n");
     371    //echo($Measure['Id'].','.($Level-1)."\n");
    376372    //echo(TimeToMysqlDateTime($TimeRange['left']).'-'.TimeToMysqlDateTime($TimeRange['right'])."\n");
    377373    $TimeSegment = TimeSegment($Level);
     
    386382      $EndTime2 = $StartTime + ($I+1) * $BurstCount * $TimeSegment;
    387383      $Values = array();
    388       DB_Select(StatTableName($Level-1), '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.
    389         TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure['id'].' AND level='.($Level-1).' ORDER BY time');
     384      DB_Select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.
     385        TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time');
    390386      while($Row = DB_Row())
    391387      {
     
    414410            $Point = ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Measure, $Level);
    415411            $Continuity = $SubValues[1]['continuity'];   
    416             DB_Insert(StatTableName($Level), array('level' => $Level, 'measure' => $Measure['id'], 'min' => $Point['min'],
     412            DB_Insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
    417413              'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime3+($EndTime3-$StartTime3)/2)));
    418414          }       
     
    424420    } 
    425421    echo("Uroven dokoncena\n");         
    426     DB_Select('stat_data', 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['id']);
     422    DB_Select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']);
    427423    $Row = DB_Row();
    428424    echo("Vlozeno ".$Row[0]." polozek.\n");
     
    438434    // Load measures
    439435  $Measures = array();
    440   $Result = $Database->select('stat_measure', '*');
     436  $Result = $Database->select('measure', '*');
    441437  while($Measures[] = $Result->fetch_array());
    442438  array_pop($Measures);
Note: See TracChangeset for help on using the changeset viewer.