<%@ LANGUAGE="VBScript" %> Create Connection Map

<% start_time = Time %><% start_date = Date %> <% timedate=Request("timedate") If Not IsDate(timedate) Then message="Wrong Time/Date format " & timedate %> <% End If operator = Replace(CStr(Request.Form("operator")),"'","") If operator="" Then operator="Unknown" End If comments = Replace(CStr(Request.Form("comments")),"'","") If comments="" Then comments="No comments" End If %>

Dear <%=operator%>, you just started a creation of a New Connection Map valid on <%=FormatDateTime(timedate, vbLongDate) %> at <%=FormatDateTime(timedate, vbLongTime) %> (this may take several minutes)

<% Set Connection = Server.CreateObject("ADODB.Connection") Connection.Open "Provider=MSDAORA;Data Source=phdb.world;User ID=assembly;Password=heinz" SQL= " create table ASSEMBLY.R_TEMP TABLESPACE PHOBOS_TEMP AS " SQL= SQL & " (SELECT to_date('" & timedate & "','MM/DD/YYYY HH24:MI:SS') REQDATE,'" & operator & "' OPERATOR FROM DUAL) " ' response.write(SQL & ";
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) in_use=1 If Err.Number=0 Then Response.write("Temporary table R_TEMP created" & "
" & vbCrLf ) in_use=0 Elseif Err.Number=&H80040E14 Then Response.write("Error: Table R_TEMP already exists, it has not been created again" & "
" & vbCrLf) in_use=1 Else Response.write(CStr(Err.Description) & "
" & vbCrLf) in_use=1 End If '--- If in_use=0 Then SQL= " INSERT INTO ASSEMBLY.FEC_MAP_LOG " SQL= SQL & " (SELECT sysdate,reqdate,'" & operator & "','" & comments & "' from ASSEMBLY.R_TEMP) " ' response.write(SQL & ";
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("A record inserted into FEC_MAP_LOG" & "
" & vbCrLf ) Elseif Err.Number=&H80040E14 Then SQL= " DROP TABLE ASSEMBLY.R_TEMP " Set RS = Connection.Execute(SQL) Response.write("The record could not be inserted into FEC_MAP_LOG, the validity time already exists" & "
" & vbCrLf ) %> <% Else Response.write(Hex(Err.Number) & " " & CStr(Err.Description) & "
" & vbCrLf) End If '--- SQL= " COMMIT " ' response.write(SQL & ";
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Insertion Committed" & "
" & vbCrLf ) Else Response.write(CStr(Err.Number) & " " & CStr(Err.Description) & "
" & vbCrLf) End If '--- SQL= " INSERT INTO ASSEMBLY.ACTIVE_FECS_PERM " SQL=SQL & " (select reqdate,fcs.startdate,fc.geo_mod,fcs.shybrid_npos,fcs.swurst_id,fc.fec_number,fc.fec_string,sr.fec_st_len " SQL=SQL & " from assembly.fec_connect fc, " SQL=SQL & " (select max(startdate) startdate,max(geo_mod) geo_mod, max(shybrid_npos) shybrid_npos, " SQL=SQL & " max(swurst_id) swurst_id from assembly.fec_connect,assembly.r_temp " SQL=SQL & " where reqdate>=startdate " SQL=SQL & " group by geo_mod,shybrid_npos,swurst_id) fcs, " SQL=SQL & " (select max(smod_type) smod_type,max(shybrid_npos) shybrid_npos,max(hybrid_npos) hybrid_npos,max(swurst_id) swurst_id,sum(wurst_length) fec_st_len " SQL=SQL & " from assembly.smod_readout group by smod_type,shybrid_npos,swurst_id) sr, " SQL=SQL & " (select max(startdate) startdate,max(fec_number) fec_number, " SQL=SQL & " max(fec_string) fec_string " SQL=SQL & " from assembly.fec_connect,assembly.r_temp where reqdate>=startdate group by fec_number,fec_string) fcn, " SQL=SQL & " assembly.geo_mods gm,assembly.r_temp, " SQL=SQL & " (select fc1.fec_number from ASSEMBLY.FEC_CONFIG fc1, " SQL=SQL & " (select max(startdate) startdate,max(abs(fec_number)) afec_number " SQL=SQL & " from assembly.fec_config,assembly.r_temp where startdate<=reqdate group by abs(fec_number) ) fcs1 " SQL=SQL & " where fc1.startdate=fcs1.startdate " SQL=SQL & " and abs(fc1.fec_number)=fcs1.afec_number and fc1.fec_number>0) fca " SQL=SQL & " where gm.startdate<=reqdate and gm.stopdate>reqdate and gm.smod_type=sr.smod_type " SQL=SQL & " and sr.shybrid_npos=fc.shybrid_npos and sr.swurst_id=fc.swurst_id and fcs.startdate=fc.startdate " SQL=SQL & " and fcn.startdate=fc.startdate and fcn.fec_number=fc.fec_number " SQL=SQL & " and fcn.fec_string=fc.fec_string and fcs.geo_mod=fc.geo_mod " SQL=SQL & " and fcs.shybrid_npos=fc.shybrid_npos and fcs.swurst_id=fc.swurst_id and fc.fec_number>0 " SQL=SQL & " and gm.geo_mod=fcs.geo_mod and fca.fec_number=fc.fec_number) " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Table ACTIVE_FECS_PERM filled" & "
" & vbCrLf ) Else Response.write(CStr(Err.Description) & "
" & vbCrLf) End If '--- SQL= " COMMIT " ' response.write(SQL & ";
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Insertion Committed" & "
" & vbCrLf ) Else Response.write(CStr(Err.Number) & " " & CStr(Err.Description) & "
" & vbCrLf) End If '--- SQL= " CREATE TABLE ASSEMBLY.GEO_MOD_MAP TABLESPACE PHOBOS_TEMP AS " SQL=SQL & " (select gs.geo_mod,gs.smod_type,sr.shybrid_npos,sr.swurst_id, " SQL=SQL & " sr.swurst_read_pos, sr.swurst_read_pos*sr.wurst_length+mm.channel chan, " SQL=SQL & " gms.geo_sensor,ms.sensor_type,ms.sensor_pos,gs.smod_orientation, " SQL=SQL & " mm.sensor_row,mm.sensor_column, mm.bonding_pattern,mm.pad, " SQL=SQL & " mm.wurst_read_pos+sr.swurst_read_pos chip_number,mm.chip_type,rt.reqdate " SQL=SQL & " from assembly.smod_readout sr,assembly.mod_map mm, " SQL=SQL & " (select * from assembly.geo_mods,ASSEMBLY.R_TEMP rt " SQL=SQL & " where rt.reqdate>=startdate and stopdate>rt.reqdate) gs, " SQL=SQL & " assembly.geo_mod_sensor gms, assembly.mod_sensor ms,ASSEMBLY.R_TEMP rt, " SQL=SQL & " (select distinct geo_mod " SQL=SQL & " from assembly.active_fecs_perm afp,ASSEMBLY.R_TEMP rt " SQL=SQL & " where afp.reqdate=rt.reqdate) xx " SQL=SQL & " where sr.smod_type=gs.smod_type " SQL=SQL & " and sr.mod_type=mm.mod_type " SQL=SQL & " and sr.mod_type=ms.mod_type " SQL=SQL & " and gms.sensor_pos=ms.sensor_pos " SQL=SQL & " and sr.hybrid_npos=mm.hybrid_npos " SQL=SQL & " and sr.wurst_id=mm.wurst_id " SQL=SQL & " and gs.geo_mod=gms.geo_mod " SQL=SQL & " and sr.smod_mod_pos=gms.smod_mod_pos " SQL=SQL & " and gms.sensor_pos=mm.sensor_pos " SQL=SQL & " and gs.geo_mod=xx.geo_mod) " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table GEO_MOD_MAP created" & "
" & vbCrLf ) Elseif Err.Number=&H80040E14 Then Response.write("Error: Table GEO_MOD_MAP already exists, it has not been created again" & "
" & vbCrLf) Else Response.write(CStr(Err.Description) & "
" & vbCrLf) End If '--- SQL= " CREATE TABLE ASSEMBLY.FEC_MAP_FULL TABLESPACE PHOBOS_TEMP AS " SQL=SQL & " (select bm.reqdate,geo_sensor,sensor_type,fec_number, " SQL=SQL & " fec_string,chan,sensor_row,sensor_column,chip_number, " SQL=SQL & " pad,bonding_pattern,chip_type from ((select gmm.geo_mod,gmm.smod_type, " SQL=SQL & " gmm.shybrid_npos,gmm.swurst_id,gmm.swurst_read_pos,gmm.chan, " SQL=SQL & " gmm.geo_sensor,gmm.sensor_type,mrc.ri*cr.rmax+mrc.rs*gmm.sensor_row sensor_row, " SQL=SQL & " mrc.ci*cr.cmax+mrc.cs*gmm.sensor_column sensor_column, gmm.chip_number,gmm.smod_orientation, " SQL=SQL & " gmm.sensor_pos,gmm.pad,gmm.bonding_pattern,gmm.chip_type,gmm.reqdate " SQL=SQL & " from ASSEMBLY.GEO_MOD_MAP gmm,assembly.mod_rotation_cr mrc, " SQL=SQL & " (select max(sensor_type) sensor_type,max(sensor_row) rmax ,max(sensor_column) cmax " SQL=SQL & " from sitester.type_con group by sensor_type) cr " SQL=SQL & " where gmm.sensor_row>=0 and cr.sensor_type=gmm.sensor_type " SQL=SQL & " and mrc.smod_orientation=gmm.smod_orientation) " SQL=SQL & " union " SQL=SQL & " (select gmm.geo_mod,gmm.smod_type,gmm.shybrid_npos,gmm.swurst_id, " SQL=SQL & " gmm.swurst_read_pos,gmm.chan, gmm.geo_sensor,gmm.sensor_type,gmm.sensor_row sensor_row, " SQL=SQL & " gmm.sensor_column,gmm.chip_number,gmm.smod_orientation,gmm.sensor_pos, " SQL=SQL & " gmm.pad,gmm.bonding_pattern,gmm.chip_type,gmm.reqdate " SQL=SQL & " from ASSEMBLY.GEO_MOD_MAP gmm where 0>gmm.sensor_row)) bm, " SQL=SQL & " (select geo_mod,shybrid_npos,swurst_id,fec_number,fec_string,fec_st_len " SQL=SQL & " from assembly.active_fecs_perm afp,ASSEMBLY.R_TEMP rt " SQL=SQL & " where rt.reqdate=afp.reqdate) fc " SQL=SQL & " where bm.geo_mod=fc.geo_mod " SQL=SQL & " and bm.shybrid_npos=fc.shybrid_npos " SQL=SQL & " and bm.swurst_id=fc.swurst_id " SQL=SQL & " and bm.chan" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table FEC_MAP_FULL Created" & "
" & vbCrLf ) Else Response.write(CStr(Err.Number) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= " alter table ASSEMBLY.FEC_MAP_FULL add constraint PK_FEC_MAP_FULL " SQL=SQL & " primary key (fec_number,fec_string,chan) " SQL=SQL & " using index tablespace phobos_temp " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary Index Created" & "
" & vbCrLf ) Else Response.write(CStr(Hex(Err.Number)) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= " create table ASSEMBLY.FEC_MAP_EMPTY tablespace phobos_temp as " SQL=SQL & " (select rt.reqdate reqdate,'XXXX' geo_sensor, -1 sensor_type, " SQL=SQL & " fc.fec_number,fs.fec_string,fch.channel chan,-1 sensor_row, -4 sensor_column, " SQL=SQL & " 20+floor((fch.channel)/64) chip_number, " SQL=SQL & " mod(fch.channel,64) pad,-1 bonding_pattern,64 chip_type " SQL=SQL & " from ASSEMBLY.FEC_CONFIG fc,ASSEMBLY.FEC_STRINGS fs, " SQL=SQL & " ASSEMBLY.FEC_CHANNELS fch, ASSEMBLY.R_TEMP rt " SQL=SQL & " where fc.startdate=fs.startdate " SQL=SQL & " and fc.fec_number=fs.fec_number " SQL=SQL & " and fs.fec_st_len>fch.channel " SQL=SQL & " and (fc.startdate,fc.fec_number) " SQL=SQL & " in (select max(startdate),max(abs(fec_number)) " SQL=SQL & " from ASSEMBLY.FEC_CONFIG,ASSEMBLY.R_TEMP rt " SQL=SQL & " where reqdate>=startdate group by abs(fec_number))) " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table FEC_MAP_EMPTY Created" & "
" & vbCrLf ) Else Response.write(CStr(Hex(Err.Number)) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= " alter table ASSEMBLY.FEC_MAP_EMPTY add constraint PK_FEC_MAP_EMPTY " SQL=SQL & " primary key (fec_number,fec_string,chan) " SQL=SQL & " using index tablespace phobos_temp " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary Index Created" & "
" & vbCrLf ) Else Response.write(CStr(Hex(Err.Number)) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= " create table ASSEMBLY.FEC_MAP_MERGED tablespace phobos_temp as " SQL=SQL & " (select reqdate,geo_sensor,sensor_type, " SQL=SQL & " fec_number,fec_string,chan,sensor_row,sensor_column, " SQL=SQL & " chip_number,pad,bonding_pattern,chip_type from assembly.fec_map_full) " SQL=SQL & " union " SQL=SQL & " (select reqdate,geo_sensor,sensor_type,fec_number,fec_string, " SQL=SQL & " chan,sensor_row,sensor_column, chip_number,pad,bonding_pattern,chip_type " SQL=SQL & " from assembly.fec_map_empty " SQL=SQL & " where not exists (select 'x' from assembly.fec_map_full " SQL=SQL & " where assembly.fec_map_empty.fec_number=assembly.fec_map_full.fec_number " SQL=SQL & " and assembly.fec_map_empty.fec_string=assembly.fec_map_full.fec_string " SQL=SQL & " and assembly.fec_map_empty.chan=assembly.fec_map_full.chan)) " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table FEC_MAP_MERGED Created" & "
" & vbCrLf ) Else Response.write(CStr(Hex(Err.Number)) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= " INSERT INTO ASSEMBLY.FEC_MAP " SQL=SQL & " (select reqdate,geo_sensor,sensor_type,fmm.fec_number,fmm.fec_string, " SQL=SQL & " fmm.chan+chan_shift chan,sensor_row,sensor_column,chip_number,pad,bonding_pattern,chip_type " SQL=SQL & " from assembly.fec_map_merged fmm, " SQL=SQL & " (select chan_shift from assembly.string_shift where startdate= " SQL=SQL & " (select max(startdate) from assembly.string_shift,ASSEMBLY.R_TEMP rt " SQL=SQL & " where rt.reqdate>=startdate)) cs, " SQL=SQL & " (select fss.fec_number,fss.fec_string,fec_st_len from assembly.fec_strings fss, " SQL=SQL & " (select max(startdate) startdate,max(abs(fec_number)) fec_number " SQL=SQL & " from ASSEMBLY.FEC_CONFIG,ASSEMBLY.R_TEMP rt " SQL=SQL & " where reqdate>=startdate " SQL=SQL & " group by abs(fec_number)) xx where xx.startdate=fss.startdate " SQL=SQL & " and xx.fec_number=fss.fec_number) fs where fmm.fec_number=fs.fec_number " SQL=SQL & " and fmm.fec_string=fs.fec_string and chan+chan_shift" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Records inserted into FEC_MAP (connected) " & "
" & vbCrLf ) Else Response.write(CStr(Hex(Err.Number)) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= " INSERT INTO ASSEMBLY.FEC_MAP " SQL=SQL & " (select reqdate,'XXXX' geo_sensor,-1 sensor_type,fmm.fec_number,fmm.fec_string, " SQL=SQL & " chan,-1 sensor_row,-5 sensor_column,-1 chip_number,-1 pad,-1 bonding_pattern,0 chip_type " SQL=SQL & " from assembly.fec_map_merged fmm, " SQL=SQL & " (select chan_shift from assembly.string_shift where startdate= " SQL=SQL & " (select max(startdate) from assembly.string_shift,ASSEMBLY.R_TEMP rt " SQL=SQL & " where reqdate>=startdate)) cs, " SQL=SQL & " (select fss.fec_number,fss.fec_string,fec_st_len from assembly.fec_strings fss, " SQL=SQL & " (select max(startdate) startdate,max(abs(fec_number)) fec_number " SQL=SQL & " from ASSEMBLY.FEC_CONFIG,ASSEMBLY.R_TEMP rt " SQL=SQL & " where reqdate>=startdate " SQL=SQL & " group by abs(fec_number)) xx " SQL=SQL & " where xx.startdate=fss.startdate " SQL=SQL & " and xx.fec_number=fss.fec_number) fs " SQL=SQL & " where fmm.fec_number=fs.fec_number " SQL=SQL & " and fmm.fec_string=fs.fec_string " SQL=SQL & " and chan" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Records inserted into FEC_MAP (not connected) " & "
" & vbCrLf ) Else Response.write(CStr(Hex(Err.Number)) & " " & CStr(Err.Description) & "
" & vbCrLf ) End If '--- SQL= "DROP TABLE ASSEMBLY.GEO_MOD_MAP" ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table GEO_MOD_MAP dropped" & "
" & vbCrLf ) Elseif Err.Number=&H80040E37 Then Response.write("Table GEO_MOD_MAP not dropped but this is OK" & "
" & vbCrLf) Else Response.write(Hex(Err.Description) & "
" & vbCrLf) End If '--- SQL= "DROP TABLE ASSEMBLY.FEC_MAP_MERGED" ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table FEC_MAP_MERGED dropped" & "
" & vbCrLf ) Elseif Err.Number=&H80040E37 Then Response.write("Table FEC_MAP_MERGED not dropped but this is OK" & "
" & vbCrLf) Else Response.write(Hex(Err.Description) & "
" & vbCrLf) End If '--- SQL= "DROP TABLE ASSEMBLY.FEC_MAP_FULL" ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table FEC_MAP_FULL dropped" & "
" & vbCrLf ) Elseif Err.Number=&H80040E37 Then Response.write("Table FEC_MAP_FULL not dropped but this is OK" & "
" & vbCrLf) Else Response.write(Hex(Err.Description) & "
" & vbCrLf) End If '--- SQL= "DROP TABLE ASSEMBLY.FEC_MAP_EMPTY" ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table FEC_MAP_EMPTY dropped" & "
" & vbCrLf ) Elseif Err.Number=&H80040E37 Then Response.write("Table FEC_MAP_EMPTY not dropped but this is OK" & "
" & vbCrLf) Else Response.write(Hex(Err.Description) & "
" & vbCrLf) End If '--- ' ' Insert records into LOG_ENTRIES ' SQLstmt=" insert into phoffline.log_entries(logid,log_date,action) " SQLstmt= SQLStmt & " values (phoffline.logid.nextval,sysdate,'SI_CONFIG_CHANGE')" ' response.write(SQLStmt & ";
") Set RS= Connection.Execute(SQLstmt) response.write(" LOG_ENTRIES Updated" & "
" & vbCrLf) ' ' Insert records into LOG_HARDWARE ' SQLstmt=" insert into phoffline.log_hardware " SQLstmt= SQLStmt & " (select phoffline.logid.currval,reqdate,'FEC_MAP_LOG','New Map Created' from assembly.r_temp) " ' response.write(SQLStmt & ";
") Set RS= Connection.Execute(SQLstmt) response.write(" LOG_HARDWARE Updated" & "
" & vbCrLf) ' ' Insert records into LOG_OPERATORS ' SQLstmt=" insert into phoffline.log_operators " SQLstmt= SQLStmt & " (select phoffline.logid.currval,'" & operator & "' from dual) " ' response.write(SQLStmt & ";
") Set RS= Connection.Execute(SQLstmt) response.write(" LOG_OPERATORS Updated" & "
" & vbCrLf) ' ' Insert records into LOG_COMMENTS ' SQLstmt=" insert into phoffline.log_comments " SQLstmt= SQLStmt & " (select phoffline.logid.currval,'" & " FEC Map Created: " & comments & "' from dual) " ' response.write(SQLStmt & ";
") Set RS= Connection.Execute(SQLstmt) response.write(" LOG_COMMENTS Updated" & "
" & vbCrLf) SQL= " COMMIT " ' response.write(SQL & ";
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Insertions Committed" & "
" & vbCrLf ) Else Response.write(CStr(Err.Number) & " " & CStr(Err.Description) & "
" & vbCrLf) End If '--- SQL= " select count(fmt.reqdate) nchannels,to_char(max(rt.reqdate),'mm/dd/yyyy hh24:mi:ss') reqdate " SQL= SQL & " from ASSEMBLY.FEC_MAP fmt,ASSEMBLY.R_TEMP rt " SQL= SQL & " where rt.REQDATE=fmt.REQDATE " ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Channels Counted" & "
" & vbCrLf ) Else Response.write(Hex(Err.Description) & "
" & vbCrLf) End If '--- reqdate=CStr(RS("REQDATE")) If Not IsNull(RS("NCHANNELS")) Then nchannels=CStr(RS("NCHANNELS")) Else nchannels=0 End If SQL= "DROP TABLE ASSEMBLY.R_TEMP" ' response.write(SQL & "
" & vbCrLf) '--- On Error Resume Next Set RS = Connection.Execute(SQL) If Err.Number=0 Then Response.write("Temporary table R_TEMP dropped" & "
" & vbCrLf ) End If %>

Full connection map with <%=nchannels%> channels, with validity time at <%=reqdate%>  has been created <% Else ' ' Table R_TEMP exists, somebody is creating a map already ! ' %>

The map cannot be created now, somebody is creating a map at this time, please wait <% End If Connection.Close %>

You may now check the complete list of maps