{ *************************************************************************** } MODULE mod_init_thresholds ; { Created 8-MAY-1992 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE } { *************************************************************************** } INCLUDE mod_common_global_flags, mod_handle_tracing, mod_def_hardware_tables, mod_def_physics_tables, mod_handle_fmln, mod_handle_cat_cards, mod_handle_thresholds, mod_io_allocation_handling, mod_common_hard_io ; {from the TRICS hardware IO library } { *************************************************************************** } EXPORT load_tree_corrections, {PROCEDURE prepare correction for tree offsets } zero_tree_corrections, {PROCEDURE zeroes correction for tree offsets } load_momentum_lookup, {PROCEDURE load FMLN with momentum lookup } init_all_thresholds, {PROCEDURE initialize all thresholds } restore_all_thresholds, {PROCEDURE restore all thresholds } initialize_energy_threshold,{PROCEDURE initialize one energy threshold } initialize_count_threshold, {PROCEDURE initialize one count threshold } check_alloc_eng_threshold_coor, {PROCEDURE alloc thres to coor if necessary } check_alloc_cnt_threshold_coor; {PROCEDURE alloc thres to coor if necessary } { *************************************************************************** } IMPORT status_type, ok, {already_done,} io_failure, {from module MOD_COMMON_GLOBAL_FLAGS } {state_type,} ON, OFF, {from module MOD_HANDLE_TRACING } inline_tracing, {from module MOD_HANDLE_TRACING } trace_info,{trace_warn,}trace_error,{from module MOD_HANDLE_TRACING } handle_trc_sys, {from module MOD_HANDLE_TRACING } handle_trc_err, {from module MOD_HANDLE_TRACING } handle_trc_inf, {from module MOD_HANDLE_TRACING } modify_trace_inf, {from module MOD_HANDLE_TRACING } modify_trace_wrn, {from module MOD_HANDLE_TRACING } modify_trace_err, {from module MOD_HANDLE_TRACING } modify_io_tracing, {from module MOD_HANDLE_TRACING } modify_db_tracing, {from module MOD_HANDLE_TRACING } save_tracing_status, {from module MOD_HANDLE_TRACING } restore_tracing_status, {from module MOD_HANDLE_TRACING } threshold_comparison_type, {from module MOD_DEF_HARDWARE_TABLES } EMEt_cmp,TOTEt_cmp, {from module MOD_DEF_HARDWARE_TABLES } threshold_reference_set_number, {from module MOD_DEF_HARDWARE_TABLES } ref_0,{ref_1, ref_2,}ref_3, {from module MOD_DEF_HARDWARE_TABLES } cat3_EM_Et_t3, cat3_HD_Et_t3, cat3_Tot_Et_t4, cat3_EM_L2_t3, cat3_HD_L2_t3, cat3_Tot_L2_t4, trc_err_init_odb_ct, {from module MOD_DEF_HARDWARE_TABLES } Global_EMEt, Global_HDEt, Global_TotEt, Global_EML2, Global_HDL2, Global_TotL2, global_energy_thresholds, {from module MOD_DEF_HARDWARE_TABLES } Thresh_EMEt, Thresh_HDEt, Thresh_TotEt, Thresh_EML2, Thresh_HDL2, Thresh_TotL2, Thresh_MisPt, {from module MOD_DEF_HARDWARE_TABLES } fmln_compare, {from module MOD_DEF_HARDWARE_TABLES } {possible_allocation,}all_none, all_coor,{all_phat, all_redundancy,} tree_correction, {from module MOD_DEF_PHYSCS_TABLE } energy_threshold, {from module MOD_DEF_PHYSCS_TABLE } count_threshold, {from module MOD_DEF_PHYSCS_TABLE } { program_fmln_momentum_lookup, {from module MOD_HANDLE_FMLN } zero_fmln_thresholds, {from module MOD_HANDLE_FMLN } update_cat3_correction, {from module MOD_HANDLE_CAT_CARDS } set_energy_threshold, {from module MOD_HANDLE_THRESHOLDS } set_count_threshold, {from module MOD_HANDLE_THRESHOLDS } allocate_trigger, {from module MOD_IO_ALLOCATION_HADLLING } deallocate_trigger, {from module MOD_IO_ALLOCATION_HADLLING } eight_bit_0_7, {from module MOD_COMMON_HARD_IO } cbus_param_list ; {from module MOD_COMMON_HARD_IO } { *************************************************************************** } { *************************************************************************** } %INCLUDE 'SITE_DEPENDENT.CST/LIST' TYPE byte = [BYTE] 0..255 ; VAR tag : VARYING_STRING(8) := 'INI/ODB%' ; ini_status : status_type ; {general purpose status buffer} fail_count : INTEGER := 0 ; { *************************************************************************** } { *************************************************************************** } PROCEDURE load_tree_corrections ( tagext : VARYING_STRING(16) := '' ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR j : INTEGER ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Loading Tree Corrections in CAT3 Cards' ) ; save_tracing_status ; modify_trace_inf ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_trace_wrn ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; IF ( trace_error.logfile = ON ) THEN modify_trace_err ( CONSOLE := OFF, LOGFILE := trc_err_init_odb_ct, REPORT := FALSE ) ELSE modify_trace_err ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_db_tracing ( STATE := ON, REPORT := FALSE ) ; modify_io_tracing ( STATE := OFF, REPORT := FALSE ) ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Load EM Et tree Correction ' + CONVERT(STRING,tree_correction[Global_EMEt]) ) ; FOR j := first_emet_sum_cmp DIV 4 TO last_emet_sum_cmp DIV 4 DO BEGIN update_cat3_correction ( CARD := ADDRESS(cat3_EM_Et_t3[j]), CORRECTION := tree_correction[Global_EMEt], {correct for tree offset} IOPAR := inipar, STATUS := ini_status ) ; END ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Load HD Et tree correction ' + CONVERT(STRING,tree_correction[Global_HDEt]) ) ; FOR j := first_hdet_sum_cmp DIV 4 TO last_hdet_sum_cmp DIV 4 DO BEGIN update_cat3_correction ( CARD := ADDRESS(cat3_HD_Et_t3[j]), CORRECTION := tree_correction[Global_HDEt], {correct for tree offset} IOPAR := inipar, STATUS := ini_status ) ; END ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Total Et tree correction ' + CONVERT(STRING,tree_correction[Global_TotEt]) ) ; FOR j := first_totet_sum_cmp DIV 4 TO last_totet_sum_cmp DIV 4 DO BEGIN update_cat3_correction ( CARD := ADDRESS(cat3_Tot_Et_t4[j]), CORRECTION := tree_correction[Global_TotEt], {correct for tree offset} IOPAR := inipar, STATUS := ini_status ) ; END ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Load EM L2 tree correction ' + CONVERT(STRING,tree_correction[Global_EML2]) ) ; update_cat3_correction ( CARD := ADDRESS(cat3_EM_L2_t3), CORRECTION := tree_correction[Global_EML2], {correct for tree offset} IOPAR := inipar, STATUS := ini_status ) ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Load HD L2 tree correction ' + CONVERT(STRING,tree_correction[Global_HDL2]) ) ; update_cat3_correction ( CARD := ADDRESS(cat3_HD_L2_t3), CORRECTION := tree_correction[Global_HDL2], {correct for tree offset} IOPAR := inipar, STATUS := ini_status ) ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Total L2 tree correction ' + CONVERT(STRING,tree_correction[Global_TotL2]) ) ; update_cat3_correction ( CARD := ADDRESS(cat3_Tot_L2_t4), CORRECTION := tree_correction[Global_TotL2], {correct for tree offset} IOPAR := inipar, STATUS := ini_status ) ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; restore_tracing_status ( REPORT := FALSE ) ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE zero_tree_corrections ( tagext : VARYING_STRING(16) := '' ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR j : INTEGER ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; handle_trc_sys ( TAG := 'INI/HDB%' + tagext , MESSAGE := ' Zeroing Tree Corrections in CAT3 Cards' ) ; FOR j := first_emet_sum_cmp DIV 4 TO last_emet_sum_cmp DIV 4 DO BEGIN update_cat3_correction ( CARD := ADDRESS(cat3_EM_Et_t3[j]), CORRECTION := 0, IOPAR := inipar, STATUS := ini_status ) ; END ; FOR j := first_hdet_sum_cmp DIV 4 TO last_hdet_sum_cmp DIV 4 DO BEGIN update_cat3_correction ( CARD := ADDRESS(cat3_HD_Et_t3[j]), CORRECTION := 0, IOPAR := inipar, STATUS := ini_status ) ; END ; FOR j := first_totet_sum_cmp DIV 4 TO last_totet_sum_cmp DIV 4 DO BEGIN update_cat3_correction ( CARD := ADDRESS(cat3_Tot_Et_t4[j]), CORRECTION := 0, IOPAR := inipar, STATUS := ini_status ) ; END ; update_cat3_correction ( CARD := ADDRESS(cat3_EM_L2_t3), CORRECTION := 0, IOPAR := inipar, STATUS := ini_status ) ; update_cat3_correction ( CARD := ADDRESS(cat3_HD_L2_t3), CORRECTION := 0, IOPAR := inipar, STATUS := ini_status ) ; update_cat3_correction ( CARD := ADDRESS(cat3_Tot_L2_t4), CORRECTION := 0, IOPAR := inipar, STATUS := ini_status ) ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE load_momentum_lookup ( tagext : VARYING_STRING(16) := '' ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; { handle_trc_sys ( TAG := 'INI/HDB%' + tagext , { MESSAGE := ' Loading FMLN with Momentum Lookup ' ) ; } save_tracing_status ; modify_trace_inf ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_trace_wrn ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; IF ( trace_error.logfile = ON ) THEN modify_trace_err ( CONSOLE := OFF, LOGFILE := trc_err_init_odb_ct, REPORT := FALSE ) ELSE modify_trace_err ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_db_tracing ( STATE := ON, REPORT := FALSE ) ; modify_io_tracing ( STATE := OFF, REPORT := FALSE ) ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; deallocate_trigger ( TAGEXT := tagext, REPORT := FALSE ) ; allocate_trigger ( TAGEXT := tagext, CALLER_ID := inipar, REPORT := FALSE ); END ELSE local_io_param := FALSE ; { program_fmln_momentum_lookup ( IOPAR := inipar, { STATUS := ini_status ) ; { { IF ( ini_status = io_failure ) { THEN BEGIN { IF ( inline_tracing(trace_error) <> 0 ) { THEN handle_trc_err ( TAG := tag + tagext, { MESSAGE := ' Failure Initializing Momentum FMLN ' ) ; { IF PRESENT(status) THEN status := ini_status ; { END ; } { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; deallocate_trigger ( TAGEXT := tagext, REPORT := FALSE ) ; END ; restore_tracing_status ( REPORT := FALSE ) ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE init_all_thresholds ( tagext : VARYING_STRING(16) := '' ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR thrshnum : INTEGER ; glob_thr : global_energy_thresholds ; cmp_typ : threshold_comparison_type ; ref_num : threshold_reference_set_number ; ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; fail_count : INTEGER ; BEGIN IF PRESENT(status) THEN status := ok ; handle_trc_sys ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Initializing all Global Thresholds ' ) ; save_tracing_status ; modify_trace_inf ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_trace_wrn ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; IF ( trace_error.logfile = ON ) THEN modify_trace_err ( CONSOLE := OFF, LOGFILE := trc_err_init_odb_ct, REPORT := FALSE ) ELSE modify_trace_err ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_db_tracing ( STATE := ON, REPORT := FALSE ) ; modify_io_tracing ( STATE := OFF, REPORT := FALSE ) ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; fail_count := 0 ; FOR thrshnum := first_emet_sum_cmp TO last_emet_sum_cmp DO BEGIN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_EMEt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_hdet_sum_cmp TO last_hdet_sum_cmp DO BEGIN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_HDEt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_totet_sum_cmp TO last_totet_sum_cmp DO BEGIN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_TotEt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_eml2_sum_cmp TO last_eml2_sum_cmp DO BEGIN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_EML2, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_hdl2_sum_cmp TO last_hdl2_sum_cmp DO BEGIN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_HDL2, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_totl2_sum_cmp TO last_totl2_sum_cmp DO BEGIN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_TotL2, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; { to save time, initialize all mementum thresholds on FMLN card in one pass} initialize_momentum_thresholds ( TAGEXT := tagext, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; FOR ref_num := ref_0 TO ref_3 DO BEGIN FOR thrshnum := first_emet_cnt_cmp TO last_emet_cnt_cmp DO BEGIN initialize_count_threshold ( TAGEXT := tagext, THRSHTYP := EMEt_cmp, REF_NUM := ref_num, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_totet_cnt_cmp TO last_totet_cnt_cmp DO BEGIN initialize_count_threshold ( TAGEXT := tagext, THRSHTYP := TotEt_cmp, REF_NUM := ref_num, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; END ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; restore_tracing_status ( REPORT := FALSE ) ; IF ( fail_count <> 0 ) THEN BEGIN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' GLobal Threshold Initialization Failure Count Is ' + CONVERT(STRING,fail_count) + ', Check Log File' ) ; IF PRESENT(status) THEN status := io_failure ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE initialize_energy_threshold ( tagext : VARYING_STRING(16) := '' ; thrshtyp : global_energy_thresholds ; thrshnum : INTEGER ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; handle_trc_inf ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Initializing Global Energy Threshold ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; set_energy_threshold ( TAGEXT := tagext, THRSHTYP := thrshtyp, THRSHNUM := thrshnum, THRSHENG := 0, IOPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Initializing Global Energy Threshold ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; IF PRESENT(status) THEN status := ini_status ; END ; energy_threshold[thrshtyp,thrshnum].status.initialized := TRUE ; energy_threshold[thrshtyp,thrshnum].allocated := ALL_NONE ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE initialize_momentum_thresholds ( tagext : VARYING_STRING(16) := '' ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; thrshnum : INTEGER ; write_protect_mask : eight_bit_0_7 ; BEGIN IF PRESENT(status) THEN status := ok ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; handle_trc_inf ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Initializing Global Momentum Thresholds ' ) ; write_protect_mask::byte := 255 ; FOR thrshnum := first_mispt_sum_cmp TO last_mispt_sum_cmp DO BEGIN write_protect_mask.bitfield[thrshnum] := 0 ; energy_threshold[Thresh_MisPt,thrshnum].status.initialized := TRUE ; energy_threshold[Thresh_MisPt,thrshnum].allocated := ALL_NONE ; END ; zero_fmln_thresholds ( TAGEXT := tagext, CARD := ADDRESS(fmln_compare), WRITE_PROTECT_MASK := write_protect_mask, IOPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Initializing' + ' Global Momentum Thresholds ' ) ; IF PRESENT(status) THEN status := ini_status ; END ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE initialize_count_threshold ( tagext : VARYING_STRING(16) := '' ; thrshtyp : threshold_comparison_type ; ref_num : threshold_reference_set_number ; thrshnum : INTEGER ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; handle_trc_inf ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Initializing Global Count Threshold ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; set_count_threshold ( TAGEXT := tagext, THRSHTYP := thrshtyp, REF_NUM := ref_num, THRSHNUM := thrshnum, THRSHCNT := 0, IOPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Initializing Global Count Threshold ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; IF PRESENT(status) THEN status := ini_status ; END ; count_threshold[thrshtyp,ref_num,thrshnum].status.initialized := TRUE ; count_threshold[thrshtyp,ref_num,thrshnum].allocated := ALL_NONE ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE restore_all_thresholds ( tagext : VARYING_STRING(16) := '' ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR thrshnum : INTEGER ; glob_thr : global_energy_thresholds ; cmp_typ : threshold_comparison_type ; ref_num : threshold_reference_set_number ; ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; fail_count : INTEGER ; BEGIN IF PRESENT(status) THEN status := ok ; handle_trc_sys ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Restoring all Global Thresholds ' ) ; save_tracing_status ; modify_trace_inf ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_trace_wrn ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; IF ( trace_error.logfile = ON ) THEN modify_trace_err ( CONSOLE := OFF, LOGFILE := trc_err_init_odb_ct, REPORT := FALSE ) ELSE modify_trace_err ( CONSOLE := OFF, LOGFILE := OFF, REPORT := FALSE ) ; modify_db_tracing ( STATE := ON, REPORT := FALSE ) ; modify_io_tracing ( STATE := OFF, REPORT := FALSE ) ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; fail_count := 0 ; FOR thrshnum := first_emet_sum_cmp TO last_emet_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_EMEt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_hdet_sum_cmp TO last_hdet_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_HDEt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_totet_sum_cmp TO last_totet_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_TotEt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_eml2_sum_cmp TO last_eml2_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_EML2, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_hdl2_sum_cmp TO last_hdl2_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_HDL2, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_totl2_sum_cmp TO last_totl2_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_TotL2, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_mispt_sum_cmp TO last_mispt_sum_cmp DO BEGIN restore_energy_threshold ( TAGEXT := tagext, THRSHTYP := Thresh_MisPt, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR ref_num := ref_0 TO ref_3 DO BEGIN FOR thrshnum := first_emet_cnt_cmp TO last_emet_cnt_cmp DO BEGIN restore_count_threshold ( TAGEXT := tagext, THRSHTYP := EMEt_cmp, REF_NUM := ref_num, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; FOR thrshnum := first_totet_cnt_cmp TO last_totet_cnt_cmp DO BEGIN restore_count_threshold ( TAGEXT := tagext, THRSHTYP := TotEt_cmp, REF_NUM := ref_num, THRSHNUM := thrshnum, INIPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN fail_count := fail_count + 1 ; END ; END ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; restore_tracing_status ( REPORT := FALSE ) ; IF ( fail_count <> 0 ) THEN BEGIN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Global Threshold Restoring Failure Count Is ' + CONVERT(STRING,fail_count) + ', Check Log File' ) ; IF PRESENT(status) THEN status := io_failure ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE restore_energy_threshold ( tagext : VARYING_STRING(16) := '' ; thrshtyp : global_energy_thresholds ; thrshnum : INTEGER ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; handle_trc_inf ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Restoring Global Energy Threshold ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; set_energy_threshold ( TAGEXT := tagext, THRSHTYP := thrshtyp, THRSHNUM := thrshnum, THRSHENG := energy_threshold[thrshtyp,thrshnum].value, IOPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Restoring Global Energy Threshold ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; IF PRESENT(status) THEN status := ini_status ; END ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE restore_count_threshold ( tagext : VARYING_STRING(16) := '' ; thrshtyp : threshold_comparison_type ; ref_num : threshold_reference_set_number ; thrshnum : INTEGER ; inipar :^cbus_param_list := NIL ; VAR status :[OPTIONAL] status_type ) ; VAR ini_status : status_type ; local_io_param : BOOLEAN := TRUE ; BEGIN IF PRESENT(status) THEN status := ok ; { *** allocate memory for the register initialization parameter list *** } IF ( inipar = NIL ) THEN BEGIN local_io_param := TRUE ; NEW ( inipar ) ; END ELSE local_io_param := FALSE ; handle_trc_inf ( TAG := 'INI/ODB%' + tagext , MESSAGE := ' Restoring Global Count Threshold ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; set_count_threshold ( TAGEXT := tagext, THRSHTYP := thrshtyp, REF_NUM := ref_num, THRSHNUM := thrshnum, THRSHCNT := count_threshold[thrshtyp,ref_num,thrshnum].value, IOPAR := inipar, STATUS := ini_status ) ; IF ( ini_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Restoring Global Count Threshold ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; IF PRESENT(status) THEN status := ini_status ; END ; { *** release the memory from the register initialization io parameters *** } IF ( local_io_param = TRUE ) THEN BEGIN DISPOSE ( inipar ) ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE check_alloc_eng_threshold_coor ( tagext : VARYING_STRING(16) := '' ; thrshtyp : global_energy_thresholds ; thrshnum : INTEGER ) ; BEGIN IF ( energy_threshold[thrshtyp,thrshnum].allocated <> all_coor ) THEN BEGIN IF ( energy_threshold[thrshtyp,thrshnum].status.initialized <> TRUE ) THEN initialize_energy_threshold ( TAGEXT := tagext, THRSHTYP := thrshtyp, THRSHNUM := thrshnum ) ; IF ( inline_tracing(trace_info) <> 0 ) THEN handle_trc_inf ( TAG := tag + tagext, MESSAGE := ' Allocating Global Energy Threshold ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) + ' to COOR' ) ; energy_threshold[thrshtyp,thrshnum].allocated := ALL_COOR ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE check_alloc_cnt_threshold_coor ( tagext : VARYING_STRING(16) := '' ; thrshtyp : threshold_comparison_type ; ref_num : threshold_reference_set_number ; thrshnum : INTEGER ) ; BEGIN IF ( count_threshold[thrshtyp,ref_num,thrshnum].allocated <> all_coor ) THEN BEGIN IF ( count_threshold[thrshtyp,ref_num,thrshnum].status.initialized <> TRUE ) THEN initialize_count_threshold ( TAGEXT := tagext, THRSHTYP := thrshtyp, REF_NUM := ref_num, THRSHNUM := thrshnum ) ; IF ( inline_tracing(trace_info) <> 0 ) THEN handle_trc_inf ( TAG := tag + tagext, MESSAGE := ' Allocating Global Count Threshold ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) + ' to COOR' ) ; count_threshold[thrshtyp,ref_num,thrshnum].allocated := ALL_COOR ; END ; END ; { *************************************************************************** } { *************************************************************************** } END.