Changeset 28 for stat_functions.php
- Timestamp:
- Feb 13, 2008, 1:59:20 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stat_functions.php
r16 r28 22 22 ); 23 23 24 function TruncateDigits($Value, $Digits = 4) 25 { 26 for($II = 2; $II > -1; $II--) 27 { 28 if($Value >= pow(10, $II)) 29 { 30 if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits; 31 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); 32 break; 33 } 34 } 35 return($Value); 36 } 37 24 38 function AddPrefixMultipliers($Value, $Unit, $Digits = 4) 25 39 { 26 40 global $PrefixMultipliers; 27 if($Unit == '') return($Value); 41 42 if($Unit == '') return(TruncateDigits($Value, $Digits)); 28 43 $I = 8; 29 44 if($Value > 0) $II = 1; … … 34 49 35 50 // Truncate digits count 36 for($II=2; $II > -1; $II--) 37 { 38 if($Value >= pow(10, $II)) 39 { 40 if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits; 41 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); 42 break; 43 } 44 } 51 $Value = TruncateDigits($Value, $Digits); 45 52 46 53 return($Value.' '.$PrefixMultipliers[$I][0].$Unit); … … 94 101 if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0; // non continuous 95 102 else $Measure['ContinuityEnabled'] = 2; // continuous graph 96 } else die('M ìøená velièina nenalezena');103 } else die('M��enďż˝ veliďż˝ina nenalezena'); 97 104 return($Measure); 98 105 } … … 182 189 function ComputeOneValue($LeftTime, $RightTime, $Values, $Measure, $Level) 183 190 { 184 global $ValueTypes ;191 global $ValueTypes, $Differential; 185 192 186 193 $NewValue = array('min' => +1000000000000000000, 'avg' => 0, 'max' => -1000000000000000000); … … 207 214 if($ValueType == 'avg') 208 215 { 209 if($Values[$I+1]['continuity'] == $Measure['ContinuityEnabled']) ; 210 else $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I+1]['time'] - $Values[$I]['time']) * 211 (($Values[$I+1][$ValueType] - $Values[$I][$ValueType]) / 2 + $Values[$I][$ValueType]); 216 if($Values[$I+1]['continuity'] == $Measure['ContinuityEnabled']); 217 else if($Differential == 0) 218 { 219 $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I+1]['time'] - $Values[$I]['time']) * 220 (($Values[$I+1][$ValueType] - $Values[$I][$ValueType]) / 2 + $Values[$I][$ValueType]); 221 } else { 222 $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I+1]['time'] - $Values[$I]['time']) * 223 (($Values[$I+1][$ValueType] - $Values[$I][$ValueType]) / 2); 224 } 212 225 } 213 226 else if($ValueType == 'max') … … 219 232 else 220 233 { 221 //if($Values[$I][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I][$ValueType]; 222 if($Values[$I+1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I+1][$ValueType]; 234 if($Differential == 0) 235 { 236 if($Values[$I+1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I+1][$ValueType]; 237 } else { 238 $Difference = $Values[$I+1][$ValueType] - $Values[$I][$ValueType]; 239 if($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 240 } 223 241 } 224 242 } … … 232 250 else 233 251 { 234 //if($Values[$I][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I][$ValueType]; 235 if($Values[$I+1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I+1][$ValueType]; 252 if($Differential == 0) 253 { 254 if($Values[$I+1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I+1][$ValueType]; 255 } else { 256 $Difference = $Values[$I+1][$ValueType] - $Values[$I][$ValueType]; 257 if($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 258 } 236 259 } 237 260 } … … 241 264 } 242 265 //if(($RightTime - $LeftTime) > 0) 243 if($Measure['Cumulative'] == 0) $NewValue['avg'] = $NewValue['avg'] / ($RightTime - $LeftTime); 266 if($Measure['Cumulative'] == 0) 267 { 268 $NewValue['avg'] = $NewValue['avg'] / ($RightTime - $LeftTime); 269 } 244 270 return($NewValue); 245 271 //echo($NewValue['avg'].'<br>');
Note:
See TracChangeset
for help on using the changeset viewer.