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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<?php
class COUNTView extends VIEW {
var $title = "Count Records";
function __construct(REQUEST $req = NULL, $options) {
parent::__construct($req, $options);
}
function GetOptions() {
$req = $this->req->CreateGroupRequest();
$x = $req->GetProp("view_x", false);
if ($x) list($x_gid, $x_id) = explode(":", $x);
else list($x_gid, $x_id) = array(0, 0);
$rdr = $req->CreateReader();
$group = $rdr->CreateGroup();
$caches = $rdr->CreateCacheSet($group, $mask);
$gid = 0;
$result = array();
$result2 = array();
foreach ($caches as $key => $cachewrap) {
array_push($result, array("label" => $cachewrap->GetGroupTitle(), "disabled" => 1));
array_push($result2, array("label" => $cachewrap->GetGroupTitle(), "disabled" => 1));
$id = 0;
$list = $cachewrap->GetItemList();
foreach ($list as $id => $info) {
$title = $info['name'];
array_push($result, array("value" => "$gid:$id", "label" => " $title"));
if (($x_gid == $gid)&&($x_id != $id))
array_push($result2, array("value" => "$gid:$id", "label" => " $title"));
$id++;
}
$gid++;
}
return array(
// array("input" => array("label" => _("Channel Combination (i.e. v1 - 2 * v2)"), "id" => "count_formula", "type" => "text", "value" => "v1")),
// array("xml"=>"<br/>"),
array("input" => array("label" => _("x"), "id" => "x_mult", "type" => "text", "size" => "3", "value" => "1")),
array("select" => array("label" => _("*"), "id" => "x", "options" => $result)),
array("xml"=>"<br/>"),
array("input" => array("label" => _("y"), "id" => "y_mult", "type" => "text", "size" => "3", "value" => "1")),
array("select" => array("label" => _("*"), "id" => "y", "options" => $result2)),
array("xml"=>"<br/>"),
array("input" => array("label" => _("From"), "id" => "count_min", "type" => "text", size => "8", "value" => "0")),
array("input" => array("label" => _("To"), "id" => "count_max", "type" => "text", size => "8", "value" => "0"))
);
}
function GetView() {
global $TMP_PATH;
$req = $this->req->CreateDataRequest();
$x = $req->GetProp("view_x", false);
$y = $req->GetProp("view_y", false);
$x_mult = $req->GetProp("view_x_mult", 1);
$y_mult = $req->GetProp("view_y_mult", 1);
$min = $req->GetProp("view_count_min", false);
$max = $req->GetProp("view_count_max", false);
if (!$x)
throw new ADEIException(translate("Parameter view_x should be set"));
list($x_gid, $x_id) = explode(":", $x);
list($y_gid, $y_id) = explode(":", $y);
if ((!$y)&&($x_gid != $y_gid))
throw new ADEIException(translate("Both x and y should belong to the same group"));
$rdr = $req->CreateReader();
$group = $rdr->CreateGroup();
$caches = $rdr->CreateCacheSet($group);
$iv = $caches->CreateInterval($req, true);
$gid = 0;
foreach ($caches as $key => $cachewrap) {
if ($gid != $x_gid) {
$gid++;
continue;
}
$total = 0;
$inrange = 0;
$points = $cachewrap->GetAllPoints($iv);
foreach($points as $t => $v) {
$total++;
$vx = $v['mean'.$x_id];
if ($y) $vy = $v['mean'.$y_id];
else $vy = 0;
$sum = $x_mult * $vx + $y_mult * $vy;
if ($min !== false) {
if ($sum < $min) continue;
}
if ($max !== false) {
if ($sum > $max) continue;
}
$inrange++;
}
return array(
"info" => array(
array("title"=>_("Total"), "value" => $total),
array("title"=>_("In Range"), "value" => $inrange),
)
);
}
return array("div" => array("xml" => "not found"));
}
};
?>
|