Ejemplo n.º 1
0
    def create_tasks(self):
        options = self.options
        self.delete_tasks()
        ao_channels = make_pattern([
                options.mirror_x_analog_output_channels,
                options.mirror_y_analog_output_channels,
                ])
        ai_channels = make_pattern([
                options.mirror_x_error_analog_input_channels,
                options.mirror_y_error_analog_input_channels,
                ])
        ao_task = nidaqmx.AnalogOutputTask()
        ao_task.create_voltage_channel(ao_channels, 
                                       min_val=-10,
                                       max_val=10,
                                       units='volts')
        ai_task = nidaqmx.AnalogInputTask()
        ai_task.create_voltage_channel(ai_channels, 
                                       terminal = 'nrse',
                                       min_val=-10,
                                       max_val=10,
                                       units='volts')
        self.max_ai_clock_rate = ai_task.get_sample_clock_max_rate ()
        do_task = nidaqmx.DigitalOutputTask()
        do_task.create_channel(options.start_trigger_digital_output_lines,
                               grouping='per_line')
        ao_task.configure_trigger_digital_edge_start (options.start_trigger_terminal,
                                                      edge='rising')
        ai_task.configure_trigger_digital_edge_start (options.start_trigger_terminal,
                                                      edge='rising')


        self.ao_task = ao_task
        self.ai_task = ai_task
        self.do_task = do_task
Ejemplo n.º 2
0
def get_nidaqmx_options_group(parser, group=None):
    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern
    if group is None:
        group = OptionGroup(parser, 'NIDAQmx options')

    phys_channel_choices = []
    if nidaqmx.get_nidaqmx_version() is not None:
        for dev in nidaqmx.System().devices:
            phys_channel_choices.extend(dev.get_digital_input_lines())

    pattern = make_pattern(phys_channel_choices)
    group.add_option('--start-trigger-digital-output-lines',
                     type='string',
                     help='Specify digital lines as a pattern [' + pattern +
                     '].')

    group.add_option('--start-trigger-terminal',
                     type='string',
                     help='Specify digital lines as a pattern [' + pattern +
                     '].')

    phys_channel_choices = []
    if nidaqmx.get_nidaqmx_version() is not None:
        for dev in nidaqmx.System().devices:
            phys_channel_choices.extend(dev.get_analog_output_channels())
    pattern = make_pattern(phys_channel_choices)
    group.add_option('--mirror-x-analog-output-channels',
                     help='Specify physical channel as a pattern [' + pattern +
                     '].')
    group.add_option('--mirror-y-analog-output-channels',
                     help='Specify physical channel as a pattern [' + pattern +
                     '].')

    phys_channel_choices = []
    if nidaqmx.get_nidaqmx_version() is not None:
        for dev in nidaqmx.System().devices:
            phys_channel_choices.extend(dev.get_analog_input_channels())
    pattern = make_pattern(phys_channel_choices)
    #group.add_option ('--mirror-x-analog-input-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    #group.add_option ('--mirror-x-analog-input-2-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    #group.add_option ('--mirror-y-analog-input-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    group.add_option('--mirror-x-error-analog-input-channels',
                     help='Specify physical channel as a pattern [' + pattern +
                     '].')
    #group.add_option ('--mirror-x-error-analog-input-2-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    group.add_option('--mirror-y-error-analog-input-channels',
                     help='Specify physical channel as a pattern [' + pattern +
                     '].')

    return group
Ejemplo n.º 3
0
def get_nidaqmx_options_group(parser, group=None):
    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern
    if group is None:
        group = OptionGroup(parser, 'NIDAQmx options')

    phys_channel_choices = []
    if nidaqmx.get_nidaqmx_version() is not None:
        for dev in nidaqmx.System().devices:
            phys_channel_choices.extend(dev.get_digital_input_lines())

    pattern = make_pattern(phys_channel_choices)
    group.add_option ('--start-trigger-digital-output-lines',
                       type = 'string',
                       help = 'Specify digital lines as a pattern ['+pattern+'].')

    group.add_option ('--start-trigger-terminal',
                       type = 'string',
                       help = 'Specify digital lines as a pattern ['+pattern+'].')

    phys_channel_choices = []
    if nidaqmx.get_nidaqmx_version() is not None:
        for dev in nidaqmx.System().devices:
            phys_channel_choices.extend(dev.get_analog_output_channels())
    pattern = make_pattern(phys_channel_choices)
    group.add_option ('--mirror-x-analog-output-channels',
                       help = 'Specify physical channel as a pattern ['+pattern+'].')
    group.add_option ('--mirror-y-analog-output-channels',
                       help = 'Specify physical channel as a pattern ['+pattern+'].')

    phys_channel_choices = []
    if nidaqmx.get_nidaqmx_version() is not None:
        for dev in nidaqmx.System().devices:
            phys_channel_choices.extend(dev.get_analog_input_channels())
    pattern = make_pattern(phys_channel_choices)
    #group.add_option ('--mirror-x-analog-input-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    #group.add_option ('--mirror-x-analog-input-2-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    #group.add_option ('--mirror-y-analog-input-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    group.add_option ('--mirror-x-error-analog-input-channels',
                       help = 'Specify physical channel as a pattern ['+pattern+'].')
    #group.add_option ('--mirror-x-error-analog-input-2-channels',
    #                   help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    group.add_option ('--mirror-y-error-analog-input-channels',
                       help = 'Specify physical channel as a pattern ['+pattern+'].')

    return group
