Changeset 52


Ignore:
Timestamp:
Feb 20, 2015, 9:31:53 AM (9 years ago)
Author:
chronos
Message:
Location:
branches/old
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/old/global.php

    r50 r52  
    1212include_once('types.php');
    1313include_once('classes.php');
     14include_once('Common/PrefixMultiplier.php');
     15$PrefixMultiplier = new PrefixMultiplier();
    1416include_once('stat_functions.php');
    1517$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
     
    7981    switch($Item['Type'])
    8082    {
    81       case 'Boolean':       
     83      case 'Boolean':
    8284        if($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';
    8385        $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>';
    8486        break;
    85       case 'String': 
     87      case 'String':
    8688        $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';
    8789        break;
    88       case 'Integer': 
     90      case 'Integer':
    8991        $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';
    9092        break;
     
    9597  }
    9698  $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat');
    97   return($Output); 
     99  return($Output);
    98100}
  • branches/old/graph.php

    r51 r52  
    161161    $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    162162    //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $K * $Height);
    163     $Text = AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3);
     163    $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3);
    164164    $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    165165    if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     
    169169
    170170  $Left = $Width - 10;
    171   $Text = "    Max. ".AddPrefixMultipliers($MaxValue, $Measure['Unit']);
     171  $Text = "    Max. ".$PrefixMultiplier->Add($MaxValue, $Measure['Unit']);
    172172  $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    173173  $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    174174  imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
    175175
    176   $Text = "    Avg.  ".AddPrefixMultipliers($AvgValue, $Measure['Unit'], 4);
     176  $Text = "    Avg.  ".$PrefixMultiplier->Add($AvgValue, $Measure['Unit'], 4);
    177177  $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    178178  $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    179179  imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
    180180
    181   $Text = "    Min.  ".AddPrefixMultipliers($MinValue, $Measure['Unit']);
     181  $Text = "    Min.  ".$PrefixMultiplier->Add($MinValue, $Measure['Unit']);
    182182  $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    183183  $Left -= ($BoundingBox[2] - $BoundingBox[0]);
  • branches/old/index.php

    r51 r52  
    182182    $RowCount = $RowCount[0];
    183183  }
    184   $Result2 = $Database->select($Measure['DataTable'], 'time, avg', 'measure='.$Measure['Id'].' AND level=0 ORDER BY time DESC LIMIT 1');
     184  $Result2 = $Database->select($Measure['DataTable'], 'time, avg', '(measure='.$Measure['Id'].') AND (level=0) ORDER BY time DESC LIMIT 1');
    185185  if($Result2->num_rows > 0)
    186186  {
    187187    $Row = $Result2->fetch_array();
    188188    $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['time']));
    189     $LastMeasureValue = AddPrefixMultipliers($Row['avg'], $Measure['Unit']);
     189    $LastMeasureValue = $PrefixMultiplier->Add($Row['avg'], $Measure['Unit']);
    190190  } else {
    191191    $LastMeasureTime = '&nbsp;';
     
    195195  if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    196196  $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    197   $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>';
     197  $Output .= '<tr><td style="text-align: left"><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>';
    198198  if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    199199  $Output .= '</tr>';
  • branches/old/stat_functions.php

    r51 r52  
    22
    33$ValueTypes = array('min', 'avg', 'max');
    4 $PrefixMultipliers = array(
    5   array('y', 'yocto', pow(10, -24)),
    6   array('z', 'zepto', pow(10, -21)),
    7   array('a', 'atto', pow(10, -18)),
    8   array('f', 'femto', pow(10, -15)),
    9   array('p', 'piko', pow(10, -12)),
    10   array('n', 'nano', pow(10, -9)),
    11   array('u', 'mikro', pow(10, -6)),
    12   array('m', 'mili', pow(10, -3)),
    13   array('', '', pow(10, 0)),
    14   array('k', 'kilo', pow(10, 3)),
    15   array('M', 'mega', pow(10, 6)),
    16   array('G', 'giga', pow(10, 9)),
    17   array('T', 'tera', pow(10, 12)),
    18   array('P', 'peta', pow(10, 15)),
    19   array('E', 'exa', pow(10, 18)),
    20   array('Z', 'zetta', pow(10, 21)),
    21   array('Y', 'yotta', pow(10, 24)),
    22 );
    23 
    24 function TruncateDigits($Value, $Digits = 4)
    25 {
    26   for($II = 2; $II > -6; $II--)
    27   {
    28     if($Value >= pow(10, $II))
    29     {
    30       if($Digits < ($II + 1)) $RealDigits = $II + 1;
    31         else $RealDigits = $Digits;
    32       $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);
    33       break;
    34     }
    35   }
    36   return($Value);
    37 }
    38 
    39 function AddPrefixMultipliers($Value, $Unit, $Digits = 4)
    40 {
    41   global $PrefixMultipliers;
    42 
    43   if($Unit == '') return(TruncateDigits($Value, $Digits));
    44   $I = 8;
    45   if($Value > 0) $II = 1;
    46   else if($Value < 0) $II = -1;
    47   else $II = 0;
    48   while((($Value / $PrefixMultipliers[$I + $II][2]) > $II) and (($I + $II) >= 0)
    49     and (($I + $II) <= count($PrefixMultipliers))) $I = $I + $II;
    50   $Value = $Value / $PrefixMultipliers[$I][2];
    51 
    52   // Truncate digits count
    53   $Value = TruncateDigits($Value, $Digits);
    54 
    55   return($Value.' '.$PrefixMultipliers[$I][0].$Unit);
    56 }
    574
    585function GetMicrotime()
Note: See TracChangeset for help on using the changeset viewer.