%@ LANGUAGE="VBScript" %>
<%
'
' Open Database
'
Dim scalers(15),frequency(15),scname(15),scsource(15)
scname(0)="Pn&Pp Narrow"
scname(1)="Recorded Collisions"
scname(2)="RHIC scaler"
scname(3)="Pn"
scname(4)="Pp"
scname(5)="Zn"
scname(6)="Zp"
scname(7)="Zn&Zp Narrow"
scname(8)="Pn&Pp Wide"
scname(9)="Collision triggers (PPPN_3)"
scname(10)=" "
scname(11)=" "
scname(12)="Central Trigger"
scname(13)="Recorded Triggers"
scname(14)=" "
scname(15)="Live Time [us]"
scsource(0)="A2B"
scsource(1)="L1.CO11"
scsource(2)="D8A"
scsource(3)="A1A"
scsource(4)="A1B"
scsource(5)="D6A"
scsource(6)="D6B"
scsource(7)="D3B"
scsource(8)="A2C"
scsource(9)="A8B"
scsource(10)=" "
scsource(11)=" "
scsource(12)="A12B"
scsource(13)="L1.CO0"
scsource(14)=" "
scsource(15)="EMM.6,7"
timedate=Request("timedate")
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Mode = adModeRead
Connection.Open phdb_rd
avgmin=0
avgmin_corr=avgmin+4.9
If Not IsEmpty(request.form("Latest")) Then
timedate=""
End If
If timedate="" Then
SQLStmt = " select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS') timedate from dual "
Set RS = Connection.Execute(SQLStmt)
timedate = CStr(RS("timedate"))
Set RS=nothing
End If
If Not IsDate(timedate) Then
message="Wrong Time/Date format " & timedate
%>
<%
End If
timedate_par=replace(timedate," ","%20")
SQLt="select to_char(logdate,'MM/DD/YYYY HH24:MI:SS') ldate,diff, "
SQLt=SQLt & " ch_00,ch_01,ch_02,ch_03, "
SQLt=SQLt & " ch_04,ch_05,ch_06,ch_07, "
SQLt=SQLt & " ch_08,ch_09,ch_10,ch_11, "
SQLt=SQLt & " ch_12,ch_13,ch_14,ch_15 "
SQLt=SQLt & " from phoffline.daq_scalers ds,"
SQLt=SQLt & " (select max(logdate) maxl,min(logdate) minl,24*60*60*(max(logdate)-min(logdate)) diff from "
SQLt=SQLt & " phoffline.daq_scalers where logdate between to_date('"&timedate&"','MM/DD/YYYY HH24:MI:SS')-(" & avgmin_corr & ")/(24*60) and to_date('"&timedate&"','MM/DD/YYYY HH24:MI:SS')) ld"
SQLt=SQLt & " where ds.logdate=ld.maxl or ds.logdate=ld.minl "
SQLt=SQLt & " order by ds.logdate desc "
set RS=connection.Execute(SQLt)
'
' expect always two records, latest time and the time approximately 20 minutes before
'
' first record
'
If Not RS.EoF Then
ldate=CStr(RS("ldate"))
diff=CDbl(RS("diff"))
For j=0 to 1
For i=0 to 15
If i<10 Then
str="0" & CStr(i)
Else
str=CStr(i)
End If
If j=0 Then
scalers(i)=CDBl(RS("ch_" & str))
Else
If diff>0 Then
sc2=CDBl(RS("ch_" & str))
' response.write(CStr(i) & "first " & CStr(scalers(i)) & "second " & CStr(sc2) & "
")
If sc2<=scalers(i) Then
frequency(i)=(scalers(i)-sc2)/diff
Else
frequency(i)=(4294967296.+scalers(i)-sc2)/diff
End If
End If
End If
Next
If j=0 Then
RS.MoveNext
If RS.EoF Then
Exit For
End If
End If
Next
skip=false
Else
skip=true
End If
%>
Last reading at <%=ldate%>. Frequency is an average over <%=round(diff/60,0)%> minutes
| Scaler Name | Source | Scaler | Frequency |
| <%=scname(i)%> | <%=scsource(i)%> | <%=scalers(i)%> | <%=round(frequency(i),1)%> |