Ejemplo n.º 4
0
def set_ao_options(parser):
    if os.name == 'posix':
        parser.run_methods = ['subcommand']

    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern

    parser.set_usage('''\
%prog [options]

Description:
  %prog provides graphical interface to NIDAQmx analog output task.
''')
    ao_phys_channel_choices = []
    for dev in nidaqmx.AnalogOutputTask.get_system_devices():
        ao_phys_channel_choices.extend(dev.get_analog_output_channels())
    pattern = make_pattern(ao_phys_channel_choices)
    parser.add_option('--create-voltage-channel-phys-channel',
                      type='string',
                      help='Specify physical channel as a pattern [' +
                      pattern + ']. Default: %default.')
    get_analog_io_options_group(parser, parser, skip_terminal=True)
    get_ao_write_options_group(parser, parser)

    parser.add_option('--ao-task', default='sin', choices=['sin'])
    parser.add_option('--ao-task-duration', type='float', default=10.0)
    parser.add_option_group(get_configure_timing_options_group(parser))
Ejemplo n.º 5
0
def set_ai_options(parser):
    if os.name == 'posix':
        parser.run_methods = ['subcommand']

    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern
    parser.set_usage('''\
%prog [options]

Description:
  %prog provides graphical interface to NIDAQmx analog input task.
''')
    ai_phys_channel_choices = []
    for dev in nidaqmx.AnalogInputTask.get_system_devices():
        ai_phys_channel_choices.extend(dev.get_analog_input_channels())
    pattern = make_pattern(ai_phys_channel_choices)
    parser.add_option('--create-voltage-channel-phys-channel',
                      type='string',
                      help='Specify physical channel as a pattern [' +
                      pattern + ']. Default: %default.')
    get_analog_io_options_group(parser, parser)
    get_ai_read_options_group(parser, parser)
    parser.add_option('--ai-task',
                      default='print',
                      choices=['print', 'plot', 'show'])
    parser.add_option_group(get_configure_timing_options_group(parser))
Ejemplo n.º 6
0
def set_do_options(parser):
    if os.name == 'posix':
        parser.run_methods = ['subcommand']

    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern
    parser.set_usage('''\
%prog [options]

Description:
  %prog provides graphical interface to NIDAQmx digital output task.
''')
    phys_channel_choices = []
    for dev in nidaqmx.DigitalOutputTask.get_system_devices():
        phys_channel_choices.extend(dev.get_digital_output_lines())
    pattern = make_pattern(phys_channel_choices)
    parser.add_option('--create-channel-lines',
                      type='string',
                      help='Specify digital lines as a pattern [' + pattern +
                      ']. Default: %default.')
    get_digital_io_options_group(parser, parser)
    get_do_write_options_group(parser, parser)
    parser.add_option('--do-task',
                      default='scalar1',
                      choices=['scalar1', 'scalar0', 'ten', 'tenfive'])
    parser.add_option('--do-task-duration', type='float', default=60.0)
