1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?php
class RESOLUTION {
var $cfg;
function __construct($minimal = 0, &$config = false) {
global $ADEI_CACHE;
if ($minimal) {
$this->cfg = array();
if ($config) $cfg = &$config;
else $cfg = &$ADEI_CACHE;
foreach ($cfg as $res) {
if ($res['res'] < $minimal) break;
else array_push($this->cfg, $res);
}
array_push($this->cfg, array("min" => -1, "res" => 0));
} else {
if ($config) {
$this->cfg = $config;
array_push($this->cfg, array("min" => -1, "res" => 0));
} else $this->cfg = &$ADEI_CACHE;
}
}
function RAW() {
return sizeof($this->cfg) - 1;
}
function Minimal() {
return sizeof($this->cfg) - 2;
}
function Smaller($res) {
if (isset($this->cfg[$res + 1])) return $res + 1;
return false;
}
function Larger($res) {
if ($res > 0) return $res - 1;
return false;
}
function Get(INTERVAL &$ivl, $amount = 0) {
if ($amount) {
for ($res = 0; isset($this->cfg[$res]);$res++)
if ((!$this->cfg[$res]["res"])||(($ivl->window_size/$this->cfg[$res]["res"])>$amount)) {
return $res;
}
} else {
for ($res = 0; isset($this->cfg[$res]);$res++)
if ($ivl->window_size > $this->cfg[$res]["min"]) {
return $res;
}
}
/*
for ($res = 0; isset($this->cfg[$res]);$res++)
if (($ivl->window_size > $this->cfg[$res]["min"])&&((!$this->cfg[$res]["res"])||(($ivl->window_size/$this->cfg[$res]["res"])>$amount)))
return $res;
$f=fopen("/tmp/xxx3", "w");
fprintf($f, $ivl->window_size . "\n");
fprintf($f, "%i %i %i\n", $ivl->window_size, (!$this->cfg[$res-1]["res"]), (($ivl->window_size/$this->cfg[$res-1]["res"])>$amount));
fprintf($f, print_r($this->cfg[$res-1], true));
fprintf($f, print_r($ivl, true));
fclose($f);
*/
if ($ivl->window_size === false)
throw new ADEIException(translate("Empty WINDOW is requested"));
else if ($ivl->window_size <= 0)
throw new ADEIException(translate("Invalid WINDOW %s is specified", $ivl->window_start . '+' . $ivl->window_size));
else
throw new ADEIException(translate("Internal Error in module RESOLUTION"));
}
function GetWindowSize($res) {
return $this->cfg[$res]["res"];
}
}
array_push($ADEI_CACHE, array("min" => -1, "res" => 0));
?>
|