<%@ LANGUAGE="VBScript" %> <% Const maxc=100 If Request("run_type")="" Then Run_type="" Else Run_type=CStr(Request("run_type")) End If If Request("run_min")="" Then Run_min=0 Else Run_min= CLng(Request("run_min")) End If If Request("run_max")="" Then Run_max=9999999 Else Run_max= CLng(Request("run_max")) End If ' response.write(Run_type) time_start=Now() ' ' Check if people registered for shift/logbook writing ' registered=0 ' ' you can only registered if you are at BNL ' If cloc="CH" Then Response.Cookies("CTEST")="cookieset" If Request.Cookies("PHOBOSPORTAL").HasKeys Then strCookie1=Request.Cookies("PHOBOSPORTAL")("OPERATOR1") If Not (IsNull(strCookie1) OR ( Len(strCookie1) = 0)) Then registered=1 End If End if End If Set Connection = Server.CreateObject("ADODB.Connection") Connection.Mode = adModeRead Connection.Open phdb_rd_repl SQLStmtx = "select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS') rddate,to_char(sysdate,'HH24:MI:SS') ttime,global_name from global_name " ' response.write(SQLStmtx & "
" ) Set RSx = Connection.Execute(SQLStmtx) If Not RSx.EOF Then select case CStr(RSx("global_name")) case "PHDB.WORLD" dbname="" case "ORACLE.WORLD" dbname="" case "KRPHOBOS.WORLD" dbname="(KR)" case "ROCHESTER.WORLD" dbname="(ROC)" end select Else dbname="Undefined Database" End If If Request("nruns")<>"" Then SQLStmt0 = "select max(RUN) maxrun from phoffline.runs " ' response.write(SQLStmt0 & "
" ) Set RS0 = Connection.Execute(SQLStmt0) run_min=CLng(RS0("maxrun"))-CLng(Request("nruns"))+1 run_max=9999999 If run_min<0 Then run_min=0 End If End If Set Cmd = Server.CreateObject("ADODB.Command") Cmd.ActiveConnection = Connection SQLStmt = " select lol.run,lol.run_date,lol.run_type,csq.nevents,csq.nseq,to_char(lol.run_date,'MM/DD/YYYY') ldate, " SQLStmt = SQLStmt & " to_char(lol.run_date,'MM/DD/YY HH24:MI:SS') ddate,lol.ncals,nvl(cs.ncals_valid,0) ncals_valid,lol.nvalid,lol.ncomments,rco.text, " SQLStmt = SQLStmt & " lss.nevents_s,lss.nseq_s,lss.nback_s,lss.ncoll_s,mg.imag_min,mg.imag_max,mg.hneg_min,mg.hneg_max,mg.imag_c " SQLStmt = SQLStmt & " from " SQLStmt = SQLStmt & " (select max(rs.RUN) run,max(rs.RUN_DATE) run_date,max(rs.RUN_TYPE) run_type, " SQLStmt = SQLStmt & " max(rs.NEVENTS) nevents,max(rs.NSEQ) nseq, " SQLStmt = SQLStmt & " sum(INSTR(le.action,'CALIBRATION_SET')) ncals, " SQLStmt = SQLStmt & " sum(INSTR(le.action,'VALIDATE_RUN')) nvalid,sum(INSTR(le.action,'COMMENT')) ncomments " SQLStmt = SQLStmt & " from phoffline.runs rs,phoffline.run_numbers rn,phoffline.log_entries le " SQLStmt = SQLStmt & " where rs.run=rn.run and rn.logid=le.logid " SQLStmt = SQLStmt & " and rs.RUN>= ? and rs.RUN<= ? " SQLStmt = SQLStmt & " group by rs.run) lol, " SQLStmt = SQLStmt & " (select max(rs.RUN) run,sum(ss.NEVENTS) nevents_s,count(sequence) nseq_s,sum(PPPN_W) nback_s,sum(PPPN_N_3) ncoll_s " SQLStmt = SQLStmt & " from phoffline.runs rs,phoffline.scaler_summary ss " SQLStmt = SQLStmt & " where ss.run=rs.run " SQLStmt = SQLStmt & " and rs.RUN>= ? and rs.RUN<= ? " SQLStmt = SQLStmt & " group by rs.run) lss, " SQLStmt = SQLStmt & " (select rs.RUN run,lc.text " SQLStmt = SQLStmt & " from phoffline.runs rs,phoffline.run_numbers rn,phoffline.log_entries le,phoffline.log_comments lc " SQLStmt = SQLStmt & " where rs.run=rn.run and rn.logid=le.logid and lc.logid=le.logid " SQLStmt = SQLStmt & " and le.action='COMMENT' and rs.RUN>= ? and rs.RUN<= ? ) rco, " SQLStmt = SQLStmt & " (select max(rs.run) run,count(c.valid) ncals_valid " SQLStmt = SQLStmt & " from phoffline.calibrations c,phoffline.runs rs " SQLStmt = SQLStmt & " where c.validity_date=rs.run_date " SQLStmt = SQLStmt & " and valid>0 " SQLStmt = SQLStmt & " and rs.RUN>= ? and rs.RUN<= ? " SQLStmt = SQLStmt & " group by rs.run ) cs, " SQLStmt = SQLStmt & " (select max(run) run,max(imag) imag_max,min(imag) imag_min,max(hall_neg) hneg_max,min(hall_neg) hneg_min,count(imag) imag_c " SQLStmt = SQLStmt & " from (select se.run,mm.logdate,mm.imag,mm.hall_neg from phoffline.magnet_monitoring mm, " SQLStmt = SQLStmt & " (select rn.run,min(log_date)-0/(24*60) start_run,max(log_date)+0/(24*60) end_run from phoffline.log_entries le,phoffline.run_numbers rn " SQLStmt = SQLStmt & " where le.logid=rn.logid and (le.action='START_RUN' OR le.action='END_RUN') " SQLStmt = SQLStmt & " and rn.RUN>= ? and rn.RUN<= ? " SQLStmt = SQLStmt & " group by rn.run) se " SQLStmt = SQLStmt & " where mm.logdate between se.start_run and se.end_run) " SQLStmt = SQLStmt & " group by run) mg, " SQLStmt = SQLStmt & " (select rn.run,sum(rs.nevents) nevents, count(rs.sequence) nseq from phoffline.runseqs rs,phoffline.runs rn " SQLStmt = SQLStmt & " where rn.run=rs.run and rn.RUN>= ? and rn.RUN<= ? group by rn.run) csq " SQLStmt = SQLStmt & " where lol.run=rco.run(+) " SQLStmt = SQLStmt & " and lol.run=cs.run(+) " SQLStmt = SQLStmt & " and lol.run=lss.run(+) " SQLStmt = SQLStmt & " and lol.run=mg.run(+) and lol.run=csq.run(+) " If Run_type<>"" Then SQLStmt = SQLStmt & " and lol.run_type= ? " End If SQLStmt = SQLStmt & " order by lol.run desc " ' response.write(SQLStmt & "
" ) Cmd.CommandText = SQLStmt Cmd.CommandType = 1 Cmd.Prepared=true 'response.write(Cstr(run_min) & " " & CStr(run_max)) for i=0 To 5 Set prm = cmd.CreateParameter("Input" & CStr(2*i),adInteger,adParamInput,,CLng(run_min)) Cmd.Parameters.Append prm Set prm=nothing Set prm = cmd.CreateParameter("Input" & CStr(2*i+1),adInteger,adParamInput,,CLng(run_max)) Cmd.Parameters.Append prm Set prm=nothing Next If Run_type<>"" Then Set prm = cmd.CreateParameter("InputRunType",adBSTR,adParamInput,30,Run_type) Cmd.Parameters.Append prm Set prm=nothing End If ' For Each p In Cmd.Parameters ' Response.Write("
" & p.Name & " = " & p.Value) ' Next Set RS = Cmd.Execute() ' Set RS = Connection.Execute(SQLStmt) time_ora=CStr(round(24*60*60*(Now()-time_start),1)) If run_type="" Then title="Run logbook" Else title="Run logbook, runs of type " & Run_type End If %> Run Log

