Changeset 45 for trunk/Application


Ignore:
Timestamp:
Nov 24, 2009, 6:01:08 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Kontrolér pro přidávání nových hodnot.
  • Opraveno: Informace o použité jednotce načítat z tabulky MeasureMethod.
Location:
trunk/Application
Files:
2 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Controller/Graph.php

    r43 r45  
    88  function Show()
    99  {
     10    $this->System->Output->FullPage = false;
     11   
    1012    $View = new GraphView($this->System);
    1113    return($View->Render());
  • trunk/Application/CustomOutput.php

    r42 r45  
    88  var $Unload = '';
    99  var $Document;
    10   var $Title;
     10  var $Title = '';
     11  var $FullPage = true;
    1112
    1213  function Header()
     
    4142  function Show($Content)
    4243  {
    43     $this->Document = new XHTMLDocument();
    44     $BodyParam = '';
    45     if($this->Load != '') $BodyParam .= ' onload="'.$this->Load.'"';
    46     if($this->Unload != '') $BodyParam .= ' onunload="'.$this->Unload.'"';
    47     $this->Document->Encoding = $this->Config['System']['Charset'];
    48     $this->Document->Formated = $this->Config['System']['FormatHTML'];
    49     $Style = new XMLTag('link');
    50     $Style->Attributes = array('rel' => 'stylesheet', 'href' => 'Application/Style/'.$this->Config['System']['Style'].'/Style.css',
    51       'type' => 'text/css', 'media' => 'all');
    52     $this->Document->HeadTag->SubElements[] = $Style;
    53     $JavaScript = new XMLTag('script');
    54     $JavaScript->Attributes = array('type' => 'text/javascript', 'src' => 'Application/Style/'.$this->Config['System']['Style'].'/Global.js');
    55     $JavaScript->ShringEmpty = false;
    56     $this->Document->HeadTag->SubElements[] = $JavaScript;
    57     $JavaScript = new XMLTag('script');
    58     $JavaScript->Attributes = array('type' => 'text/javascript', 'src' => 'Base/Style/jquery.js');
    59     $JavaScript->ShringEmpty = false;
    60     $this->Document->HeadTag->SubElements[] = $JavaScript;
    61     $this->Document->TitleTag->SubElements = $this->Config['System']['Title'].' - '.$this->Title;
    62     $this->Document->BodyTag->SubElements = array($this->Header(), $Content, $this->Footer());
    63     echo($this->Document->GetOutput());
     44    if($this->FullPage)
     45    {
     46      $this->Document = new XHTMLDocument();
     47      $BodyParam = '';
     48      if($this->Load != '') $BodyParam .= ' onload="'.$this->Load.'"';
     49      if($this->Unload != '') $BodyParam .= ' onunload="'.$this->Unload.'"';
     50      $this->Document->Encoding = $this->Config['System']['Charset'];
     51      $this->Document->Formated = $this->Config['System']['FormatHTML'];
     52      $Style = new XMLTag('link');
     53      $Style->Attributes = array('rel' => 'stylesheet', 'href' => 'Application/Style/'.$this->Config['System']['Style'].'/Style.css',
     54        'type' => 'text/css', 'media' => 'all');
     55      $this->Document->HeadTag->SubElements[] = $Style;
     56      $JavaScript = new XMLTag('script');
     57      $JavaScript->Attributes = array('type' => 'text/javascript', 'src' => 'Application/Style/'.$this->Config['System']['Style'].'/Global.js');
     58      $JavaScript->ShringEmpty = false;
     59      $this->Document->HeadTag->SubElements[] = $JavaScript;
     60      $JavaScript = new XMLTag('script');
     61      $JavaScript->Attributes = array('type' => 'text/javascript', 'src' => 'Base/Style/jquery.js');
     62      $JavaScript->ShringEmpty = false;
     63      $this->Document->HeadTag->SubElements[] = $JavaScript;
     64      $this->Document->TitleTag->SubElements = $this->Config['System']['Title'].' - '.$this->Title;
     65      $this->Document->BodyTag->SubElements = array($this->Header(), $Content, $this->Footer());
     66      echo($this->Document->GetOutput());
     67    } else echo($Content);
    6468  }
    6569
  • trunk/Application/Model/Measure.php

    r43 r45  
    1414  var $ValueTypes = array('Min', 'Avg', 'Max');
    1515 
    16   function Add($Value)
    17   {
    18     if(gethostbyaddr($_SERVER['REMOTE_ADDR']) == $this->Data['PermissionAdd'])
    19     {
    20       $this->AddValue(array('Min' => $Value, 'Avg' => $Value, 'Max' => $Value));
    21       $Output = 'Hodnota '.$Value.' uložena';
    22     } else throw new Exception('Access denied');
    23   }
    24  
    2516  function Load($Id)
    2617  {
     
    5748    //echo(TimeToMysqlDateTime($Time).'|'.$Level."\n");
    5849
    59     $Result = $Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
     50    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
    6051    //echo($Database->LastQuery."\n");
    6152    if($Result->num_rows == 0)
    6253    {
    63        $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'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0));
    6455       //echo($Database->LastQuery."\n");
    6556    } else if($Result->num_rows == 1)
    6657    {
    67       $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));
     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));
    6859      //echo($Database->LastQuery."\n");
    6960    } else
     
    7768      } else
    7869      {
    79         if(($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;
     70        if(($Time - $this->Database->MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;
    8071          else $Continuity = 0;
    8172        echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n");
     
    8374        {
    8475          $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$Measure['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));
    85           echo($this->Database->LastQuery."\n");
     76          //echo($this->Database->LastQuery."\n");
    8677        } else
    8778        {
    88           $Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $Measure['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => $Continuity));
    89           echo($this->Database->LastQuery."\n");
     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));
    9080        }
    9181      } 
    9282
    9383      // Update next level
    94       if($Level < $MaxLevel)
     84      if($Level < $this->MaxLevel)
    9585      {
    9686        $Level = $Level + 1;
     
    120110          // Load subsidary values
    121111          print_r($Values);
    122           $Values = array_merge($this->LoadLeftSideValue($Level - 1, $this->Data, $StartTime), $Values, $this->LoadRightSideValue($Level - 1, $Measure, $EndTime));
     112          $Values = array_merge($this->LoadLeftSideValue($Level - 1, $this->Data, $StartTime), $Values, $this->LoadRightSideValue($Level - 1, $EndTime));
    123113          print_r($Values);
    124114
    125           $Point = $this->ComputeOneValue($StartTime, $EndTime, $Values, $this->Data, $Level);
     115          $Point = $this->ComputeOneValue($StartTime, $EndTime, $Values, $Level);
    126116        //print_r($Point);
    127117
    128118          $this->Database->delete($this->Data['DataTable'], '(Time > "'.$this->Database->TimeToMysqlDateTime($StartTime).'") AND (Time < "'.$this->Database->TimeToMysqlDateTime($EndTime).'") AND Measure='.$this->Data['Id'].' AND Level='.$Level);
    129119          $this->Data['Period'] = $TimeSegment;
    130           $this->AddValue($this->Data, array('Min' => $Point['Min'], 'Avg' => $Point['Avg'], 'Max' => $Point['Max']), $Level, $StartTime + ($EndTime - $StartTime) / 2);
     120          $this->AddValue(array('Min' => $Point['Min'], 'Avg' => $Point['Avg'], 'Max' => $Point['Max']), $Level, $StartTime + ($EndTime - $StartTime) / 2);
    131121        }
    132122      }
     
    288278      //$Time = $Values[0]['Time'] - 60;
    289279      //array_unshift($Values, array('Time' => $Time, 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
     280      if($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level));
    290281      $Result[] = array('Time' => ($Time - $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0);
    291282
     
    350341
    351342        $EndIndex = $StartIndex;
    352         //while(($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1;
    353         while(($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;
     343        while(($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1;
     344        //while(($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;
    354345        $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    355346        //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br>');
  • trunk/Application/View/Graph.php

    r43 r45  
    3737    $Measure->Differential = $this->Config['Application']['DefaultVariables']['Differential'];
    3838    $Measure->Debug = $Debug;
     39    $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure->Data['Method']);
     40    $MeasureMethod = $DbResult2->fetch_assoc();
    3941
    4042    $FontSize = $this->Config['Application']['FontSize'];
     
    177179        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    178180        //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $this->Config['Application']['ValueToImageHeigthCoefficient'] * $Height);
    179         $Text = $this->System->AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $this->Config['Application']['ValueToImageHeigthCoefficient'] * ($MaxValue - $MinValue) + $MinValue)), $Measure->Data['Unit'], 3);
     181        $Text = $this->System->AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $this->Config['Application']['ValueToImageHeigthCoefficient'] * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
    180182        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    181183        if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     
    185187
    186188      $Left = $Width - 10;
    187       $Text = '    Max. '.$this->System->AddPrefixMultipliers($MaxValue, $Measure->Data['Unit']);
     189      $Text = '    Max. '.$this->System->AddPrefixMultipliers($MaxValue, $MeasureMethod['Unit']);
    188190      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    189191      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    190192      imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
    191193
    192       $Text = '    Avg.  '.$this->System->AddPrefixMultipliers($AvgValue, $Measure->Data['Unit']);
     194      $Text = '    Avg.  '.$this->System->AddPrefixMultipliers($AvgValue, $MeasureMethod['Unit']);
    193195      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    194196      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    195197      imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
    196198
    197       $Text = '    Min.  '.$this->System->AddPrefixMultipliers($MinValue, $Measure->Data['Unit']);
     199      $Text = '    Min.  '.$this->System->AddPrefixMultipliers($MinValue, $MeasureMethod['Unit']);
    198200      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    199201      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
  • trunk/Application/View/Main.php

    r44 r45  
    180180    $Output .= '</tr>';
    181181    $Result = $this->Database->select('Measure', '*', 'Enabled=1 ORDER BY Description');
    182     //echo($Database->error);
    183 
    184182    while($Measure = $Result->fetch_array())
    185183    {
     184      $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure['Method']);
     185      $MeasureMethod = $DbResult2->fetch_assoc();
    186186      $StopWatchStart = $this->System->GetMicrotime();
    187187      if(array_key_exists('Debug', $_GET))
     
    196196        $Row = $Result2->fetch_array();
    197197        $LastMeasureTime = date('j.n.Y G:i:s', $this->Database->MysqlDateTimeToTime($Row['Time']));
    198         $LastMeasureValue = $this->System->AddPrefixMultipliers($Row['Avg'], $Measure['Unit']);
     198        $LastMeasureValue = $this->System->AddPrefixMultipliers($Row['Avg'], $MeasureMethod['Unit']);
    199199      } else
    200200      {
Note: See TracChangeset for help on using the changeset viewer.