source: trunk/Mars/datacenter/db/plotdb.php@ 14152

Last change on this file since 14152 was 9458, checked in by aparavac, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 11.6 KB
Line 
1<?php
2{
3 function GetSequencesFromDataSet($onoff)
4 {
5 include("db.php");
6 $db_id = mysql_pconnect($host, $user, $pw);
7 if ($db_id==FALSE)
8 {
9 printf("mysql_connect returned the following error: %s\n", mysql_error());
10 die("");
11 }
12 mysql_select_db($db);
13 $query="SELECT fSequenceFirst FROM DataSetSequenceMapping WHERE fDataSetNumber IN (";
14 $query .= str_replace(" ", ",", trim($_GET["Set"])) . ") AND fOnOff=" . $onoff;
15// printf("Q: %s<br>", $query);
16 $result=mysql_query($query, $db_id);
17
18 $sequences="";
19 while ($row = mysql_fetch_row($result))
20 $sequences.= $row[0] . " ";
21
22 mysql_free_result($result);
23 mysql_close($db_id);
24
25 $text="";
26 if (!empty($sequences))
27 $text.= str_replace(" ", "+", trim($sequences));
28 return $text;
29 }
30
31 function PrintDiv($host, $user, $pw, $db, $column, $tables, $num)
32 {
33 $list=GetList($host, $user, $pw, $db, $column, $tables);
34
35 if (($_GET["prim"]==$column && empty($num))
36 || ($_GET["prim"]==$column && $num==3)
37 || ($_GET["prim"]==$column && $num==4)
38 || ($_GET["prim"]==$column && $_GET["plot"]=="val" && $num==2)
39 || (empty($_GET["prim"]) && $column=="fSequenceFirst"))
40 printf("<div id='%s%s' style='display:inline'>\n", $column, $num);
41 else
42 printf("<div id='%s%s' style='display:none'>\n", $column, $num);
43
44 if ($num==2)
45 $vs="vs";
46
47 printf("<select name='%sCol%s' size='1' class='Width'>\n", $column, $num);
48 foreach($list as $column2)
49 if ($_GET[$column."Col".$num]==$column2)
50 printf("<option value='%s' selected>%s %s</option>\n", $column2, $vs, $column2);
51 else
52 printf("<option value='%s'>%s %s</option>\n", $column2, $vs, $column2);
53
54 printf("</select>\n<br>\n");
55 printf("</div>\n");
56 }
57
58 ini_set("display_errors", "On");
59 ini_set("mysql.trace_mode", "On");
60
61 echo (file_get_contents("index-header.html"));
62
63 include("plotinclude.php");
64
65 //init
66 if (empty($_GET["plot"]))
67 $_GET["plot"]="";
68 if (empty($_GET["primstart"]))
69 $_GET["primstart"]="";
70 if (empty($_GET["primstop"]))
71 $_GET["primstop"]="";
72 if (empty($_GET["prim"]))
73 $_GET["prim"]="";
74 if (empty($_GET["fSequenceFirstCol"]))
75 $_GET["fSequenceFirstCol"]="";
76 if (empty($_GET["fSequenceFirstCol2"]))
77 $_GET["fSequenceFirstCol2"]="";
78 if (empty($_GET["fSequenceFirstCol3"]))
79 $_GET["fSequenceFirstCol3"]="";
80 if (empty($_GET["fRunNumberCol"]))
81 $_GET["fRunNumberCol"]="";
82 if (empty($_GET["fRunNumberCol2"]))
83 $_GET["fRunNumberCol2"]="";
84 if (empty($_GET["fRunNumberCol3"]))
85 $_GET["fRunNumberCol3"]="";
86 if (empty($_GET["fDataSetNumberCol"]))
87 $_GET["fDataSetNumberCol"]="";
88 if (empty($_GET["fDataSetNumberCol2"]))
89 $_GET["fDataSetNumberCol2"]="";
90 if (empty($_GET["fDataSetNumberCol3"]))
91 $_GET["fDataSetNumberCol3"]="";
92 if (empty($_GET["Start"]))
93 $_GET["Start"]="";
94 if (empty($_GET["Stop"]))
95 $_GET["Stop"]="";
96 if (empty($_GET["Start2"]))
97 $_GET["Start2"]="";
98 if (empty($_GET["Stop2"]))
99 $_GET["Stop2"]="";
100 if (empty($_GET["Start3"]))
101 $_GET["Start3"]="";
102 if (empty($_GET["Stop3"]))
103 $_GET["Stop3"]="";
104 if (empty($_GET["Start4"]))
105 $_GET["Start4"]="";
106 if (empty($_GET["Stop4"]))
107 $_GET["Stop4"]="";
108 if (empty($_GET["Set"]))
109 $_GET["Set"]="";
110 if (empty($_GET["Set2"]))
111 $_GET["Set2"]="";
112 if (empty($_GET["set"]))
113 $_GET["set"]="";
114
115 if (empty($_GET["x"]))
116 $totalx=640+410+60;
117 else
118 $totalx=$_GET["x"]+410+60;
119
120 printf("<center>\n<table cellpadding='0' width='%s' border='0'>\n", $totalx);
121 printf("<tr><td align='left'>\n");
122 printf("<form style='margin-bottom:0;' action='plotdb.php' METHOD='GET'>\n");
123
124 printf("&nbsp;<input type='radio' name='plot' value='prim' onclick='hidepulldown2()' %s> vs primary &nbsp;", $_GET["plot"]=="prim" ? "checked" : "");
125 printf("&nbsp;<input type='radio' name='plot' value='val' onclick='showpulldown2()' %s> vs value <br><br>", ($_GET["plot"]=="val" || empty($_GET["plot"])) ? "checked" : "");
126
127 printf("<table>\n");
128 printf("<tr><td>\n");
129 printf("<select name='prim' size='1' class='Width'>\n");
130 foreach($prims as $primary => $column)
131 if ($_GET["prim"]==$column)
132 printf("<option onclick=\"showpulldown('%s')\" value='%s' selected>%s</option>\n", $column, $column, $primary);
133 else
134 printf("<option onclick=\"showpulldown('%s')\" value='%s'>%s</option>\n", $column, $column, $primary);
135 printf("</select>\n");
136 printf(" </td><td valign='top'>\n ");
137 printf(" from&nbsp;<input name='primstart' type='text' size='8' maxlength='8' value='%s'>", $_GET["primstart"]);
138 printf(" to&nbsp;<input name='primstop' type='text' size='8' maxlength='8' value='%s'>", $_GET["primstop"]);
139 printf("</td>\n</tr>\n");
140
141 printf("<tr><td>\n");
142 foreach($prims as $primary => $column)
143 PrintDiv($host, $user, $pw, $db, $column, $tables, "");
144 printf(" </td><td valign='top'>\n <div id='Range' style='display:inline'>\n ");
145 printf(" from&nbsp;<input name='Start' type='text' size='8' maxlength='8' value='%s'>", $_GET["Start"]);
146 printf(" to&nbsp;<input name='Stop' type='text' size='8' maxlength='8' value='%s'>\n", $_GET["Stop"]);
147 printf("</div></td>\n</tr>\n");
148
149 printf("<tr><td>\n");
150 foreach($prims as $primary => $column)
151 PrintDiv($host, $user, $pw, $db, $column, $tables, "2");
152// if ($_GET["plot"]=="val")
153 if ($_GET["plot"]=="val" || empty($_GET["plot"]))
154 printf(" </td><td valign='top'>\n <div id='Range2' style='display:inline'>\n ");
155 else
156 printf(" </td><td valign='top'>\n <div id='Range2' style='display:none'>\n ");
157 printf(" from&nbsp;<input name='Start2' type='text' size='8' maxlength='8' value='%s'>", $_GET["Start2"]);
158 printf(" to&nbsp;<input name='Stop2' type='text' size='8' maxlength='8' value='%s'>\n", $_GET["Stop2"]);
159 printf("</div></td>\n</tr>\n");
160
161 printf("<tr>\n<td colspan='2'>\nLimits</td>\n</tr>\n<tr>\n<td>\n");
162 foreach($prims as $primary => $column)
163 PrintDiv($host, $user, $pw, $db, $column, $tables, "3");
164 printf(" </td><td valign='top'>\n <div id='Range3' style='display:inline'>\n ");
165 printf(" from&nbsp;<input name='Start3' type='text' size='8' maxlength='8' value='%s'>", $_GET["Start3"]);
166 printf(" to&nbsp;<input name='Stop3' type='text' size='8' maxlength='8' value='%s'>\n", $_GET["Stop3"]);
167 printf("</div></td>\n</tr>\n");
168
169 printf("<tr>\n<td>\n");
170 foreach($prims as $primary => $column)
171 PrintDiv($host, $user, $pw, $db, $column, $tables, "4");
172 printf(" </td><td valign='top'>\n <div id='Range4' style='display:inline'>\n ");
173 printf(" from&nbsp;<input name='Start4' type='text' size='8' maxlength='8' value='%s'>", $_GET["Start4"]);
174 printf(" to&nbsp;<input name='Stop4' type='text' size='8' maxlength='8' value='%s'>\n", $_GET["Stop4"]);
175 printf("</div></td>\n</tr>\n");
176
177 printf("</table>\n");
178 printf("<br>\n");
179
180 printf("&nbsp;<input type='radio' name='set' value='sequences' onclick='showset2()' %s> sequences &nbsp;\n", $_GET["set"]=="sequences" ? "checked" : "");
181 printf("&nbsp;<input type='radio' name='set' value='datasets' onclick='hideset2()' %s> datasets <br>\n", $_GET["set"]=="datasets" ? "checked" : "");
182
183 printf("<div id='set1' style='display:inline'>Set1: <input name='Set' type='text' size='20' maxlength='150' value='%s'>\n</div>\n<br>\n", $_GET["Set"]);
184 if (empty($_GET["set"]) || $_GET["set"]=="sequences")
185 printf("<div id='set2' style='display:inline'>Set2: <input name='Set2' type='text' size='20' maxlength='100' value='%s'>\n</div>\n<br>\n", $_GET["Set2"]);
186 else
187 printf("<div id='set2' style='display:none'>Set2: <input name='Set2' type='text' size='20' maxlength='150' value='%s'>\n</div>\n<br>\n", $_GET["Set2"]);
188
189 printf("<br>\nSource&nbsp;(<A HREF=\"regexp.html\">regexp</A>)&nbsp;<input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
190 if (!empty($_GET["fSourceN"]))
191 printf("%s", $_GET["fSourceN"]);
192 printf("\">\n<br>\n");
193
194 printf("<br>\nPlot format: &nbsp; x = <select name='x' size='1'>\n");
195 $x = array( 740, 640, 540, 440);
196 foreach($x as $key => $el)
197 if ($_GET["x"]==$el || (empty($_GET["x"]) && $el==640))
198 printf("<option value='%s' selected>%s</option>\n", $el, $el);
199 else
200 printf("<option value='%s'>%s</option>\n", $el, $el);
201 printf("</select>\n ");
202
203 printf("&nbsp; y = <select name='y' size='1'>\n");
204 $y= array( 600, 500, 400, 300);
205 foreach($y as $key => $el)
206 if ($_GET["y"]==$el || (empty($_GET["y"]) && $el==400))
207 printf("<option value='%s' selected>%s</option>\n", $el, $el);
208 else
209 printf("<option value='%s'>%s</option>\n", $el, $el);
210 printf("</select>\n");
211
212 printf("<br><br><input class='Width' type='submit' value='Query Plot'> &nbsp;\n");
213 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"plotdb.php\"'><br>\n");
214
215 printf("</form>");
216 printf("</td>\n");
217
218// printf("<td align='right' width='640px' height='400px'>\n");
219 printf("<td align='right'>\n");
220 if (!empty($_GET))
221 {
222 $img="plot.php?par=hallo";
223 foreach($_GET as $var => $val)
224 {
225 if ($var=="Set2" && $_GET["set"]=="datasets")
226 continue;
227 if ($var=="Set" && $_GET["set"]=="datasets" && !empty($val))
228 {
229 $img.= "&amp;Set=" . GetSequencesFromDataSet("1");
230 $img.= "&amp;Set2=" . GetSequencesFromDataSet("2");
231 continue;
232 }
233 $img.="&amp;".$var ."=".$val;
234 }
235// printf("link: %s<br>", $img);
236 printf("<img src='%s' alt='plot'>", $img);
237 }
238 printf("</td></tr>\n");
239 printf("<tr><td colspan='2'>\n");
240 printf("<br>some remarks:\n<ul>");
241 printf("<li>For Runs plotting the whole range (i.e. without giving a range or when giving a too large range) \n");
242 printf("doesn't work with ChartDirector.</li>\n");
243 printf("<li>In Set1 and Set2 Sets can be given: <br>\n ");
244 printf("If 'sequences' is selected e.g. on sequences in Set1 (displayed in blue) and off sequences in Set2 \n");
245 printf("(diplayed in red). <br>\n ");
246 printf("If 'datasets' is selected you can enter a dataset number as Set1. The on data is displayed in blue, \n");
247 printf("the off data in red. <br>\n");
248 printf("&nbsp;&nbsp;&nbsp;Please give the numbers with space as separator (e.g. 40004 40022).<br>\n</<li>\n");
249 printf("<li>0 is not accepted in the ranges fields, please write .0 or 00</li>\n");
250 printf("<li>Be aware, that plotting timestamps, e.g. fRunStart, and strings, e.g. fComment doesn't work. </li>\n");
251 printf("</ul>\n</td>\n</tr>\n");
252
253 /*
254 printf("<tr><td colspan='2'>\n");
255 $query=GetQuery($tables, $joins, "");
256 printf("Q: %s<br>", $query);
257 if (!empty($_GET["Set"]))
258 {
259 $query=GetQuery($tables, $joins, "Set");
260 printf("Q: %s<br>", $query);
261 }
262 if (!empty($_GET["Set2"]))
263 {
264 $query=GetQuery($tables, $joins, "Set2");
265 printf("Q: %s<br>", $query);
266 }
267 printf("</td></tr>");
268 */
269
270 printf("</table>\n");
271 printf("</center>\n");
272
273 echo (file_get_contents("index-footer.html"));
274
275 ini_set("display_errors", "Off");
276 ini_set("mysql.trace_mode", "Off");
277}
278?>
Note: See TracBrowser for help on using the repository browser.