{ *************************************************************************** } MODULE mod_trics_main ; { Created 2-MAY-1989 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE } {---------------------------------------------------------------------- {- Purpose and Methods : this is the main process, setting up the {- D0TCC hardware and software {- and creating detached connection processes {- {- Created 12-NOV-1988 MICHIGAN STATE UNIVERSITY, TRIGGER SOFTWARE {- Updated 16-NOV-1988 {- Updated 21-MAR-1989 {- Updated 4-MAY-1989 move to EPASCAL {- Updated 5-JUN-1989 reorganize console messages/tracing {- Updated 1-JUl-1989 replace initialization subroutines {- Updated 2-OCT-1989 add double buffer synchronizing {- Updated 27-NOV-1989 delete test task before exiting {- Updated 15-JAN-1991 task initialize LSM system {- Updated 1-FEB-1991 add mailer job, and mail messages {- Updated 1-MAR-1991 add wait for LSM minimal before init hardware {- Updated 25-MAR-1991 change site dependent from module to constants {- Updated 11-JUL-1991 LSM system uses ZEBRA file, quickly operational {- Updated 20-MAR-1992 add auxiliary boot file {- Updated 24-MAR-1992 add begin/end run {- Updated 8-MAY-1992 add threshold table {- Updated 1-JUL-1992 add initialize boot_directory name {- Updated 19-NOV-1993 add create pQBA master device {- Updated 29-APR-1994 add create pVBA master device {- Updated 16-JUN-1994 Now dual device {- Updated 16-JUN-1994 Now dual device {- Updated 19-JUL-1994 Now read all scalers before resetting them { *************************************************************************** } INCLUDE mod_common_global_flags, mod_handle_console, mod_handle_logfile, mod_handle_tracing, mod_handle_read_input, mod_handle_mail, mod_handle_zrl, mod_def_hardware_tables, mod_def_physics_tables, mod_handle_l15ct, mod_init_lsm, mod_init_cbus_cards, mod_init_geosec, mod_init_sptrg, mod_init_globals, mod_init_trgtwr, mod_init_auxi, mod_init_thresholds, mod_handle_begin_end_run, mod_tst_task, mod_soft_conn_dispatch, mod_soft_conn_channel, mod_common_hard_io, mod_tcs_io_DRV11J_handling, {from the TRICS hardware IO library } mod_tcs_io_comint_handling, {from the TRICS hardware IO library } mod_handle_monit_pool, mod_handle_dble_buff, $KERNEL ; { from ELN$:RTLOBJECT.OLB } { *************************************************************************** } EXPORT ; { *************************************************************************** } IMPORT L1_obey_L15, {from module MOD_COMMON_GLOBAL_FLAGS } boot_directory_name, {from module MOD_COMMON_GLOBAL_FLAGS } result_directory_name, {from module MOD_COMMON_GLOBAL_FLAGS } main_process, {from module MOD_COMMON_GLOBAL_FLAGS } name_main, {from module MOD_COMMON_GLOBAL_FLAGS } lock_console, {from module MOD_HANDLE_CONSOLE } unlock_console, {from module MOD_HANDLE_CONSOLE } display_shutdown, {from module MOD_HANDLE_CONSOLE } close_logfile, {from module MOD_HANDLE_LOGFILE } init_tracing, {from module MOD_HANDLE_TRACING } handle_trc_sys, {from module MOD_HANDLE_TRACING } handle_trc_sta, {from module MOD_HANDLE_TRACING } handle_exception, {from module MOD_HANDLE_TRACING } init_flush_to_logfile, {from module MOD_HANDLE_TRACING } set_trc_exc_mode, {from module MOD_HANDLE_TRACING } start_time, {from module MOD_HANDLE_TRACING } init_read_cons, {from module MOD_HANDLE_READ_INPUT } init_ZRL_devices_and_DRV11Js, {from module MOD_HANDLE_ZRL } find_mail_locks, {from module MOD_MAILER } send_mail, {from module MOD_MAILER } def_hardware_table, {from module MOD_DEF_HARDWARE_TABLES } init_cbus_cards, {from module MOD_INIT_CBUS_CARDS } def_sptrg_table, {from module MOD_DEF_PHYSICS_TABLES } def_geosec_table, {from module MOD_DEF_PHYSICS_TABLES } def_trgtwr_table, {from module MOD_DEF_PHYSICS_TABLES } def_threshold_table, {from module MOD_DEF_PHYSICS_TABLES } Init_L15CT_Progr, {from module MOD_HANDLE_L15CT } create_init_lsm_task, {from module MOD_INIT_LSM } lsm_fully_operational, {from module MOD_INIT_LSM } init_all_geosec, {from module MOD_INIT_GEOSEC } init_all_sptrg, {from module MOD_INIT_SPTRG } init_global_scalers, {from module MOD_INIT_GLOBALS } init_all_trgtwr, {from module MOD_INIT_TRGTWR } init_all_LgTile, {from module MOD_INIT_TRGTWR } init_auxi, {from module MOD_INIT_AUXI } load_tree_corrections, {from module MOD_INIT_THRESHOLDS } load_momentum_lookup, {from module MOD_INIT_THRESHOLDS } init_all_thresholds, {from module MOD_INIT_THRESHOLDS } init_begin_end_run, {from module MOD_HANDLE_BEGIN_END_RUN } create_begin_end_run, {from module MOD_HANDLE_BEGIN_END_RUN } initiate_write_host_file, {from module MOD_HANDLE_BEGIN_END_RUN } synchronize_wrt_host, {from module MOD_HANDLE_BEGIN_END_RUN } {PORTA,}PORTB, PORTC,{PORTD,} {from module MOD_COMMON_HARD_IO } reg_drv11j_pilot, {from module MOD_COMMON_HARD_IO } reg_drv11j_assist, {from module MOD_COMMON_HARD_IO } proced_tcs_release_dbbuilder, {from module MOD_TCS_IO_COMINT_HANDLING } proced_tcs_dis_int, {from module MOD_TCS_IO_DRV11J_HANDLING } init_dispatch, {from module MOD_SOFT_CONN_DISPATCH } init_connections, {from module MOD_SOFT_CONN_CHANNEL } start_rfrsh_mpool_proc, {from module MOD_HANDLE_MONIT_POOL } delete_rfrsh_mpool_proc, {from module MOD_HANDLE_MONIT_POOL } proc_watch_dbl_buff, {from module MOD_HANDLE_DBLE_BUFF } init_watch_dble_buff, {from module MOD_HANDLE_DBLE_BUFF } quit_test_mode, {from module MOD_HARDWARE_TEST } KER$NAME_OBJECT ; {from module $KERNEL } { *************************************************************************** } { *************************************************************************** } PROGRAM trics_main (INPUT, OUTPUT) ; CONST one_second = 10000000 ; %INCLUDE 'SITE_DEPENDENT.CST/LIST' VAR status : INTEGER ; tagext : VARYING_STRING(8) := 'boot%' ; scaler_file : VARYING_STRING(35) ; BEGIN boot_directory_name := local_directory ; {initialized here, init_lsm might} {change it for the host_directory} {if there is a problem accessing } {the local disk} result_directory_name := local_result_directory ; L1_Obey_l15 := FALSE ; { **** connect to console lock, write banner, open logfile... } init_tracing ; handle_trc_sys ( TAG := 'INI/SYS%', MESSAGE := ' TRIGGER CONTROL SOFTWARE INITIALIZING' ) ; { **** create the concurrent process closing logfile, and the exception mbx } init_flush_to_logfile ; { **** send mail to advertize boot } IF ( mailer_ok = TRUE ) THEN BEGIN find_mail_locks ( CALLER := ' TRICS', STATUS := status ) ; IF ( status = 1 ) THEN send_mail ( SUBJECT := ' Booting' ) ; END ; { **** connect and initialize master pQBA/pVBA device } init_ZRL_devices_and_DRV11Js ; { **** must create dispatching process to allocate memory used by init_auxi } init_dispatch ; { *** define hardware and physics tables } def_hardware_table ; def_sptrg_table ; def_geosec_table ; def_trgtwr_table ; def_threshold_table ; { **** create the concurrent process to initialize the LSM data base } create_init_lsm_task ; { **** Wait for LSM file to be loaded } REPEAT WAIT_ANY ( TIME := - one_second ) ; UNTIL ( lsm_fully_operational = TRUE ) ; { **** execute commands from the auxiliary BOOT file } init_auxi ( FILENAME := boot_directory_name + aux_boot_filename, TAGEXT := tagext ) ; { **** create the concurrent process writing begin/end run files to the host } init_begin_end_run ; IF ( begin_end_run_ok = TRUE ) THEN BEGIN create_begin_end_run ; { **** read all scalers, as a recovery in case of TCC crash/reboot } scaler_file := scaler_recovery_dir + 'TCC_BOOT_' + SUBSTR(start_time,1,2) + SUBSTR(start_time,4,3) + SUBSTR(start_time,10,2) + '.INFO' ; initiate_write_host_file ( FILENAME := scaler_file, NAME := 'TCC Boot', RCP_TYPE := 'TCC_BOOT' ) ; {Make an attempt at waiting for the completion of the above request. } {This will avoid mixing messages in the logfile } {But most importantly avoid that the initialization happens before the } {scalers are read } {It isn't totally critical that the file is completely written, } {because the begin/end run task runs at higher priority, and collects the } {data first, before opening the host file } {This waits for up to 30 s, which is enough of a headstart in any case } synchronize_wrt_host ; END ; { **** initialize L1.5 Cal Trig Programming } Init_L15CT_Progr ; { **** initialize all cards, not checking for previous content consistency } init_cbus_cards ( TAGEXT := tagext ) ; { **** initialize all geographic sections } init_all_geosec ( TAGEXT := tagext ) ; { **** initialize all specific triggers } init_all_sptrg ( TAGEXT := tagext ) ; { **** reset all global scalers } init_global_scalers ( TAGEXT := tagext ) ; { **** initialize all trigger towers and Large Tiles } init_all_trgtwr ( TAGEXT := tagext ) ; init_all_LgTile ( TAGEXT := tagext ) ; { **** initialize all energy and count thresholds } init_all_thresholds ( TAGEXT := tagext ) ; { **** initialize momentum lookup } load_momentum_lookup ( TAGEXT := tagext ) ; { **** initialize CAT3 cards for tree offset correction } load_tree_corrections ( TAGEXT := tagext ) ; { **** execute commands from the auxiliary intitialization file } init_auxi ( FILENAME := boot_directory_name + aux_init_filename, TAGEXT := tagext ) ; init_auxi ( FILENAME := boot_directory_name + aux_init_L15CT_filename, TAGEXT := tagext ) ; { **** releases the control bus and the data block builder } proced_tcs_release_dbbuilder ; { **** create the concurrent communication processes } init_connections ( TOTAL := total_elncon_channel ); { **** create the concurrent process watching the double buffering synchro } IF ( watch_dbl_buff_ok = TRUE ) THEN init_watch_dble_buff ; { **** create the concurrent process refreshing monitoring pool } IF ( rfrsh_mpool_ok = TRUE ) THEN start_rfrsh_mpool_proc ; { **** create the concurrent process accepting keyboard input } IF ( read_cons_ok = TRUE ) THEN init_read_cons ; { **** this job's main process can now fall asleep but not disappear } WAIT_ANY ( TIME := TIME_VALUE('0 0:0:1.0') ) ; handle_trc_sys ( TAG := 'INI/DON%', MESSAGE := ' INITIALIZATION COMPLETE ' ) ; CURRENT_PROCESS ( main_process, STATUS := status ) ; handle_trc_sta ( TAG := 'CUR/PRC%main', STATUS := status ) ; KER$NAME_OBJECT( name_main, 'INITIALIZE', main_process, STATUS := status ) ; handle_trc_sta ( TAG := 'NAM/PRC%main', STATUS := status ) ; SUSPEND ( main_process, STATUS := status ) ; handle_trc_sta ( TAG := 'SUS/PRC%main', STATUS := status ) ; { *********** SUSPENDED UNTIL SHUTDOWN REQUEST ****************************** } ESTABLISH ( exchand_main ) ; handle_trc_sys ( TAG := 'INI/SHT%', MESSAGE := ' Shutdown In 15 Seconds ' ) ; delete_rfrsh_mpool_proc ; quit_test_mode ; proced_tcs_dis_int ( reg_drv11j_pilot, PortB ) ; proced_tcs_dis_int ( reg_drv11j_pilot, PortC ) ; proced_tcs_dis_int ( reg_drv11j_assist, PortB ) ; proced_tcs_dis_int ( reg_drv11j_assist, PortC ) ; lock_console ; SIGNAL ( proc_watch_dbl_buff, STATUS := status ); unlock_console ; handle_trc_sta ( TAG := 'SIG/PRC%dblbuf%', STATUS := status ) ; send_mail ( SUBJECT := ' Shutdown' ) ; WAIT_ANY ( TIME := TIME_VALUE('0 0:0:10') ) ; handle_trc_sys ( TAG := 'INI/SHT%', MESSAGE := ' Shutdown In 5 Seconds ' ) ; WAIT_ANY ( TIME := TIME_VALUE('0 0:0:05') ) ; close_logfile ; display_shutdown ; EXIT ; END ; { *************************************************************************** } { *************************************************************************** } FUNCTION exchand_main OF TYPE EXCEPTION_HANDLER ; BEGIN set_trc_exc_mode ( TRUE ) ; exchand_main := handle_exception ( TAG := 'MAN/EXC%', EXC_CODE := signal_args.name ) ; set_trc_exc_mode ( FALSE ) ; END ; { *************************************************************************** } PROCESS_BLOCK shutdown ; BEGIN RESUME ( main_process ) ; END ; { *************************************************************************** } PROCESS_BLOCK delete_job ; BEGIN SIGNAL ( main_process ) ; END ; { *************************************************************************** } END .