<%=Title%> as of <%=RSx("rddate")%> <%=dbname%>

To insert comments for a specific run click on the little book icon. 

<% If registered=1 Then %> <% End If %> <% run_old=-1 DV_disp="" Do While Not RS.EoF run=CLng(RS("run")) If run=run_old Then ' ' append comments ' If Not IsNull(RS("TEXT")) Then comments= comments & "." & CStr(RS("TEXT")) End If Else If run_old<>-1 Then If Len(comments)>maxc Then comments=Left(comments,maxc-3) & "..." End If ' ' print old run with all the comments ' %> <% If registered=1 Then %> <% End if %> <% End If ' ' prepare variables for the new run ' ddate=(date-datevalue(CStr(RS("ldate")))) If ddate=0 Then rcolor="#BEBE7C" Elseif ddate=1 Then rcolor="#AEBEEE" Else rcolor="#FFFFFF" End if ddate=CStr(RS("ddate")) run_type=CStr(RS("run_type")) If IsNull(RS("NEVENTS")) Then nevents="Not Known" Else nevents=CStr(RS("NEVENTS")) End if If IsNull(RS("NSEQ")) Then nseq="" Else nseq=CStr(RS("NSEQ")) End If If IsNull(RS("TEXT")) Then comments="." Else comments=CStr(RS("TEXT")) End If If Cint(RS("nvalid"))=0 Then nvalid="" Else nvalid=CStr(RS("nvalid")) End If ' If run_type="SICAL" Or run_type="SIPED" Then ncals=CInt(RS("ncals")) ncals_valid=CInt(RS("ncals_valid")) If ncals_valid>0 Then 'at least one valid calibration run_type_disp="" Elseif ncals>0 Then 'novalid calibrations but calibrations have been run run_type_disp="" Else run_type_disp="" End If End if nevents_s="" nseq_s="" nback_s="" ncoll_s="" If run_type="ALLBEAM" Then If Not IsNull(RS("nevents_s")) Then nevents_s=CStr(RS("nevents_s")) nevents_sd=CDbl(nevents_s) End If If Not IsNull(RS("nseq_s")) Then nseq_s=CStr(RS("nseq_s")) End If If Not IsNull(RS("nback_s")) Then nback_s=CStr(RS("nback_s")) nback_sd=CDbl(nback_s) End If If Not IsNull(RS("ncoll_s")) Then ncoll_s=CStr(RS("ncoll_s")) ncoll_sd=CDbl(ncoll_s) End If If nevents_sd>0 Then nback_sd=(nback_sd/nevents_sd)*100 ncoll_sd=(ncoll_sd/nevents_sd)*100 Else nback_sd=0 ncoll_sd=0 End If End if ' ' Check what is known about magnetic field ' If Not IsNull(RS("hneg_min")) Then hneg_min=CDbl(RS("hneg_min")) hneg_max=CDbl(RS("hneg_max")) If abs(hneg_min)>abs(hneg_max) Then hneg_sign=hneg_min Else hneg_sign=hneg_max End If hneg_diff=abs(hneg_min-hneg_max) If hneg_diff>0.1 Then bfield="CHG" Else If abs(hneg_sign)>1.9 Then If hneg_sign<0 Then bfield="ON(+)" Else bfield="ON(-)" End If Elseif abs(hneg_sign)>0.1 Then bfield="HN= " & CStr(Round(hneg_sign,3)) & "?" Else bfield="OFF " End If End If Else bfield="?" End If ' bfield="N/A" End if run_old=run RS.MoveNext Loop ' ' print last run with all the comments ' %> <% If registered=1 Then %> <% End if %>
Run Log Date Run Type Mag Events (seq) Totals Comments

