Skip to content

CREATE_TASK

Download Flojoy Studio to try this app
Creates a task **Compatibility:** Compatible with National Instruments devices that utilize NI-DAQmx. This block is designed for use with Windows and Linux systems due to NI driver availability. Ensure you have installed the NI-DAQmx runtime from https://www.ni.com/en/support/downloads/drivers/download.ni-daq-mx.html. Params: task_name : str The name of the task to create. Returns: out : Optional[DataContainer] This block does not return any meaningful data;
Python Code
from flojoy import flojoy, DataContainer, DeviceConnectionManager, HardwareDevice
from typing import Optional
import nidaqmx


@flojoy(deps={"nidaqmx": "0.9.0"})
def CREATE_TASK(
    task_name: str,
    default: Optional[DataContainer] = None,
) -> Optional[DataContainer]:
    """Creates a task

    **Compatibility:**
    Compatible with National Instruments devices that utilize NI-DAQmx.

    This block is designed for use with Windows and Linux systems due to NI driver availability. Ensure you have installed the NI-DAQmx runtime from https://www.ni.com/en/support/downloads/drivers/download.ni-daq-mx.html.

    Parameters
    ----------
    task_name : str
        The name of the task to create.

    Returns
    -------
    Optional[DataContainer]
        This block does not return any meaningful data;
    """

    assert (
        task_name not in DeviceConnectionManager.handles
    ), f"Task {task_name} already exists"
    assert task_name != "" and task_name is not None, "Task name cannot be empty"

    task = nidaqmx.Task(new_task_name=task_name)
    DeviceConnectionManager.register_connection(
        HardwareDevice(task_name), task, lambda task: task.close()
    )

Find this Flojoy Block on GitHub

Example App

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

This app shows how to use input stream blocks for with National Instruments Compact DAQ module.

Blocks used:

  • CREATE_TASK_ANALOG_INPUT_CURRENT
  • CONFIG_INPUT_STREAM
  • READ_INPUT_STREAM
  • READ_INPUT_STREAM_INTO_BUFFER
  • 2x LINE
  • PRINT_DATACONTAINER
  • TEXT_VIEW
  • TIMER
  • LOOP

The blocks were connected as shown, and the app was run. The result displayed the first 100 samples from an analog module in the first plot and constantly updated the second plot with the latest data from the device buffer.