Changeset 45 for trunk/Application
- Timestamp:
- Nov 24, 2009, 6:01:08 PM (15 years ago)
- Location:
- trunk/Application
- Files:
-
- 2 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Controller/Graph.php
r43 r45 8 8 function Show() 9 9 { 10 $this->System->Output->FullPage = false; 11 10 12 $View = new GraphView($this->System); 11 13 return($View->Render()); -
trunk/Application/CustomOutput.php
r42 r45 8 8 var $Unload = ''; 9 9 var $Document; 10 var $Title; 10 var $Title = ''; 11 var $FullPage = true; 11 12 12 13 function Header() … … 41 42 function Show($Content) 42 43 { 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); 64 68 } 65 69 -
trunk/Application/Model/Measure.php
r43 r45 14 14 var $ValueTypes = array('Min', 'Avg', 'Max'); 15 15 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 25 16 function Load($Id) 26 17 { … … 57 48 //echo(TimeToMysqlDateTime($Time).'|'.$Level."\n"); 58 49 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'); 60 51 //echo($Database->LastQuery."\n"); 61 52 if($Result->num_rows == 0) 62 53 { 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)); 64 55 //echo($Database->LastQuery."\n"); 65 56 } else if($Result->num_rows == 1) 66 57 { 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)); 68 59 //echo($Database->LastQuery."\n"); 69 60 } else … … 77 68 } else 78 69 { 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; 80 71 else $Continuity = 0; 81 72 echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n"); … … 83 74 { 84 75 $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"); 86 77 } else 87 78 { 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)); 90 80 } 91 81 } 92 82 93 83 // Update next level 94 if($Level < $ MaxLevel)84 if($Level < $this->MaxLevel) 95 85 { 96 86 $Level = $Level + 1; … … 120 110 // Load subsidary values 121 111 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)); 123 113 print_r($Values); 124 114 125 $Point = $this->ComputeOneValue($StartTime, $EndTime, $Values, $ this->Data, $Level);115 $Point = $this->ComputeOneValue($StartTime, $EndTime, $Values, $Level); 126 116 //print_r($Point); 127 117 128 118 $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); 129 119 $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); 131 121 } 132 122 } … … 288 278 //$Time = $Values[0]['Time'] - 60; 289 279 //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)); 290 281 $Result[] = array('Time' => ($Time - $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0); 291 282 … … 350 341 351 342 $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; 354 345 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 355 346 //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br>'); -
trunk/Application/View/Graph.php
r43 r45 37 37 $Measure->Differential = $this->Config['Application']['DefaultVariables']['Differential']; 38 38 $Measure->Debug = $Debug; 39 $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure->Data['Method']); 40 $MeasureMethod = $DbResult2->fetch_assoc(); 39 41 40 42 $FontSize = $this->Config['Application']['FontSize']; … … 177 179 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 178 180 //$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); 180 182 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 181 183 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) … … 185 187 186 188 $Left = $Width - 10; 187 $Text = ' Max. '.$this->System->AddPrefixMultipliers($MaxValue, $Measure ->Data['Unit']);189 $Text = ' Max. '.$this->System->AddPrefixMultipliers($MaxValue, $MeasureMethod['Unit']); 188 190 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 189 191 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 190 192 imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text); 191 193 192 $Text = ' Avg. '.$this->System->AddPrefixMultipliers($AvgValue, $Measure ->Data['Unit']);194 $Text = ' Avg. '.$this->System->AddPrefixMultipliers($AvgValue, $MeasureMethod['Unit']); 193 195 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 194 196 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 195 197 imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text); 196 198 197 $Text = ' Min. '.$this->System->AddPrefixMultipliers($MinValue, $Measure ->Data['Unit']);199 $Text = ' Min. '.$this->System->AddPrefixMultipliers($MinValue, $MeasureMethod['Unit']); 198 200 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 199 201 $Left -= ($BoundingBox[2] - $BoundingBox[0]); -
trunk/Application/View/Main.php
r44 r45 180 180 $Output .= '</tr>'; 181 181 $Result = $this->Database->select('Measure', '*', 'Enabled=1 ORDER BY Description'); 182 //echo($Database->error);183 184 182 while($Measure = $Result->fetch_array()) 185 183 { 184 $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure['Method']); 185 $MeasureMethod = $DbResult2->fetch_assoc(); 186 186 $StopWatchStart = $this->System->GetMicrotime(); 187 187 if(array_key_exists('Debug', $_GET)) … … 196 196 $Row = $Result2->fetch_array(); 197 197 $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']); 199 199 } else 200 200 {
Note:
See TracChangeset
for help on using the changeset viewer.