Insert Comment

Details
<%= run_old %> <%= ddate %> <%= run_type %> <%= bfield %> <% =nevents %>(<%=nseq%>)

<% If nevents_s<>"" Then response.write(nevents_s & "(" & nseq_s & ")") End If %>

<% If ncoll_s<>"" Then response.write(Round(ncoll_sd,1) & "%/" & Round(nback_sd,1) & "%") End If %>
<% =comments%> <% If Nvalid<>"" Then %> (<%=nvalid%>)<%=DV_disp%> <% End If %> <%If run_type="SIPED" Or run_type="SICAL" Then %> <%=run_type_disp%> <% End If %> Details
<%= run_old %> <%= ddate %> <%= run_type %> <%= bfield %> <% =nevents %>(<%=nseq%>)

<% If nevents_s<>"" Then response.write(CStr(nevents_s) & "(" & nseq_s & ")") End If %>

<% If ncoll_s<>"" Then response.write(Round(ncoll_sd,1) & "%/" & Round(nback_sd,1) & "%") End If %>
<% =comments%> <% If Nvalid<>"" Then %> (<%=nvalid%>)<%=DV_disp%> <% End If %> <%If run_type="SIPED" Or run_type="SICAL" Then %> <%=run_type_disp%> <% End If %> Details
<% Connection.Close time_tot=CStr(round(24*60*60*(Now()-time_start),1)) response.write("
" & Time_ora & "," & Time_tot) %>