nidaqmx.task.out_stream

class nidaqmx._task_modules.out_stream.OutStream(task, interpreter)[source]

Bases: object

Exposes an output data stream on a DAQmx task.

The output data stream be used to control writing behavior and can be used in conjunction with writer classes to write samples to an NI-DAQmx task.

property accessory_insertion_or_removal_detected

Indicates if any devices in the task detected the insertion or removal of an accessory since the task started. Reading this property clears the accessory change status for all channels in the task. You must read this property before you read devs_with_inserted_or_removed_accessories. Otherwise, you will receive an error.

Type

bool

property auto_start

Specifies if the “write” method automatically starts the stream’s owning task if you did not explicitly start it with the DAQmx Start Task method.

Type

bool

property curr_write_pos

Indicates the position in the buffer of the next sample to generate. This value is identical for all channels in the task.

Type

int

property devs_with_inserted_or_removed_accessories

Indicates the names of any devices that detected the insertion or removal of an accessory since the task started. You must read accessory_insertion_or_removal_detected before you read this property. Otherwise, you will receive an error.

Type

List[str]

property do_num_booleans_per_chan

Indicates the number of Boolean values expected per channel in a sample for line-based writes. This property is determined by the channel in the task with the most digital lines. If a channel has fewer lines than this number, NI- DAQmx ignores the extra Boolean values.

Type

int

property external_overvoltage_chans

Indicates a list of names of any virtual channels in the task for which an External Overvoltage condition has been detected. You must read External OvervoltageChansExist before you read this property. Otherwise, you will receive an error.

Type

List[str]

property external_overvoltage_chans_exist

Indicates if the device(s) detected an External Overvoltage condition for any channel in the task. Reading this property clears the External Overvoltage status for all channels in the task. You must read this property before you read External OvervoltageChans. Otherwise, you will receive an error.

Type

bool

property num_chans

Indicates the number of channels that DAQmx Write writes to the task. This value is the number of channels in the task.

Type

int

property offset

Specifies in samples per channel an offset at which a write operation begins. This offset is relative to the location you specify with relative_to.

Type

int

property open_current_loop_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected an open current loop. You must read open_current_loop_chans_exist before you read this property. Otherwise, you will receive an error.

Type

List[str]

property open_current_loop_chans_exist

Indicates if the device(s) detected an open current loop for any channel in the task. Reading this property clears the open current loop status for all channels in the task. You must read this property before you read open_current_loop_chans. Otherwise, you will receive an error.

Type

bool

property output_buf_size

Specifies the number of samples the output buffer can hold for each channel in the task. Zero indicates to allocate no buffer. Use a buffer size of 0 to perform a hardware-timed operation without using a buffer. Setting this property overrides the automatic output buffer allocation that NI- DAQmx performs.

Type

int

property output_onbrd_buf_size

Specifies in samples per channel the size of the onboard output buffer of the device.

Type

int

property overcurrent_chans

Indicates a list of names of any virtual channels in the task for which an overcurrent condition has been detected. You must read overcurrent_chans_exist before you read this property. Otherwise, you will receive an error.

Type

List[str]

property overcurrent_chans_exist

Indicates if the device(s) detected an overcurrent condition for any channel in the task. Reading this property clears the overcurrent status for all channels in the task. You must read this property before you read overcurrent_chans. Otherwise, you will receive an error.

Type

bool

property overloaded_chans

Indicates a list of names of any overloaded virtual channels in the task. You must read overloaded_chans_exist before you read this property. Otherwise, you will receive an error.

Type

List[str]

property overloaded_chans_exist

Indicates if the device(s) detected an overload in any virtual channel in the task. Reading this property clears the overload status for all channels in the task. You must read this property before you read overloaded_chans. Otherwise, you will receive an error.

Type

bool

property overtemperature_chans

Indicates a list of names of any overtemperature virtual channels. You must read overtemperature_chans_exist before you read this property. Otherwise, you will receive an error. The list of names may be empty if the device cannot determine the source of the overtemperature.

Type

List[str]

property overtemperature_chans_exist

Indicates if the device(s) detected an overtemperature condition in any virtual channel in the task. Reading this property clears the overtemperature status for all channels in the task. You must read this property before you read overtemperature_chans. Otherwise, you will receive an error.

Type

bool

