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