def getParamMode(self, channel, mode): """Get the Configuration Parameter "Mode" of the digital input channel. This method calls the GetParam function of the module and returns the Configuration Parameter "Mode". Args: channel: IO channel number. Must be in the range 0 ... 3 mode: Operation Mode as a list with one LCDI4Mode integer value Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % type(channel)) if not isinstance(mode, list): raise TypeError('Expected mode as list, got %s' % type(mode)) if len(mode) < 1: raise TypeError('Expected mode as list with 1 int, got %d' % len(mode)) if not isinstance(mode[0], int): raise TypeError('Expected mode[0] as int, got %s' % type(mode[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDI4ParamAddress.MODE, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: if data[0] == LCDI4Mode.INACTIVE: mode[0] = LCDI4Mode.INACTIVE elif data[0] == LCDI4Mode.REFLECT_VALUE: mode[0] = LCDI4Mode.REFLECT_VALUE elif data[0] == LCDI4Mode.RISING_EDGE: mode[0] = LCDI4Mode.RISING_EDGE elif data[0] == LCDI4Mode.FALLING_EDGE: mode[0] = LCDI4Mode.FALLING_EDGE elif data[0] == LCDI4Mode.COUNT: mode[0] = LCDI4Mode.COUNT else: mode[0] = LCDI4Mode.INACTIVE return ret
def getParamCountTime(self, channel, countTime): """Get the Configuration Parameter "Count Time" of the digital input channel. This method calls the GetParam function of the module and returns the Configuration Parameter "Count Time". Args: channel: IO channel number. Must be in the range 0 ... 3 countTime: Parameter "Count Time" as a list containing one integer value in microseconds Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % type(channel)) if not isinstance(countTime, list): raise TypeError('Expected countTime as list, got %s' % type(countTime)) if len(countTime) < 1: raise TypeError('Expected countTime as list with 1 int, got %d' % len(countTime)) if not isinstance(countTime[0], int): raise TypeError('Expected countTime[0] as int, got %s' % type(countTime[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDI4ParamAddress.COUNT_TIME, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: countTime[0] = struct.unpack("<I", buffer(data))[0] else: countTime[0] = 0 return ret
def getParamFlagCanRetrigger(self, channel, canRetrigger): """Get the Configuration Parameter Flag "Can Retrigger". This method calls the GetParam function of the module and returns the Configuration Flag "Can Retrigger". Args: channel: IO channel number. Must be in the range 0 ... 3 canRetrigger: Parameter Flag "Can Retrigger" as a list containing one boolean value Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % (type(channel))) if not isinstance(canRetrigger, list): raise TypeError('Expected canRetrigger as list, got %s' % type(canRetrigger)) if len(canRetrigger) < 1: raise TypeError( 'Expected canRetrigger as list with 1 bool, got %d' % len(canRetrigger)) if not isinstance(canRetrigger[0], int): raise TypeError('Expected canRetrigger[0] as bool, got %s' % type(canRetrigger[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDO4ParamAddress.FLAGS, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: if data[0] & _LCDO4Flag.CAN_RETRIGGER: canRetrigger[0] = True else: canRetrigger[0] = False return ret
def getParamScanInterval(self, channel, scanInterval): """Get the Configuration Parameter "Scan Interval" of the analog input channel. This method calls the GetParam function of the module and returns the Configuration Parameter "Scan Interval". Args: channel: IO channel number. Must be in the range 0 ... 3 scanInterval: Scan Interval as a list containing one integer value in milliseconds Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % type(channel)) if not isinstance(scanInterval, list): raise TypeError('Expected scanInterval as list, got %s' % type(scanInterval)) if len(scanInterval) < 1: raise TypeError( 'Expected scanInterval as list with 1 int, got %d' % len(scanInterval)) if not isinstance(scanInterval[0], int): raise TypeError('Expected scanInterval[0] as int, got %s' % type(scanInterval[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCAI4ParamAddress.SCAN_INTERVAL, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: scanInterval[0] = struct.unpack("<H", buffer(data))[0] else: scanInterval[0] = 0 return ret
def setParamFlagCanCancel(self, channel, persistent, canCancel): """Set the Configuration Parameter Flag "Can Cancel". This method calls the SetParam function of the module and sets the Configuration Flag "Can Cancel". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true canCancel: Parameter Flag "Can Cancel" as boolean Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % (type(channel))) if not isinstance(persistent, bool): raise TypeError('Expected persistent as bool, got %s' % (type(persistent))) if not isinstance(canCancel, bool): raise TypeError('Expected canCancel as bool, got %s' % (type(canCancel))) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') # Read current flags data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDO4ParamAddress.FLAGS, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: data[0] &= ~_LCDO4Flag.CAN_CANCEL if (canCancel == True): data[0] |= _LCDO4Flag.CAN_CANCEL ret = cmd.setParam(_LCDO4ParamAddress.FLAGS, channel, persistent, data) return ret
def getParamFlagResetCounterRead(self, channel, resetCounterRead): """Get the Configuration Parameter Flag "Reset Counter on Read". This method calls the GetParam function of the module and returns the Configuration Flag "Reset Counter on Read". Args: channel: IO channel number. Must be in the range 0 ... 3 resetCounterRead: Parameter Flag "Reset Counter on Read" as a list containing one boolean value Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % type(channel)) if not isinstance(resetCounterRead, list): raise TypeError('Expected resetCounterRead as list, got %s' % type(resetCounterRead)) if len(resetCounterRead) < 1: raise TypeError('Expected resetCounterRead as list with 1 bool, \ got %d' % len(resetCounterRead)) if not isinstance(resetCounterRead[0], int): raise TypeError('Expected resetCounterRead[0] as bool, got %s' % type(resetCounterRead[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDI4ParamAddress.FLAGS, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: if data[0] & _LCDI4Flag.RESET_COUNTER_READ: resetCounterRead[0] = True else: resetCounterRead[0] = False return ret
def getParamOffset(self, channel, offset): """Get the Configuration Parameter "Offset" of the analog output channel. This method calls the GetParam function of the module and returns the Configuration Parameter "Offset". Args: channel: IO channel number. Must be in the range 0 ... 3 offset: Offset as a list containing one integer value representing the offset voltage in millivolt. Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % type(channel)) if not isinstance(offset, list): raise TypeError('Expected offset as list, got %s' % type(offset)) if len(offset) < 1: raise TypeError('Expected offset as list with 1 int, got %d' % len(offset)) if not isinstance(offset[0], int): raise TypeError('Expected offset[0] as int, got %s' % type(offset[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCAO4ParamAddress.OFFSET, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: offset[0] = struct.unpack("<h", buffer(data))[0] else: offset[0] = 0 return ret
def getParamCalUrs(self, channel, calUrs): """Get the Configuration Parameter "CalUrs" of the RTD input channel. This method calls the GetParam function of the module and returns the Configuration Parameter "CalUrs". Args: channel: IO channel number. Must be in the range 0 ... 3 calUrs: Calibration value URS as a list containing one integer value Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % type(channel)) if not isinstance(calUrs, list): raise TypeError('Expected calUrs as list, got %s' % type(calUrs)) if len(calUrs) < 1: raise TypeError('Expected calUrs as list with 1 int, got %d' % len(calUrs)) if not isinstance(calUrs[0], int): raise TypeError('Expected calUrs[0] as int, got %s' % type(calUrs[0])) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCRT4ParamAddress.CAL_URS, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: calUrs[0] = struct.unpack("<h", buffer(data))[0] else: calUrs[0] = 0 return ret
def getParamOnDelay(self, channel, onDelay): """Get the Configuration Parameter "On Delay" of the digital output channel. This method calls the GetParam function of the module and returns the Configuration Parameter "On Delay". Args: channel: IO channel number. Must be in the range 0 ... 3 onDelay: Parameter "On Delay" as a list containing one integer value in microseconds Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % (type(channel))) if not isinstance(onDelay, list): raise TypeError('Expected onDelay as list, got %s' % type(onDelay)) if len(onDelay) < 1: raise TypeError('Expected onDelay as list with 1 int, got %d' % len(onDelay)) if not isinstance(onDelay[0], int): raise TypeError('Expected onDelay[0] as int, got %s' % type(onDelay[0])) data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDO4ParamAddress.ON_DELAY, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: onDelay[0] = struct.unpack("<I", buffer(data))[0] else: onDelay[0] = 0 return ret
def getParamValue(self, channel, value): """Get the Configuration Parameter "Value" of a digital output channel. This method calls the GetParam function of the module and returns the value of the Configuration Parameter "Value". The Configuration Parameter "Value" contains the current value or state of the output channel. It is recommended to call getIo instead of this method. Args: channel: IO channel number. Must be in the range 0 ... 3 value: Digital value object of type ValueDI1. Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel value is out of range """ if not isinstance(channel, int): raise TypeError('Expected channel as int, got %s' % (type(channel))) if not isinstance(value, ValueDI1): raise TypeError('Expected value as ValueDI1, got %s' % (type(value))) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray() cmd = Cmd(self.com) ret = cmd.getParam(_LCDO4ParamAddress.VALUE, channel, data) if ret == IoReturn.IoReturn.IO_RETURN_OK: value._setData(data) return ret