property power_supply_fault_chans

Indicates a list of names of any virtual channels in the task that have a power supply fault. You must read power_supply_fault_chans_exist before you read this property. Otherwise, you will receive an error.

Type

List[str]

property power_supply_fault_chans_exist

Indicates if the device(s) detected a power supply fault for any channel in the task. Reading this property clears the power supply fault status for all channels in the task. You must read this property before you read power_supply_fault_chans. Otherwise, you will receive an error.

Type

bool

property raw_data_width

Indicates in bytes the required size of a raw sample to write to the task.

Type

int

property regen_mode

Specifies whether to allow NI-DAQmx to generate the same data multiple times.

Type

nidaqmx.constants.RegenerationMode

property relative_to

Specifies the point in the buffer at which to write data. If you also specify an offset with offset, the write operation begins at that offset relative to this point you select with this property.

Type

nidaqmx.constants.WriteRelativeTo

property sleep_time

Specifies in seconds the amount of time to sleep after checking for available buffer space if wait_mode is WaitMode2.SLEEP.

Type

float

property space_avail

Indicates in samples per channel the amount of available space in the buffer.

Type

int

property sync_unlocked_chans

Indicates the channels from devices in an unlocked target.

Type

List[str]

property sync_unlocked_chans_exist

Indicates whether the target is currently locked to the grand master. Devices may report PLL Unlock either during acquisition or after acquisition.

Type

bool

property timeout

Specifies the amount of time in seconds to wait for the write method to write all samples. NI-DAQmx performs a timeout check only if the write method must wait before it writes data. The write method returns an error if the time elapses. The default timeout is 10 seconds. If you set “timeout” to nidaqmx.WAIT_INFINITELY, the write method waits indefinitely. If you set timeout to 0, the write method tries once to write the submitted samples. If the write method could not write all the submitted samples, it returns an error and the number of samples successfully written in the number of samples written per channel output.

Type

float

property total_samp_per_chan_generated

Indicates the total number of samples generated by each channel in the task. This value is identical for all channels in the task.

Type

int

property wait_mode

Specifies how DAQmx Write waits for space to become available in the buffer.

Type

nidaqmx.constants.WaitMode

write(numpy_array)[source]

Writes raw samples to the task or virtual channels you specify.

The number of samples per channel to write is determined using the following equation:

number_of_samples_per_channel = math.floor(
numpy_array_size_in_bytes / (

number_of_channels_to_write * raw_sample_size_in_bytes))

Raw samples constitute the internal representation of samples in a device, read directly from the device or buffer without scaling or reordering. The native format of a device can be an 8-, 16-, or 32-bit integer, signed or unsigned.

If you use a different integer size than the native format of the device, one integer can contain multiple samples or one sample can stretch across multiple integers. For example, if you use 32-bit integers, but the device uses 8-bit samples, one integer contains up to four samples. If you use 8-bit integers, but the device uses 16-bit samples, a sample might require two integers. This behavior varies from device to device. Refer to your device documentation for more information.

NI-DAQmx does not separate raw data into channels. It accepts data in an interleaved or non-interleaved 1D array, depending on the raw ordering of the device. Refer to your device documentation for more information.

If the task uses on-demand timing, this method returns only after the device generates all samples. On-demand is the default timing type if you do not use the timing property on the task to configure a sample timing type. If the task uses any timing type other than on-demand, this method returns immediately and does not wait for the device to generate all samples. Your application must determine if the task is done to ensure that the device generated all samples.

Use the “auto_start” property on the stream to specify if this method automatically starts the stream’s owning task if you did not explicitly start it with the DAQmx Start Task method.

Use the “timeout” property on the stream to specify the amount of time in seconds to wait for the method to write all samples. NI-DAQmx performs a timeout check only if the method must wait before it writes data. This method returns an error if the time elapses. The default timeout is 10 seconds. If you set timeout to nidaqmx.WAIT_INFINITELY, the method waits indefinitely. If you set timeout to 0, the method tries once to write the submitted samples. If the method could not write all the submitted samples, it returns an error and the number of samples successfully written.

Parameters

numpy_array (numpy.ndarray) – Specifies a 1D NumPy array that contains the raw samples to write to the task.

Returns

Specifies the actual number of samples per channel successfully written to the buffer.

Return type

int