Ejemplo n.º 7
0
def set_ao_options (parser):
    if os.name == 'posix':
        parser.run_methods = ['subcommand']

    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern

    parser.set_usage ('''\
%prog [options]

Description:
  %prog provides graphical interface to NIDAQmx analog output task.
''')
    ao_phys_channel_choices = []
    for dev in nidaqmx.AnalogOutputTask.get_system_devices():
        ao_phys_channel_choices.extend(dev.get_analog_output_channels())
    pattern = make_pattern(ao_phys_channel_choices)
    parser.add_option ('--create-voltage-channel-phys-channel',
                       type = 'string',
                       help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    get_analog_io_options_group(parser, parser, skip_terminal=True)
    get_ao_write_options_group (parser, parser)

    parser.add_option('--ao-task',
                      default = 'sin',
                      choices = ['sin'])
    parser.add_option ('--ao-task-duration',
                       type = 'float',
                       default = 10.0)
    parser.add_option_group (get_configure_timing_options_group (parser))
Ejemplo n.º 8
0
def set_ai_options (parser):
    if os.name == 'posix':
        parser.run_methods = ['subcommand']

    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern
    parser.set_usage ('''\
%prog [options]

Description:
  %prog provides graphical interface to NIDAQmx analog input task.
''')
    ai_phys_channel_choices = []
    for dev in nidaqmx.AnalogInputTask.get_system_devices():
        ai_phys_channel_choices.extend(dev.get_analog_input_channels())
    pattern = make_pattern(ai_phys_channel_choices)
    parser.add_option ('--create-voltage-channel-phys-channel',
                       type = 'string',
                       help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.')
    get_analog_io_options_group (parser, parser)
    get_ai_read_options_group (parser, parser)
    parser.add_option('--ai-task',
                      default = 'print',
                      choices = ['print', 'plot', 'show'])
    parser.add_option_group (get_configure_timing_options_group (parser))
Ejemplo n.º 9
0
def set_do_options (parser):
    if os.name == 'posix':
        parser.run_methods = ['subcommand']

    import nidaqmx
    from nidaqmx.libnidaqmx import make_pattern
    parser.set_usage ('''\
%prog [options]

Description:
  %prog provides graphical interface to NIDAQmx digital output task.
''')
    phys_channel_choices = []
    for dev in nidaqmx.DigitalOutputTask.get_system_devices():
        phys_channel_choices.extend(dev.get_digital_output_lines())
    pattern = make_pattern(phys_channel_choices)
    parser.add_option ('--create-channel-lines',
                       type = 'string',
                       help = 'Specify digital lines as a pattern ['+pattern+']. Default: %default.')
    get_digital_io_options_group (parser, parser)
    get_do_write_options_group (parser, parser)
    parser.add_option('--do-task', default = 'scalar1', choices = ['scalar1', 'scalar0', 'ten', 'tenfive'])
    parser.add_option ('--do-task-duration',
                       type = 'float',
                       default = 60.0)
Ejemplo n.º 10
0
        plt.draw()
        plt.show()
        return
    if options.task == 'measure':
        import nidaqmx
        from nidaqmx.libnidaqmx import make_pattern

        vx_target = mirror.vx_t_array()
        vy_target = mirror.vy_t_array()
        i_target = mirror.i_t_array()
        j_target = mirror.j_t_array()

        mirror.set_params(**mirror_params)

        ao_channels = make_pattern([
            options.mirror_x_analog_output_channels,
            options.mirror_y_analog_output_channels,
        ])
        ai_channels = make_pattern([
            options.mirror_x_error_analog_input_channels,
            options.mirror_y_error_analog_input_channels,
        ])

        ao_task = nidaqmx.AnalogOutputTask()
        print 'Creating AO voltage channel:', ao_channels
        ao_task.create_voltage_channel(ao_channels,
                                       min_val=-10,
                                       max_val=10,
                                       units='volts')
        ao_task.configure_timing_sample_clock(
            rate=clock_rate,
            active_edge='rising',
Ejemplo n.º 11
0
        plt.draw()
        plt.show()
        return
    if options.task=='measure':
        import nidaqmx
        from nidaqmx.libnidaqmx import make_pattern

        vx_target = mirror.vx_t_array()
        vy_target = mirror.vy_t_array()
        i_target = mirror.i_t_array()
        j_target = mirror.j_t_array()

        mirror.set_params(**mirror_params)
        
        ao_channels = make_pattern([
                options.mirror_x_analog_output_channels,
                options.mirror_y_analog_output_channels,
                ])
        ai_channels = make_pattern([
                options.mirror_x_error_analog_input_channels,
                options.mirror_y_error_analog_input_channels,
                ])

        ao_task = nidaqmx.AnalogOutputTask()
        print 'Creating AO voltage channel:', ao_channels
        ao_task.create_voltage_channel(ao_channels, 
                                       min_val=-10,
                                       max_val=10,
                                       units='volts')
        ao_task.configure_timing_sample_clock(rate = clock_rate,
                                              active_edge = 'rising',
                                              sample_mode = 'finite',