#! /usr/bin/env mpscript # # This script constructs a 2-dimensional motor scan record and then runs it # using mpscript. The script also demonstrates how to build a scan record # based on the scan parameters. # def main( mx_database, argv ): if ( len(argv) == 0 ): print( "" ) print( "Usage: mp_scan_2 ..." ) print( "" ) sys.exit(1) #print( "mx_database = %s" % ( mx_database ) ) print( "argv = %s" % ( argv ) ) motor_name = [] motor_start = [] motor_step_size = [] motor_num_measurements = [] motor_name.append( argv[0] ) motor_start.append( float( argv[1] ) ) motor_step_size.append( float( argv[2] ) ) motor_num_measurements.append( int( argv[3] ) ) motor_name.append( argv[4] ) motor_start.append( float( argv[5] ) ) motor_step_size.append( float( argv[6] ) ) motor_num_measurements.append( int( argv[7] ) ) datafile_name = argv[8] timer_name = argv[9] measurement_time = float( argv[10] ) input_device_name = argv[11:] num_input_devices = len(input_device_name) # Start constructing the scan description. scan_name = "test_scan" description = \ ( "%s scan linear_scan motor_scan \"\" \"\" " % (scan_name) ) num_scans = 1 num_motors = 2 num_independent_variables = num_motors description = description + \ ( "%d %d %d " % ( num_scans, num_independent_variables, num_motors ) ) for i in range(num_motors): description = description + ( "%s " % ( motor_name[i] ) ) description = description + ( "%d " % ( num_input_devices ) ) for i in range(num_input_devices): description = description + ( "%s " % ( input_device_name[i] ) ) scan_flags = 0x0 settling_time = 0.0 measurement_type = "preset_time" description = description + ( "%x %f %s \"%f %s\" " % \ ( scan_flags, settling_time, measurement_type, measurement_time, timer_name )) datafile_description = "text" plot_description = "gnuplot" plot_arguments = "$f[0]" description = description + ( "%s %s %s %s " % \ ( datafile_description, datafile_name, plot_description, plot_arguments )) for i in range(num_input_devices): description = description + ( "%f " % ( motor_start[i] ) ) for i in range(num_input_devices): description = description + ( "%f " % ( motor_step_size[i] ) ) for i in range(num_input_devices): description = description + \ ( "%d " % ( motor_num_measurements[i] ) ) # # The scan description is complete now, so we print it and # try to run it. # print( "description = '%s'" % description ) mx_database.create_record_from_description( description ) scan = mx_database.get_record( scan_name ) scan.finish_record_initialization() scan.perform_scan() print( "Test scan complete." )