function __construct(READER $rdr, LOGGROUP $grp, DATAFilter $filter, &$opts = NULL) { if ($rdr instanceof CACHEReader) { $this->skip = true; } else { $this->skip = false; $this->filters = array(); foreach ($opts['extractors'] as $ext => &$items) { $config =& $opts['config'][$ext]; $filter_class = $config['filter']; ADEI::RequireClass("extractors/{$filter_class}", true); $this->filters[$ext] = array(); foreach ($items as $item => $mask) { $this->filters[$ext][$item] = new $filter_class($mask, $config); } } $this->mappings = $opts['mappings']; $mask = $filter->GetItemMask(); if ($mask && !$mask->IsFull()) { $this->check_masked = true; $this->cur_indexes = array(); $i = 0; foreach ($mask->ids as $id) { $this->cur_indexes[$id] = $i++; } } else { $this->check_masked = false; $this->cur_indexes = range(0, $rdr->GetGroupSize($grp) - 1); } if ($opts['mask'] && !$opts['mask']->IsFull()) { $this->real_indexes = array(); $i = 0; foreach ($opts['mask']->ids as $id) { $this->real_indexes[$id] = $i++; } } else { $this->real_indexes = range(0, $rdr->GetGroupSize($grp) - 1); } $this->remove = sizeof($this->cur_mask) - sizeof($this->real_mask); if ($this->remove < 0) { $this->remove = 0; } } }
<?php header('Access-Control-Allow-Origin: *'); require "../adei.php"; try { ADEI::RequireService($_GET['service']); } catch (ADEIException $ex) { $ex->logInfo(); $service_error = xml_escape($ex->getInfo()); } if ($service_error) { echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; echo "<result><Error>{$service_error}</Error></result>"; }
static function Parse($srctree, $optimize = false, $flags = 0) { global $ADEI; global $ADEI_SRCTREE_EXTRA; $elements = explode(",", preg_replace_callback("/(\\([^)]+,[^)]+\\))/", create_function('$matches', ' return preg_replace("/,/", ";", $matches[0]); '), $srctree)); $curid = false; $res = array(); $idnum = array(); $extras = array(); if (!$elements || !$elements[0]) { $elements = array(); } if ($flags & SOURCETree::EXPAND_SERVERS) { $remove_dublicates = false; $new_elements = array(); foreach ($elements as $element) { if (preg_match("/^(.*)\\(([^)]+)\\)\$/", $element, $m)) { array_push($new_elements, $element); } else { $parts = explode("__", $element, 4); if (sizeof($parts) == 1) { $req = new SERVERRequest($props = array("db_server" => $parts[0])); $list = $req->GetDatabaseList(); foreach ($list as $id => $info) { array_push($new_elements, $parts[0] . "__" . $id); } $remove_dublicates = true; } else { if (sizeof($parts) > 2 && $parts[0] == "virtual") { $extra = $parts[1]; if (!$extras[$extra]) { ADEI::RequireClass("srctree/{$ADEI_SRCTREE_EXTRA[$extra]['class']}"); $extras[$extra] = new $ADEI_SRCTREE_EXTRA[$extra]['class']($req, $ADEI_SRCTREE_EXTRA[$extra]['options']); } $parts = explode("__", $element, 3); $list = $extras[$extra]->Parse($parts[2]); foreach ($list as $item) { array_push($new_elements, $item); } $remove_dublicates = true; } else { array_push($new_elements, $element); } } } } $elements = array(); foreach ($new_elements as $element) { if (preg_match("/^(.*)\\(([^)]+)\\)\$/", $element, $m)) { array_push($elements, $element); } else { $parts = explode("__", $element, 4); if (sizeof($parts) == 2) { $req = new SOURCERequest($props = array("db_server" => $parts[0], "db_name" => $parts[1])); $list = $req->GetGroupList(); foreach ($list as $gid => $info) { array_push($elements, $parts[0] . "__" . $parts[1] . "__" . $gid); } $remove_dublicates = true; } else { array_push($elements, $element); } } } if ($remove_dublicates) { if ($optimize) { $elements = array_unique($elements); } else { $new_elements = array_unique($elements); ksort($new_elements); $elements = array_values($new_elements); } } } foreach ($elements as $element) { if (preg_match("/^(.*)\\(([^)]+)\\)\$/", $element, $m)) { $id = $m[1]; $parts = explode("__", $m[1], 3); if (sizeof($parts) < 3) { throw new ADEIException(translate("Unsupported element (%s) in the source tree", $m[1])); } $items = explode(";", $m[2]); } else { $parts = explode("__", $element, 4); if (sizeof($parts) == 1 && ($flags & SOURCETree::IGNORE_UIDS) == 0) { $item_props = $ADEI->ResolveUID($parts[0]); // Controls are not supported at the moment if ($item_props) { $parts = explode("__", SOURCETree::PropsToItem($item_props)); } else { if (($flags & SOURCETree::IGNORE_BADITEMS) == 0) { throw new ADEIException(translate("UID (%s) is not available", $parts[0])); } else { continue; } } } if (sizeof($parts) < 3) { if (($flags & SOURCETree::IGNORE_BADITEMS) == 0) { throw new ADEIException(translate("Unsupported element (%s) of source tree", $element)); } else { continue; } } $id = $parts[0] . "__" . $parts[1] . "__" . $parts[2]; if (sizeof($parts) == 4) { $items = array($parts[3]); } else { $items = false; } } if ($optimize) { $realid = $id; } else { if (strcmp($id, $curid)) { if ($idnum[$id]) { $realid = $id . "__" . ++$idnum[$id]; } else { $realid = $id; $idnum[$id] = 1; } $curid = $id; } } if (!isset($res[$realid])) { $res[$realid] = array('props' => array('db_server' => $parts[0], 'db_name' => $parts[1], 'db_group' => $parts[2]), 'items' => array()); } if ($items === false) { $res[$realid]['items'] = false; unset($res[$realid]['props']['db_mask']); } else { if (is_array($res[$realid]['items'])) { $res[$realid]['items'] = array_merge($res[$realid]['items'], $items); $res[$realid]['props']['db_mask'] = implode(",", $res[$realid]['items']); } } } return $res; }
/** * Check Mode * * This snippet checks the mode from the Projection Tab and * returns the corresponding image if the requirements are met. * * @parameter String $mode mode selected from the projection control * panel * * @return Array $res If valid, an ID that points to the image * generated. If not valid, throws error message. * */ global $READER_DB; global $TMP_PATH; $tmp_file = ADEI::GetTmpFile(); $res = array("error" => "", "id" => ""); $servername = $READER_DB["kitcube"]["host"]; $username = $READER_DB["kitcube"]["user"]; $password = $READER_DB["kitcube"]["password"]; $mode = $_GET["mode"]; $loggroup = $_GET["loggroup"]; $database = $_GET["database"]; $width = $_GET["width"]; // left and right of projection container has 5% offset $width = $width * 0.95; $width_yaxis = $width * 0.05; $height = $_GET["height"]; $start = $_GET["timestamp"] * 1000000; $frame = $_GET["frame"] * 1000000; $end = $start + $frame;
<?php global $ADEI_TIMINGS; global $EXPORT_SAMPLING_RATES; global $EXPORT_FORMATS; ADEI::RequireClass("export"); ADEI::RequireClass("draw"); header("Content-type: text/xml"); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); if ($_GET['version'] == 1) { $item_tag = "MenuItem"; $item_title = "name"; $item_image = "src"; $separator_tag = "divider"; $separator_attrs = ""; } else { $item_tag = "item"; $item_title = "text"; $item_image = "img"; $separator_tag = "item"; $separator_attrs = "type=\"separator\""; } /* echo "<?xml version='1.0' ?>"; echo "<menu maxItems=\"1\" $item_title=\"\">"; echo "<$item_tag $item_title=\"\" src=\"menu.png\" id=\"main_file\" width=\"20px\" withoutImages=\"yes\"/>"; echo "</menu>"; return; */ function ListExperiments(&$list, &$query)
<?php ADEI::RequireClass("time/unixticks"); // .NET timestamp (The number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001) class MSTICKS extends UNIXTicks { function __construct(READER $reader = NULL, $opts = 0) { if (!is_array($opts)) { $opts = array("correction" => $opts); } $opts['offset'] = 6.21355968E+17; $opts['ticks_per_second'] = 10000000; parent::__construct($reader, $opts); } }
function GetView() { global $TMP_PATH; $tmp_file = ADEI::GetTmpFile(); $im = new Imagick(); $tmp = new Imagick(); $image = new Imagick(); $final = new Imagick(); $with_axes = new Imagick(); $output = new Imagick(); $tick = new ImagickDraw(); $ceiling = new ImagickDraw(); $color = new ImagickPixel('#666666'); $background = new ImagickPixel('none'); // Transparent date_default_timezone_set('UTC'); $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "HDCP10"; $req = $this->req->CreateGroupRequest(); $req = $this->req->CreateDataRequest(); $fstart = $req->GetProp("view_pb_start", 0); $width = $req->GetProp("control_width", 800); $height = $req->GetProp("control_height", 600); $height = $height - 180; // 60px for the xaxis (50px) $start = 1367366400000000.0; // GMT: Wed, 01 May 2013 00:00:00 GMT $end = 1367452800000000.0; // GMT: Thu, 02 May 2013 00:00:00 GMT //$end = 1367539200000000; // GMT: Fri, 03 May 2013 00:00:00 GMT $current = $start; $step = 3600000000.0; try { $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); while (true) { if ($current >= $end) { break; } $start_interval = $current; $end_interval = $start_interval + $step; $sql = "SELECT img_id, image, timestamp FROM Profiles_060_WTH_STATIC_EL90_Images_Stitch_Im1_3600 WHERE timestamp >= " . $start_interval . " AND timestamp < " . $end_interval; $stmt = $conn->query($sql); $row = $stmt->fetchObject(); if ($row == false) { $im->newImage($width, $height - $height * 20 / 100, "white"); } else { if (is_null($row->image)) { $im->newImage($width, $height - $height * 20 / 100, "white"); } else { $im->readimageblob($row->image); $im->resizeImage($width, $height - $height * 20 / 100, Imagick::FILTER_LANCZOS, 1); } } #$text = date('H:s', ($current / 1000000)); #$draw = new ImagickDraw(); $tick = new ImagickDraw(); $ceiling = new ImagickDraw(); /* Font properties */ #$draw->setFont('Arial'); #$draw->setFontSize(200); #$draw->setFillColor($color); #$draw->setStrokeAntialias(true); #$draw->setTextAntialias(true); /* Get font metrics */ #$metrics = $image->queryFontMetrics($draw, $text); /* Create text */ #$draw->annotation(0, $metrics['ascender']+20, $text); $tick->setStrokeWidth(10); $tick->setStrokeColor($color); $tick->setFillColor($color); $tick->line(0, 0, 0, 20); //imageline($image, $width/2, 0, $width/2, 50, $color); $ceiling->setStrokeColor($color); $ceiling->setFillColor($color); $ceiling->line(0, 0, $width, 0); /* Create image */ $image->newImage($width, 20, $background); $image->setImageFormat('png'); #$image->drawImage($draw); $image->drawImage($tick); $image->drawImage($ceiling); $im->addImage($image); $im->resetIterator(); $tmp = $im->appendImages(true); $final->addImage($tmp); $current = $end_interval; $im->clear(); $image->clear(); $tmp->clear(); $tick->clear(); $ceiling->clear(); } } catch (PDOException $e) { //echo "Connection failed: " . $e->getMessage(); } /* Append the images into one */ $final->resetIterator(); $combined = $final->appendImages(false); /* Output the image */ $combined->setImageFormat("png"); $combined->resizeImage($width, $height - $height * 20 / 100, Imagick::FILTER_LANCZOS, 1); $draw = new ImagickDraw(); /* Font properties */ $draw->setFont('Arial'); $draw->setFontSize(12); $draw->setFillColor($color); $draw->setStrokeAntialias(true); $draw->setTextAntialias(true); $runner = $start; $axis_interval = $width / 24; $i = 0; while ($runner < $end) { $text = date('H:s', $runner / 1000000); $metrics = $image->queryFontMetrics($draw, $text); $draw->annotation($i * $axis_interval, $metrics['ascender'] + 20, $text); $runner = $runner + $step; $i++; } $xaxis = new Imagick(); $xaxis->newImage($width, 50, $background); $xaxis->setImageFormat('png'); $xaxis->drawImage($draw); $with_axes->addImage($combined); $with_axes->addImage($xaxis); $with_axes->resetIterator(); $output = $with_axes->appendImages(true); file_put_contents("{$TMP_PATH}/{$tmp_file}", $output); return array("img" => array("id" => $tmp_file, "yaxis" => "testest"), "div" => array("class" => "image-player", "xml" => "<div id='media'>" . "<div style='width:100px; margin: 0 auto;'>1367539200000000</div>" . "<div id='jet' class='colormap'></div>" . "<div class='range'><p class='lower'>-2</p><p class='upper'>2</p></div>" . "<div style='clear: both;'></div>" . "<div id='media-controls'>" . "<button id='play-pause-button' title='play' onclick='togglePlayPause();'>Play</button>" . "<button id='stop-button' title='stop' onclick='stopPlay();'>Stop</button>" . "<progress id='progress-bar' min='0' max='100' value='0' style='width:" . ($width - $width * 10 / 100) . "px'>0% played</progress>" . "</div>" . "</div>" . "<div id='timestamp1' style='display: none;' data='" . $start . "'></div>" . "<div id='timestamp2' style='display: none;' data='0'></div>")); }
function GetDateLimit($default_from = false, $default_to = false) { $date_limit = $this->Get('date_limit'); if ($date_limit) { if (is_array($date_limit)) { if (is_int($date_limit[0])) { $start_date = $date_limit[0]; } else { $start_date = ADEI::ParseDate($date_limit[0]); } if (is_int($date_limit[1])) { $end_date = $date_limit[1]; } else { $end_date = ADEI::ParseDate($date_limit[1]); } } else { if (is_int($date_limit)) { $start_date = $date_limit; } else { $start_date = ADEI::ParseDate($date_limit); } $end_date = $default_to; } } else { if (is_string($default_from)) { $start_date = ADEI::ParseDate($default_from); } else { $start_date = $default_from; } $end_date = $default_to; } return array($start_date, $end_date); }
function GetView() { global $TMP_PATH; $tmp_file = ADEI::GetTmpFile(); $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "HDCP10"; $width = 800; $height = 600; $window = "1365832800-1365854400"; $interval = explode("-", $this->window); $total_seconds = $interval[1] - $interval[0]; $start = $interval[0] * 1000000; $end = $interval[1] * 1000000; $im = new Imagick(); $draw2 = new ImagickDraw(); $draw2->setStrokeColor("#808080"); $draw2->setStrokeWidth(1); $draw2->setFontSize(72); $draw2->line(700, 240, 800, 240); $ystroke = new Imagick(); $ystroke->newImage(800, 480, "white"); $ystroke->setImageFormat("png"); $ystroke->drawImage($draw2); $im->addImage($ystroke); $draw = new ImagickDraw(); $draw->setStrokeColor("#808080"); $draw->setStrokeWidth(100); $draw->setFontSize(72); $draw->line(100, 0, 100, 480); $yaxis = new Imagick(); $yaxis->newImage(100, 480, "white"); $yaxis->setImageFormat("png"); $yaxis->drawImage($draw); $im->addImage($yaxis); try { $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT count(*) FROM Profiles_060_WTH_STATIC_EL90_Images_1 WHERE P_id = 8"; $stmt = $conn->query($sql); $row = $stmt->fetch(); $total = $row[0]; $sql = "SELECT img_id, image FROM Profiles_060_WTH_STATIC_EL90_Images_1 WHERE P_id = 8 ORDER BY img_id ASC"; $stmt = $conn->query($sql); while ($row = $stmt->fetchObject()) { if (is_null($row->image)) { $im->newImage(7, 480, "white"); continue; } $im->readimageblob($row->image); } } catch (PDOException $e) { //echo "Connection failed: " . $e->getMessage(); } /* Create new imagick object */ //$im = new Imagick(); /* create red, green and blue images */ //$im->newImage(100, 50, "red"); //$im->newImage(100, 50, "green"); //$im->newImage(100, 50, "blue"); /* Append the images into one */ $im->resetIterator(); $combined = $im->appendImages(false); /* Output the image */ $combined->setImageFormat("png"); /* Having to do alot of resizing, i needed to know the speeds of the different resize filters. This was how long it took to resize a 5906x5906 JPEG image to 1181x1181. FILTER_POINT took: 0.334532976151 seconds FILTER_BOX took: 0.777871131897 seconds FILTER_TRIANGLE took: 1.3695909977 seconds FILTER_HERMITE took: 1.35866093636 seconds FILTER_HANNING took: 4.88722896576 seconds FILTER_HAMMING took: 4.88665103912 seconds FILTER_BLACKMAN took: 4.89026689529 seconds FILTER_GAUSSIAN took: 1.93553304672 seconds FILTER_QUADRATIC took: 1.93322920799 seconds FILTER_CUBIC took: 2.58396601677 seconds FILTER_CATROM took: 2.58508896828 seconds FILTER_MITCHELL took: 2.58368492126 seconds FILTER_LANCZOS took: 3.74232912064 seconds FILTER_BESSEL took: 4.03305602074 seconds FILTER_SINC took: 4.90098690987 seconds */ $combined->resizeImage(1200, 600, Imagick::FILTER_LANCZOS, 1); #$draw3 = new ImagickDraw(); #$draw3->setStrokeColor("black"); //$draw3->setFillColor($fillColor); #$draw3->setStrokeWidth(0.1); #$draw3->setFontSize(8); #$combined->annotateImage($draw3, 0, 300, 0, "500"); file_put_contents("{$TMP_PATH}/{$tmp_file}", $combined); return array("img" => array("id" => $tmp_file)); }
function GetView() { global $TMP_PATH; $req = $this->req->CreateDataRequest(); $x = $req->GetProp("view_x", false); $y = $req->GetProp("view_y", false); if (!$x || !$y) { throw new ADEIException(translate("Parameters view_x and view_y are not set")); } list($x_gid, $x_id) = explode(":", $x); list($y_gid, $y_id) = explode(":", $y); if ($this->object) { $width = $req->GetProp($this->object . "_width", $this->min_width + 20) - 20; if ($width < $this->min_width) { $width = $this->min_width; } $height = $width - 40; //$req->GetProp($this->object . "_height", $this->min_height); } else { $width = $req->GetProp("page_width", $this->min_width + 5) - 5; $height = $req->GetProp("page_height", $this->min_height); if ($width < $this->min_width) { $width = $this->min_width; } if ($height < $this->min_height) { $height = $this->min_height; } } /* print_r($this); echo "$width $height\n"; exit;*/ $rdr = $req->CreateReader(); $group = $rdr->CreateGroup(); $caches = $rdr->CreateCacheSet($group, $mask); // $iv = new INTERVAL($req->props); $iv = $caches->CreateInterval($req, true); $window_size = $iv->GetWindowSize(); $window_start = $iv->GetWindowStart(); $window_end = $iv->GetWindowEnd(); $rescfg = array('limit' => $this->max_points, 'resolution' => $res); $gid = 0; $res = array(); foreach ($caches as $key => $cachewrap) { if ($gid != $x_gid && $gid != $y_gid) { $gid++; continue; } $resolution = $cachewrap->GetResolution(); $r = $resolution->Get($iv, $width); $size = $resolution->GetWindowSize($r); if ($size > 0 && $window_size / $size > $this->max_points) { $new_r = $resolution->Larger($r); if ($new_r !== false) { $r = $new_r; } $size = $resolution->GetWindowSize($r); } $rescfg['resolution'] = $r; $points = $cachewrap->GetIntervals($iv, $rescfg, CACHE::TRUNCATE_INTERVALS); $operation_info = $points->GetOperationInfo(); if ($gid == $x_gid) { $res_x = $size; } if ($gid == $y_gid) { $res_y = $size; } foreach ($points as $t => $v) { /* if (($t < $window_start)||(($t + $size) > $window_end)) { continue; }*/ if ($gid == $x_gid && is_numeric($v['mean' . $x_id])) { if (!is_array($res[$t])) { $res[$t] = array(); } $res[$t]['x'] = $v['mean' . $x_id]; } if ($gid == $y_gid && is_numeric($v['mean' . $y_id])) { if (!is_array($res[$t])) { $res[$t] = array(); } $res[$t]['y'] = $v['mean' . $y_id]; } } $gid++; } $x = array(); $y = array(); foreach ($res as $val) { if (isset($val['x']) && isset($val['y'])) { array_push($x, $val['x']); array_push($y, $val['y']); } } if (!$x) { throw new ADEIException(translate("No data found")); } $corr = stats_stat_correlation($x, $y); $tmp_file = ADEI::GetTmpFile(); $graph = new Graph($width, $height); if ($res_x == $res_y) { $title = "Resolution: {$res_x}"; } else { $title = "Resolution: {$res_x}, {$res_y}"; } if (!$this->object) { $title = "{$title}, " . date('c', $iv->GetWindowStart()) . " - " . date('c', $iv->GetWindowEnd()); } $graph->title->Set($title); $graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE); $graph->img->SetMargin(55, 5, 10, 20); $graph->SetScale("linlin"); $graph->xaxis->SetPos("min"); $graph->yaxis->SetPos("min"); $graph->xaxis->SetLabelFormat('%3.1e'); $graph->yaxis->SetLabelFormat('%3.1e'); $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->yaxis->HideFirstTickLabel(); $sp = new ScatterPlot($x, $y); $graph->Add($sp); /* $txt = new Text(); $txt->SetFont(FF_ARIAL,FS_BOLD,11); $txt->Set(sprintf("R = %01.2f", $corr)); $txt->SetPos(0.99,0.1,'right'); $txt->SetBox('lightyellow'); $graph->Add($txt); */ $graph->Stroke("{$TMP_PATH}/{$tmp_file}"); if ($this->object) { return array("img" => array("id" => $tmp_file), "div" => array("xml" => "<b>Correlation</b>: " . $corr . "<br/>" . "<b>From</b>: " . date('c', $iv->GetWindowStart()) . "<br/>" . "<b>To</b>: " . date('c', $iv->GetWindowEnd()) . "<br/>")); } else { return array("img" => array("id" => $tmp_file)); } }
function CreateCacheReader(CACHEDB &$cache = NULL) { if ($this->srv['virtual']) { $reader = $this->srv['reader']; try { ADEI::RequireClass("readers/{$reader}", true); } catch (ADEIException $ae) { if ($this->srv['reader']) { throw new ADEIException(translate("Unsupported data reader is configured: \"%s\"", $this->srv['reader'])); } else { throw new ADEIException(translate("The data reader is not configured")); } } if (method_exists($reader, "ConvertToCacheReader")) { $rdr = new $reader($this); $rdr->ConvertToCacheReader($cache); return $rdr; } if (method_exists($reader, "CreateCacheReader")) { $rdr = new $reader($this); return $rdr->CreateCacheReader($cache); } } return new CACHEReader($this, $cache); }
$warning = TryPlot($req, $draw, $no_data); $file = $draw->Save(); if (!$no_data) { $scale = $draw->GetScaleInfo(); } } else { $draw = $req->CreateImageHelper(); $draw->Create(); $file = $draw->Save(); $no_data = true; } break; default: if ($req->props['module']) { try { ADEI::RequireServiceClass("update", $req->props['module']); $loaded = true; } catch (ADEIException $ae) { // modules without updates are perfectly OK $loaded = false; } if ($loaded) { if (!function_exists("ADEIServiceGetUpdateInfo")) { throw new ADEIException(translate("Update code for module (%s) does not provide any suitable interface")); } $info = ADEIServiceGetUpdateInfo($req); } } } } catch (ADEIException $e) { $error = $e->getInfo();
function GetView() { global $TMP_PATH; $req = $this->req->CreateDataRequest(); $x = $req->GetProp("view_x", false); if (!$x) { throw new ADEIException(translate("Parameter view_x is not set")); } list($x_gid, $x_id) = explode(":", $x); if ($this->object) { $width = $req->GetProp($this->object . "_width", $this->min_width + 20) - 20; if ($width < $this->min_width) { $width = $this->min_width; } $height = $width - 40; //$req->GetProp($this->object . "_height", $this->min_height); } else { $width = $req->GetProp("page_width", $this->min_width + 5) - 5; $height = $req->GetProp("page_height", $this->min_height); if ($width < $this->min_width) { $width = $this->min_width; } if ($height < $this->min_height) { $height = $this->min_height; } } $rdr = $req->CreateReader(); $group = $rdr->CreateGroup(); $caches = $rdr->CreateCacheSet($group, $mask); $myreq = $this->req->CreateDataRequest(); $iv = $caches->CreateInterval($req, true); $window_size = $iv->GetWindowSize(); $window_start = $iv->GetWindowStart(); $window_end = $iv->GetWindowEnd(); $rescfg = array('limit' => $this->max_points, 'resolution' => $res); $gid = 0; $res = array(); foreach ($caches as $key => $cachewrap) { if ($gid != $x_gid) { $gid++; continue; } $resolution = $cachewrap->GetResolution(); $r = $resolution->Get($iv, $width); $size = $resolution->GetWindowSize($r); if ($size > 0 && $window_size / $size > $this->max_points) { $new_r = $resolution->Larger($r); if ($new_r !== false) { $r = $new_r; } $size = $resolution->GetWindowSize($r); } $rescfg['resolution'] = $r; $points = $cachewrap->GetIntervals($iv, $rescfg, CACHE::TRUNCATE_INTERVALS); $operation_info = $points->GetOperationInfo(); if ($gid == $x_gid) { $res_x = $size; } foreach ($points as $t => $v) { /* if (($t < $window_start)||(($t + $size) > $window_end)) { continue; }*/ if ($gid == $x_gid && is_numeric($v['mean' . $x_id])) { if (!is_array($res[$t])) { $res[$t] = array(); } $res[$t]['x'] = $v['mean' . $x_id]; $res[$t]['t'] = $t; } } $gid++; } $x = array(); $t = array(); foreach ($res as $val) { if (isset($val['x'])) { array_push($x, $val['x']); } } if (!$x) { throw new ADEIException(translate("No data found")); } $bins = $req->GetProp("view_bins", 0); if (!$bins) { $bins = ceil(sqrt(sizeof($x))); } $norm = $req->GetProp("view_hist_norm", 0); $fit = $req->GetProp("view_hist_fit", 0); $min = min($x); $max = max($x); $step = ($max - $min) / $bins; $coef = $norm ? 1 / ($step * sizeof($x)) : 1; $h = array_fill(0, $bins, 0); foreach ($x as $val) { $idx = ($val - $min) / $step; if ($idx == $bins) { $idx--; } $h[$idx] += $coef; } for ($i = 0; $i < $bins; $i++) { array_push($t, sprintf("%3.1e", $min + $i * $step)); } $tmp_file = ADEI::GetTmpFile(); $graph = new Graph($width, $height); /* $title = "Resolution: $res_x"; $graph->title->SetFont(FF_ARIAL,FS_BOLD,10); $graph->title->Set($title);*/ $graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE); $graph->img->SetMargin(55, 5, 10, 20); $graph->SetScale("textlin"); $graph->xaxis->SetPos("min"); $graph->yaxis->SetPos("min"); // $graph->xaxis->SetLabelFormat('%3.1e'); // if (abs(max($h))<9999 && (abs(min($h))>0.01)) $graph->yaxis->SetLabelFormat('%01.2f'); // else $graph->yaxis->SetLabelFormat('%3.1e'); $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); // $graph->yaxis->HideFirstTickLabel(); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD); //$graph->xaxis->title->Set($arr[0]['select']['options'][$x_idg]['label']); if ($bins > 8) { $graph->xaxis->SetTextLabelInterval(ceil($bins / 6)); } $graph->xaxis->SetTickLabels($t); $bplot = new BarPlot($h); $bplot->SetWidth(1); $graph->Add($bplot); $graph->yaxis->scale->SetGrace(14); $mean = array_sum($x) / sizeof($x); $stddev = stats_standard_deviation($x); $var = stats_variance($x); $sigma = sqrt($var); $re = 100 * $sigma / $mean; sort($x); if (sizeof($x) % 2) { $median = $x[(sizeof($x) - 1) / 2]; } else { $median = ($x[sizeof($x) / 2 - 1] + $x[sizeof($x) / 2]) / 2; } // Gaussian fitting if ($fit) { $ydata = array(); $xdata = array(); if ($norm) { $coef = 1 / sqrt(2 * pi() * $var); } else { $coef = sizeof($x) * $step / sqrt(2 * pi() * $var); } $xi2 = 0; for ($i = 0; $i <= $bins; $i++) { $offset = $i * $step; $y = $coef * exp(-pow($min + $offset - $mean, 2) / (2 * $var)); array_push($xdata, $i); array_push($ydata, $y); $xi2 += pow($y - $h[$i], 2) / $y; } $xi2 /= $bins; $lineplot = new LinePlot($ydata, $xdata); $graph->Add($lineplot); } $char_sigma = SymChar::Get('sigma', false); /* $txt = new Text(); $txt->SetFont(FF_ARIAL,FS_BOLD,10); if( $req->GetProp("view_GFit", false) == "true") $txt->Set("m=$mean\n$char_sigma=$sigma\nRE=$RE%\nx^2=$xi2");//\ns=$stdDev else $txt->Set("m=$mean\n$char_sigma=$sigma\nRE=$RE%");//\ns=$stdDev $txt->ParagraphAlign('right'); $txt->SetPos(0.96,0.1,'right'); //$txt->SetBox('white'); $graph->Add($txt); */ $graph->Stroke("{$TMP_PATH}/{$tmp_file}"); if ($this->object) { $res = array(array("img" => array("id" => $tmp_file)), array("info" => array(array("title" => _("From"), "value" => date('c', $iv->GetWindowStart())), array("title" => _("To"), "value" => date('c', $iv->GetWindowEnd())), array("title" => _("Resolution"), "value" => $res_x), array("title" => _("Bins"), "value" => $bins), array("title" => _("First Bin"), "value" => $min), array("title" => _("Last Bin"), "value" => $min + $bins * $step), array("title" => _("Mean"), "value" => $mean), array("title" => _("Median"), "value" => $median), array("title" => _("StdDev"), "value" => $stddev), array("title" => _("Sigma"), "value" => $sigma), array("title" => _("RE"), "value" => $re . "%")))); if ($fit) { array_push($res[1]["info"], array("title" => _("xi2"), "value" => $xi2)); } return $res; } else { return array("img" => array("id" => $tmp_file)); } }
<?php switch ($_GET['target']) { case 'xslt': // header("Content-type: text/xsl"); header("Content-type: text/xml"); try { $req = new REQUEST(); $xslt = $req->GetProp("xslt"); if (!$xslt) { throw new ADEIException(translate("No xslt stylesheet is specified")); } $file = ADEI::GetXSLTFile($xslt); } catch (ADEIException $ex) { $ex->logInfo(NULL, $export); echo '<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8"/> <xsl:template match="/"> <span class="error">' . $ex->getInfo() . '</span> </xsl:template> </xsl:stylesheet>'; break; } readfile($file); break; default: if (isset($_GET['target'])) { $errror = translate("Unknown get target (%s) is specified", $_GET['target']); } else { $error = translate("The get target is not specified");
protected function AppendExtractedItems(LOGGROUP $grp, MASK $mask, array &$items, $flags = 0) { if ($flags & REQUEST::SKIP_GENERATED) { return; } $exts = $this->GetGroupOption($grp, "data_extractors"); if ($exts) { $all_items = $this->GetItemList($grp, $full_mask = new MASK(), REQUEST::LIST_CUSTOM | REQUEST::SKIP_GENERATED); $nextid = 0; foreach ($all_items as &$item) { if (!$item['custom'] && $item['id'] >= $nextid) { $nextid = $item['id'] + 1; } } foreach ($exts as $ekey => $opts) { $filter_class = $opts['filter']; ADEI::RequireClass("extractors/" . strtolower($filter_class), true); if (isset($opts['item_mask'])) { if (is_array($opts['item_mask'])) { $key = $opts['item_mask']['key']; $re = $opts['item_mask']['items']; } else { $key = "id"; $re = $opts['item_mask']; } } else { $key = "id"; $re = "/./"; } if (isset($opts['output_mask'])) { if (is_array($opts['output_mask'])) { $fkey = $opts['output_mask']['key']; $fre = $opts['output_mask']['items']; } else { $fkey = "id"; $fre = $opts['output_mask']; } } else { $fkey = "id"; $fre = "/./"; } foreach ($all_items as &$item) { if (!preg_match($re, $item[$key])) { continue; } $filter_items = $filter_class::GetItemList($item, $flags); foreach ($filter_items as $eid => $fi) { if (!preg_match($fre, $fi[$fkey])) { continue; } $fi['id'] = $nextid++; if (!$mask->Check($fi['id'])) { continue; } if (isset($opts['title'])) { $fi['name'] = sprintf($opts['title'], $item['name']); } else { if (isset($fi['name'])) { $fi['name'] = sprintf($fi['name'], $item['name']); } else { $fi['name'] = "{$item['name']} {$filter_class}"; } } $fi['item_type'] = 'extract'; $fi['item_extractor'] = $opts['filter']; $fi['item_extractor_id'] = $ekey; $fi['item_dependency'] = $item['id']; $fi['extractor_item'] = $eid; foreach ($item as $ikey => $val) { $fi["item_dependency_{$ikey}"] = $val; } array_push($items, $fi); } } } } }
function GetView() { global $ADEI_ID_DELIMITER; global $TMP_PATH; $req = $this->req->CreateDataRequest(); $mapping_group = $req->GetProp("view_mapping_group", false); if (!$mapping_group) { throw new ADEIException(translate("Parameter view_mapping_group is not set")); } if ($mapping_group != "all") { list($server_db, $name_db, $group_db) = explode($ADEI_ID_DELIMITER, $mapping_group); $props_to_replace = array("db_server" => $server_db, "db_name" => $name_db, "db_group" => $group_db, "db_mask" => ""); $req = new DATARequest(array_merge($req->props, $props_to_replace)); } if ($this->object) { $width = $req->GetProp($this->object . "_width", $this->min_width + 20) - 20; if ($width < $this->min_width) { $width = $this->min_width; } $height = $width - 40; } else { $width = $req->GetProp("page_width", $this->min_width + 5) - 5; $height = $req->GetProp("page_height", $this->min_height); if ($width < $this->min_width) { $width = $this->min_width; } if ($height < $this->min_height) { $height = $this->min_height; } } $rdr = $req->CreateReader(); $group = $rdr->CreateGroup(); $caches = $rdr->CreateCacheSet($group, $mask); $myreq = $this->req->CreateDataRequest(); $iv = $caches->CreateInterval($req, true); $window_size = $iv->GetWindowSize(); $window_start = $iv->GetWindowStart(); $window_end = $iv->GetWindowEnd(); $rescfg = array('limit' => 1, 'resolution' => $res); $norm_hist_max = $req->GetProp("view_hist_norm_max", false); $norm_hist_srf = $req->GetProp("view_hist_norm_srf", false); $scale_log = $req->GetProp("view_log_scale", false); $mode_of_draw = $req->GetProp("view_draw_mode", false); $bin_from = $req->GetProp("view_bin_from", false); $bin_to = $req->GetProp("view_bin_to", false); $max_of_y = $req->GetProp("view_y_max", false); if (!$bin_from || $bin_from <= 0 || $bin_from == "false") { $bin_from = 1; } if (!isset($max_of_y) || $max_of_y < 0) { $max_of_y = 0; } $x_bin = array(); $x_bin_min = array(); $x_bin_max = array(); $x_bin_sum = array(); $x_axis_tick_labels = array(); foreach ($caches as $key => $cachewrap) { $resolution = $cachewrap->GetResolution(); if (!$bin_to || $bin_to <= 0 || $bin_to == "false") { $bin_to = $cachewrap->GetWidth(); } $bins_n = $bin_to - $bin_from + 1; $r = $resolution->Get($iv, $width); $size = $resolution->GetWindowSize($r); if ($size > 0 && $window_size / $size > $this->max_points) { $new_r = $resolution->Larger($r); if ($new_r !== false) { $r = $new_r; } $size = $resolution->GetWindowSize($r); } $rescfg['resolution'] = $r; $points = $cachewrap->GetIntervals($iv, $rescfg, CACHE::TRUNCATE_INTERVALS); $operation_info = $points->GetOperationInfo(); $res_x = $size; $sum_of_vars = 0; $sum_of_vars_min = 0; $sum_of_vars_max = 0; $number_of_events = 0; $number_of_events_min = 0; $number_of_events_max = 0; foreach ($points as $t => $v) { for ($i = $bin_from - 1; $i < $bin_to; $i++) { $bin_height = $v['mean' . $i]; if ($mode_of_draw == "hist_sum") { $bin_height *= $v['items']; } $x_bin[$i - $bin_from + 1] += $bin_height; $sum_of_vars += ($i + 1) * $bin_height; $number_of_events += $bin_height; if ($mode_of_draw == "hist_minmax") { $x_bin_min[$i - $bin_from + 1] += $v['min' . $i]; $x_bin_max[$i - $bin_from + 1] += $v['max' . $i]; } array_push($x_axis_tick_labels, sprintf("%d", $i + 1)); } } if (!$x_bin) { throw new ADEIException(translate("No data found")); } $mean = $sum_of_vars / $number_of_events; $var_std = 0; $var_sum = 0; $var_bin = 0; $half_number_of_events = $number_of_events / 2; for ($i = $bin_from; $i <= $bin_to; $i++) { $var_std += ($i - $mean) * ($i - $mean) * $x_bin[$i - $bin_from]; if ($var_sum < $half_number_of_events) { $var_sum += $x_bin[$i - $bin_from]; $var_bin = $i - $bin_from; } } $stddev = sqrt($var_std / $number_of_events); $median = $var_bin + ($half_number_of_events - $var_sum + $x_bin[$var_bin + 1]) / $x_bin[$var_bin + 1]; } $tmp_file = ADEI::GetTmpFile(); $graph = new Graph($width, $height); $graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE); $graph->img->SetMargin(55, 5, 10, 20); if (!$scale_log) { $graph->SetScale("textlin", 0, $max_of_y); } else { if (min($x_bin) >= 0) { $graph->SetScale("textlog"); } else { throw new ADEIException(translate("The selected data contains negative values which can't be visualized on the log scale")); } } $graph->xaxis->SetPos("min"); $graph->yaxis->SetPos("min"); $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD); if ($bins_n > 16) { $graph->xaxis->SetTextLabelInterval(ceil($bins_n / ceil($width / 25))); } $graph->xaxis->SetTickLabels($x_axis_tick_labels); $bplot = new BarPlot($x_bin); $bplot->SetWidth(1); if ($mode_of_draw == "hist_sum") { $bplot->SetLegend("Sum Mode"); } else { $bplot->SetLegend("AVG Mode"); } if ($mode_of_draw == "hist_minmax") { $bplot_min = new BarPlot($x_bin_min); $bplot_min->SetWidth(1); $bplot_min->SetLegend("Minimum"); $bplot_min->SetFillColor('deepskyblue'); $bplot_max = new BarPlot($x_bin_max); $bplot_max->SetWidth(1); $bplot_max->SetLegend("Maximum"); $bplot_max->SetFillColor('indianred1'); } if ($mode_of_draw == "hist_minmax") { $graph->Add($bplot_max); } $graph->Add($bplot); if ($mode_of_draw == "hist_minmax") { $graph->Add($bplot_min); } $graph->yaxis->scale->SetGrace(14); $graph->Stroke("{$TMP_PATH}/{$tmp_file}"); if ($this->object) { $res = array(array("img" => array("id" => $tmp_file)), array("info" => array(array("title" => _("Number of Bins"), "value" => round($bins_n, 3)), array("title" => _("Mode"), "value" => array_search(max($x_bin), $x_bin) + $bin_from), array("title" => _("Mean"), "value" => round($mean, 3)), array("title" => _("Median"), "value" => round($median, 3)), array("title" => _("Value of Mode"), "value" => round(max($x_bin), 3)), array("title" => _("Integral of Hist"), "value" => round($number_of_events, 3)), array("title" => _("StdDev"), "value" => round($stddev, 3)), array("title" => _("RE"), "value" => round($stddev / $mean * 100 . "%", 3) . "%"), array("title" => _("From"), "value" => date('c', $iv->GetWindowStart())), array("title" => _("To"), "value" => date('c', $iv->GetWindowEnd())), array("title" => _("Resolution"), "value" => round($res_x, 3))))); return $res; } else { return array("img" => array("id" => $tmp_file)); } }