#! /usr/bin/env mpscript # # This script counts for the requested number of seconds and then # reads out the scalers. # import time def main( record_list, argv ): if ( len(argv) <= 1 ): print( "" ) print( "Usage: mp_count time timer_name scaler1 scaler2 ..." ) print( "" ) sys.exit(1); counting_time = float( argv[0] ) timer_name = argv[1] timer = record_list.get_record( timer_name ) timer.stop() print ( "Counting with timer '%s' for %g seconds." \ % ( timer_name, counting_time ) ) scaler_name_list = argv[2:] num_scalers = len(scaler_name_list) # Find and clear all the scalers. i = 0 scaler_list = [] while ( i < num_scalers ): scaler = record_list.get_record( scaler_name_list[i] ) scaler.clear() scaler_list = scaler_list + [ scaler ] i = i + 1 # Start the timer. timer.start( counting_time ) # Wait for the timer to finish counting down. while (1): if ( timer.is_busy() == 0 ): break time.sleep( 1.0 ) # Now read out all of the scalers. i = 0 while ( i < num_scalers ): scaler_name = scaler_name_list[i] value = scaler_list[i].read() print ( " %s = %i" % ( scaler_name, value ) ) i = i + 1