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