Changeset 655
- Timestamp:
- May 11, 2014, 4:28:01 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r636 r655 5 5 /* @var $Database Database */ 6 6 $Database = NULL; 7 7 8 8 include_once(dirname(__FILE__).'/VarDumper.php'); 9 9 include_once(dirname(__FILE__).'/Base.php'); … … 17 17 include_once(dirname(__FILE__).'/Config.php'); 18 18 include_once(dirname(__FILE__).'/Setup/Setup.php'); 19 include_once(dirname(__FILE__).'/PrefixMultiplier.php'); 19 20 20 21 //define('NEW_PERMISSION', '1'); 21 22 22 $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 23 $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 23 24 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'); 24 25 25 26 $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); 26 27 $YesNo = array(false => 'Ne', true => 'Ano'); 27 28 28 29 function HumanSize($Value) 29 30 { … … 54 55 function HumanDate($Time) 55 56 { 56 if($Time != '') { 57 if($Time != '') { 57 58 $Date = explode(' ', $Time); 58 59 $Parts = explode('-', $Date[0]); 59 60 if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]); 60 61 else return(' '); 61 } else return(' '); 62 } else return(' '); 62 63 } 63 64 … … 70 71 if($Count>1) 71 72 { 72 if($Page>0) 73 if($Page>0) 73 74 { 74 75 $Result.= '<a href="'.$URL.'0"><<</a> '; … … 88 89 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> '; 89 90 if($i==$Page) $Result.= '</strong>'; 90 } 91 } 91 92 if($PagesMax<($Count-1)) $Result .= ' .. '; 92 if($Page<($Count-1)) 93 if($Page<($Count-1)) 93 94 { 94 95 $Result.= '<a href="'.$URL.($Page+1).'">></a> '; … … 97 98 } 98 99 return($Result); 99 } 100 } 100 101 101 102 function ExtractTime($Time) 102 { 103 { 103 104 return(array( 104 'Year' => date('Y', $Time), 105 'Month' => date('n', $Time), 105 'Year' => date('Y', $Time), 106 'Month' => date('n', $Time), 106 107 'Day' => date('j', $Time), 107 108 'Hour' => date('h', $Time), … … 137 138 } 138 139 139 class Paging 140 class Paging 140 141 { 141 142 var $TotalCount; … … 144 145 var $SQLLimit; 145 146 var $Page; 146 147 147 148 function __construct() 148 149 { 149 150 global $System; 150 151 151 152 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 152 153 $this->Around = $System->Config['Web']['VisiblePagingItems']; 153 154 } 154 155 155 156 function Show() 156 157 { 157 158 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 158 159 159 160 $Result = ''; 160 if(array_key_exists('all', $QueryItems)) 161 if(array_key_exists('all', $QueryItems)) 161 162 { 162 163 $PageCount = 1; 163 $ItemPerPage = $this->TotalCount; 164 } else 164 $ItemPerPage = $this->TotalCount; 165 } else 165 166 { 166 167 $ItemPerPage = $this->ItemPerPage; … … 168 169 $PageCount = floor($this->TotalCount / $ItemPerPage) + 1; 169 170 } 170 171 171 172 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 172 173 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 173 174 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 174 175 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 175 $CurrentPage = $_SESSION['Page']; 176 176 $CurrentPage = $_SESSION['Page']; 177 177 178 $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: '; 178 179 179 180 $Result = ''; 180 181 if($PageCount > 1) 181 182 { 182 if($CurrentPage > 0) 183 if($CurrentPage > 0) 183 184 { 184 $QueryItems['page'] = 0; 185 $QueryItems['page'] = 0; 185 186 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 186 187 $QueryItems['page'] = ($CurrentPage - 1); … … 202 203 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 203 204 } 204 } 205 } 205 206 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 206 if($CurrentPage < ($PageCount - 1)) 207 if($CurrentPage < ($PageCount - 1)) 207 208 { 208 209 $QueryItems['page'] = ($CurrentPage + 1); … … 214 215 $QueryItems['all'] = '1'; 215 216 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 216 217 217 218 $Result = '<div style="text-align: center">'.$Result.'</div>'; 218 219 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; … … 225 226 { 226 227 global $System; 227 228 228 229 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 229 230 230 231 $Result = ''; 231 if(array_key_exists('all', $QueryItems)) 232 if(array_key_exists('all', $QueryItems)) 232 233 { 233 234 $PageCount = 1; 234 $ItemPerPage = $TotalCount; 235 } else 235 $ItemPerPage = $TotalCount; 236 } else 236 237 { 237 238 $ItemPerPage = $System->Config['Web']['ItemsPerPage']; … … 239 240 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 240 241 } 241 242 242 243 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 243 244 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; … … 245 246 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 246 247 $CurrentPage = $_SESSION['Page']; 247 248 248 249 249 250 $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> Stránky: '; 250 251 … … 252 253 if($PageCount > 1) 253 254 { 254 if($CurrentPage > 0) 255 { 256 $QueryItems['page'] = 0; 255 if($CurrentPage > 0) 256 { 257 $QueryItems['page'] = 0; 257 258 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 258 259 $QueryItems['page'] = ($CurrentPage - 1); … … 274 275 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 275 276 } 276 } 277 } 277 278 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 278 if($CurrentPage < ($PageCount - 1)) 279 if($CurrentPage < ($PageCount - 1)) 279 280 { 280 281 $QueryItems['page'] = ($CurrentPage + 1); … … 286 287 $QueryItems['all'] = '1'; 287 288 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 288 289 289 290 $Result = '<div style="text-align: center">'.$Result.'</div>'; 290 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 291 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 291 292 'Page' => $CurrentPage, 292 293 'Output' => $Result, … … 300 301 { 301 302 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 302 303 303 304 if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 304 305 if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 305 306 if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 306 307 if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 307 308 308 309 // Check OrderCol 309 310 $Found = false; … … 312 313 if($Column['Name'] == $_SESSION['OrderCol']) 313 314 { 314 $Found = true; 315 $Found = true; 315 316 break; 316 317 } … … 323 324 // Check OrderDir 324 325 if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 325 326 326 327 $Result = ''; 327 328 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); … … 362 363 { 363 364 global $Database; 364 365 365 366 $DbResult = $Database->query('SELECT Id FROM Member WHERE (SELECT Member FROM NetworkDevice WHERE (SELECT Device FROM NetworkInterface WHERE LocalIP = "'.$IP.'") = NetworkDevice.Id) = Member.Id'); 366 367 if($DbResult->num_rows > 0) 367 368 { 368 $DbRow = $DbResult->fetch_assoc(); 369 $DbRow = $DbResult->fetch_assoc(); 369 370 return($DbRow['Id']); 370 371 } else return(''); … … 374 375 { 375 376 return(str_replace( 376 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 377 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 377 378 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), 378 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 379 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 379 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 380 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 380 381 $Text)); 381 382 } … … 384 385 { 385 386 return(strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', 386 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 387 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 387 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 388 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 388 389 'ť' => 't', 'ň' => 'n', 'ó' => 'o', 389 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 390 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 390 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 391 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 391 392 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o', 392 393 ))); … … 395 396 function NotBlank($Text) 396 397 { 397 if($Text == '') return(' '); 398 if($Text == '') return(' '); 398 399 else return($Text); 399 400 } … … 403 404 preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches); 404 405 return str_replace($matches[0], $matches[1], $string); 405 } 406 } 406 407 407 408 function html2txt($document) … … 414 415 $text = preg_replace($search, '', $document); 415 416 return $text; 416 } 417 } 417 418 418 419 function ProcessURL() … … 425 426 if(strpos($_SERVER['REQUEST_URI'], '?') !== false) 426 427 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 427 else $_SERVER['QUERY_STRING'] = ''; 428 else $_SERVER['QUERY_STRING'] = ''; 428 429 parse_str($_SERVER['QUERY_STRING'], $_GET); 429 430 return($PathItems); -
trunk/Common/PrefixMultiplier.php
r548 r655 78 78 if($Value >= pow(10, $II)) 79 79 { 80 if($Digits < ($II + 1)) $RealDigits = $II + 1; 80 if($Digits < ($II + 1)) $RealDigits = $II + 1; 81 81 else $RealDigits = $Digits; 82 82 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); … … 87 87 } 88 88 89 function Add PrefixMultipliers($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal')89 function Add($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal') 90 90 { 91 91 global $PrefixMultipliers; … … 98 98 $I = $PrefixMultipliers[$PrefixType]['BaseIndex']; 99 99 if($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit); 100 101 if($Value > 1) 100 101 if($Value > 1) 102 102 { 103 103 while((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1)) 104 104 $I = $I + 1; 105 } else 105 } else 106 106 if($Value < 1) 107 107 { … … 110 110 } 111 111 $Value = $Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]; 112 112 113 113 // Truncate digits count 114 114 $Value = $this->TruncateDigits($Value, $Digits); 115 115 if($Negative) $Value = -$Value; 116 116 return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit); 117 } 117 } 118 118 } -
trunk/Modules/TimeMeasure/Graph.php
r569 r655 1 1 <?php 2 2 3 class GraphView extends View3 class PageGraph extends Page 4 4 { 5 var $FontSize; 6 var $FontFileName; 7 var $ValueToImageHeigthCoefficient; 8 var $DefaultWidth; 9 var $DefaultHeight; 10 11 function __construct($System) 12 { 13 parent::__construct($System); 14 $this->FontSize = 10; 15 $this->FontFileName = 'Arial.ttf'; 16 $this->ValueToImageHeigthCoefficient = 0.9; 17 } 18 19 function Show() 20 { 21 $this->ClearPage = true; 22 return($this->Render()); 23 } 24 5 25 function Render() 6 26 { 7 if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 27 $PrefixMultiplier = new PrefixMultiplier(); 28 29 if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 8 30 else $Debug = 0; 9 31 10 32 if(!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku'); 11 33 $StartTime = addslashes($_GET['From']); … … 15 37 $TimeDifference = $EndTime - $StartTime; 16 38 if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu'); 17 $MeasureId = addslashes($_GET['Measure']); 18 if(!array_key_exists('Width', $_GET)) $Width = $ DefaultWidth;39 $MeasureId = addslashes($_GET['Measure']); 40 if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 19 41 else $Width = addslashes($_GET['Width']); 20 if(!array_key_exists('Height', $_GET)) $Height = $ DefaultHeight;42 if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight; 21 43 else $Height = addslashes($_GET['Height']); 22 44 if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential']; 23 45 else $Differential = addslashes($_GET['Differential']); 24 $VerticalLinesCount = round($Height / ($this-> Config['Application']['FontSize']+ 4));25 26 $StopWatchStart = $this->System->GetMicrotime();46 $VerticalLinesCount = round($Height / ($this->FontSize + 4)); 47 48 $StopWatchStart = GetMicrotime(); 27 49 28 50 $Measure = new Measure($this->System); 29 51 $Measure->Load($MeasureId); 30 $Measure->LevelReducing = $this->Config['Application']['LevelReducing'];31 $Measure->ReferenceTime = $this->Config['Application']['ReferenceTime'];32 $Measure->MaxLevel = $this->Config['Application']['MaxLevel'];33 $Measure->DivisionCount = $this->Config['Application']['DivisionCount'];34 $Measure->Differential = $this->Config['Application']['DefaultVariables']['Differential'];52 //$Measure->LevelReducing = $this->LevelReducing; 53 //$Measure->ReferenceTime = $this->Config['Application']['ReferenceTime']; 54 //$Measure->MaxLevel = $this->Config['Application']['MaxLevel']; 55 //$Measure->DivisionCount = $this->Config['Application']['DivisionCount']; 56 //$Measure->Differential = $this->Config['Application']['DefaultVariables']['Differential']; 35 57 $Measure->Debug = $Debug; 36 58 $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure->Data['Method']); 37 59 $MeasureMethod = $DbResult2->fetch_assoc(); 38 60 39 $FontSize = $this-> Config['Application']['FontSize'];40 $FontFile = dirname(__FILE__).'/../ Style/'.$this->Config['System']['Style'].'/'.$this->Config['Application']['FontFileName'];61 $FontSize = $this->FontSize; 62 $FontFile = dirname(__FILE__).'/../../style/'.$this->System->Config['Web']['Style'].'/'.$this->FontFileName; 41 63 42 64 $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1; … … 47 69 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); 48 70 49 if($Debug) echo('Points count: '.count($Points).'<br/>'); 50 //if($Debug) foreach($Points as $Index => $Item) 71 if($Debug) echo('Points count: '.count($Points).'<br/>'); 72 //if($Debug) foreach($Points as $Index => $Item) 51 73 // echo($Index.': '.$Item['min'].'<br>'); 52 74 … … 70 92 $AvgValue = $AvgValue / count($Points); //round( * $Measure['Divider']) / $Measure['Divider']; 71 93 72 // Generate polygon and recalculate y values to fit graph height 94 // Generate polygon and recalculate y values to fit graph height 73 95 $PointsMin = array(0, $Height - 1); 74 96 $PointsAvg = array(0, $Height - 1); 75 97 $PointsMax = array(0, $Height - 1); 76 98 if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 77 { 99 { 78 100 foreach($Points as $Index => $Item) 79 101 { 80 102 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; 81 $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this-> Config['Application']['ValueToImageHeigthCoefficient'];103 $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient; 82 104 $PointsAvg[] = $Index * $Width / $Measure->DivisionCount; 83 $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this-> Config['Application']['ValueToImageHeigthCoefficient'];105 $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient; 84 106 $PointsMax[] = $Index * $Width / $Measure->DivisionCount; 85 $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this-> Config['Application']['ValueToImageHeigthCoefficient'];107 $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient; 86 108 //echo($Index.' - '.$Item.' '.$Points[$Index].'<br>'); 87 109 } … … 107 129 108 130 //print_r($PointsMax); 109 131 110 132 // Generate image 111 if(!$Debug) 133 if(!$Debug) 112 134 { 113 135 Header('Content-type: image/png'); 114 Header('Cache-Control: no-cache'); // Dynamic graph - no cache 136 Header('Cache-Control: no-cache'); // Dynamic graph - no cache 115 137 $Image = @imagecreate($Width, $Height); 116 138 $BackgroundColor = imagecolorallocate($Image, 255, 255, 255); … … 129 151 imagefilledpolygon($Image, $PointsAvg, count($PointsAvg) / 2, $LightGreen); 130 152 imagefilledpolygon($Image, $PointsMin, count($PointsMin) / 2, $LightBlue); 131 153 132 154 $TimeMarks = array(1, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*30, 60*60*24*365, 60*60*24*365*10); 133 155 134 156 $TimeRange = $EndTime - $StartTime; 135 157 $TimeMarksIndex = 0; … … 137 159 if($TimeMarksIndex < 2) $TimeMarksIndex = 2; 138 160 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 139 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 140 141 $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 161 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 162 163 $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 142 164 //imagestring($Image, 10, 40, 50, $TimeShift, $Black); 143 165 144 166 // Zobraz měřítko Y 145 167 $VerticalLinesDistance = $Height / $VerticalLinesCount; … … 149 171 for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray); 150 172 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 151 } 152 153 $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 154 173 } 174 175 $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 176 155 177 // Zobraz měřítko X 156 178 $LastTextEnd = 0; 157 179 for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 158 180 { 159 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 181 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 160 182 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 161 183 if(($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift); … … 169 191 } 170 192 else for($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray); 171 } 172 193 } 194 173 195 // Popisky osy Y 174 196 for($I = 1; $I <= $VerticalLinesCount; $I++) 175 197 { 176 198 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 177 //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $this->Config['Application']['ValueToImageHeigthCoefficient'] * $Height); 178 $Text = $this->System->AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $this->Config['Application']['ValueToImageHeigthCoefficient'] * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3); 199 //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * 200 // $this->ValueToImageHeigthCoefficient * $Height); 201 $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance / $Height / 202 $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3); 179 203 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 180 204 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 181 205 imagettftext($Image, $FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text); 182 } 183 $GenerationTime = floor(( $this->System->GetMicrotime() - $StopWatchStart) * 1000 ) / 1000;206 } 207 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 184 208 185 209 $Left = $Width - 10; 186 $Text = ' Max. '.$ this->System->AddPrefixMultipliers($MaxValue, $MeasureMethod['Unit']);210 $Text = ' Max. '.$PrefixMultiplier->Add($MaxValue, $MeasureMethod['Unit']); 187 211 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 188 212 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 189 213 imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text); 190 214 191 $Text = ' Avg. '.$ this->System->AddPrefixMultipliers($AvgValue, $MeasureMethod['Unit']);215 $Text = ' Avg. '.$PrefixMultiplier->Add($AvgValue, $MeasureMethod['Unit']); 192 216 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 193 217 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 194 218 imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text); 195 219 196 $Text = ' Min. '.$ this->System->AddPrefixMultipliers($MinValue, $MeasureMethod['Unit']);220 $Text = ' Min. '.$PrefixMultiplier->Add($MinValue, $MeasureMethod['Unit']); 197 221 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 198 222 $Left -= ($BoundingBox[2] - $BoundingBox[0]); … … 205 229 imagepng($Image); 206 230 imagedestroy($Image); 207 } 231 } 208 232 } 209 233 } -
trunk/Modules/TimeMeasure/Main.php
r577 r655 3 3 class PageMeasure extends Page 4 4 { 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 8 28 ( 9 29 'hour' => array( … … 22 42 'caption' => 'Měsíc', 23 43 'period' => 2592000, // 3600 * 24 * 30, 24 ), 44 ), 25 45 'year' => array( 26 46 'caption' => 'Rok', … … 32 52 ), 33 53 ); 54 } 34 55 35 56 function EditTime($Time) … … 44 65 for($I = 1; $I < 32; $I++) 45 66 { 46 if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 67 if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 47 68 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 48 69 } … … 52 73 $Output .= '<select name="Month">'; 53 74 foreach($this->Months as $Index => $Month) 54 { 75 { 55 76 if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = ''; 56 77 if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>'; … … 61 82 $Output .= '<select name="Year">'; 62 83 for($I = 2000; $I < 2010; $I++) 63 { 84 { 64 85 if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = ''; 65 86 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; … … 70 91 $Output .= '<select name="Hour">'; 71 92 for($I = 0; $I < 24; $I++) 72 { 93 { 73 94 if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = ''; 74 95 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; … … 78 99 // Minute selection 79 100 $Output .= '<select name="Minute">'; 80 for($I = 0; $I < 60; $I++) 101 for($I = 0; $I < 60; $I++) 81 102 { 82 103 if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = ''; … … 98 119 $Debug = 0; 99 120 100 foreach($this-> System->Config['Application']['DefaultVariables']as $Index => $Variable)121 foreach($this->DefaultVariables as $Index => $Variable) 101 122 { 102 123 if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable; … … 110 131 $_SESSION['TimeEnd'] = time() - 60; 111 132 $_SESSION['TimeStart'] = $_SESSION['TimeEnd'] - $this->GraphTimeRanges[$_SESSION['Period']]['period']; 112 } 113 114 $Output = ' <div class="Title">Statistiky</div>';133 } 134 135 $Output = ''; 115 136 116 137 if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = ''; … … 128 149 } 129 150 } 130 break; 151 break; 131 152 case 'SetTimeNow': 132 if(array_key_exists('Time', $_GET)) 153 if(array_key_exists('Time', $_GET)) 133 154 { 134 155 if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) … … 160 181 $Output .= '<br/>'.$this->MeasureTable(); 161 182 return($Output); 162 } 163 183 } 184 164 185 function Graph() 165 186 { 166 187 $Output = '<strong>Graf:</strong><br/>'; 167 $Output .= '<img alt="Graf" src="?M=Graph&Measure='.$_SESSION['Measure'].'&From='.$_SESSION['TimeStart'].'&To='.$_SESSION['TimeEnd'].'&Width='.$this->Config['Application']['GraphSize']['Width'].'&Height='.$this->Config['Application']['GraphSize']['Height'].'&Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['GraphSize']['Width'].'" height="'.$this->Config['Application']['GraphSize']['Height'].'"><br>'; 168 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='.$_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&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 '&From='.$_SESSION['TimeStart'].'&To='.$_SESSION['TimeEnd'].'&Width='. 190 $this->ImageWidth.'&Height='.$this->ImageHeight.'&Differential='. 191 $_SESSION['Differential']).'" width="'.$this->ImageWidth.'" height="'.$this->ImageHeight.'"><br>'; 192 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='. 193 $_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>'; 194 return($Output); 195 } 196 172 197 function MeasureTable() 173 198 { 199 $PrefixMultiplier = new PrefixMultiplier(); 174 200 $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">'; 175 201 $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>'; … … 181 207 $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure['Method']); 182 208 $MeasureMethod = $DbResult2->fetch_assoc(); 183 $StopWatchStart = $this->System->GetMicrotime();209 $StopWatchStart = GetMicrotime(); 184 210 if(array_key_exists('Debug', $_GET)) 185 211 { … … 192 218 { 193 219 $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']); 196 222 } else 197 223 { … … 199 225 $LastMeasureValue = ' '; 200 226 } 201 if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 227 if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 202 228 else $Interpolate = 'Ne'; 203 if($Measure['Info'] == '') $Measure['Info'] = ' ';204 $GenerationTime = floor(( $this->System->GetMicrotime() - $StopWatchStart) * 1000 ) / 1000;229 //if($Measure['Description'] == '') $Measure['Description'] = ' '; 230 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 205 231 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&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>'; 206 232 if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; … … 211 237 //print_r(gd_info()); 212 238 //print_r($_SESSION); 213 239 214 240 //ShowPage($Output); 215 //echo( AddPrefixMultipliers('-0.000000071112345', 'B'));241 //echo($PrefixMultiplier->Add('-0.000000071112345', 'B')); 216 242 return($Output); 217 243 } -
trunk/Modules/TimeMeasure/Measure.php
r569 r655 11 11 var $DivisionCount = 500; 12 12 var $ValueTypes = array('Min', 'Avg', 'Max'); 13 13 14 14 function Load($Id) 15 15 { … … 22 22 } else throw new Exception('Measure not found'); 23 23 } 24 24 25 25 function TimeSegment($Base, $Level) 26 26 { … … 48 48 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2'); 49 49 //echo($Database->LastQuery."\n"); 50 if($Result->num_rows == 0) 51 { 52 $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)); 50 if($Result->num_rows == 0) 51 { 52 $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)); 53 53 //echo($Database->LastQuery."\n"); 54 54 } else if($Result->num_rows == 1) … … 61 61 $NextToLastValue = $Result->fetch_assoc(); 62 62 //echo($Level.': '.$Time.' - '.MysqlDateTimeToTime($LastValue['Time']).' '.($Time - MysqlDateTimeToTime($LastValue['Time'])).' = '.$Measure['Period']."\n"); 63 if((($Time - $this->Database->MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))64 { 63 if((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0)) 64 { 65 65 echo('Too short period\n'); 66 66 } else 67 67 { 68 if(($Time - $this->Database->MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;68 if(($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1; 69 69 else $Continuity = 0; 70 70 echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n"); 71 71 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)) 72 72 { 73 $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$ Measure['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));73 $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time))); 74 74 //echo($this->Database->LastQuery."\n"); 75 75 } else … … 77 77 $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)); 78 78 } 79 } 79 } 80 80 81 81 // Update next level … … 95 95 $Values = array(); 96 96 //.'" AND Time < "'.TimeToMysqlDateTime($EndTime).'" AND Measure='.$Measure['Id'].' AND Level='.($Level - 1).' ORDER BY Time'); 97 $Result = $this->Database->select($this->Data['DataTable'], '*', '(Time > "'. $this->Database->TimeToMysqlDateTime($StartTime).'") AND (Time < "'.$this->Database->TimeToMysqlDateTime($EndTime).'") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time');97 $Result = $this->Database->select($this->Data['DataTable'], '*', '(Time > "'.TimeToMysqlDateTime($StartTime).'") AND (Time < "'.$this->Database->TimeToMysqlDateTime($EndTime).'") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time'); 98 98 while($Row = $Result->fetch_assoc()) 99 99 { 100 $Row['Time'] = $this->Database->MysqlDateTimeToTime($Row['Time']);100 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 101 101 $Values[] = $Row; 102 102 } … … 108 108 // Load subsidary values 109 109 print_r($Values); 110 $Values = array_merge($this->LoadLeftSideValue($Level - 1, $this->Data, $StartTime), $Values, $this->LoadRightSideValue($Level - 1, $EndTime)); 110 $Values = array_merge($this->LoadLeftSideValue($Level - 1, $this->Data, 111 $StartTime), $Values, $this->LoadRightSideValue($Level - 1, $EndTime)); 111 112 print_r($Values); 112 113 … … 114 115 //print_r($Point); 115 116 116 $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); 117 $this->Database->delete($this->Data['DataTable'], '(Time > "'.TimeToMysqlDateTime($StartTime). 118 '") AND (Time < "'.TimeToMysqlDateTime($EndTime).'") AND Measure='.$this->Data['Id'].' AND Level='.$Level); 117 119 $this->Data['Period'] = $TimeSegment; 118 $this->AddValue(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'], 121 'Max' => $Point['Max']), $Level, $StartTime + ($EndTime - $StartTime) / 2); 119 122 } 120 123 } … … 180 183 } 181 184 } 182 } 183 else if($ValueType == 'Min') 184 { 185 //echo($Values[$I+1]['continuity'].'=='.$Measure['ContinuityEnabled'].'<br>'); 185 } 186 else if($ValueType == 'Min') 187 { 188 //echo($Values[$I+1]['continuity'].'=='.$Measure['ContinuityEnabled'].'<br>'); 186 189 if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 187 190 { … … 201 204 $NewValue[$ValueType] = $NewValue[$ValueType]; 202 205 } 203 //if(($RightTime - $LeftTime) > 0) 204 if($this->Data['Cumulative'] == 0) 206 //if(($RightTime - $LeftTime) > 0) 207 if($this->Data['Cumulative'] == 0) 205 208 { 206 209 $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime); … … 214 217 { 215 218 // Get first and last time 216 //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n"); 219 //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n"); 217 220 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time LIMIT 1'); 218 221 if($Result->num_rows > 0) … … 229 232 } else $AbsoluteRightTime = 0; 230 233 231 if($this->Debug) 232 { 233 echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('. $this->Database->TimeToMysqlDateTime($AbsoluteLeftTime).')<br>');234 echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('. $this->Database->TimeToMysqlDateTime($AbsoluteRightTime).')<br>');234 if($this->Debug) 235 { 236 echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('.TimeToMysqlDateTime($AbsoluteLeftTime).')<br>'); 237 echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('.TimeToMysqlDateTime($AbsoluteRightTime).')<br>'); 235 238 } 236 239 return(array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime)); … … 238 241 239 242 function LoadRightSideValue($Level, $Time) 240 { 243 { 241 244 $Result = array(); 242 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'. $this->Database->TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1');245 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1'); 243 246 if($DbResult->num_rows > 0) 244 247 { 245 248 $Row = $DbResult->fetch_assoc(); 246 $Row['Time'] = $this->Database->MysqlDateTimeToTime($Row['Time']);249 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 247 250 return(array($Row)); 248 251 } else … … 251 254 //array_push($Values, array('Time' => $Time, 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 252 255 $Result[] = array('Time' => ($Time + $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0); 253 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'.$this->Database->TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 256 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'. 257 TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 254 258 if($DbResult->num_rows > 0) 255 259 { 256 260 $Row = $DbResult->fetch_assoc(); 257 array_unshift($Result, array('Time' => ( $this->Database->MysqlDateTimeToTime($Row['Time']) + 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));261 array_unshift($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) + 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 258 262 } 259 263 // if($Debug) print_r($Result); … … 266 270 $Result = array(); 267 271 //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'Time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY Time DESC LIMIT 1'."<br>\n"); 268 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'. $this->Database->TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1');272 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 269 273 if($DbResult->num_rows > 0) 270 274 { 271 275 $Row = $DbResult->fetch_assoc(); 272 $Row['Time'] = $this->Database->MysqlDateTimeToTime($Row['Time']);276 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 273 277 return(array($Row)); 274 278 } else … … 279 283 $Result[] = array('Time' => ($Time - $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0); 280 284 281 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'. $this->Database->TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1');285 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1'); 282 286 if($DbResult->num_rows > 0) 283 287 { 284 288 $Row = $DbResult->fetch_assoc(); 285 array_push($Result, array('Time' => ( $this->Database->MysqlDateTimeToTime($Row['Time']) - 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));289 array_push($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) - 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 286 290 } 287 291 // if($Debug) print_r($Result); … … 292 296 function GetValues($TimeFrom, $TimeTo, $Level) 293 297 { 294 if($this->Debug) echo('TimeFrom: '.$TimeFrom.'('. $this->Database->TimeToMysqlDateTime($TimeFrom).')<br>');295 if($this->Debug) echo('TimeTo: '.$TimeTo.'('. $this->Database->TimeToMysqlDateTime($TimeTo).')<br>');298 if($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>'); 299 if($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>'); 296 300 297 301 //$AbsoluteTime = GetTimeRange($MeasureId); 298 302 299 // if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and 303 // if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and 300 304 // ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime)) 301 305 // { 302 306 303 307 // Load values in time range 304 $Result = $this->Database->select($this->Data['DataTable'], 'Time, Min, Avg, Max, Continuity', '(Time > "'.$this->Database->TimeToMysqlDateTime($TimeFrom).'") AND (Time < "'.$this->Database->TimeToMysqlDateTime($TimeTo).'") AND (Measure='.$this->Data['Id'].') AND (Level='.$Level.') ORDER BY Time'); 308 $Result = $this->Database->select($this->Data['DataTable'], 'Time, Min, Avg, Max, Continuity', '(Time > "'. 309 TimeToMysqlDateTime($TimeFrom).'") AND (Time < "'. 310 TimeToMysqlDateTime($TimeTo).'") AND (Measure='. 311 $this->Data['Id'].') AND (Level='.$Level.') ORDER BY Time'); 305 312 // echo($Level.' '.TimeToMysqlDateTime($TimeFrom).' '.TimeToMysqlDateTime($TimeTo)); 306 313 $Values = array(); … … 311 318 // echo($III.' '.$Row['Time'].' '.memory_get_usage().','); 312 319 // $III++; 313 $Values[] = array('Time' => $this->Database->MysqlDateTimeToTime($Row['Time']), 'Min' => $Row['Min'], 'Avg' => $Row['Avg'], 'Max' => $Row['Max'], 'Continuity' => $Row['Continuity']); 320 $Values[] = array('Time' => MysqlDateTimeToTime($Row['Time']), 'Min' => $Row['Min'], 321 'Avg' => $Row['Avg'], 'Max' => $Row['Max'], 'Continuity' => $Row['Continuity']); 314 322 } 315 323 // array_pop($Values); … … 317 325 // die(); 318 326 if($this->Debug) echo('Item count: '.count($Values)); 319 327 320 328 $Points = array(); 321 329 if(count($Values) > 0) … … 385 393 while($Row = $DbResult->fetch_assoc()) 386 394 { 387 $Row['Time'] = $this->Database->MysqlDateTimeToTime($Row['Time']);395 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 388 396 $Values[] = $Row; 389 397 } … … 416 424 // Load values in time range 417 425 //array_pop($NextValues); 418 } 426 } 419 427 echo("Uroven dokoncena<br>\n"); 420 428 $DbResult = $this->Database->select($this->Data['DataTable'], 'COUNT(*)', 'Level='.$Level.' AND Measure='.$this->Data['Id']); -
trunk/Modules/TimeMeasure/TimeMeasure.php
r586 r655 17 17 $this->Dependencies = array('User'); 18 18 } 19 19 20 20 function DoInstall() 21 21 { 22 22 } 23 23 24 24 function DoUnInstall() 25 25 { … … 28 28 function DoStart() 29 29 { 30 $this->System->Pages['grafy'] = 'PageMeasure'; 30 $this->System->RegisterPage('grafy', 'PageMeasure'); 31 $this->System->RegisterPage(array('grafy', 'graf.png'), 'PageGraph'); 31 32 $this->System->FormManager->RegisterClass('Measure', array( 32 33 'Title' => 'Měření', … … 45 46 'DataTable' => array('Type' => 'String', 'Caption' => 'Tabulka měřených dat', 'Default' => 'data'), 46 47 ), 47 )); 48 )); 48 49 } 49 50
Note:
See TracChangeset
for help on using the changeset viewer.