nidaqmx.task.in_stream
- class nidaqmx._task_modules.in_stream.InStream(task)[source]
Bases:
object
Exposes an input data stream on a DAQmx task.
The input data stream be used to control reading behavior and can be used in conjunction with reader classes to read samples from an NI-DAQmx task.
- property accessory_insertion_or_removal_detected
Indicates if any device(s) 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 DAQmx Read automatically starts the task if you did not start the task explicitly by using DAQmx Start. The default value is True. When DAQmx Read starts a finite acquisition task, it also stops the task after reading the last sample.
- Type
bool
- property aux_power_error_chans
Indicates a list of names of any virtual channels in the task for which an auxiliary power supply error condition has been detected. You must read the Aux Power Error Channels Exist property before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property aux_power_error_chans_exist
Indicates if the device(s) detected an auxiliary power supply error condition for any channel in the task. Reading this property clears the error condition status for all channels in the task. You must read this property before you read the Aux Power Error Channels property. Otherwise, you will receive an error.
- Type
bool
- property avail_samp_per_chan
Indicates the number of samples available to read per channel. This value is the same for all channels in the task.
- Type
int
- property change_detect_overflowed
Indicates if samples were missed because change detection events occurred faster than the device could handle them. Some devices detect overflows differently than others.
- Type
bool
- property channels_to_read
nidaqmx._task_modules.channels.channel.Channel
: Specifies a subset of channels in the task from which to read.
- property common_mode_range_error_chans
Indicates a list of names of any virtual channels in the task for which the device(s) detected a common mode range violation. You must read common_mode_range_error_chans_exist before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property common_mode_range_error_chans_exist
Indicates if the device(s) detected a common mode range violation for any virtual channel in the task. Common mode range violation occurs when the voltage of either the positive terminal or negative terminal to ground are out of range. Reading this property clears the common mode range violation status for all channels in the task. You must read this property before you read common_mode_range_error_chans. Otherwise, you will receive an error.
- Type
bool
- configure_logging(file_path, logging_mode=LoggingMode.LOG_AND_READ, group_name='', operation=LoggingOperation.OPEN_OR_CREATE)[source]
Configures TDMS file logging for the task.
- Parameters
file_path (str) – Specifies the path to the TDMS file to which you want to log data.
logging_mode (Optional[nidaqmx.constants.LoggingMode]) – Specifies whether to enable logging and whether to allow reading data while logging. “log” mode allows for the best performance. However, you cannot read data while logging if you specify this mode. If you want to read data while logging, specify “LOG_AND_READ” mode.
group_name (Optional[str]) – Specifies the name of the group to create within the TDMS file for data from this task. If you append data to an existing file and the specified group already exists, NI-DAQmx appends a number symbol and a number to the group name, incrementing that number until finding a group name that does not exist. For example, if you specify a group name of Voltage Task, and that group already exists, NI-DAQmx assigns the group name Voltage Task #1, then Voltage Task #2. If you do not specify a group name, NI-DAQmx uses the name of the task.
operation (Optional[nidaqmx.constants.LoggingOperation]) – Specifies how to open the TDMS file.
- property curr_read_pos
Indicates in samples per channel the current position in the buffer.
- Type
long
- 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 di_num_booleans_per_chan
Indicates the number of booleans per channel that NI-DAQmx returns in a sample for line-based reads. If a channel has fewer lines than this number, the extra booleans are False.
- Type
int
- property excit_fault_chans
Indicates a list of names of any virtual channels in the task for which the device(s) detected an excitation fault condition. You must read excit_fault_chans_exist before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property excit_fault_chans_exist
Indicates if the device(s) detected an excitation fault condition for any virtual channel in the task. Reading this property clears the excitation fault status for all channels in the task. You must read this property before you read excit_fault_chans. Otherwise, you will receive an error.
- Type
bool
- property input_buf_size
Specifies the number of samples the input 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 input buffer allocation that NI- DAQmx performs.
- Type
int
- property input_limits_fault_chans
Indicates the virtual channels that have detected samples outside the upper or lower limits configured for each channel in the task. You must read input_limits_fault_chans_exist before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property input_limits_fault_chans_exist
Indicates if the device or devices detected a sample that was outside the upper or lower limits configured for each channel in the task. Reading this property clears the input limits fault channel status for all channels in the task. You must read this property before you read input_limits_fault_chans. Otherwise, you will receive an error. Note: Fault detection applies to both positive and negative inputs. For instance, if you specify a lower limit of 2 mA and an upper limit of 12 mA, NI-DAQmx detects a fault at 15 mA and -15 mA, but not at -6 mA because it is in the range of -12 mA to -2 mA.
- Type
bool
- property input_onbrd_buf_size
Indicates in samples per channel the size of the onboard input buffer of the device.
- Type
int
- property logging_file_path
Specifies the path to the TDMS file to which you want to log data. If the file path is changed while the task is running, this takes effect on the next sample interval (if Logging.SampsPerFile has been set) or when DAQmx Start New File is called. New file paths can be specified by ending with “" or “/”. Files created after specifying a new file path retain the same name and numbering sequence.
- Type
str
- property logging_file_preallocation_size
Specifies a size in samples to be used to pre-allocate space on disk. Pre-allocation can improve file I/O performance, especially in situations where multiple files are being written to disk. For finite tasks, the default behavior is to pre-allocate the file based on the number of samples you configure the task to acquire.
- Type
long
- property logging_file_write_size
Specifies the size, in samples, in which data will be written to disk. The size must be evenly divisible by the volume sector size, in bytes.
- Type
int
- property logging_mode
Specifies whether to enable logging and whether to allow reading data while logging. Log mode allows for the best performance. However, you cannot read data while logging if you specify this mode. If you want to read data while logging, specify Log and Read mode.
- property logging_pause
Specifies whether logging is paused while a task is executing. If logging_mode is set to Log and Read mode, this value is taken into consideration on the next call to DAQmx Read, where data is written to disk. If logging_mode is set to Log Only mode, this value is taken into consideration the next time that data is written to disk. A new TDMS group is written when logging is resumed from a paused state.
- Type
bool
- property logging_samps_per_file
Specifies how many samples to write to each file. When the file reaches the number of samples specified, a new file is created with the naming convention of <filename>_####.tdms, where #### starts at 0001 and increments automatically with each new file. For example, if the file specified is C:data.tdms, the next file name used is C:data_0001.tdms. To disable file spanning behavior, set this attribute to 0. If logging_file_path is changed while this attribute is set, the new file path takes effect on the next file created.
- Type
long
- property logging_tdms_group_name
Specifies the name of the group to create within the TDMS file for data from this task. If you append data to an existing file and the specified group already exists, NI- DAQmx appends a number symbol and a number to the group name, incrementing that number until finding a group name that does not exist. For example, if you specify a group name of Voltage Task, and that group already exists, NI- DAQmx assigns the group name Voltage Task #1, then Voltage Task #2.
- Type
str
- property logging_tdms_operation
Specifies how to open the TDMS file.
- property num_chans
Indicates the number of channels that DAQmx Read reads from the task. This value is the number of channels in the task or the number of channels you specify with channels_to_read.
- Type
int
- property offset
Specifies an offset in samples per channel at which to begin a read operation. This offset is relative to the location you specify with relative_to.
- Type
int
- property open_chans
Indicates a list of names of any open virtual channels. You must read open_chans_exist before you read this property. Otherwise you will receive an error.
- Type
List[str]
- property open_chans_details
Indicates a list of details of any open virtual channels. You must read open_chans_exist before you read this property. Otherwise you will receive an error.
- Type
List[str]
- property open_chans_exist
Indicates if the device or devices detected an open channel condition in any virtual channel in the task. Reading this property clears the open channel status for all channels in this task. You must read this property before you read open_chans. Otherwise, you will receive an error.
- Type
bool
- 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 virtual 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 open_thrmcpl_chans
Indicates a list of names of any virtual channels in the task for which the device(s) detected an open thermcouple. You must read open_thrmcpl_chans_exist before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property open_thrmcpl_chans_exist
Indicates if the device(s) detected an open thermocouple connected to any virtual channel in the task. Reading this property clears the open thermocouple status for all channels in the task. You must read this property before you read open_thrmcpl_chans. Otherwise, you will receive an error.
- Type
bool
- property over_write
Specifies whether to overwrite samples in the buffer that you have not yet read.
- property overcurrent_chans
Indicates a list of names of any virtual channels in the task for which the device(s) detected an overcurrent condition. You must read overcurrent_chans_exist before you read this property. Otherwise, you will receive an error. On some devices, you must restart the task for all overcurrent channels to recover.
- Type
List[str]
- property overcurrent_chans_exist
Indicates if the device(s) detected an overcurrent condition for any virtual 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.
- 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 pll_unlocked_chans
Indicates the channels that had their PLLs unlock.
- Type
List[str]
- property pll_unlocked_chans_exist
Indicates whether the PLL is currently locked, or whether it became unlocked during the previous acquisition. Devices may report PLL Unlock either during acquisition or after acquisition.
- Type
bool
- property power_supply_fault_chans
Indicates the virtual channels that have detected 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 or devices detected a power supply fault condition in any virtual channel in the task. Reading this property clears the power supply fault status for all channels in this 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 size of a raw sample from the task.
- Type
int
- read(number_of_samples_per_channel=- 1)[source]
Reads raw samples from the task or virtual channels you specify.
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.
NI-DAQmx does not separate raw data into channels. It returns 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.
This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.
Use the “timeout” property on the stream to specify the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. 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 read the requested samples and returns an error if it is unable to.
- Parameters
number_of_samples_per_channel (int) –
Specifies the number of samples to read.
If you set this input to nidaqmx.READ_ALL_AVAILABLE, NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples.
If the task acquires samples continuously and you set this input to nidaqmx.READ_ALL_AVAILABLE, this method reads all the samples currently available in the buffer.
If the task acquires a finite number of samples and you set this input to nidaqmx.READ_ALL_AVAILABLE, the method waits for the task to acquire all requested samples, then reads those samples. If you set the “read_all_avail_samp” property to TRUE, the method reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.
- Returns
The samples requested in the form of a 1D NumPy array. This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.
- Return type
numpy.ndarray
- property read_all_avail_samp
Specifies whether subsequent read operations read all samples currently available in the buffer or wait for the buffer to become full before reading. NI-DAQmx uses this setting for finite acquisitions and only when the number of samples to read is -1. For continuous acquisitions when the number of samples to read is -1, a read operation always reads all samples currently available in the buffer.
- Type
bool
- readall()[source]
Reads all available raw samples from the task or virtual channels you specify.
NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples.
If the task acquires samples continuously, this method reads all the samples currently available in the buffer.
If the task acquires a finite number of samples, the method waits for the task to acquire all requested samples, then reads those samples. If you set the “read_all_avail_samp” property to TRUE, the method reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.
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.
NI-DAQmx does not separate raw data into channels. It returns 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.
This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.
Use the “timeout” property on the stream to specify the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. 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 read the requested samples and returns an error if it is unable to.
- Returns
The samples requested in the form of a 1D NumPy array. This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.
- Return type
numpy.ndarray
- readinto(numpy_array)[source]
Reads raw samples from the task or virtual channels you specify into numpy_array.
The object numpy_array should be a pre-allocated, writable 1D numpy array.
The number of samples per channel to read is determined using the following equation:
- number_of_samples_per_channel = math.floor(
- numpy_array_size_in_bytes / (
number_of_channels_to_read * 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 returns 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.
Use the “timeout” property on the stream to specify the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to -1, the method waits indefinitely. If you set timeout to 0, the method tries once to read the requested samples and returns an error if it is unable to.
- Parameters
numpy_array – Specifies the 1D NumPy array object into which the samples requested are read.
- Returns
Indicates the total number of samples read.
- Return type
int
- property relative_to
Specifies the point in the buffer at which to begin a read operation. If you also specify an offset with offset, the read operation begins at that offset relative to the point you select with this property. The default value is ReadRelativeTo.CURRENT_READ_POSITION unless you configure a Reference Trigger for the task. If you configure a Reference Trigger, the default value is ReadRelativeTo.FIRST_PRETRIGGER_SAMPLE.
- property remote_sense_error_chans
Indicates a list of names of any virtual channels in the task for which a remote sense connection error condition has been detected. You must read Remote Sense Error Channels Exist before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property remote_sense_error_chans_exist
Indicates if the device(s) detected an error condition of the remote sense connection for any channel in the task. You must disable the output and resolve the hardware connection issue to clear the error condition. You must read this property before you read the Remote Sense Error Channels property. Otherwise, you will receive an error.
- Type
bool
- property reverse_voltage_error_chans
Indicates a list of names of any virtual channels in the task for which reverse voltage error condition has been detected. You must read the Reverse Voltage Error Channels Exist property before you read this property. Otherwise, you will receive an error.
- Type
List[str]
- property reverse_voltage_error_chans_exist
Indicates if the device(s) detected reverse voltage error for any channel in the task. Reverse voltage error will occured if the local voltage is equal to negative saturated voltage. Reading this property clears the error condition status for all channels in the task. You must read this property before you read the Reverse Voltage Error Channels property. Otherwise, you will receive an error.
- Type
bool
- property sleep_time
Specifies in seconds the amount of time to sleep after checking for available samples if wait_mode is WaitMode.SLEEP.
- Type
float
- start_new_file(file_path)[source]
Starts a new TDMS file the next time data is written to disk.
- Parameters
file_path (str) – Specifies the path to the TDMS file to which you want to log data.
- 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 samples to become available. If the time elapses, the read method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to nidaqmx.WAIT_INFINITELY, the read method waits indefinitely. If you set timeout to 0, the read method tries once to read the requested samples and returns an error if it is unable to.
- Type
float
- property total_samp_per_chan_acquired
Indicates the total number of samples acquired by each channel. NI-DAQmx returns a single value because this value is the same for all channels. For retriggered acquisitions, this value is the cumulative number of samples across all retriggered acquisitions.
- Type
long
- property wait_mode
Specifies how DAQmx Read waits for samples to become available.