/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to docs/samples/draw.php

  • Committer: Suren A. Chilingaryan
  • Date: 2014-10-17 14:09:35 UTC
  • Revision ID: csa@suren.me-20141017140935-aous739tn3noirae
Added samples of PHP API to documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
require("../adei.php");
 
3
 
 
4
header("Content-type: application/json");
 
5
header("Cache-Control: no-cache, must-revalidate");
 
6
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 
7
 
 
8
 
 
9
$_POST['props'] = "{\"db_server\": \"autogen\", \"db_name\": \"minutely\", \"db_group\": \"default\", \"db_mask\": \"6\", \"experiment\": \"0-0\", \"window\": \"1104537600-1262304000,-2:2\", \"width\": 1024, \"height\": 768, \"hide_axes\": 0, \"show_gaps\": \"POINTS\"}";
 
10
 
 
11
try {
 
12
    $req = new REQUEST();
 
13
    if ($req->CheckData()) {
 
14
        $req = $req->CreateDataRequest();
 
15
 
 
16
        
 
17
        $time[1] = gettimeofday(true);
 
18
        $draw = $req->CreatePlotter();
 
19
//      print_r($draw->cache->req);
 
20
        $time[2] = gettimeofday(true);
 
21
        $draw->Create();
 
22
        $time[3] = gettimeofday(true);
 
23
        $file = $draw->Save();
 
24
        $time[4] = gettimeofday(true);
 
25
        $scale = $draw->GetScaleInfo();
 
26
        $time[5] = gettimeofday(true);
 
27
 
 
28
        foreach ($time as $i => $tm) {
 
29
            echo $tm . " - " . $i . "\n";
 
30
        }
 
31
        echo "Main computations: " . ($time[4] - $time[3]) . "\n";
 
32
 
 
33
        echo time() . " - 3\n";
 
34
        echo time() . " - Starting\n";
 
35
    }
 
36
} catch(ADEIException $e) {
 
37
    $error = $e->getMessage();
 
38
}
 
39
 
 
40
if ($error) {
 
41
    echo json_encode(array("error" => $error));
 
42
} else {
 
43
    if ($draw) {
 
44
        echo json_encode(array_merge(array(
 
45
            "error" => 0,
 
46
            "module" => "graph",
 
47
            "draw" => 1,
 
48
            "image" => $file
 
49
        ), $scale));
 
50
    } else {
 
51
        echo json_encode(array("error" => 0));
 
52
    }
 
53
}
 
54
 
 
55
 
 
56
?>
 
 
b'\\ No newline at end of file'