def set_value(self, channel_name, value): """ Sets the value of channel""" try: channel_name = self.channel_name(channel_name) except: raise if re.match('DAC', channel_name): try: if value is None: raise LabJackPython.AddRequest(self.handle, LabJackPython.LJ_ioPUT_DAC, self.channel_numbers[channel_name], value, 0, 0) LabJackPython.Go() exec('self.%s=float("%s")' % (channel_name, value)) except: # TODO catch the error for passing None Specifically pass elif re.match('FIO|EIO|CIO', channel_name): LabJackPython.AddRequest(self.handle, LabJackPython.LJ_ioPUT_DIGITAL_BIT, self.channel_numbers[channel_name], value, 0, 0) LabJackPython.Go() elif re.match('GND|SGND|VS|SPC', channel_name) or channel_name is None: pass else: raise LabJackInstrumentError('Invalid channel name for set_value.') self.current_state = self.get_state()
def write(self, command, channel, value=0, optional_parameter=0, user_buffer=0): """ Writes a command to the LabJack device """ LabJackPython.AddRequest(self.handle, command, channel, value, optional_parameter, user_buffer) LabJackPython.Go()
def ask(self, command, channel, value=0, optional_parameter=0, user_buffer=0): """ Writes a command to the labjack and returns a value """ LabJackPython.AddRequest(self.handle, command, channel, value, optional_parameter, user_buffer) LabJackPython.Go() answer = LabJackPython.GetResult(self.handle, command, channel) return answer