Ignore:
Timestamp:
May 11, 2014, 4:28:01 PM (10 years ago)
Author:
chronos
Message:
  • Opraveno: Zobrazování grafů mřených veličin.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/TimeMeasure/Main.php

    r577 r655  
    33class PageMeasure extends Page
    44{
    5   var $Months = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
    6 
    7   var $GraphTimeRanges = array
     5  var $Months;
     6  var $GraphTimeRanges;
     7  var $DefaultVariables;
     8  var $ImageHeight;
     9  var $ImageWidth;
     10
     11  function __construct($System)
     12  {
     13    parent::__construct($System);
     14    $this->ShortTitle = 'Grafy';
     15    $this->FullTitle = 'Časové grafy veličin';
     16    $this->ImageWidth = 800;
     17    $this->ImageHeight = 200;
     18    $this->ParentClass = 'PagePortal';
     19        $this->DefaultVariables = array(
     20      'TimeSpecify' => 0,
     21      'Period' => 'day',
     22      'Measure' => 1,
     23      'Differential' => 0,
     24    );
     25    $this->Months = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen',
     26      'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
     27    $this->GraphTimeRanges = array
    828  (
    929    'hour' => array(
     
    2242      'caption' => 'Měsíc',
    2343      'period' => 2592000, // 3600 * 24 * 30,
    24     ), 
     44    ),
    2545    'year' => array(
    2646      'caption' => 'Rok',
     
    3252    ),
    3353  );
     54  }
    3455
    3556  function EditTime($Time)
     
    4465    for($I = 1; $I < 32; $I++)
    4566    {
    46       if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 
     67      if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    4768      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    4869    }
     
    5273    $Output .= '<select name="Month">';
    5374    foreach($this->Months as $Index => $Month)
    54     { 
     75    {
    5576      if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    5677      if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
     
    6182    $Output .= '<select name="Year">';
    6283    for($I = 2000; $I < 2010; $I++)
    63     { 
     84    {
    6485      if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    6586      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
     
    7091    $Output .= '<select name="Hour">';
    7192    for($I = 0; $I < 24; $I++)
    72     { 
     93    {
    7394      if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    7495      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
     
    7899    // Minute selection
    79100    $Output .= '<select name="Minute">';
    80     for($I = 0; $I < 60; $I++) 
     101    for($I = 0; $I < 60; $I++)
    81102    {
    82103      if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
     
    98119    $Debug = 0;
    99120
    100     foreach($this->System->Config['Application']['DefaultVariables'] as $Index => $Variable)
     121    foreach($this->DefaultVariables as $Index => $Variable)
    101122    {
    102123      if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
     
    110131      $_SESSION['TimeEnd'] = time() - 60;
    111132      $_SESSION['TimeStart'] = $_SESSION['TimeEnd'] - $this->GraphTimeRanges[$_SESSION['Period']]['period'];
    112     } 
    113 
    114     $Output = '<div class="Title">Statistiky</div>';
     133    }
     134
     135    $Output = '';
    115136
    116137    if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     
    128149          }
    129150        }
    130         break; 
     151        break;
    131152      case 'SetTimeNow':
    132         if(array_key_exists('Time', $_GET)) 
     153        if(array_key_exists('Time', $_GET))
    133154        {
    134155          if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     
    160181    $Output .= '<br/>'.$this->MeasureTable();
    161182    return($Output);
    162   } 
    163  
     183  }
     184
    164185  function Graph()
    165186  {
    166187    $Output = '<strong>Graf:</strong><br/>';
    167     $Output .= '<img alt="Graf" src="?M=Graph&amp;Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width='.$this->Config['Application']['GraphSize']['Width'].'&amp;Height='.$this->Config['Application']['GraphSize']['Height'].'&amp;Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['GraphSize']['Width'].'" height="'.$this->Config['Application']['GraphSize']['Height'].'"><br>';
    168     $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.$_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
    169     return($Output);
    170   }
    171  
     188    $Output .= '<img alt="Graf" src="'.$this->System->Link('/grafy/graf.png?Measure='.$_SESSION['Measure'].
     189      '&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width='.
     190      $this->ImageWidth.'&amp;Height='.$this->ImageHeight.'&amp;Differential='.
     191      $_SESSION['Differential']).'" width="'.$this->ImageWidth.'" height="'.$this->ImageHeight.'"><br>';
     192    $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.
     193      $_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
     194    return($Output);
     195  }
     196
    172197  function MeasureTable()
    173198  {
     199    $PrefixMultiplier = new PrefixMultiplier();
    174200    $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">';
    175201    $Output .= '<tr><th>Měřená veličina</th><th>Poslední hodnota</th><th>Čas posledního měření</th><th>Interpolace</th><th>Poznámky</th>';
     
    181207      $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure['Method']);
    182208      $MeasureMethod = $DbResult2->fetch_assoc();
    183       $StopWatchStart = $this->System->GetMicrotime();
     209      $StopWatchStart = GetMicrotime();
    184210      if(array_key_exists('Debug', $_GET))
    185211      {
     
    192218      {
    193219        $Row = $Result2->fetch_array();
    194         $LastMeasureTime = date('j.n.Y G:i:s', $this->Database->MysqlDateTimeToTime($Row['Time']));
    195         $LastMeasureValue = $this->System->AddPrefixMultipliers($Row['Avg'], $MeasureMethod['Unit']);
     220        $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['Time']));
     221        $LastMeasureValue = $PrefixMultiplier->Add($Row['Avg'], $MeasureMethod['Unit']);
    196222      } else
    197223      {
     
    199225        $LastMeasureValue = '&nbsp;';
    200226      }
    201       if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 
     227      if($Measure['Continuity'] == 1) $Interpolate = 'Ano';
    202228        else $Interpolate = 'Ne';
    203       if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    204       $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
     229      //if($Measure['Description'] == '') $Measure['Description'] = '&nbsp;';
     230      $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    205231      $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Name'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Description'].'</td>';
    206232      if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
     
    211237    //print_r(gd_info());
    212238    //print_r($_SESSION);
    213  
     239
    214240    //ShowPage($Output);
    215     //echo(AddPrefixMultipliers('-0.000000071112345', 'B'));
     241    //echo($PrefixMultiplier->Add('-0.000000071112345', 'B'));
    216242    return($Output);
    217243  }
Note: See TracChangeset for help on using the changeset viewer.