<%@ LANGUAGE="VBScript" %> <% ' Monitoring Graph ' Written by Bolek Wyslouch, 3 March 2000 ' ' This script will make One and only one graph. ' ' The plot can contain several series (separate lines). Since data from the database can ' come in separate columns or separate rows we steer the logic by using ncols and nrows ' variables. The logic is only needed to fill the measurement() array, the plotting ' will be automatic ' ' This plot will always contain all FECs ' ' Dim Chart Dim measurement() Dim Color(8) Color(0)=vbBlue Color(1)=vbRed Color(2)=vbGreen Color(3)=vbMagenta Color(4)=vbBlack Color(5)=vbCyan ' ' Open Database connection, read only ! ' Set Connection = Server.CreateObject("ADODB.Connection") Connection.Mode = adModeRead Connection.Open phdb_rd ' ' get input control parameters ' delta=0 If IsEmpty(Request("days")) Then days=1 Else days=CInt(Request("days"))-1 If days<0 Then days=0 End If End If If IsEmpty(Request("day_start")) Or Not IsDate(Request("day_start")) Then day_start="" Else day_start=Request("day_start") End If If IsEmpty(Request("day_stop")) Or Not IsDate(Request("day_stop")) Then day_stop="" Else day_stop=Request("day_stop") End If ' ' sounds crazy but it is beter to use Oracle to do date/time calculations ' If Not (day_start="" Or day_stop="") Then delta=1 SQLStmt = "select 24*(to_date('" & day_stop & "','MM/DD/YYYY HH24:MI:SS')-to_date('" & day_start & "','MM/DD/YYYY HH24:MI:SS')) ddif from dual " ' response.write(CStr(SQLStmt) & "
") Set RST = Connection.Execute(SQLStmt) hours=CDbl(RST("ddif")) End If measurement_id=Request("measurement_id") If IsEmpty(Request("width")) Then width=600 Else width=CInt(Request("width")) End If If IsEmpty(Request("height")) Then height=300 Else height=CInt(Request("height")) End If If IsEmpty(Request("vauto")) Then vauto=0 Else vauto=CInt(Request("vauto")) End If ' ' Select the set of variables to plot. The code that follows is highly "hardwired" ' Select Case measurement_id Case "FEC_VBC","FEC_TEMP","FEC_OUTBIAS","FEC_IBC","FEC_PREBIAS","FEC_SHABIAS","FEC_VFP","FEC_VFS" ' ' FEC monitoring, as measured in Mercury, ALL Fecs together ' ' ' Count how many FECs are in this time range ' ' Use one selection satring two times, store ' SQL_select="" If Not (day_start="" or day_stop="") Then SQL_select = SQL_select & " and logdate>to_date('" & day_start & "','MM/DD/YYYY HH24:MI:SS') " SQL_select = SQL_select & " and to_date('" & day_stop & "','MM/DD/YYYY HH24:MI:SS')>logdate " Else SQL_select = SQL_select & " and logdate>to_date(to_char(sysdate,'MM/DD/YYYY'),'MM/DD/YYYY')-" & days End If SQL_select = SQL_select & " and ascii(fec_vbc)>0 " ' ' Calculate total number of FEC's and ports to plot ' SQLStmt="select count(fec_number) nrows from (select distinct fec_number,fec_port from phoffline.fec_monitoring" SQLStmt=SQLStmt & " where fec_number>0 " SQLStmt=SQLStmt & SQL_select & ")" ' response.write(SQLStmt & "
" ) Set RSn = Connection.Execute(SQLStmt) nrows=CInt(RSn("nrows")) Set RSn=nothing ' ' prepare now the main SQL statement SQLStmt = "select to_char(logdate,'hh24:mi:ss') ttime,to_char(logdate,'MM/DD/YYYY') tdate, " SQLStmt = SQLStmt & "fs.ifec," If measurement_id="FEC_VBC" Then SQLStmt = SQLStmt & "1.95*(ascii(fec_vbc)-127) to_plot0 " description="Vbc" val_min=-10 val_max=120 units="V" name="Bias Voltage" ncols=1 Elseif measurement_id="FEC_TEMP" Then SQLStmt = SQLStmt & "0.195*(ascii(fec_temp)+128) to_plot0 " description="Hybrid T" val_min=0 val_max=80 units="C" name="Temperature" ncols=1 Elseif measurement_id="FEC_OUTBIAS" Then SQLStmt = SQLStmt & "19.5*(ascii(fec_outbias)-127) to_plot0 " description="Outbias" val_min=100 val_max=500 units="mV" name="Outbias" ncols=1 Elseif measurement_id="FEC_IBC" Then SQLStmt = SQLStmt & "19.5*(ascii(fec_ibc)-127) to_plot0 " description="Ibc" val_min=-10 val_max=300 units="uA" name="Current" ncols=1 Elseif measurement_id="FEC_PREBIAS" Then SQLStmt = SQLStmt & "19.5*(ascii(fec_prebias)-127) to_plot0 " description="Prebias" val_min=1100 val_max=1300 units="mV" name="Prebias" ncols=1 Elseif measurement_id="FEC_SHABIAS" Then SQLStmt = SQLStmt & "19.5*(ascii(fec_shabias)-127) to_plot0 " description="Shabias" val_min=-200 val_max=0 units="mV" name="Shabias" ncols=1 Elseif measurement_id="FEC_VFP" Then SQLStmt = SQLStmt & "19.5*(ascii(fec_vfp)-127) to_plot0 " description="Vfp" val_min=-400 val_max=-300 units="mV" name="Vfp" ncols=1 Elseif measurement_id="FEC_VFS" Then SQLStmt = SQLStmt & "19.5*(ascii(fec_vfs)-127) to_plot0 " description="Vfs" val_min=500 val_max=900 units="mV" name="Vfs" ncols=1 End If SQLStmt = SQLStmt & " FROM phoffline.fec_monitoring fm, " SQLStmt = SQLStmt & " (select rownum ifec,fec_number,fec_port from " SQLStmt = SQLStmt & " (select distinct fec_number,fec_port " SQLStmt = SQLStmt & " from phoffline.fec_monitoring " SQLStmt = SQLStmt & " where fec_number>0 " SQLStmt = SQLStmt & SQL_select & ")) fs" SQLStmt = SQLStmt & " where fm.fec_number=fs.fec_number " SQLStmt = SQLStmt & " and fm.fec_port=fs.fec_port " SQLStmt = SQLStmt & " and fm.fec_number>0 " SQLStmt = SQLStmt & SQL_select SQLStmt = SQLStmt & " order by ifec,logdate " End Select ' response.write(SQLStmt & "
" ) Set RS1 = Connection.Execute(SQLStmt) If days>0 Then title= description & ", last " & days+1 & " days" Else title= description & ", today" End if ' ' Fill arrays with database data ' If Not RS1.EOF Then If Not (day_start="" or day_stop="") Then time_begin=DateValue(day_start)+TimeValue(day_start) ihour=24 Else time_begin=DateValue(Now()-days) ihour=1 End If End If ' Prepare current plot rem ********************************************************************** rem * Instantiate the Chart component rem ********************************************************************** Set Chart = Server.CreateObject ("ASPChart.Chart") rem ********************************************************************** rem * Fill points rem ********************************************************************** vmin_auto=100000 vmax_auto=-100000 nseries=0 ifec_old=-999999 Do While Not RS1.Eof and nseries<2 ifec=CInt(RS1("ifec")) If (ifec>ifec_old) Then ' ' start new series ' nseries=nseries+1 Chart.AddSeries 5 Chart.LineWidth = 2.0 Chart.SeriesInLegend = false End If ifec_old=ifec timdat=ihour*(TimeValue(RS1("ttime"))+DateValue(RS1("tdate"))-time_begin) meas=Cdbl(RS1("to_plot0")) If meas>vmax_auto Then vmax_auto=meas End if If meas200 and width>200 Then Chart.ChartTitleFont.Size="12" Else Chart.ChartTitleFont.Size="9" End If Chart.ChartTitleAdd Description If delta=0 Then Chart.HorizAxisMin = 0. Chart.HorizAxisMax = days+1 If days<3 Then Chart.BottomAxisIncrement = 0.25 Else Chart.BottomAxisIncrement = 1.00 End If Axis2="Time [days]" Else Chart.HorizAxisMin = 0. Chart.HorizAxisMax = hours If hours<24 Then Chart.BottomAxisIncrement = 1. Else Chart.BottomAxisIncrement = 24 End If Axis2="Time [hours]" End if Set RS2 = Connection.Execute("select to_char(sysdate,'MM/DD/YY HH24:MI:SS') ddate from dual") Axis2=Axis2 & " (Graph updated at " & CStr(RS2("ddate")) & ")" Chart.AddAxisLabel 2 , Axis2 If vauto=0 Then Chart.VertAxisMin = val_min Chart.VertAxisMax = val_max End If Chart.AddAxisLabel 1 , name & "[" & units & "]" ' ' send binary picture to the screen ' Chart.ProgressiveJPEGEncoding = true Chart.JPEGQuality = 65 Response.ContentType = "image/JPEG" Response.BinaryWrite Chart.Image Set Chart=nothing Connection.Close Set Connection=nothing Set RS0=nothing Set RS1=nothing Set RS2=nothing %> Monitoring Graph