Exemplo n.º 1
0
def main(device):
    '''
    This demonstrates the basic Engine interface that we will be using to
    communicate with the DAQ hardware. A subclass of the Engine will implement
    NI hardware-specific logic.  Another subclass will implement MCC
    (TBSI)-specific logic. This enables us to write code that does not care
    whether it's communicating with a NI or MCC device.
    '''
    def ao_callback(names, offset, samples):
        print('{} samples needed at {} for {}'.format(samples, offset, names))
        engine.write_hw_ao(np.zeros(samples))

    def ai_callback(names, data):
        print('{} samples acquired from {}'.format(data.shape[-1], names))

    def et_callback(change, line, event_time):
        print('{} edge on {} at {}'.format(change, line, event_time))
        queue.put((event_time - 100, 100))

    def ai_epoch_callback(names, start, duration, data):
        print('Epoch {} acquired with {} samples from {}' \
              .format(start, data.shape, names))

    queue = Queue.Queue()
    engine = Engine()

    # Set the polling interval to a high value to minimize clutter on the scren.
    engine.hw_ao_monitor_period = 5
    engine.hw_ai_monitor_period = 5
    engine.configure_hw_ai(1e3,
                           '/{}/ai0:2'.format(device), (-10, 10),
                           sync_ao=False)
    engine.configure_hw_ao(1e3, '/{}/ao0'.format(device), (-10, 10))
    engine.configure_et('/{}/port0/line0:7'.format(device), 'ao/SampleClock')

    engine.register_ao_callback(ao_callback)
    engine.register_ai_callback(ai_callback)
    engine.register_et_callback(et_callback)
    engine.register_ai_epoch_callback(ai_epoch_callback, queue)

    queue.put((0, 100))
    queue.put((15, 100))
    queue.put((55, 100))

    engine.start()
    raw_input('Demo running. Hit enter to exit.\n')
Exemplo n.º 2
0
def main(device):
    '''
    This demonstrates the basic Engine interface that we will be using to
    communicate with the DAQ hardware. A subclass of the Engine will implement
    NI hardware-specific logic.  Another subclass will implement MCC
    (TBSI)-specific logic. This enables us to write code that does not care
    whether it's communicating with a NI or MCC device.
    '''
    def ao_callback(names, offset, samples):
        print('{} samples needed at {} for {}'.format(samples, offset, names))
        engine.write_hw_ao(np.zeros(samples))

    def ai_callback(names, data):
        print('{} samples acquired from {}'.format(data.shape[-1], names))

    def et_callback(change, line, event_time):
        print('{} edge on {} at {}'.format(change, line, event_time))
        queue.put((event_time-100, 100))

    def ai_epoch_callback(names, start, duration, data):
        print('Epoch {} acquired with {} samples from {}' \
              .format(start, data.shape, names))

    queue = Queue.Queue()
    engine = Engine()

    # Set the polling interval to a high value to minimize clutter on the scren.
    engine.hw_ao_monitor_period = 5
    engine.hw_ai_monitor_period = 5
    engine.configure_hw_ai(1e3, '/{}/ai0:2'.format(device), (-10, 10),
                           sync_ao=False)
    engine.configure_hw_ao(1e3, '/{}/ao0'.format(device), (-10, 10))
    engine.configure_et('/{}/port0/line0:7'.format(device), 'ao/SampleClock')

    engine.register_ao_callback(ao_callback)
    engine.register_ai_callback(ai_callback)
    engine.register_et_callback(et_callback)
    engine.register_ai_epoch_callback(ai_epoch_callback, queue)

    queue.put((0, 100))
    queue.put((15, 100))
    queue.put((55, 100))

    engine.start()
    raw_input('Demo running. Hit enter to exit.\n')
Exemplo n.º 3
0
def main(device):
    '''
    Demonstrates detection of changes on lines configured for hardware-timed
    digital input.
    '''
    def di_callback(names, data):
        print('{} samples from {}'.format(data.shape, names))

    def change_callback(name, change, event_time):
        print('{} edge on {} at {}'.format(change, name, event_time))

    engine = Engine()
    engine.hw_ai_monitor_period = 1
    engine.configure_hw_di(100, '/{}/port0/line0:1'.format(device),
                           names=['poke', 'spout'],
                           clock='/Dev1/Ctr0')
    engine.register_di_callback(di_callback)
    engine.register_di_change_callback(change_callback, debounce=10)
    engine.start()
    raw_input('Demo running. Hit enter to exit.\n')
Exemplo n.º 4
0
def main(device):
    '''
    Demonstrates detection of changes on lines configured for hardware-timed
    digital input.
    '''
    def di_callback(names, data):
        print('{} samples from {}'.format(data.shape, names))

    def change_callback(name, change, event_time):
        print('{} edge on {} at {}'.format(change, name, event_time))

    engine = Engine()
    engine.hw_ai_monitor_period = 1
    engine.configure_hw_di(100,
                           '/{}/port0/line0:1'.format(device),
                           names=['poke', 'spout'],
                           clock='/Dev1/Ctr0')
    engine.register_di_callback(di_callback)
    engine.register_di_change_callback(change_callback, debounce=10)
    engine.start()
    raw_input('Demo running. Hit enter to exit.\n')