New PSU ';
print 'Back to search ';
?>
Log Off
Voltage
Low Voltage
';
print 'Wiener PSU Search
';
$sorttxt = array("location","status","firmware","type");
$sortval = array("loc_id","status","firmware","type");
$NumSort = sizeof($sortval);
print 'Enter Wiener serial. Example: "4894056" and "all" for all Wieners.
';
print 'The serial is matched to the beginning. Example: "48" prints all serials starting with 48.
';
print '';
print 'Enter date (in yymmdd format) and time (in hhmmss format). Please note the reversed date format!
';
print 'Location&status for all Wieners at that date and time will be printed (for eg., to see LV configuration during a run).
';
print '';
$sorttxt = array("IP address","outlet");
$sortval = array("ip_addr","outlet_id");
$NumSort = sizeof($sortval);
print 'LV bin search
';
print 'Enter LV bin rack and height. Example: "I27" and "11". If rack is "all" all ';
print 'bins are printed.
If only rack is given, all heights for that rack are printed.
';
print '';
print '
High Voltage
';
print 'ISEG PSU Search
';
$sorttxt = array("location","status","firmware","type");
$sortval = array("loc_id","status","firmware","type");
$NumSort = sizeof($sortval);
print 'Enter ISEG serial. Example: "71020" and "all" for all Wieners.
';
print 'The serial is matched to the beginning. Example: "4" prints all serials starting with 4.
';
print '';
}
?>
Wiener LV PSUs:';
// set up the db query:
$serreq = strtoupper(trim($_POST['serial'])); // to check for 'ALL' only
if($serreq=='ALL'){
$query = "SELECT * FROM psu ORDER BY ".$_POST['sortpar'];
} else {
$query = "SELECT * FROM psu WHERE serial LIKE '".$serreq."%' ORDER BY ".$_POST['sortpar'];
}
$result = pg_query($query) or die ("
ERROR - Couldn't execute Wiener query: ".$query);
$num = pg_num_rows($result);
print "A total of $num Wieners were found. Click on Wiener for history and to change its location and/or status.";
if($num != 0 ){
$WienerPars = array('serial','location','MAC address','firmware','status','type');
$NumPars = sizeof($WienerPars);
echo '';
echo Array_to_HTML_Table($WienerPars,$NumPars);
while ($row = pg_fetch_array($result)){
extract($row);
$lser = ''.$serial.'';
if(isset($loc_id)){
$locq = "SELECT name FROM loc WHERE loc_id=".$loc_id;
$resq = pg_query($locq) or die ("
ERROR - Couldn't execute location query: ".$locq);
$rowq = pg_fetch_array($resq); extract($rowq);
$location = $name;
} else $location = $rack_id.'-'.$height;
$CurrentWiener = array($lser,$location,$mac_addr,$firmware,$status,$typetxt[$type]);
echo Array_to_HTML_Table($CurrentWiener,$NumPars);
}
echo '
'; // close table
} else {
print "
No Wieners found.
";
}
} // print Wiener output
?>
Location&status of all Wiener LV PSUs on $tDATE at $tTIME";
echo '';
echo 'Click on Wiener for history and to change its location and/or status.';
echo '
';
$sortpar = $_POST['sortpar'];
if($sortpar=='bin') $sortpar = 'rack_id,height';
$sorting = " ORDER BY ".$sortpar;
$query = "SELECT * FROM psu".$sorting;
$result = pg_query($query) or die ("
ERROR - Couldn't execute Wiener query: ".$query);
$num = pg_num_rows($result);
if($num != 0 ){
$WienerPars = array('serial','location','status','person','from','to');
$NumPars = sizeof($WienerPars);
echo '';
echo Array_to_HTML_Table($WienerPars,$NumPars);
$NumWieners = 0;
while ($row = pg_fetch_array($result)){
extract($row);
$lser = ''.$serial.'';
$DBdate=(int)substr($begin_time,2,2).substr($begin_time,5,2).substr($begin_time,8,2);
$DBtime=(int)substr($begin_time,11,2).substr($begin_time,14,2).substr($begin_time,17,2);
if(((int)$date>=$DBdate) && ((int)$time>=$DBtime)){ // requested date&time correspond to current record
if(isset($loc_id)){
$locq = "SELECT name FROM loc WHERE loc_id=".$loc_id;
$resq = pg_query($locq) or die ("
ERROR - Couldn't execute location query: ".$locq);
$rowq = pg_fetch_array($resq); extract($rowq);
$location = $name;
} else $location = $rack_id.'-'.$height;
$CurrentWiener = array($lser,$location,$status,$person,substr($begin_time,0,19),'now');
echo Array_to_HTML_Table($CurrentWiener,$NumPars);
$NumWieners++;
} else { // search history stored in psu_old for that serial for a date&time match
$histq = "SELECT * FROM psu_old WHERE serial='".$serial."'";
$histres = pg_query($histq) or die ("
ERROR - Couldn't execute Wiener history query: ".$histq);
$histnum = pg_num_rows($histres);
if($histnum != 0 ){
while ($histrow = pg_fetch_array($histres)){
extract($histrow);
$BGdate=(int)substr($begin_time,2,2).substr($begin_time,5,2).substr($begin_time,8,2);
$BGtime=(int)substr($begin_time,11,2).substr($begin_time,14,2).substr($begin_time,17,2);
$ENDdate=(int)substr($end_time,2,2).substr($end_time,5,2).substr($end_time,8,2);
$ENDtime=(int)substr($end_time,11,2).substr($end_time,14,2).substr($end_time,17,2);
if( ((int)$date>=$BGdate) && ((int)$date<=$ENDdate) &&
((int)$time>=$BGtime) && ((int)$time<=$ENDtime) ){ // date&time correspond to history record
if(isset($loc_id)) $location = $loc_id; else $location = $rack_id.'-'.$height;
$CurrentWiener = array($lser,$location,$status,$person,substr($begin_time,0,19),substr($end_time,0,19));
echo Array_to_HTML_Table($CurrentWiener,$NumPars);
$NumWieners++;
} //
} // loop over history query
} // history query returned hits
} // try history query
} // loop over normal query
echo '
'; // close table
print "
A total of ".$NumWieners." Wieners were found.";
} else {
print "
No Wieners found.
";
}
} // print Wiener locations
?>
LV Bins:';
$sortpar = $_POST['sortpar2'];
if($sortpar=='bin') $sortpar = 'rack_id,height';
$sorting = " ORDER BY ".$sortpar;
$rackreq = strtoupper(trim($_POST['rack'])); // to check for 'ALL' only
if($_POST['height']) $htreq = trim($_POST['height']);
else $htreq = -1;
if($rackreq=='ALL'){ $query = "SELECT * FROM psu_bin".$sorting;
} else {
if($htreq==-1) $query = "SELECT * FROM psu_bin WHERE rack_id='".$rackreq."'".$sorting;
else $query = "SELECT * FROM psu_bin WHERE rack_id='".$rackreq."' AND height='".$htreq."'";
}
$result = pg_query($query) or die ("
ERROR - Couldn't execute bin query: ".$query);
$num = pg_num_rows($result);
print "A total of $num bins were found.";
if($num != 0){
$BinPars = array('bin','IP address','outlet','connections');
$NumPars = sizeof($BinPars);
echo '';
echo Array_to_HTML_Table($BinPars,$NumPars);
while($row = pg_fetch_array($result)){
extract($row);
$lrack = $rack_id."-".$height;
$connq = "SELECT * FROM psu_chan WHERE rack_id='".$rack_id."' AND height='".$height."' ORDER BY channel";
$connr = pg_query($connq) or die ("
ERROR - Couldn't execute channel query: ".$connq);
$connections = "";
while($connrow = pg_fetch_array($connr)){
extract($connrow); $connections .= $channel.":".$goesto."
";
}
$CurrentBin = array($lrack,$ip_addr,$outlet_id,$connections);
echo Array_to_HTML_Table($CurrentBin,$NumPars);
}
echo '
'; // close table
} else {
print "
No bins found.
";
}
} // print lv bins output
?>
ISEG HV PSUs:';
echo 'Click on PSU for details. You can also change its location and status.';
echo '
Note: 32-channel PSUs actually have two serial numbers (ending in 0 and 1), but since they always are operating together, we put them as one dropping the last digit. Example: 71025 stands here for both 710250 and 710251.
';
// set up the db query:
$sorting = " ORDER BY ".$_POST['sortpar3'];
$serreq = strtoupper(trim($_POST['hvser'])); // to check for 'ALL' only
if($serreq=='ALL') $query = "SELECT * FROM psuhv".$sorting;
else $query = "SELECT * FROM psuhv WHERE psuhv_id LIKE '".$serreq."%'".$sorting;
$result = pg_query($query) or die ("
ERROR - Couldn't execute ISEG query: ".$query);
$num = pg_num_rows($result);
print "
A total of $num PSUs were found.";
if($num != 0 ){
$IsegPars = array('serial','location','type (channels)','firmware','status','since');
$NumPars = sizeof($IsegPars);
echo '';
echo Array_to_HTML_Table($IsegPars,$NumPars);
while ($row = pg_fetch_array($result)){
extract($row);
$lser = ''.$psuhv_id.'';
if(isset($loc_id)){
$resq = pg_query("SELECT name FROM loc WHERE loc_id=$loc_id") or die ("
ERROR - Couldn't execute location query");
$rowq = pg_fetch_array($resq);
$location = $rowq['name'];
} else {
$resq = pg_query("SELECT trd_pos,loc_id FROM sm WHERE sm_id=$sm_id") or die ("
ERROR - Couldn't execute SM query");
$rowq = pg_fetch_array($resq); extract($rowq);
if(isset($trd_pos)) {
$location = 'SM#'.$sm_id.' (sector '.$trd_pos.')';
} else {
$resq = pg_query("SELECT name FROM loc WHERE loc_id=$loc_id") or die ("
ERROR - Couldn't execute SM location query");
$rowq = pg_fetch_array($resq); extract($rowq);
$location = 'SM#'.$sm_id.' ('.$name.')';
}
}
$ltype = $type.' ('.$numchann.')';
$CurrentIseg = array($lser,$location,$ltype,$firmware,$status,substr($begin_time,0,19));
echo Array_to_HTML_Table($CurrentIseg,$NumPars);
}
echo '
'; // close table
} else {
print "
No ISEG PSUs found.
";
}
} // print HV psu output
?>