Changeset 655 for trunk/Modules/TimeMeasure/Main.php
- Timestamp:
- May 11, 2014, 4:28:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.