source: trunk/xgraph/xfel8.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 5.6 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_line.php');
4require_once ('jpgraph/jpgraph_date.php');
5require_once ('jpgraph/jpgraph_mgraph.php');
6
7//echo "la periode demandee est " , $_POST['period'];
8if (!strcmp($_POST['period'],"1H"))
9     $rapport=100;
10elseif (!strcmp($_POST['period'],"10H"))
11     $rapport=10;
12elseif (!strcmp($_POST['period'],"20H"))
13     $rapport=5;
14elseif (!strcmp($_POST['period'],"50H"))
15     $rapport=2;
16elseif (!strcmp($_POST['period'],"100H"))
17     $rapport=1;
18else
19     $rapport=100;
20//echo "la periode demandee est " , $rapport;
21
22
23DEFINE('NDATAPOINTS',28000);
24DEFINE('SAMPLERATE',300);
25
26$start = time();
27$end = $start+(NDATAPOINTS/$rapport)*SAMPLERATE;
28$xdata = array();
29
30//read simulation data file
31$arrayTime = array();
32$arrayValue = array();
33$i = 0;
34$handle = fopen ("egiga.txt","r");
35while (!feof($handle)){
36  $fileinfo = fscanf ($handle,"%s %s\t%E\n");
37  if ($fileinfo) {
38    list($date,$time,$value)=$fileinfo;
39    //echo $date . " " . $time . " " . $value . "\n";
40    $arrayValue[$i] = $value;
41    $arrayTime[$i] = $time;
42    //echo $date, " ", $time, " ",$arrayValue[$i],"\n";
43    ++$i;
44  }
45  $fileinfo=NULL;
46}
47fclose ($handle);
48
49
50$data_temperature[0] = rand(20,30);
51$data_vacuum[0] = rand(100,200);
52$data_power[0] = rand(10,30);
53
54for( $i=0; $i < (NDATAPOINTS/$rapport)-1; ++$i ) {
55    $data_temperature[$i+1] = $data_temperature[$i] + rand(-4,4);
56    if($data_temperature[$i+1] < 10 || $data_temperature[$i+1] > 59)
57        $data_temperature[$i+1] = 47;
58
59    //$data_vacuum[$i+1] = $data_vacuum[$i] + rand(-2,2);
60    //if($data_vacuum[$i+1] < 0 )
61    // $data_vacuum[$i+1] = 0;
62    $data_vacuum[$i+1] = $arrayValue[$i]*(1E+9);
63 
64    $data_power[$i+1] = $data_power[$i] + rand(-1.5,1.5);
65
66    //$xdata[$i] = $start + $i * SAMPLERATE;
67    $xdata[$i] = $arrayTime[$i];
68    //    echo $data_vacuum[$i], " ", $xdata[$i], "\n";
69}
70$xdata[$i] = $start + $i * SAMPLERATE;
71
72//DEFINE('BKG_COLOR','lightgray:1.7');
73DEFINE('BKG_COLOR','green:1.98');
74DEFINE('WIND_HEIGHT',800);
75DEFINE('WIND_WIDTH',250);
76
77
78//------------------------------------------------------------------
79// Setup the Temperature graph
80//------------------------------------------------------------------
81$graph = new Graph(WIND_WIDTH,WIND_HEIGHT);
82$graph->SetMarginColor(BKG_COLOR);
83$graph->SetScale('datlin',0,60);
84$graph->Set90AndMargin(50,10,70,30);
85$graph->SetFrame(true,'white',0);
86$graph->SetBox();
87
88$graph->title->Set('Temperature');
89$graph->title->SetColor('red');
90$graph->title->SetFont(FF_FONT1,FS_BOLD,48);
91$graph->title->SetMargin(5);
92
93$graph->xaxis->SetFont(FF_FONT0,FS_NORMAL,9);
94
95//$graph->xaxis->scale->SetDateFormat('H:i');
96$graph->xaxis->SetTickLabels($xdata);
97
98$graph->xgrid->Show();
99
100$graph->yaxis->SetLabelAngle(90);
101$graph->yaxis->SetColor('red');
102$graph->yaxis->SetFont(FF_FONT0,FS_NORMAL,9);
103$graph->yaxis->SetLabelMargin(0);
104$graph->yaxis->scale->SetAutoMin(10);
105
106//$line = new LinePlot($data_temperature,$xdata);
107$line = new LinePlot($data_temperature);
108$line->SetStepStyle();
109$line->SetColor('red');
110
111$graph->AddLine($line);
112
113//$graph->Add($line);
114
115//------------------------------------------------------------------
116// Setup the Vacuum graph
117//------------------------------------------------------------------
118$graph2 = new Graph(WIND_WIDTH-30,WIND_HEIGHT);
119//$graph2->SetScale('datlin');
120$graph2->SetScale('datlin',+3,+8);
121$graph2->Set90AndMargin(5,20,70,30);
122$graph2->SetMarginColor(BKG_COLOR);
123$graph2->SetFrame(true,'white',0);
124$graph2->SetBox();
125
126$graph2->title->Set('Vacuum');
127$graph2->title->SetColor('blue');
128$graph2->title->SetFont(FF_FONT1,FS_BOLD,48);
129$graph2->title->SetMargin(5);
130
131$graph2->xaxis->HideLabels();
132$graph2->xgrid->Show();
133
134$graph2->yaxis->SetLabelAngle(90);
135$graph2->yaxis->SetColor('blue');
136$graph2->yaxis->SetFont(FF_FONT0,FS_NORMAL,9);
137$graph2->yaxis->SetLabelMargin(0);
138//$graph2->yaxis->scale->SetAutoMin(50);
139
140//$line2 = new LinePlot($data_vacuum,$xdata);
141$line2 = new LinePlot($data_vacuum);
142$line2->SetStepStyle();
143$line2->SetColor('blue');
144
145$graph2->AddLine($line2);
146
147//$graph2->Add($line2);
148
149//------------------------------------------------------------------
150// Setup the power graph
151//------------------------------------------------------------------
152$graph3 = new Graph(WIND_WIDTH-30,WIND_HEIGHT);
153$graph3->SetScale('datlin');
154$graph3->Set90AndMargin(5,20,70,30);
155$graph3->SetMarginColor(BKG_COLOR);
156$graph3->SetFrame(true,'white',0);
157$graph3->SetBox();
158
159$graph3->title->Set('RF Power');
160$graph3->title->SetColor('black');
161$graph3->title->SetFont(FF_FONT1,FS_BOLD,48);
162$graph3->title->SetMargin(5);
163
164$graph3->xaxis->HideLabels();
165$graph3->xgrid->Show();
166
167$graph3->yaxis->SetLabelAngle(90);
168$graph3->yaxis->SetColor('black');
169$graph3->yaxis->SetFont(FF_FONT0,FS_NORMAL,9);
170$graph3->yaxis->SetLabelMargin(0);
171$graph3->yaxis->scale->SetAutoMin(-10);
172
173//$line3 = new LinePlot($data_power,$xdata);
174$line3 = new LinePlot($data_power);
175$line3->SetStepStyle();
176$line3->SetColor('black');
177
178$graph3->AddLine($line3);
179
180//$graph3->Add($line3);
181
182//-----------------------
183// Create a multigraph
184//----------------------
185$mgraph = new MGraph();
186$mgraph->SetMargin(2,2,2,2);
187$mgraph->SetFrame(true,'darkgray',2);
188$mgraph->SetFillColor(BKG_COLOR);
189$mgraph->Add($graph,0,50);
190$mgraph->Add($graph2,250,50);
191$mgraph->Add($graph3,460,50);
192$mgraph->title->Set('XFEL Stand A August 2013');
193$mgraph->title->SetFont(FF_FONT2,FS_BOLD,80);
194$mgraph->title->SetMargin(8);
195$mgraph->Stroke();
196
197
198?>
Note: See TracBrowser for help on using the repository browser.