5
- Channel splitting is not supported in ZEUSMask, Backup, etc.
3
8
class ZEUSLogGroup extends LOGGROUP {
6
14
function __construct(array &$info, ZEUS $zeus, $flags = 0) {
7
15
parent::__construct($info, $zeus, $flags);
9
if ($this->gid === false) $this->gid = 0;
10
$this->table = "log" . $this->gid;
17
if ($this->gid === false) {
21
$this->length = 65535;
22
} elseif (preg_match("/_/", $this->gid)) {
23
$prm = preg_split("/_/", $this->gid);
24
$this->zeus_gid=$prm[0];
25
$this->length=$zeus->req->GetGroupOption("max_channels", $this, ZEUS::MAX_CHANNELS);
26
$this->offset=$prm[1] * $this->length;
28
$this->zeus_gid = $this->gid;
30
$this->length = 65535;
32
$this->table = "log" . $this->zeus_gid;
43
65
class ZEUSData implements Iterator {
49
function __construct(ZEUS $zeus, PDOStatement $stmt) {
72
function __construct(ZEUS $zeus, ZEUSLogGroup $grp, PDOStatement $stmt) {
50
73
$this->zeus = $zeus;
51
74
$this->stmt = $stmt;
77
$split = $zeus->req->GetGroupOption("split_channels", $grp, false);
78
if ($split) $this->grp = $grp;
79
else $this->grp = false;
55
82
function ParseBlob($data) {
309
343
$req_cols = "gid, name";
312
$res = $this->db->Query("SELECT $req_cols FROM groups WHERE gid=" . $grp->gid);
346
if ($grp instanceof ZEUSLogGroup)
347
$res = $this->db->Query("SELECT $req_cols FROM groups WHERE gid=" . $grp->zeus_gid);
349
$res = $this->db->Query("SELECT $req_cols FROM groups WHERE gid=" . $grp->gid);
314
351
$res = $this->db->Query("SELECT $req_cols FROM groups");
316
354
$groups = array();
317
if ($flags&REQUEST::NEED_INFO) {
318
foreach ($res as $row) {
320
$groups[$gid] = $row;
322
$ginfo = array("db_group" => $gid);
323
$grzeus = $this->CreateGroup($ginfo);
355
foreach ($res as $row) {
357
$ginfo0 = array("db_group" => $gid0);
358
$grzeus0 = $this->CreateGroup($ginfo0);
360
if ($flags&REQUEST::CONTROL) {
361
$n_groups = 1; // Splitting not supported and not neeeded
363
$split = $this->req->GetGroupOption("split_channels", $grzeus0, false);
365
$maxchan = $this->req->GetGroupOption("max_channels", $grzeus0, ZEUS::MAX_CHANNELS);
366
$size = $this->GetGroupSize($grzeus0, $flags);
367
$n_groups = $size / $maxchan;
373
for ($sgid = 0; $sgid < $n_groups; $sgid++) {
375
$gid = $gid0 . "_" . $sgid;
376
$ginfo = array("db_group" => $gid);
377
$grzeus = $this->CreateGroup($ginfo);
383
$groups[$gid] = $row;
386
$groups[$gid]['name'] .= " (channels " . ($grzeus->offset) . " - " . ($grzeus->offset + $grzeus->length - 1) . ")";
387
$groups[$gid]['gid'] = $gid;
390
if (!($flags&REQUEST::NEED_INFO)) continue;
325
392
$groups[$gid]['__internal__'] = array();
365
432
if ($flags&REQUEST::NEED_ITEMINFO) {
366
433
$groups[$gid]['items'] = $this->GetItemList($grzeus, NULL, $flags);
371
foreach ($res as $row) {
372
$groups[$row['gid']] = $row;
376
438
return $grp?$groups[$grp->gid]:$groups;
413
$resp = $this->db->Query("SELECT maskid, name, mask FROM masks WHERE gid=" . $grp->gid);
475
$resp = $this->db->Query("SELECT maskid, name, mask FROM masks WHERE gid=" . $grp->zeus_gid);
414
476
foreach ($resp as $row) {
415
477
if (!preg_match("/[\w\d]/", $row['name'])) $row['name'] = _("No name");
507
569
$items = array();
509
$resp = $this->db->Query("SELECT id FROM g2id WHERE gid=" . $grp->gid . " ORDER BY pos ASC");
571
$resp = $this->db->Query("SELECT id FROM g2id WHERE gid=" . $grp->zeus_gid . " ORDER BY pos ASC");
510
572
foreach ($resp as $row) {
511
573
array_push($bids, $row['id']);
521
583
$names = preg_split("/\r?\n/", $this->db->RecodeMessage($res['itemnames']));
522
584
for ($i = 0; $i < $res['length']; $i++, $pos++) {
523
if (!$mask->Check($pos)) continue;
585
if (($pos < $grp->offset)||($pos >= ($grp->offset + $grp->length))) continue;
586
if (!$mask->Check($pos - $grp->offset)) continue;
525
588
$items[$rpos] = array(
589
"id" => $pos - $grp->offset,
527
590
"block_name" => $this->db->RecodeMessage($res['name']),
528
591
"chan_name" => $names[$i],
529
592
"name" => $names[$i],
617
$resp = $this->db->Query("SELECT id FROM g2id WHERE gid=" . $grp->gid);
680
$resp = $this->db->Query("SELECT id FROM g2id WHERE gid=" . $grp->zeus_gid);
618
681
foreach ($resp as $row) {
619
682
array_push($bids, $row['id']);
689
755
$query = $this->db->SelectRequest($grp->table, "ts, data", $selopts);
690
756
$stmt = $this->db->Prepare($query);
692
return new ZEUSData($this, $stmt);
758
return new ZEUSData($this, $grp, $stmt);
695
761
function GetRawAlarms(LOGGROUP $grp = NULL, $from = false, $to = false, DATAFilter $filter = NULL, &$filter_data = NULL) {