Ignore:
Timestamp:
Mar 1, 2015, 12:43:56 PM (10 years ago)
Author:
chronos
Message:
  • Moved trunk as mvc branch.
Location:
branches/mvc
Files:
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/mvc/Application/CustomOutput.php

    r47 r59  
    3535      $Tag->SubElements[] = $ExecutionTimeTag;
    3636      $UsedMemoryTag = new XMLTag('li');
    37       $UsedMemoryTag->SubElements = 'Použitá paměť: '.$this->System->AddPrefixMultipliers(memory_get_peak_usage(FALSE), 'B').' / '.ini_get('memory_limit').'B';
     37      $PrefixMultiplier = new PrefixMultiplier();
     38      $UsedMemoryTag->SubElements = 'Použitá paměť: '.$PrefixMultiplier->Add(memory_get_peak_usage(FALSE), 'B').' / '.ini_get('memory_limit').'B';
    3839      $Tag->SubElements[] = $UsedMemoryTag;
    3940    }
  • branches/mvc/Application/Model/Measure.php

    r47 r59  
    4141  }
    4242
    43 
    4443  function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0)
    4544  {
     
    4847    //echo(TimeToMysqlDateTime($Time).'|'.$Level."\n");
    4948
    50     $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
     49    $Result = $this->Database->select($this->Data['DataTable'], '*', '(Measure='.$this->Data['Id'].') AND '.
     50      '(Level='.$Level.') ORDER BY Time DESC LIMIT 2');
    5151    //echo($Database->LastQuery."\n");
    5252    if($Result->num_rows == 0)
    5353    {
    54        $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0));
     54       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     55         'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     56         'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0));
    5557       //echo($Database->LastQuery."\n");
    5658    } else if($Result->num_rows == 1)
    5759    {
    58       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 1));
     60      $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     61        'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     62        'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 1));
    5963      //echo($Database->LastQuery."\n");
    6064    } else
     
    7175          else $Continuity = 0;
    7276        echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n");
    73         if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and ($LastValue['Continuity'] == 1) and ($Continuity == 1))
    74         {
    75           $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));
     77        if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and
     78        ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and
     79        ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and
     80        ($LastValue['Continuity'] == 1) and ($Continuity == 1))
     81        {
     82          $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") '.
     83            'AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array(
     84            'Time' => $this->Database->TimeToMysqlDateTime($Time)));
    7685          //echo($this->Database->LastQuery."\n");
    7786        } else
    7887        {
    79           $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => $Continuity));
     88          $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     89            'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     90            'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time),
     91            'Continuity' => $Continuity));
    8092        }
    8193      }
  • branches/mvc/Application/Style/Basic/Style.css

    r43 r59  
    33  font-family :  Arial, sans-serif;
    44}
     5
     6.Main
     7{
     8  text-align: center;
     9}
     10
    511.BasicTable
    612{
     
    2531  padding: 2px;
    2632}
     33
     34.WideTable
     35{
     36  border-color: #A0A0A0;
     37  border-style: solid;
     38  border-width: 1px 1px 0px 0px;
     39  border-spacing: 0px;
     40  text-align: center;
     41  margin-left: auto;
     42  margin-right: auto; 
     43}
     44
     45.WideTable th
     46{
     47  border-color: #A0A0A0;
     48  border-style: solid;
     49  border-width: 0px 0px 1px 1px;
     50  padding: 1px 5px 1px 5px;
     51  background-color: #F0F0FF
     52}
     53
     54.WideTable td
     55{
     56  border-color: #A0A0A0;
     57  border-style: solid;
     58  border-width: 0px 0px 1px 1px;
     59  padding: 1px 5px 1px 5px;
     60  text-align: center;
     61}
     62
    2763h3
    2864{
  • branches/mvc/Application/View/Graph.php

    r47 r59  
    66class GraphView extends View
    77{
     8  var $FontSize;
     9  var $FontFileName;
     10  var $ValueToImageHeigthCoefficient;
    811  var $DefaultWidth;
    912  var $DefaultHeight;
     
    1417    $this->DefaultWidth = 800;
    1518    $this->DefaultHeight = 200;
     19    $this->FontSize = 10;
     20    $this->FontFileName = 'Arial.ttf';
     21    $this->ValueToImageHeigthCoefficient = 0.9;
    1622  }
    1723
     
    3541    if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
    3642      else $Differential = addslashes($_GET['Differential']);
    37     $VerticalLinesCount = round($Height / ($this->Config['Application']['FontSize'] + 4));
    38 
     43    $VerticalLinesCount = round($Height / ($this->FontSize + 4));
     44
     45    $PrefixMultiplier = new PrefixMultiplier();
    3946    $StopWatchStart = $this->System->GetMicrotime();
    4047
     
    5057    $MeasureMethod = $DbResult2->fetch_assoc();
    5158
    52     $FontSize = $this->Config['Application']['FontSize'];
    53     $FontFile = dirname(__FILE__).'/../Style/'.$this->Config['System']['Style'].'/'.$this->Config['Application']['FontFileName'];
     59    $FontSize = $this->FontSize;
     60    $FontFile = dirname(__FILE__).'/../Style/'.$this->Config['System']['Style'].'/'.$this->FontFileName;
    5461
    5562    $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1;
     
    9299      {
    93100        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
    94         $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     101        $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) /
     102          ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    95103        $PointsAvg[] = $Index * $Width / $Measure->DivisionCount;
    96         $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     104        $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) /
     105          ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    97106        $PointsMax[] = $Index * $Width / $Measure->DivisionCount;
    98         $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     107        $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) /
     108          ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    99109        //echo($Index.' - '.$Item.' '.$Points[$Index].'<br/>');
    100110      }
     
    113123    $PointsMax[] = $Height - 1;
    114124
    115 
    116125    //array_unshift($Points, $Height - 1);
    117126    //array_unshift($Points, 0);
    118127    //$Points[] = $Width - 1;
    119128    //$Points[] = $Height - 1;      echo('sds');
    120 
    121 
    122129    //print_r($PointsMax);
    123130
     
    179186        {
    180187          for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    181           imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $FontFile, $Text);
     188          imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,
     189            $Height - 2, $Black, $FontFile, $Text);
    182190          $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    183191        }
     
    190198        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    191199        //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $this->Config['Application']['ValueToImageHeigthCoefficient'] * $Height);
    192         $Text = $this->System->AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $this->Config['Application']['ValueToImageHeigthCoefficient'] * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
     200        $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance /
     201          $Height / $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
    193202        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    194203        if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     
    198207
    199208      $Left = $Width - 10;
    200       $Text = '    Max. '.$this->System->AddPrefixMultipliers($MaxValue, $MeasureMethod['Unit']);
     209      $Text = '    Max. '.$PrefixMultiplier->Add($MaxValue, $MeasureMethod['Unit']);
    201210      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    202211      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    203212      imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
    204213
    205       $Text = '    Avg.  '.$this->System->AddPrefixMultipliers($AvgValue, $MeasureMethod['Unit']);
     214      $Text = '    Avg.  '.$PrefixMultiplier->Add($AvgValue, $MeasureMethod['Unit']);
    206215      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    207216      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    208217      imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
    209218
    210       $Text = '    Min.  '.$this->System->AddPrefixMultipliers($MinValue, $MeasureMethod['Unit']);
     219      $Text = '    Min.  '.$PrefixMultiplier->Add($MinValue, $MeasureMethod['Unit']);
    211220      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    212221      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
  • branches/mvc/Application/View/Main.php

    r47 r59  
    113113    }
    114114
    115     $Output = '<div class="Title">Statistiky</div>';
     115    $Output = '<div class="Main">';
     116    $Output .= '<div class="Title">Statistiky</div>';
    116117
    117118    if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     
    160161
    161162    $Output .= '<br/>'.$this->MeasureTable();
     163    $Output .= '</div>';
    162164    return($Output);
    163165  }
     
    178180  function MeasureTable()
    179181  {
    180     $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">';
     182    $Output = '<table class="WideTable">';
    181183    $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>';
    182184    if(array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
    183185    $Output .= '</tr>';
     186    $PrefixMultiplier = new PrefixMultiplier();
    184187    $Result = $this->Database->select('Measure', '*', 'Enabled=1 ORDER BY Description');
    185188    while($Measure = $Result->fetch_array())
     
    199202        $Row = $Result2->fetch_array();
    200203        $LastMeasureTime = date('j.n.Y G:i:s', $this->Database->MysqlDateTimeToTime($Row['Time']));
    201         $LastMeasureValue = $this->System->AddPrefixMultipliers($Row['Avg'], $MeasureMethod['Unit']);
     204        $LastMeasureValue = $PrefixMultiplier->Add($Row['Avg'], $MeasureMethod['Unit']);
    202205      } else
    203206      {
     
    219222
    220223    //ShowPage($Output);
    221     //echo(AddPrefixMultipliers('-0.000000071112345', 'B'));
    222224    return($Output);
    223225  }
Note: See TracChangeset for help on using the changeset viewer.