2
require_once($ADEI_ROOTDIR . "/classes/views/basehistogramview.php");
3
class COUNTView extends VIEW {
4
class COUNTView extends BASEHistogramView {
4
5
var $title = "Count Records";
6
7
function __construct(REQUEST $req = NULL, $options) {
7
8
parent::__construct($req, $options);
9
$this->max_points = $this->GetOption('max_points', 100000);
10
12
function GetOptions() {
11
$req = $this->req->CreateGroupRequest();
12
$x = $req->GetProp("view_x", false);
13
if ($x) list($x_gid, $x_id) = explode(":", $x);
14
else list($x_gid, $x_id) = array(0, 0);
16
$rdr = $req->CreateReader();
17
$group = $rdr->CreateGroup();
18
$caches = $rdr->CreateCacheSet($group, $mask);
23
foreach ($caches as $key => $cachewrap) {
24
array_push($result, array("label" => $cachewrap->GetGroupTitle(), "disabled" => 1));
25
array_push($result2, array("label" => $cachewrap->GetGroupTitle(), "disabled" => 1));
28
$list = $cachewrap->GetItemList();
29
foreach ($list as $id => $info) {
30
$title = $info['name'];
31
array_push($result, array("value" => "$gid:$id", "label" => " $title"));
32
if (($x_gid == $gid)&&($x_id != $id))
33
array_push($result2, array("value" => "$gid:$id", "label" => " $title"));
41
// array("input" => array("label" => _("Channel Combination (i.e. v1 - 2 * v2)"), "id" => "count_formula", "type" => "text", "value" => "v1")),
42
// array("xml"=>"<br/>"),
13
$chan = $this->GetDataVariants(array("x", "y"), VIEW::FORBID_MULTIPLE_GROUPS);
14
$hist = $this->GetHistOptions();
16
return array_merge(array(
44
17
array("input" => array("label" => _("x"), "id" => "x_mult", "type" => "text", "size" => "3", "value" => "1")),
45
array("select" => array("label" => _("*"), "id" => "x", "options" => $result)),
18
array("select" => array("label" => _("*"), "id" => "x", "options" => $chan[0])),
46
19
array("xml"=>"<br/>"),
47
20
array("input" => array("label" => _("y"), "id" => "y_mult", "type" => "text", "size" => "3", "value" => "1")),
48
array("select" => array("label" => _("*"), "id" => "y", "options" => $result2)),
21
array("select" => array("label" => _("*"), "id" => "y", "options" => $chan[1])),
49
22
array("xml"=>"<br/>"),
50
23
array("input" => array("label" => _("From"), "id" => "count_min", "type" => "text", size => "8", "value" => "")),
51
array("input" => array("label" => _("To"), "id" => "count_max", "type" => "text", size => "8", "value" => ""))
24
array("input" => array("label" => _("To"), "id" => "count_max", "type" => "text", size => "8", "value" => "")),
25
array("xml"=>"<br/>"),
26
array("input" => array("label" => _("Test"), "id" => "count_test", "type" => "text", "value" => "")),
27
array("xml"=>"<br/>"),
55
31
function GetView() {
58
34
$req = $this->req->CreateDataRequest();
59
$x = $req->GetProp("view_x", false);
60
$y = $req->GetProp("view_y", false);
61
35
$x_mult = $req->GetProp("view_x_mult", 1);
62
36
$y_mult = $req->GetProp("view_y_mult", 1);
63
37
$min = $req->GetProp("view_count_min", false);
64
38
$max = $req->GetProp("view_count_max", false);
39
$test = $req->GetProp("view_count_test", false);
67
throw new ADEIException(translate("Parameter view_x should be set"));
69
list($x_gid, $x_id) = explode(":", $x);
70
list($y_gid, $y_id) = explode(":", $y);
72
if ((!$y)&&($x_gid != $y_gid))
73
throw new ADEIException(translate("Both x and y should belong to the same group"));
75
$rdr = $req->CreateReader();
76
$group = $rdr->CreateGroup();
77
$caches = $rdr->CreateCacheSet($group);
78
$iv = $caches->CreateInterval($req, true);
83
foreach ($caches as $key => $cachewrap) {
92
$points = $cachewrap->GetAllPoints($iv);
93
foreach($points as $t => $v) {
97
if ($y) $vy = $v[$y_id];
100
$sum = $x_mult * $vx + $y_mult * $vy;
102
if (is_numeric($min)) {
103
if ($sum < $min) continue;
106
if (is_numeric($max)) {
107
if ($sum > $max) continue;
115
array("title"=>_("Total"), "value" => $total),
116
array("title"=>_("In Range"), "value" => $inrange),
121
return array("div" => array("xml" => "not found"));
42
$func = dsMathCreateFunction('$x,$y', $test);
45
$res = $this->GetData(array("x", "y"), NULL, VIEW::GET_RAW_DATA);
51
foreach($res['data'] as $t => $v) {
54
$sum = $x_mult * $v[0] + $y_mult * $v[1];
57
if (!$func($v[0], $v[1]))
60
if (is_numeric($min)) {
61
if ($sum < $min) continue;
64
if (is_numeric($max)) {
65
if ($sum > $max) continue;
70
array_push($data, $sum);
74
array("title"=>_("Total"), "value" => $total),
75
array("title"=>_("In Range"), "value" => $inrange),
79
$view = $this->GetHistView($data);
80
$this->MergeViewInfo($view, $info, VIEW::MERGE_START);
82
$view = array("info" => $info);
b'\\ No newline at end of file'