Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 setAttributeViReal64(self, attributeId, value):
errorCode = self.library.niDMM_SetAttributeViReal64(self.sessionHandle, b'', attributeId, value)
errors._handleError(self.library, self.sessionHandle, errorCode)
def getAttributeViReal64(self, attributeId):
value = ctypes.c_double(0)
errorCode = self.library.niDMM_GetAttributeViReal64(self.sessionHandle, None, attributeId, ctypes.byref(value))
errors._handleError(self.library, self.sessionHandle, errorCode)
return value.value
def getAttributeViString(self, attributeId):
errorCode = self.library.niDMM_GetAttributeViString(self.sessionHandle, None, attributeId, 0, None)
# Do the IVI dance
# Don't use _handleError, because positive value in errorCode means size, not warning.
if(errors._isError(errorCode)): raise errors.Error(self.library, self.sessionHandle, errorCode)
bufferSize = errorCode
value = ctypes.create_string_buffer(bufferSize)
errorCode = self.library.niDMM_GetAttributeViString(self.sessionHandle, None, attributeId, bufferSize, value)
errors._handleError(self.library, self.sessionHandle, errorCode)
return value.value.decode("ascii")
def setAttributeViString(self, attributeId, value):
errorCode = self.library.niDMM_SetAttributeViString(self.sessionHandle, b'', attributeId, value.encode('ascii'))
errors._handleError(self.library, self.sessionHandle, errorCode)
def getAttributeViBoolean(self, attributeId):
value = ctypes.c_ushort(0)
errorCode = self.library.niDMM_GetAttributeViBoolean(self.sessionHandle, None, attributeId, ctypes.byref(value))
errors._handleError(self.library, self.sessionHandle, errorCode)
return value.value
def read(self, timeoutInMilliseconds = 10000):
measurement = ctypes.c_double(0)
errorCode = self.library.niDMM_Read(self.sessionHandle, timeoutInMilliseconds, ctypes.byref(measurement))
errors._handleError(self.library, self.sessionHandle, errorCode)
return measurement.value
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)
def setAttributeViBoolean(self, attributeId, value):
errorCode = self.library.niDMM_SetAttributeViBoolean(self.sessionHandle, b'', attributeId, value)
errors._handleError(self.library, self.sessionHandle, errorCode)