Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if type(value) is not self.attributeType: raise TypeError('Value mode must be of type ' + str(self.attributeType))
obj.setAttributeViInt32(self.attributeId, value.value)
class Session(object):
"""An NI-DMM session to a National Instruments Digital Multimeter"""
specificDriverClassSpecMajorVersion = AttributeViInt32(1050515)
specificDriverClassSpecMinorVersion = AttributeViInt32(1050516)
sampleCount = AttributeViInt32(1250301)
triggerCount = AttributeViInt32(1250304)
range = AttributeViReal64(1250002)
resolutionDigits = AttributeViReal64(1250003)
serialNumber = AttributeViString(1150054)
simulate = AttributeViBoolean(1050005)
function = AttributeEnum(1250001, enums.Function)
def __init__(self, resourceName, idQuery = 0, reset = False):
#print("__init__ entered")
self.sessionHandle = ctypes.c_ulong(0)
self.library = library.getLibrary()
errorCode = self.library.niDMM_init(resourceName.encode('ascii'), idQuery, reset, ctypes.byref(self.sessionHandle))
errors._handleError(self.library, self.sessionHandle, errorCode)
def __del__(self):
#print("__del__ entered")
pass
def __enter__(self):
#print("__enter__ entered")
return self
'''Base class for all NI-DMM sessions.'''
# This is needed during __init__. Without it, __setattr__ raises an exception
_is_frozen = False
ac_max_freq = attributes.AttributeViReal64(1250007)
'''
Specifies the maximum frequency component of the input signal for AC measurements. This attribute is used only for error checking and verifies that the value of this parameter is less than the maximum frequency of the device. This attribute affects the DMM only when you set the NIDMM_ATTR_FUNCTION attribute to AC measurements.
The valid range is 1 Hz-300 kHz for the NI 4070/4071/4072, 10 Hz-100 kHz for the NI 4065, and 20 Hz-25 kHz for the NI 4050 and NI 4060.
'''
ac_min_freq = attributes.AttributeViReal64(1250006)
'''
Specifies the minimum frequency component of the input signal for AC measurements. This attribute affects the DMM only when you set the NIDMM_ATTR_FUNCTION attribute to AC measurements.
The valid range is 1 Hz-300 kHz for the NI 4070/4071/4072, 10 Hz-100 kHz for the NI 4065, and 20 Hz-25 kHz for the NI 4050 and NI 4060.
'''
adc_calibration = attributes.AttributeEnum(attributes.AttributeViInt32, enums.ADCCalibration, 1150022)
'''
For the NI 4070/4071/4072 only, specifies the ADC calibration mode.
'''
aperture_time = attributes.AttributeViReal64(1250321)
'''
Specifies the measurement aperture time for the current configuration. Aperture time is specified in units set by NIDMM_ATTR_APERTURE_TIME_UNITS. To override the default aperture, set this attribute to the desired aperture time after calling niDMM_ConfigureMeasurement. To return to the default, set this attribute to NIDMM_VAL_APERTURE_TIME_AUTO (-1).
On the NI 4070/4071/4072, the minimum aperture time is 8.89 usec, and the maximum aperture time is 149 sec. Any number of powerline cycles (PLCs) within the minimum and maximum ranges is allowed on the NI 4070/4071/4072.
On the NI 4065 the minimum aperture time is 333 µs, and the maximum aperture time is 78.2 s. If setting the number of averages directly, the total measurement time is aperture time X the number of averages, which must be less than 72.8 s. The aperture times allowed are 333 µs, 667 µs, or multiples of 1.11 ms-for example 1.11 ms, 2.22 ms, 3.33 ms, and so on. If you set an aperture time other than 333 µs, 667 µs, or multiples of 1.11 ms, the value will be coerced up to the next supported aperture time.
On the NI 4060, when the powerline frequency is 60 Hz, the PLCs allowed are 1 PLC, 6 PLC, 12 PLC, and 120 PLC. When the powerline frequency is 50 Hz, the PLCs allowed are 1 PLC, 5 PLC, 10 PLC, and 100 PLC.
'''
aperture_time_units = attributes.AttributeEnum(attributes.AttributeViInt32, enums.ApertureTimeUnits, 1250322)
'''
Specifies the units of aperture time for the current configuration.
The NI 4060 does not support an aperture time set in seconds.
'''
auto_range_value = attributes.AttributeViReal64(1250331)
| NIDMM_VAL_TEMP_TC_K | Thermocouple type K |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_N | Thermocouple type N |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_R | Thermocouple type R |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_S | Thermocouple type S |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_T | Thermocouple type T |
+---------------------+---------------------+
reference_junction_type (enums.ThermocoupleReferenceJunctionType): Specifies the type of reference junction to be used in the reference
junction compensation of a thermocouple measurement. NI-DMM uses this
value to set the Reference Junction Type property. The only supported
value is NIDMM_VAL_TEMP_REF_JUNC_FIXED.
'''
if type(thermocouple_type) is not enums.ThermocoupleType:
raise TypeError('Parameter mode must be of type ' + str(enums.ThermocoupleType))
if type(reference_junction_type) is not enums.ThermocoupleReferenceJunctionType:
raise TypeError('Parameter mode must be of type ' + str(enums.ThermocoupleReferenceJunctionType))
vi_ctype = visatype.ViSession(self._vi) # case 1
thermocouple_type_ctype = visatype.ViInt32(thermocouple_type.value) # case 10
reference_junction_type_ctype = visatype.ViInt32(reference_junction_type.value) # case 10
error_code = self._library.niDMM_ConfigureThermocouple(vi_ctype, thermocouple_type_ctype, reference_junction_type_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return
+---+----------------------------+
| 1 | Finished with backlog |
+---+----------------------------+
| 2 | Finished with no backlog |
+---+----------------------------+
| 3 | Paused |
+---+----------------------------+
| 4 | No acquisition in progress |
+---+----------------------------+
'''
vi_ctype = visatype.ViSession(self._vi) # case 1
acquisition_backlog_ctype = visatype.ViInt32() # case 14
acquisition_status_ctype = visatype.ViInt16() # case 14
error_code = self._library.niDMM_ReadStatus(vi_ctype, ctypes.pointer(acquisition_backlog_ctype), ctypes.pointer(acquisition_status_ctype))
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return int(acquisition_backlog_ctype.value), enums.AcquisitionStatus(acquisition_status_ctype.value)
| NIDMM_VAL_TEMP_RTD_PT3750 |
+---------------------------------+
| NIDMM_VAL_TEMP_RTD_PT3916 |
+---------------------------------+
| NIDMM_VAL_TEMP_RTD_PT3920 |
+---------------------------------+
| NIDMM_VAL_TEMP_RTD_PT3911 |
+---------------------------------+
| NIDMM_VAL_TEMP_RTD_PT3928 |
+---------------------------------+
| \*No standard. Check the TCR. |
+---------------------------------+
rtd_resistance (float): Specifies the RTD resistance in ohms at 0 °C. NI-DMM uses this value to
set the RTD Resistance property. The default is 100 (Ω).
'''
if type(rtd_type) is not enums.RTDType:
raise TypeError('Parameter mode must be of type ' + str(enums.RTDType))
vi_ctype = visatype.ViSession(self._vi) # case 1
rtd_type_ctype = visatype.ViInt32(rtd_type.value) # case 10
rtd_resistance_ctype = visatype.ViReal64(rtd_resistance) # case 9
error_code = self._library.niDMM_ConfigureRTDType(vi_ctype, rtd_type_ctype, rtd_resistance_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return
| NIDMM_VAL_TEMP_TC_N | Thermocouple type N |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_R | Thermocouple type R |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_S | Thermocouple type S |
+---------------------+---------------------+
| NIDMM_VAL_TEMP_TC_T | Thermocouple type T |
+---------------------+---------------------+
reference_junction_type (enums.ThermocoupleReferenceJunctionType): Specifies the type of reference junction to be used in the reference
junction compensation of a thermocouple measurement. NI-DMM uses this
value to set the Reference Junction Type property. The only supported
value is NIDMM_VAL_TEMP_REF_JUNC_FIXED.
'''
if type(thermocouple_type) is not enums.ThermocoupleType:
raise TypeError('Parameter mode must be of type ' + str(enums.ThermocoupleType))
if type(reference_junction_type) is not enums.ThermocoupleReferenceJunctionType:
raise TypeError('Parameter mode must be of type ' + str(enums.ThermocoupleReferenceJunctionType))
vi_ctype = visatype.ViSession(self._vi) # case 1
thermocouple_type_ctype = visatype.ViInt32(thermocouple_type.value) # case 10
reference_junction_type_ctype = visatype.ViInt32(reference_junction_type.value) # case 10
error_code = self._library.niDMM_ConfigureThermocouple(vi_ctype, thermocouple_type_ctype, reference_junction_type_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return
aperture_time_units (enums.ApertureTimeUnits): Indicates the units of aperture time as powerline cycles (PLCs) or
seconds. Returns the value of the APERTURE_TIME_UNITS
attribute.
+-----------------------------+---+------------------+
| NIDMM_VAL_SECONDS | 0 | Seconds |
+-----------------------------+---+------------------+
| NIDMM_VAL_POWER_LINE_CYCLES | 1 | Powerline Cycles |
+-----------------------------+---+------------------+
'''
vi_ctype = visatype.ViSession(self._vi) # case 1
aperture_time_ctype = visatype.ViReal64() # case 14
aperture_time_units_ctype = visatype.ViInt32() # case 14
error_code = self._library.niDMM_GetApertureTimeInfo(vi_ctype, ctypes.pointer(aperture_time_ctype), ctypes.pointer(aperture_time_units_ctype))
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return float(aperture_time_ctype.value), enums.ApertureTimeUnits(aperture_time_units_ctype.value)
def configure_multi_point(self, trigger_count, sample_count, sample_trigger=enums.SampleTrigger.IMMEDIATE, sample_interval=-1):
'''configure_multi_point
Configures the attributes for multipoint measurements. These attributes
include TRIGGER_COUNT, SAMPLE_COUNT,
SAMPLE_TRIGGER, and SAMPLE_INTERVAL.
For continuous acquisitions, set TRIGGER_COUNT or
SAMPLE_COUNT to zero. For more information, refer to
`Multiple Point
Acquisitions `__,
`Triggering `__, and `Using
Switches `__.
Args:
trigger_count (int): Sets the number of triggers you want the DMM to receive before returning
to the Idle state. The driver sets TRIGGER_COUNT to this
`LabWindows/CVI Trigger
Routing `__ section.
trigger_delay (float): Specifies the time that the DMM waits after it has received a trigger
before taking a measurement. The driver sets the
TRIGGER_DELAY attribute to this value. By default,
**trigger_delay** is NIDMM_VAL_AUTO_DELAY (-1), which means the DMM
waits an appropriate settling time before taking the measurement. On the
NI 4060, if you set **trigger_delay** to 0, the DMM does not settle
before taking the measurement. The NI 4065 and NI 4070/4071/4072 use the
value specified in **trigger_delay** as additional settling time.
Note:
When using the NI 4050, **Trigger_Delay** must be set to
NIDMM_VAL_AUTO_DELAY (-1).
'''
if type(trigger_source) is not enums.TriggerSource:
raise TypeError('Parameter mode must be of type ' + str(enums.TriggerSource))
vi_ctype = visatype.ViSession(self._vi) # case 1
trigger_source_ctype = visatype.ViInt32(trigger_source.value) # case 10
trigger_delay_ctype = visatype.ViReal64(trigger_delay) # case 9
error_code = self._library.niDMM_ConfigureTrigger(vi_ctype, trigger_source_ctype, trigger_delay_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return
def configureMeasurementDigits(self, mode, range, digitsOfResolution):
if type(mode) is not enums.Function: raise TypeError('Parameter mode must be of type ' + str(enums.Function))
errorCode = self.library.niDMM_ConfigureMeasurementDigits(self.sessionHandle, mode.value, range, digitsOfResolution)
errors._handleError(self.library, self.sessionHandle, errorCode)