include # Column definitions for the output table. define ROOT_COLUMN_NAME "ROOTNAME" define ROOT 1 define COUNTS_COLUMN_NAME "COUNTS" define COUNTS 2 define DIODES_COLUMN_NAME "DIODES" define DIODES 3 define FIRST_DIODE_COLUMN_NAME "FIRST_DIODE" define FIRST_DIODE 4 define TIME_COLUMN_NAME "TIME" define TIME 5 define MAX_COLUMNS 5 #--------------------------------------------------------------------------- .help event_table May 92 hrs .ih NAME dst_event_open -- Open the statistics tables. dst_event_write -- Write the statistics to the specified table. .endhelp #--------------------------------------------------------------------------- procedure dst_event_open (table_name, table, row) char table_name[ARB] # I: Name of table to open. pointer table # O: The table descriptor. int row # O: The current row of the table. # Declarations. int ip # Generic index. pointer sp # Stack pointer. pointer tmp # Temporary string. include "event_table.com" # Function prototypes. int access(), strlen(), tbpsta(), tbtacc() pointer tbtopn() begin # If no name is specified, no table is opened. if (strlen (table_name) == 0) { table = NULL } else { call smark(sp) call salloc (tmp, SZ_LINE, TY_CHAR) # Iniitalize the column names. call strcpy (ROOT_COLUMN_NAME, col_names[1,ROOT], SZ_COLNAME) call strcpy (COUNTS_COLUMN_NAME, col_names[1,COUNTS], SZ_COLNAME) call strcpy (DIODES_COLUMN_NAME, col_names[1,DIODES], SZ_COLNAME) call strcpy (FIRST_DIODE_COLUMN_NAME, col_names[1,FIRST_DIODE], SZ_COLNAME) call strcpy (TIME_COLUMN_NAME, col_names[1,TIME], SZ_COLNAME) if (access (table_name, 0, 0) == YES) { if (tbtacc (table_name) == YES) { table = tbtopn (table_name, READ_WRITE, 0) call tbcfnd (table, col_names, columns, MAX_COLUMNS) # Check to make sure all the columns exist. If one # doesn't die off. for (ip= 1; ip <= MAX_COLUMNS; ip = ip + 1) if (columns[ip] == NULL) { call sprintf (Memc[tmp], SZ_LINE, "column %s doesn't exist in table %s") call pargstr (col_names[1,ip]) call pargstr (table_name) call error (1, Memc[tmp]) } # Determine the next row to append. row = tbpsta (table, TBL_NROWS) + 1 } else { call sprintf (Memc[tmp], SZ_LINE, "file %s exists but isn't a table") call pargstr (table_name) call error (1, Memc[tmp]) } } else { table = tbtopn (table_name, NEW_FILE, 0) call tbcdef (table, columns[ROOT], col_names[1,ROOT], "", "%20s", -20, 1, 1) call tbcdef (table, columns[COUNTS], col_names[1,COUNTS], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[DIODES], col_names[1,DIODES], "", "%6d", TY_INT, 1, 1) call tbcdef (table, columns[FIRST_DIODE], col_names[1,FIRST_DIODE], "", "%6d", TY_INT, 1, 1) call tbcdef (table, columns[TIME], col_names[1,TIME], "MJD", "%-24s", -24, 1, 1) call tbtcre (table) row = 1 } call sfree(sp) } end #--------------------------------------------------------------------------- # End of dst_event_open #--------------------------------------------------------------------------- # dst_event_write -- Write the statistics to the table. procedure dst_event_write (table, root, first_diode, n_diodes, counts, time, row) pointer table # I: Table descriptor. char root[ARB] # I: Root name. int first_diode # I: The first diode of the event. int n_diodes # I: Number of diodes in event. double counts # I: Total counts in the event. char time[ARB] # I: Time event occured. int row # IO: The current row of the table. # Declarations. include "event_table.com" # Function prototypes. int strlen() begin if (table != NULL) { call tbrptt (table, columns[ROOT], root, strlen (root), 1, row) call tbrptt (table, columns[TIME], time, strlen (time), 1, row) call tbrptd (table, columns[COUNTS], counts, 1, row) call tbrpti (table, columns[FIRST_DIODE], first_diode, 1, row) call tbrpti (table, columns[DIODES], n_diodes, 1, row) row = row + 1 } end #--------------------------------------------------------------------------- # End of dst_event_write #---------------------------------------------------------------------------