File indexing completed on 2024-04-06 12:23:16
0001 <?php
0002
0003
0004
0005
0006
0007
0008 require_once 'common.php';
0009 require_once 'db_functions.php';
0010 require_once 'pager_functions.php';
0011
0012 $conn = connect($_GET['location']);
0013
0014 $compact = 1 - isset($_GET['expanded']);
0015
0016 function input_errors() {
0017 $error = "";
0018
0019 foreach (array('location', 'run_type', 'run_gen_tag', 'run_select') as $input) {
0020 if (!isset($_GET[$input])) {
0021 $error = $error."<h1>ERROR: Missing input parameter '$input'.</h1>";
0022 }
0023 }
0024
0025 if ($_GET['run_select'] == 'run_range' &&
0026 (!isset($_GET['min_run']) || !isset($_GET['max_run']))) {
0027 $error = $error."<h1>ERROR: Must provide 'min_run' and 'max_run' if using 'run_range'</h1>";
0028 }
0029
0030 if ($_GET['run_select'] == 'date_range') {
0031 if ( !$_GET['min_start'] || !$_GET['max_start'] ) {
0032 $error = $error."<h1>ERROR: Must provide 'min_start' and 'max_start' if using 'date_range'</h1>";
0033 }
0034 foreach (array($_GET['min_start'], $_GET['max_start']) as $date) {
0035 if (! strptime($date, '%Y-%m-%d %H:%M:%S') ) {
0036 $error = $error."<h1>ERROR: Date '$date' is invalid. Use the format YYYY-MM-DD hh:mm:ss.</h1>";
0037 }
0038 }
0039 }
0040
0041 return $error;
0042 }
0043
0044 function draw_data_table($datatype, $run, $run_iov_id, $runtype) {
0045 echo "<table class='$datatype'>";
0046 if ($datatype == 'MON') { fill_monitoring_table($run, $run_iov_id, $runtype); }
0047 elseif ($datatype == 'DCU') { fill_dcu_table($run, $run_iov_id); }
0048 elseif ($datatype == 'BEAM') { fill_beam_table($run); }
0049 elseif ($datatype == 'LMF') { fill_laser_table($run, $run_iov_id, $runtype); }
0050 else {
0051 echo "<tr><td class='noresults'>Data type $datatype is not finished</td></tr>";
0052 }
0053 echo "</table>";
0054 }
0055
0056 function fill_monitoring_table($run, $run_iov_id, $runtype) {
0057 $monresults = fetch_mon_data($run_iov_id);
0058 $nmonrows = count($monresults['SUBRUN_NUM']);
0059
0060
0061 if ($nmonrows > 0) {
0062
0063 $monselect_headers = get_monselect_headers();
0064 echo "<tr>";
0065 echo "<th class='typehead' rowspan='", $nmonrows+1, "'>MON</th>";
0066 foreach($monselect_headers as $db_handle => $head) {
0067 echo "<th>$head</th>";
0068 }
0069 echo "<th><nobr> Tasks </nobr></th>";
0070 echo "<th>DQM Pages</th>";
0071 echo "<th>DB Plot</th>";
0072 echo "</tr>";
0073
0074 for ($i = 0; $i < $nmonrows; $i++) {
0075 echo "<tr>\n";
0076 foreach ($monselect_headers as $db_handle => $head) {
0077 echo "<td>", $monresults[$db_handle][$i], "</td>\n";
0078 }
0079 $exists_str = $monresults['DAT_EXISTS'][$i];
0080 $iov_id = $monresults['IOV_ID'][$i];
0081 $loc = $_GET['location'];
0082 $dqm_url = htmlentities(get_dqm_url($loc, $runtype, $run));
0083 $dqm_url2 = htmlentities(get_dqm_url2($loc, $runtype, $run));
0084 $list_bits = $monresults['TASK_LIST'][$i];
0085 $outcome_bits = $monresults['TASK_OUTCOME'][$i];
0086 echo "<td>", draw_tasklist($list_bits, $outcome_bits, $run, $loc, $iov_id), "</td>";
0087 echo "<td><a href='$dqm_url'>DQM</a> - <a href='$dqm_url2'>log</a></td>";
0088 echo "<td class='dbplot'>", draw_plotlink('MON', $exists_str, $run, $loc, $iov_id), "</td>";
0089 echo "</tr>\n";
0090 }
0091 } else {
0092 echo "<tr>
0093 <th class='typehead'>MON</th>
0094 <td class='noresults'>No monitoring results</td></tr>";
0095 }
0096 }
0097 function fill_laser_table($run, $run_iov_id, $runtype) {
0098 $monresults = fetch_las_data($run_iov_id);
0099 $nmonrows = count($monresults['SUBRUN_NUM']);
0100
0101
0102 if ($nmonrows > 0) {
0103
0104 $monselect_headers = get_lmfselect_headers();
0105 echo "<tr>";
0106 echo "<th class='typehead' rowspan='", $nmonrows+1, "'>LMF</th>";
0107 foreach($monselect_headers as $db_handle => $head) {
0108 echo "<th>$head</th>";
0109 }
0110 echo "<th>DB Plot</th>";
0111 echo "</tr>";
0112
0113 for ($i = 0; $i < $nmonrows; $i++) {
0114 echo "<tr>\n";
0115 foreach ($monselect_headers as $db_handle => $head) {
0116 echo "<td>", $monresults[$db_handle][$i], "</td>\n";
0117 }
0118 $exists_str = $monresults['DAT_EXISTS'][$i];
0119 $iov_id = $monresults['IOV_ID'][$i];
0120 $loc = $_GET['location'];
0121 echo "<td class='dbplot'>", draw_plotlink('LMF', $exists_str, $run, $loc, $iov_id), "</td>";
0122 echo "</tr>\n";
0123 }
0124 } else {
0125 echo "<tr>
0126 <th class='typehead'>LMF</th>
0127 <td class='noresults'>No Laser results</td></tr>";
0128 }
0129 }
0130
0131 function fill_dcu_table($run, $run_iov_id) {
0132 $dcuresults = fetch_dcu_data($run_iov_id);
0133 $ndcurows = count($dcuresults['SINCE']);
0134
0135 if ($ndcurows > 0) {
0136 $dcuselect_headers = get_dcuselect_headers();
0137 echo "<tr>";
0138 echo "<th class='typehead' rowspan='", $ndcurows+1, "'>DCU</th>";
0139 foreach($dcuselect_headers as $db_handle => $head) {
0140 echo "<th>$head</th>";
0141 }
0142 echo "<th>DB Plot</th>";
0143 echo "</tr>";
0144 for ($i = 0; $i < $ndcurows; $i++) {
0145 echo "<tr>\n";
0146 foreach ($dcuselect_headers as $db_handle => $head) {
0147 $head = $dcuresults[$db_handle][$i];
0148 echo "<td>", $head, "</td>\n";
0149 }
0150 $exists_str = $dcuresults['DAT_EXISTS'][$i];
0151 $iov_id = $dcuresults['IOV_ID'][$i];
0152 $loc = $_GET['location'];
0153 echo "<td class='dbplot'>", draw_plotlink('DCU', $exists_str, $run, $loc, $iov_id), "</td>";
0154 echo "</tr>\n";
0155 }
0156 } else {
0157 echo "<tr>
0158 <th class='typehead'>DCU</th>
0159 <td class='noresults'>No DCU results</td></tr>";
0160 }
0161 }
0162
0163 function fill_beam_table($run) {
0164 $loc = $_GET['location'];
0165 $beamresults = fetch_beam_data($run, $loc);
0166 if ($beamresults) {
0167 $nbeamrows = count($beamresults['RUN_NUM']);
0168 } else {
0169 $nbeamrows = 0;
0170 }
0171
0172 if ($nbeamrows > 0) {
0173 $beamselect_headers = get_beamselect_headers();
0174 echo "<tr>";
0175 echo "<th class='typehead' rowspan='", $nbeamrows+1, "'>BEAM</th>";
0176 foreach($beamselect_headers as $db_handle => $head) {
0177 echo "<th>$head</th>";
0178 }
0179
0180 echo "<th>Beam line data</th>";
0181
0182 echo "</tr>";
0183 for ($i = 0; $i < $nbeamrows; $i++) {
0184 echo "<tr>\n";
0185 foreach ($beamselect_headers as $db_handle => $head) {
0186 $head = $beamresults[$db_handle][$i];
0187 echo "<td>", $head, "</td>\n";
0188 }
0189
0190
0191
0192 echo "<td class='dbplot'><a href=beam.php?run_num=$run&loc=$loc>Data</td>";
0193
0194 echo "</tr>\n";
0195 }
0196 } else {
0197 echo "<tr>
0198 <th class='typehead'>BEAM</th>
0199 <td class='noresults'>No BEAM results</td></tr>";
0200 }
0201 }
0202 function draw_beamlink( $run, $loc) {
0203
0204 $url = htmlentities("beam.php?run_num=$run&loc=$loc");
0205 $target = "beam$run$loc";
0206
0207
0208 echo "<div class='ttp bc'>";
0209 echo "<a onclick=\"return popup(this, '$target', 700)\" href='$url' >Data</a>";
0210
0211
0212
0213
0214
0215 echo "</div>";
0216
0217
0218 }
0219
0220 function draw_plotlink($datatype, $exists_str, $run, $loc, $iov_id) {
0221 if ($exists_str) {
0222 $url = htmlentities("plot.php?run=$run&loc=$loc&datatype=$datatype&iov_id=$iov_id&exists_str=$exists_str");
0223 $target = "plot$datatype$iov_id";
0224
0225
0226 echo "<div class='ttp bc'>";
0227 echo "<a onclick=\"return popup(this, '$target', 700)\" href='$url' >Plot</a>";
0228 echo "<div class='rtt tt'><b>Data Available:</b><br/>";
0229 foreach (split(',', $exists_str) as $t) {
0230 echo "$t<br />";
0231 }
0232 echo "</div></div>";
0233 } else {
0234 echo "No Data Available";
0235 }
0236 }
0237
0238 $meta = "";
0239 if (isset($_GET['run_select']) && $_GET['run_select'] == 'last_100') {
0240 $meta ="<meta http-equiv='Refresh' content='300' />
0241 <meta http-equiv='Pragma' content='no-cache' />
0242 <meta http-equiv='Cache-Control' content='no-cache' />";
0243 }
0244
0245 function draw_tasklist($list_bits, $outcome_bits, $run, $loc, $iov_id) {
0246
0247 $tasks = get_task_array();
0248 $outcome = get_task_outcome($list_bits, $outcome_bits);
0249
0250 if (! $outcome) { return; }
0251
0252 foreach ($outcome as $taskcode => $result) {
0253 $status = $result ? 'good' : 'bad';
0254 $url = htmlentities("bad_channels.php?run=$run&loc=$loc&iov_id=$iov_id&taskcode=$taskcode");
0255 $target = "bad_channels$run$loc$iov_id$taskcode";
0256
0257 echo "<div class='ttp bl $status'>
0258 <a onclick=\"return popup(this, '$target', 1000)\" href='$url'>$taskcode</a>
0259 <div class='tt' style='width: 150px'>$tasks[$taskcode]</div></div>";
0260 }
0261 }
0262
0263 ?>
0264 <!DOCTYPE html
0265 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
0266 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0267 <html>
0268 <head>
0269 <title>List Runs</title>
0270 <?php echo get_stylelinks( $compact ); ?>
0271 <script type="text/javascript">
0272 <!--
0273 function popup(mylink, windowname, width)
0274 {
0275 if (! window.focus)return true;
0276 var href;
0277 if (typeof(mylink) == 'string')
0278 href=mylink;
0279 else
0280 href=mylink.href;
0281 var param = 'width='+width+',height=600,scrollbars=yes';
0282 window.open(href, windowname, param);
0283 return false;
0284 }
0285
0286 </script>
0287 <?php echo $meta ?>
0288 </head>
0289 <body>
0290
0291 <?php
0292 if ($errors = input_errors()) {
0293 echo $errors;
0294 } else {
0295 $rows_per_page = 100;
0296 $url = htmlentities($_SERVER['REQUEST_URI']);
0297 $sqlresult = build_runselect_sql($_GET);
0298 $sql = $sqlresult['sql'];
0299 $binds = $sqlresult['binds'];
0300
0301 $total_rows = count_rows($conn, $sql, $binds);
0302 $sum_events = fetch_sum_events($sqlresult);
0303
0304 if ($total_rows == 0) {
0305 echo "<h3>No results found.</h3>";
0306 } else {
0307 $total_pages = total_pages($total_rows, $rows_per_page);
0308
0309
0310 if (isset($_GET['page'])) { $page = $_GET['page']; }
0311 if ( !isset($_GET['page']) ||
0312 !preg_match('/^[0-9]+$/', $_GET['page']) ||
0313 $_GET['page'] < 1 ) {
0314 $page = 1;
0315 } else if ( $_GET['page'] > $total_pages ) {
0316 $page = $total_pages;
0317 }
0318
0319 $start_row = page_to_row($page, $rows_per_page);
0320 $stmt = & paged_result($conn, $sql, $binds, $start_row, $rows_per_page);
0321
0322 $runselect_headers = get_runselect_headers();
0323 $nruncols = count($runselect_headers);
0324
0325 $datatypes = get_datatype_array();
0326 $ndisplay = 0;
0327 foreach ($datatypes as $name => $prefix) {
0328 if (isset($_GET[$prefix])) { $ndisplay++; }
0329 }
0330
0331
0332
0333
0334 echo "<table><tr><td>";
0335
0336 echo "<h3>$total_rows runs returned - $sum_events events</h3>";
0337 echo "<h6>Showing page $page of $total_pages, $rows_per_page runs per page</h6>";
0338 echo "</td><td>";
0339
0340 foreach ($datatypes as $name => $prefix) {
0341 if (isset($_GET[$prefix])) {
0342 }
0343 }
0344 echo "</td></tr></table>";
0345
0346 draw_pager($url, $total_pages, $page, "index.php");
0347
0348
0349 echo "<table class='runs'>";
0350 if ($ndisplay == 0) {
0351 echo "<tr>";
0352 foreach ($runselect_headers as $db_handle => $head) {
0353 echo "<th>$head</th>";
0354 }
0355 echo "</tr>";
0356 }
0357
0358 while ($run = oci_fetch_assoc($stmt)) {
0359
0360 if ($ndisplay > 0) {
0361 echo "<tr>";
0362 foreach ($runselect_headers as $db_handle => $head) {
0363 echo "<th>$head</th>";
0364 }
0365 echo "</tr>";
0366 }
0367
0368
0369 echo "<tr>";
0370 foreach ($runselect_headers as $db_handle => $head) {
0371 if ($db_handle == 'RUN_NUM') {
0372 echo "<td class='run_num' rowspan='", $ndisplay+1, "'>";
0373 } else { echo "<td>"; }
0374 echo $run[$db_handle], "</td>";
0375 }
0376 echo "</tr>";
0377
0378 foreach ($datatypes as $name => $prefix) {
0379 if (isset($_GET[$prefix])) {
0380 echo "<tr><td colspan='",$nruncols-1, "'>";
0381 draw_data_table($prefix, $run['RUN_NUM'], $run['RUN_IOV_ID'], $run['RUN_TYPE']);
0382 echo "</td></tr>";
0383 }
0384 }
0385 }
0386 echo "</table>";
0387
0388 draw_pager($url, $total_pages, $page, "index.php");
0389 }
0390 }
0391 ?>
0392
0393 <pre>
0394 <?php
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404 ?>
0405 </pre>
0406
0407 </body>
0408 </html>