def setParamMode(self, channel, persistent, mode): """Set the Configuration Parameter "Mode" of an analog input channel. This method calls the SetParam function of the module and sets the Configuration Parameter "Mode". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true mode: Operation Mode as LCAI4Mode 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(persistent, bool): raise TypeError('Expected persistent as bool, got %s' % type(persistent)) if not isinstance(mode, int): raise TypeError('Expected mode as int, got %s' % type(mode)) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') data = bytearray([mode]) cmd = Cmd(self.com) return cmd.setParam(_LCAI4ParamAddress.MODE, channel, persistent, data)
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 setParamCycleTime(self, channel, persistent, cycleTime): """Set the Configuration Parameter "Cycle Time" of a digital output channel. This method calls the SetParam function of the module and sets the Configuration Parameter "Cycle Time". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true cycleTime: Parameter "Cycle Time" in microseconds Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel or cycleTime 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(cycleTime, int): raise TypeError('Expected cycleTime as int, got %s' % (type(cycleTime))) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') if (cycleTime < 0) | (cycleTime >= pow(2, 32)): raise ValueError('Cycle Time out of range') data = bytearray(struct.pack("<I", cycleTime)) cmd = Cmd(self.com) return cmd.setParam(_LCDO4ParamAddress.CYCLE_TIME, channel, persistent, data)
def setParamScanInterval(self, channel, persistent, scanInterval): """Set the Configuration Parameter "Scan Interval" of an analog input channel. This method calls the SetParam function of the module and sets the Configuration Parameter "Scan Interval". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true scanInterval: Parameter "Scan Interval" in milliseconds. Value range 0 ... 0xFFFF Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel or scanInterval 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(scanInterval, int): raise TypeError('Expected scanInterval as int, got %s' % type(scanInterval)) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') if (scanInterval < 0) | (scanInterval >= pow(2, 16)): raise ValueError('Scan Interval out of range') data = bytearray(struct.pack("<H", scanInterval)) cmd = Cmd(self.com) return cmd.setParam(_LCAI4ParamAddress.SCAN_INTERVAL, channel, persistent, data)
def setParamNrSamples(self, channel, persistent, nrSamples): """Set the Configuration Parameter "Number of Samples" of an analog input channel. This method calls the SetParam function of the module and sets the Configuration Parameter "Number of Samples". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true nrSamples: Parameter "Number of Samples" Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel or nrSamples 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(nrSamples, int): raise TypeError('Expected nrSamples as int, got %s' % type(nrSamples)) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') if (nrSamples < 0): raise ValueError('nrSamples out of range') data = bytearray(struct.pack("<H", nrSamples)) cmd = Cmd(self.com) return cmd.setParam(_LCAI4ParamAddress.NR_SAMPLES, channel, persistent, data)
def setParamOffset(self, channel, persistent, offset): """Set the Configuration Parameter "Offset" of an analog input channel. This method calls the SetParam function of the module and sets the Configuration Parameter "Offset". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true offset: Parameter "Offset" Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel or offset 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(offset, int): raise TypeError('Expected offset as int, got %s' % type(offset)) if (channel >= self.nrOfChannels): raise ValueError('Channel out of range') if (offset < (-pow(2, 15))) | (offset >= pow(2, 16)): raise ValueError('Offset out of range') data = bytearray(struct.pack("<h", offset)) cmd = Cmd(self.com) return cmd.setParam(_LCAI4ParamAddress.OFFSET, channel, persistent, data)
def setParamValue(self, channel, persistent, value): 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(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) value._getData(data) return cmd.setParam(_LCDO4ParamAddress.VALUE, channel, persistent, data)
def setParamCalUrs(self, channel, persistent, calUrs): """Set the Configuration Parameter "calUrs" of a RTD input channel. This method calls the SetParam function of the module and sets the Configuration Parameter "calUrs". Args: channel: IO channel number. Must be in the range 0 ... 3 persistent: Store parameter permanently if true calUrs: Calibration Parameter "calUrs" Returns: IO_RETURN_OK in case of success, otherwise detailed IoReturn error code. Raises: TypeError: Passed argument types are wrong ValueError: Channel or scanInterval 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(calUrs, int): raise TypeError('Expected calUrs as int, got %s' % type(calUrs)) if (calUrs < (-pow(2, 15))) | (calUrs >= pow(2, 16)): raise ValueError('CalUrs out of range') data = bytearray(struct.pack("<h", calUrs)) cmd = Cmd(self.com) return cmd.setParam(_LCRT4ParamAddress.CAL_URS, channel, persistent, data)