%@ LANGUAGE="VBScript" %>
<%
time_start=Now()
'
' actions(0,i) action
' actions(1,i) description
'
Dim actions(1,20)
'create array for assigned icons
Dim color(4)
'color(0)="img src="ccc-r0.jpg" width="26" height="10""" ' option1
'color(1)="img src="ff3-r0.jpg" width="26" height="10""" 'option2
'color(2)="img src="0cf-r0.jpg" width="26" height="10""" 'option3
'color(3)="img src="0c0-r0.jpg" width="26" height="10""" 'option4
'color(4)="img src="f00-r0.jpg" width="26" height="10""" 'option5
'
color(0)="N/A" ' option1
color(1)="OK" 'option2
color(2)="MULT" 'option3
'color(3)="img src="0c0-r0.jpg" width="26" height="10""" 'option4
'color(4)="img src="f00-r0.jpg" width="26" height="10""" 'option5
'
' the database is programmed to send a fixed number of
' records for each run. We will select a set of runs of a given run type
' For each run type there is a well defined sequence of actions that need to be
' taken. To save network and computing bandwidth we will get a detailed list of
' actions and then assume that the individual run data comes in the same sequence.
'
' The actions will be stored in an array
'
'
If Request("run_type")<>"" Then
run_type=CStr(Request("run_type"))
Else
run_type="ALLBEAM"
End If
'
' Get first and last run number
'
If Request("rmin")<>"" Then
rmin=CInt(Request("rmin"))
Else
rmin=5000
End If
If Request("rmax")<>"" Then
rmax=CInt(Request("rmax"))
Else
rmax=5010
End If
'
' Open Database
'
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Mode = adModeRead
Connection.Open phdb_rd
'
' This SQL statement gives an ordered list of actions related to run of type run_type
'
SQLStmt = " select ta.action,la.description from phoffline.track_actions ta,phoffline.log_actions la "
SQLStmt = SQLStmt & " where la.action=ta.action and la.action_type=1 and ta.run_type='" & run_type & "' "
SQLStmt = SQLStmt & " order by la.action_order "
' response.write(SQLStmt)
Set RS = Connection.Execute(SQLStmt)
nactions=0
Do While Not RS.EOF
actions(0,nactions)=CStr(RS("action"))
actions(1,nactions)=CStr(RS("description"))
nactions=nactions+1
RS.MoveNext
Loop
Set RS=nothing
'
' And this statement lists the run number and the number of times a given
' action was performed. 0 means that the action was never done.
'
SQLStmt = " select max(ta1.run) run,count(rl.action) naction from "
SQLStmt = SQLStmt & " (select rn.run,ru.run_type,ta.action from phoffline.log_entries le,phoffline.log_actions la, "
SQLStmt = SQLStmt & " phoffline.run_numbers rn, phoffline.runs ru, phoffline.track_actions ta "
SQLStmt = SQLStmt & " where ta.action=le.action and la.action=ta.action and rn.logid=le.logid and rn.run=ru.run"
SQLStmt = SQLStmt & " and ru.run_type='" & run_type & "' "
SQLStmt = SQLStmt & " and ta.run_type=ru.run_type and la.action_type=1 "
SQLStmt = SQLStmt & " and ru.run between " & CStr(rmin) & " and " & CStr(rmax) & ") rl, "
SQLStmt = SQLStmt & " (select r.run,l.action,l.action_order,r.run_type "
SQLStmt = SQLStmt & " from phoffline.track_actions t,phoffline.runs r,phoffline.log_actions l "
SQLStmt = SQLStmt & " where r.run_type='" & run_type & "' "
SQLStmt = SQLStmt & " and l.action=t.action and t.run_type=r.run_type and l.action_type=1 "
SQLStmt = SQLStmt & " and r.run between " & CStr(rmin) & " and " & CStr(rmax) & ") ta1 "
SQLStmt = SQLStmt & " where ta1.action=rl.action(+) and ta1.run=rl.run(+) "
SQLStmt = SQLStmt & " group by ta1.run,ta1.action "
SQLStmt = SQLStmt & " order by ta1.run desc,max(ta1.action_order) "
' response.write(SQLStmt)
Set RS = Connection.Execute(SQLStmt)
%>
Run Production Status
Run Production Status
Runs of type <%=run_type%> from <%=rmin%> to <%=rmax%>
<%
'
' Create table with actions. The number of columns is determined dynamically
' based on the number of nactions
' Create header row, first column contains Run number
'
response.write("")
response.write("| Run | ")
For i=0 To nactions-1
response.write("" & i+1 & " | ")
Next
response.write("
")
'
' We are now ready to loop through the runs. The number of runs is not known
' at this moment but we are sure that once the run is there it will have nactions-1 columns
'
'
Do While Not RS.EOF
run=CStr(RS("run"))
Response.write(" " & vbCrLf)
Response.write("" & run & " | ")
For i=0 To nactions-1
naction=CInt(RS("naction"))
'
' Here we know the run number, action and how many times the given action was done
' Let's do primitive analysis/printouts
'
If naction=0 Then
Response.write("" & color(0) & " | ")
Elseif naction=1 Then
Response.write("" & color(1) & " | ")
Else
Response.write("" & color(2) & " | ")
End If
RS.MoveNext
Next
Loop
Response.write("" & vbCrLf)
%>
Legend
<%
For i=0 To nactions-1
%>
-
<%
Response.write (actions(1,i))
%>
<%
Next
%>
<%
'
' CLose database connection
'
Set RS=nothing
Connection.Close
Set Connection=nothing
time_stop=Now()
time_tot=Round(24*60*60*(time_stop-time_start),1)
%>
<%=time_tot%>