Python API Reference¶
The Python API for Linux allows users to communicate and control a Measurement Computing WebDAQ logger using the Python language.
The API provides structures and enumerations to manage connected devices, obtain information about device capabilities, and configure hardware settings. Subsystem methods provide full-functionality for each device type.
Device Discovery¶
The API provides a method that gets a list of available WebDAQ devices connected to the system.
-
get_daq_device_inventory
(interface_type, number_of_devices=100)¶ Gets a list of
DaqDeviceDescriptor
objects that can be used as theDaqDevice
class parameter to create DaqDevice objects.Parameters: - interface_type (InterfaceType) – One or more of the
InterfaceType
attributes (suitable for bit-wise operations) specifying which physical interfaces (such as USB) to search for devices. - number_of_devices (Optional[int]) – Optional parameter indicating the maximum number of devices to return in the list; the default is 100).
Returns: A list of
DaqDeviceDescriptor
objects that describe each of the each of the devices found on the specified interface.Return type: list[DaqDeviceDescriptor]
Raises: - interface_type (InterfaceType) – One or more of the
Device Management¶
The API provides a class to manage devices connected to the system:
DaqDevice class¶
Provides access to available MCC WebDAQ devices for operation, configuration, and retrieving information.
Methods¶
-
class
DaqDevice
(daq_device_descriptor)¶ Creates a
DaqDevice
object based on the daq_device_descriptor (usually obtained usingget_daq_device_inventory()
). The DaqDevice object allows access to all of the classes, methods, and attributes for the associated MCC device.Parameters: daq_device_descriptor (DaqDeviceDescriptor) – The object that describes the DAQ device. Raises: ULException
Method Description get_descriptor()
Returns the DaqDeviceDescriptor for an existing DaqDevice
object.connect()
Establishes a connection to a physical DAQ device referenced by the DaqDevice
object.is_connected()
Gets the connection status of a DAQ device referenced by the DaqDevice
object.disconnect()
Disconnects from the DAQ device referenced by the DaqDevice
object.get_ai_device()
Gets the analog input subsystem object used to access the AI subsystem for the device referenced by the DaqDevice
object.release()
Removes the device referenced by the DaqDevice
object from the Universal Library, and releases all resources associated with that device.-
get_descriptor
()¶ Returns the DaqDeviceDescriptor for an existing
DaqDevice
object.Returns: The object that describes the DAQ device. Return type: DaqDeviceDescriptor Raises: ULException
-
connect
()¶ Establish a connection to a physical DAQ device referenced by the
DaqDevice
object.Raises: ULException
-
is_connected
()¶ Gets the DAQ device connection status for the device referenced by the
DaqDevice
object.Returns: True if the DAQ device is connected, otherwise False. Return type: bool Raises: ULException
-
disconnect
()¶ Disconnects from the DAQ device referenced by the
DaqDevice
object.Raises: ULException
-
get_ai_device
()¶ Gets the analog input subsystem object used to access the AI subsystem for the device referenced by the
DaqDevice
object.Returns: The object used to access the AI subsystem. Return type: AiDevice
-
release
()¶ Removes the device referenced by the
DaqDevice
object from the Universal Library, and releases all resources associated with that device.Raises: ULException
-
Analog Input Subsystem¶
The API provides classes to manage the AI subsystem on a device:
AiDevice class¶
Analog input subsystem of the UL DAQ Device.
Methods¶
-
class
AiDevice
¶ An instance of the AiDevice class is obtained by calling
DaqDevice.get_ai_device()
.Method Description get_config()
Gets the analog input configuration object for the device referenced by the AiDevice
object.a_in_scan()
Scans a range of A/D channels on the device referenced by the AiDevice
object, and stores the samples.a_in_load_queue()
Loads the A/D queue of the device referenced by the AiDevice
object.get_scan_status()
Gets the status, count, and index of an A/D scan operation on the device referenced by the AiDevice
object.scan_stop()
Stops the analog input scan operation currently running on the device referenced by the AiDevice
object.-
get_config
()¶ Gets the analog input configuration object for the device referenced by the
AiDevice
object.Returns: An object used for setting and retrieving the configuration settings for the analog input subsystem of the UL DAQ Device. Return type: AiConfig
-
a_in_scan
(low_channel, high_channel, input_mode, analog_range, samples_per_channel, rate, options, flags, data)¶ Scans a range of A/D channels on the device referenced by the
AiDevice
object, and stores the samples.Parameters: - low_channel (int) – First A/D channel in the scan.
- high_channel (int) – Last A/D channel in the scan.
- input_mode (AiInputMode) – The input mode of the specified channels.
- analog_range (Range) – The range of the data being read.
- samples_per_channel (int) – the number of A/D samples to collect from each channel in the scan.
- rate (float) – A/D sample rate in samples per channel per second.
- options (ScanOption) – One or more of the attributes (suitable for bit-wise operations) specifying the optional conditions that will be applied to the scan, such as continuous or external clock.
- flags (AInScanFlag) – One or more of the attributes (suitable for bit-wise operations) specifying the conditioning applied to the data before it is returned.
- data (Array[float]) – The buffer to receive the data. Use
create_float_buffer
to create the buffer.
Returns: The actual input scan rate of the scan.
Return type: float
Raises:
-
a_in_load_queue
(queue)¶ Loads the A/D queue of the device referenced by the
AiDevice
object.Parameters: queue (list[AiQueueElement]) – A list of AiQueueElement structs, each of which contains fields specifying the channel, range, and mode. Raises: ULException
-
get_scan_status
()¶ Gets the status, count, and index of an A/D scan operation on the device referenced by the
AiDevice
object.Returns: A namedtuple containing the scan status, total sample count, and current buffer index for the analog input background operation. Return type: ScanStatusInfo Raises: ULException
-
scan_stop
()¶ Stops the analog input scan operation currently running on the device referenced by the
AiDevice
object.Raises: ULException
-
AiConfig class¶
Provides information about the configuration of the analog input subsystem.
Methods¶
-
class
AiConfig
¶ Provides information about the configuration of the analog input subsystem.
Parameters: handle – UL DAQ Device handle. Method Description set_chan_type()
Configures the channel type for the specified A/D channel. get_chan_type()
Gets the channel type for the specified A/D channel. set_chan_tc_type()
Configures the thermocouple type for the specified A/D channel. get_chan_tc_type()
Gets the thermocouple type for the specified A/D channel. set_chan_temp_unit()
Configures the temperature unit for the specified A/D channel. get_chan_temp_unit()
Gets the temperature unit for the specified A/D channel. set_auto_zero_mode()
Configures the auto zero mode for the analog input subsystem. get_auto_zero_mode()
Gets the auto zero mode of the analog input subsystem. set_adc_timing_mode()
Configures the A/D converter timing mode for the analog input subsystem. get_adc_timing_mode()
Gets the A/D converter timing mode of the analog input subsystem. set_chan_iepe_mode()
Configures the IEPE mode for the specified A/D channel. get_chan_iepe_mode()
Gets the IEPE mode of the specified A/D channel. set_chan_coupling_mode()
Configures the coupling mode for the specified A/D channel. get_chan_coupling_mode()
Gets the coupling mode of the specified A/D channel. set_chan_sensor_sensitivity()
Configures the sensor sensitivity of the specified A/D channel. get_chan_sensor_sensitivity()
Gets the sensor sensitivity of the specified A/D channel. set_chan_slope()
Configures the slope multiplier for the specified A/D channel. get_chan_slope()
Gets the slope multiplier of the specified A/D channel. set_chan_offset()
Configures the offset value for the specified A/D channel. get_chan_offset()
Gets the offset value of the specified A/D channel. get_cal_date()
Gets the calibration date for the DAQ device. -
set_chan_type
(channel, chan_type)¶ Configures the channel type for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number.
- chan_type (AiChanType) – The channel type to be set.
Raises:
-
get_chan_type
(channel)¶ Gets the channel type for the specified A/D channel.
Parameters: channel (int) – The A/D channel number. Returns: The channel type of the specified channel. Return type: AiChanType Raises: ULException
-
set_chan_tc_type
(channel, tc_type)¶ Configures the thermocouple type for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose thermocouple type is being set.
- tc_type (TcType) – The thermocouple type to set`
Raises:
-
get_chan_tc_type
(channel)¶ Gets the thermocouple type for the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose thermocouple type is being determined. Returns: The thermocouple type of the specified channel. Return type: TcType Raises: ULException
-
set_chan_temp_unit
(channel, temp_unit)¶ Configures the temperature unit for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose temperature unit is being set.
- temp_unit (TempUnit) – The temperature unit to set.
Raises:
-
get_chan_temp_unit
(channel)¶ Get the temperature unit for the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose temperature unit is being determined. Returns: The temperature unit of the specified channel. Return type: TempUnit Raises: ULException
-
set_auto_zero_mode
(mode)¶ Configures the auto zero mode for the analog input subsystem.
Parameters: mode (AutoZeroMode) – The auto zero mode to set. Raises: ULException
-
get_auto_zero_mode
()¶ Gets the auto zero mode of the analog input subsystem.
Returns: The auto zero mode. Return type: AutoZeroMode Raises: ULException
-
set_adc_timing_mode
(mode)¶ Configures the A/D converter timing mode for the analog input subsystem.
Parameters: mode (AdcTimingMode) – The A/D converter timing mode. Raises: ULException
-
get_adc_timing_mode
()¶ Gets the A/D converter timing mode of the analog input subsystem.
Returns: The A/D converter timing mode. Return type: AdcTimingMode Raises: ULException
-
set_chan_iepe_mode
(channel, mode)¶ Configures the IEPE mode for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose IEPE mode is being set.
- mode (IepeMode) – The IEPE mode to set.
Raises:
-
get_chan_iepe_mode
(channel)¶ Gets the IEPE mode of the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose IEPE mode is being determined. Returns: The IEPE mode of the specified channel. Return type: IepeMode Raises: ULException
-
set_chan_coupling_mode
(channel, mode)¶ Configures the coupling mode for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose coupling mode is being set.
- mode (CouplingMode) – The coupling mode to set.
Raises:
-
get_chan_coupling_mode
(channel)¶ Gets the coupling mode of the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose coupling mode is being determined. Returns: The coupling mode of the specified channel. Return type: CouplingMode Raises: ULException
-
set_chan_sensor_sensitivity
(channel, sensitivity)¶ Configures the sensor sensitivity for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose sensor sensitivity is being set.
- sensitivity (float) – The sensor sensitivity to set in V/unit.
Raises:
-
get_chan_sensor_sensitivity
(channel)¶ Gets the sensor sensitivity for the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose sensor sensitivity is being determined. Returns: The sensor sensitivity of the specified channel. Return type: float Raises: ULException
-
set_chan_slope
(channel, slope)¶ Configures the slope multiplier for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose slope is being set.
- slope (float) – The slope multiplier value to set.
Raises:
-
get_chan_slope
(channel)¶ Gets the slope multiplier of the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose slope is being determined. Returns: The slope multiplier of the specified A/D channel. Return type: float Raises: ULException
-
set_chan_offset
(channel, offset)¶ Sets the offset value for the specified A/D channel.
Parameters: - channel (int) – The A/D channel number whose offset is being set.
- offset (float) – The offset value to set.
Raises:
-
get_chan_offset
(channel)¶ Gets the offset value of the specified A/D channel.
Parameters: channel (int) – The A/D channel number whose offset is being determined. Returns: The offset of the specified A/D channel. Return type: float Raises: ULException
-
get_cal_date
()¶ Gets the calibration date for the DAQ device.
Returns: An integer containing the calibration date for the DAQ device in UNIX Epoch time. Return type: int Raises: ULException
-
Global Methods¶
Buffer Management¶
Provides a method to allocate buffers for data storage:
Method Description create_float_buffer()
Creates a buffer for double precision floating point sample values.
-
create_float_buffer
(number_of_channels, samples_per_channel)¶ Create a buffer for double precision floating point sample values.
Parameters: - number_of_channels (int) – Number of channels in the scan.
- samples_per_channel (int) – Number samples per channel to be stored in the buffer.
Returns: An array of size number_of_channels * samples_per_channel
Return type: Array[float]
Constants¶
-
class
AiChanType
¶ Contains attributes suitable for bit-wise operations describing channel types.
-
VOLTAGE
= 1¶ Voltage
-
TC
= 2¶ Thermocouple
-
RTD
= 3¶ Resistance Temperature Detector (RTD)
-
THERMISTOR
= 4¶ Thermistor
-
SEMICONDUCTOR
= 5¶ Semiconductor
-
DISABLED
= 100¶ Disabled
-
-
class
AiInputMode
¶ Contains attributes indicating A/D channel input modes. Used with most analog input methods and with many of the
get_info
methods.-
DIFFERENTIAL
= 1¶ Differential
-
SINGLE_ENDED
= 2¶ Single-ended
-
PSEUDO_DIFFERENTIAL
= 3¶ Pseudo-differential
-
-
class
AInScanFlag
¶ Contains attributes indicating conditioning to apply to analog input data before it’s returned.
-
DEFAULT
= 0¶ User data should be in scaled format (usually volts). The data is then written to the device after converting to native device format and calibration factors (if any) applied.
-
NOSCALEDATA
= 1¶ Data is returned in native format, without scaling applied.
-
NOCALIBRATEDATA
= 2¶ Data is returned without calibration factors applied.
-
-
class
InterfaceType
¶ Contains attributes suitable for bit-wise operations indicating the physical connection interface used to communicate with a DAQ device. Values can be OR’d together to specify multiple interfaces.
-
USB
= 1¶ USB interface
-
BLUETOOTH
= 2¶ Bluetooth interface
-
ETHERNET
= 4¶ Ethernet interface
-
ANY
= 7¶ Any interface
-
-
class
Range
¶ Used with many analog input and output functions, as well as a return value for get_ranges().
-
BIP60VOLTS
= 1¶ -60 to +60 Volts
-
BIP30VOLTS
= 2¶ -30 to +30 Volts
-
BIP15VOLTS
= 3¶ -15 to +15 Volts
-
BIP20VOLTS
= 4¶ -20 to +20 Volts
-
BIP10VOLTS
= 5¶ -10 to +10 Volts
-
BIP5VOLTS
= 6¶ -5 to +5 Volts
-
BIP4VOLTS
= 7¶ -4 to +4 Volts
-
BIP2PT5VOLTS
= 8¶ -2.5 to +2.5 Volts
-
BIP2VOLTS
= 9¶ -2.0 to +2.0 Volts
-
BIP1PT25VOLTS
= 10¶ -1.25 to +1.25 Volts
-
BIP1VOLTS
= 11¶ -1 to +1 Volts
-
BIPPT625VOLTS
= 12¶ -.625 to +.625 Volts
-
BIPPT5VOLTS
= 13¶ -.5 to +.5 Volts
-
BIPPT25VOLTS
= 14¶ -0.25 to +0.25 Volts
-
BIPPT125VOLTS
= 15¶ -0.125 to +0.125 Volts
-
BIPPT2VOLTS
= 16¶ -0.2 to +0.2 Volts
-
BIPPT1VOLTS
= 17¶ -.1 to +.1 Volts
-
BIPPT05VOLTS
= 18¶ -.05 to +.05 Volts
-
BIPPT01VOLTS
= 19¶ -.01 to +.01 Volts
-
BIPPT005VOLTS
= 20¶ -.005 to +.005 Volts
-
BIP1PT67VOLTS
= 21¶ -1.67 to +1.67 Volts
-
BIPPT312VOLTS
= 22¶ -0.312 to +0.312 Volts
-
BIPPT156VOLTS
= 23¶ -0.156 to +0.156 Volts
-
BIPPT078VOLTS
= 24¶ -0.078 to +0.078 Volts
-
-
class
ScanOption
¶ Contains attributes suitable for bit-wise operations indicating optional scan modes. These values can be OR’d together to specify multiple options.
-
DEFAULTIO
= 0¶ Transfers A/D data based on the board type and sampling speed.
-
SINGLEIO
= 1¶ Transfers one packet of data at a time.
-
BLOCKIO
= 2¶ Transfers A/D data in blocks.
-
BURSTIO
= 4¶ Transfers A/D data from the FIFO after the scan completes. Allows maximum rates for finite scans up to the full capacity of the FIFO. Not recommended for slow acquisition rates.
-
CONTINUOUS
= 8¶ Scans data in an endless loop. The only way to stop the operation is with scan_stop().
-
EXTCLOCK
= 16¶ Data conversions are controlled by an external clock signal.
-
EXTTRIGGER
= 32¶ Sampling begins when a trigger condition is met.
-
RETRIGGER
= 64¶ Re-arms the trigger after a trigger event is performed.
-
BURSTMODE
= 128¶ Enables burst mode sampling, minimizing the channel skew.
-
-
class
TcType
¶ Contains attributes for thermocouple types.
-
J
= 1¶ Type J
-
K
= 2¶ Type K
-
T
= 3¶ Type T
-
E
= 4¶ Type E
-
R
= 5¶ Type R
-
S
= 6¶ Type S
-
B
= 7¶ Type B
-
N
= 8¶ Type N
-
-
class
TempUnit
¶ Contains attributes for temperature units.
-
CELSIUS
= 1¶ Celsius
-
FAHRENHEIT
= 2¶ Fahrenheit
-
KELVIN
= 3¶ Kelvin
-
-
class
ULError
¶ Error codes for Universal Library.
-
NO_ERROR
= 0¶ No error has occurred
-
UNHANDLED_EXCEPTION
= 1¶ Unhandled internal exception
-
BAD_DEV_HANDLE
= 2¶ Invalid device handle
-
BAD_DEV_TYPE
= 3¶ This function cannot be used with this device
-
USB_INTERFACE_CLAIMED
= 4¶ USB interface is already claimed
-
DEV_NOT_FOUND
= 5¶ Device not found
-
DEV_NOT_CONNECTED
= 6¶ Device not connected or connection lost
-
DEAD_DEV
= 7¶ Device no longer responding
-
BAD_BUFFER_SIZE
= 8¶ Buffer too small for operation
-
BAD_BUFFER
= 9¶ Invalid buffer
-
BAD_MEM_TYPE
= 10¶ Invalid memory type
-
BAD_MEM_REGION
= 11¶ Invalid memory region
-
BAD_RANGE
= 12¶ Invalid range
-
BAD_AI_CHAN
= 13¶ Invalid analog input channel specified
-
BAD_INPUT_MODE
= 14¶ Invalid input mode specified
-
ALREADY_ACTIVE
= 15¶ A background process is already in progress
-
BAD_TRIG_TYPE
= 16¶ Invalid trigger type specified
-
OVERRUN
= 17¶ FIFO overrun, data was not transferred from device fast enough
-
UNDERRUN
= 18¶ FIFO underrun, data was not transferred to device fast enough
-
TIMEDOUT
= 19¶ Operation timed out
-
BAD_OPTION
= 20¶ Invalid option specified
-
BAD_RATE
= 21¶ Invalid sampling rate specified
-
BAD_BURSTIO_COUNT
= 22¶ Sample count cannot be greater than FIFO size for BURSTIO scans
-
CONFIG_NOT_SUPPORTED
= 23¶ Configuration not supported
-
BAD_CONFIG_VAL
= 24¶ Invalid configuration value
-
BAD_AI_CHAN_TYPE
= 25¶ Invalid analog input channel type specified
-
ADC_OVERRUN
= 26¶ ADC overrun occurred
-
BAD_TC_TYPE
= None¶ Invalid thermocouple type specified
-
BAD_UNIT
= 27¶ Invalid unit specified
-
BAD_QUEUE_SIZE
= 29¶ Invalid queue size
-
BAD_CONFIG_ITEM
= 30¶ Invalid config item specified
-
BAD_INFO_ITEM
= 31¶ Invalid info item specified
-
BAD_FLAG
= 32¶ Invalid flag specified
-
BAD_SAMPLE_COUNT
= 33¶ Invalid sample count specified
-
INTERNAL
= 34¶ Internal error
-
BAD_COUPLING_MODE
= 35¶ Invalid coupling mode
-
BAD_SENSOR_SENSITIVITY
= 36¶ Invalid sensor sensitivity
-
BAD_IEPE_MODE
= 37¶ Invalid IEPE mode
-
BAD_AI_CHAN_QUEUE
= 38¶ Invalid channel queue specified
-
BAD_AI_GAIN_QUEUE
= 39¶ Invalid gain queue specified
-
Types¶
-
class
DaqDeviceDescriptor
¶ A class containing properties that define a particular DAQ device.
-
product_name
¶ The generic (unqualified) product name of the device referenced by the DaqDeviceDescriptor.
-
product_id
¶ The numeric string indicating the product type referenced by the DaqDeviceDescriptor.
-
dev_interface
¶ The
InterfaceType
indicating the type of interface in use by the device referenced by the DaqDeviceDescriptor.
-
dev_string
¶ Similar to product_name, but may contain additional information.
-
unique_id
¶ A string that uniquely identifies a specific device, usually with a serial number or MAC address.
-
-
class
AiQueueElement
¶ A class containing properties that define an analog input queue element.
-
channel
¶ The analog input channel number for the queue element.
-
input_mode
¶ The
AiInputMode
value to use for the specified channel for the queue element.
-