format("Y,n-1,j,G,i,s,0").")"; //return "new Date(".($d->getTimestamp()*1000).")";//format("Y,n-1,j,G,i,s,0").")"; } // ==================================================================== function QuerySchedule(&$data, &$html1, &$html2, &$query, $db_id, $table, $date) { $query = <<\n"; $html1 .= " ".$row["fMeasurementTypeName"]."\n"; $html1 .= " |".$row["fSourceName"]."\n"; $html1 .= " [".$row["fUser"]."]\n"; $html1 .= " \n"; $array[$n++] = $row; } $html1 .= "\n"; mysql_free_result($result); } else $html1 = "[empty:".mysql_error()."]\n"; // -------------------------------------------------------------------- $html2 = "\n"; $suspend = false; $prev_data = array(); for ($i=0; $i<$n-1; $i++) { // Switch to "suspend-mode" if ($array[$i]['fMeasurementTypeName']=='Suspend') $suspend = true; // If a resume is found, the data is replaced with the // last data run with the resume-time as start time. if ($array[$i]['fMeasurementTypeName']=='Resume') { // Sanity check: There is not much we can do if (empty($prev_data) || !$suspend) continue; $prev_data['fStart'] = $array[$i]['fStart']; $array[$i] = $prev_data; $suspend = false; } // None data runs are not displayed if ($array[$i]['fMeasurementTypeName']!='Data') continue; // If this is a data run keep that for use after a suspend/resume $prev_data = $array[$i]; // If the system is suspended, don't display the runs if ($suspend) continue; $data .= "["; $data .= "'".$table."',"; $data .= "'".$array[$i]['fSourceName']."',"; $data .= fmt($array[$i]['fStart']).","; // in case two resumes are scheduled without suspend inbetween, the stop of a later observations needs to be used if ($array[$i+1]['fMeasurementTypeName']=='Resume' && !$suspend) $data .= fmt($array[$i+2]['fStart']).","; else $data .= fmt($array[$i+1]['fStart']).","; $data .= "],\n"; $html2 .= " "; $html2 .= " \n"; $html2 .= " \n"; // in case two resumes are scheduled without suspend inbetween, the stop of a later observations needs to be used if ($array[$i+1]['fMeasurementTypeName']=='Resume' && !$suspend) $html2 .= " \n"; else $html2 .= " \n"; $html2 .= " \n"; } $html2 .= "
".$array[$i]['fStart']."|".$array[$i]["fSourceName"]."|".$array[$i+2]["fStart"]."||".$array[$i+1]["fStart"]."|
\n"; } // -------------------------------------------------------------------- function QueryRunInfo(&$data, &$diff, &$html2, &$query2, $night, $db_id, $where) { $query2 = <<< EOT SELECT fRunID, fSourceName, fRunStart, fRunStop FROM RunInfo LEFT JOIN Source USING(fSourceKey) LEFT JOIN AnalysisResultsRunLP USING (fNight, fRunID) WHERE fNight=$night AND NOT fRunStart='0000-00-00 00:00:00' AND NOT fRunStop='0000-00-00 00:00:00' AND fRunTypeKEY=1 $where ORDER BY fRunID EOT; // -------------------------------------------------------------------- $array2 = array(); $result2 = mysql_query($query2, $db_id); if ($result2) { $html2 .= "\n"; $n = 0; while ($row = mysql_fetch_assoc($result2)) { if (empty($row['fSourceName'])) continue; $data .= "["; $data .= "'RunInfo',"; $data .= "'".$row['fSourceName']."',"; $data .= fmt($row['fRunStart']).","; $data .= fmt($row['fRunStop']).","; $data .= "],\n"; $html2 .= " \n"; $html2 .= " \n"; $html2 .= " \n"; $html2 .= " \n"; $html2 .= " \n"; $diff .= $row["fRunStart"]." | "; $diff .= $row["fSourceName"]." | "; $diff .= $row["fRunStop"]."\n"; $n++; } $html2 .= "
".$row["fRunStart"]." | ".$row["fSourceName"]." | ".$row["fRunStop"]."
\n"; mysql_free_result($result2); } else $html2 = "[empty:".mysql_error()."]\n"; } // -------------------------------------------------------------------- QuerySchedule($data, $html0a, $html0b, $query0, $db_id, "AutoSchedule", $date); QuerySchedule($data, $html1a, $html1b, $query1, $db_id, "Schedule", $date); // -------------------------------------------------------------------- QueryRunInfo($dataA, $diffA, $html2, $query2, $night, $db_id, ""); QueryRunInfo($dataB, $diffB, $html3, $query3, $night, $db_id, "AND NOT ISNULL(fNumExcEvts)"); $data .= $dataA; $diff = ""; if ($dataA!=$dataB) { $diff = Diff::toTable(Diff::compare($diffA, $diffB)); $data .= str_replace("RunInfo", "QLA", $dataB); } // -------------------------------------------------------------------- mysql_close($db_id); // -------------------------------------------------------------------- $color = "false"; if (empty($data)) { $data = "['No Schedule','',new Date(1970,1,1,19,0,0),new Date(1970,1,2,7,0,0)]"; $color = "'#eee'"; } $querycol0 = colorize($query0); $querycol1 = colorize($query1); $querycol2 = colorize($query2); $querycol3 = colorize($query3); // -------------------------------------------------------------------- echo <<

Date:

Preparing chart... please stand by.










EOT; ?>