簡體   English   中英

nidaqmx:訪問現有任務

[英]nidaqmx: Access an existing task

我正在使用nidaqmx-python庫獲取數據。 是否可以訪問NI MAX中已定義的現有任務?

由於@nekomatic的提示,我的解決方案是:

import nidaqmx

system = nidaqmx.system.System.local()  # load local system

task_names = system.tasks.task_names  # returns a list of task names

task = system.tasks[0]  # selected the first task
loaded_task = task.load()  # load the task

sent_samples = []  # list for saving acquired data

with loaded_task:
    loaded_task.timing.cfg_samp_clk_timing(
        rate=2560, 
        sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS, 
        samps_per_chan=1000)

    def callback(task_handle, every_n_samples_event_type,
                 number_of_samples, callback_data):
        """
        Callback function/
        """
        print('Every N Samples callback invoked.')

        samples = loaded_task.read(number_of_samples_per_channel=2560)
        sent_samples.extend(samples)

        return 0

    loaded_task.register_every_n_samples_acquired_into_buffer_event(
        200, callback)

    loaded_task.start()

    input('Running task. Press Enter to stop.\n')    

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM