def query(self, c, data): """Make a GPIB query. This query is atomic. No other communication to the device will occur while the query is in progress. """ if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) # Ex: mcdermott5125 GPIB Bus - GPIB0::2::SIM900::4 dev = self.devices[c['addr'].split('::')[0]] # gpibBusServName = c['addr'].split(' - ')[0] slot = c['addr'][-1] p = dev.packet() p.open(dev.address) p.timeout(c['timeout']) escape = self.escapeString() p.write_line("CONN %s,'%s'" % (slot, escape)) p.write_line(data) p.pause(0.1 * units.s) p.read_line() p.write_line(escape) p.close() resp = yield p.send() returnValue(resp['read_line'])
def getDevice(self, c): if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.devices: raise Exception('Could not find device ' + c['addr']) instr = self.devices[c['addr']] return instr
def getDeviceDID(self, c): if 'SN' not in c: raise DeviceNotSelectedError('No Lab Brick Attenuator ' 'serial number is selected') if c['SN'] not in self._SN2DID.keys(): raise Exception('Cannot find Lab Brick Attenuator with ' 'serial number %s' % c['SN']) return self._SN2DID[c['SN']]
def getDeviceDID(self, c): if 'SN' not in c: raise DeviceNotSelectedError('No Lab Brick RF Generator ' 'serial number selected') if c['SN'] not in self._SN2DID.keys(): raise Exception('Could not find Lab Brick RF Generator ' 'with serial number %d' % c['SN']) return self._SN2DID[c['SN']]
def getDevice(self, c): if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) instr = self.mydevices[c['addr']] instr.timeout = c['timeout']['ms'] return instr
def write(self, c, data): """Write a string to the GPIB bus.""" if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) # Ex: mcdermott5125 GPIB Bus - GPIB0::2::SIM900::4 gpibBusServName = c['addr'].split(' - ')[0] slot = c['addr'][-1] p = self.client[gpibBusServName].packet() p.address(self.mydevices[c['addr']]) p.timeout(c['timeout']) escape = self.escapeString() p.write("CONN %s,'%s'" % (str(slot), escape)) p.write(data) p.write(escape) p.send()
def read(self, c): """Read from the GPIB bus.""" if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) # Ex: mcdermott5125 GPIB Bus - GPIB0::2::INSTR::SIM900::4 gpibBusServName = c['addr'].split(' - ')[0] slot = c['addr'][-1] p = self.client[gpibBusServName].packet() p.address(self.mydevices[c['addr']]) p.timeout(c['timeout']) escape = self.escapeString() p.write("CONN %s,'%s'" % (str(slot), escape)) p.read() p.write(escape) resp = yield p.send() returnValue(resp['read'])
def read(self, c): """Read from the GPIB bus.""" if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) # Ex: mcdermott5125 GPIB Bus - GPIB0::2::SIM900::4 dev = self.devices[c['addr'].split('::')[0]] # gpibBusServName = c['addr'].split(' - ')[0] slot = c['addr'][-1] p = dev.packet() p.open(dev.address) p.timeout(c['timeout']) escape = self.escapeString() p.write_line("CONN %s,'%s'" % (slot, escape)) p.read_line() p.write_line(escape) p.close() resp = yield p.send() returnValue(resp['read_line'])
def query(self, c, data): """Make a GPIB query. This query is atomic. No other communication to the device will occur while the query is in progress. """ if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) # Ex: mcdermott5125 GPIB Bus - GPIB0::2[::INSTR]::SIM900::4 gpibBusServName = c['addr'].split(' - ')[0] slot = c['addr'][-1] p = self.client[gpibBusServName].packet() p.address(self.mydevices[c['addr']]) p.timeout(c['timeout']) escape = self.escapeString() p.write("CONN %s,'%s'" % (str(slot), escape)) p.query(data) p.write(escape) resp = yield p.send() returnValue(resp['query'])
def read_raw(self, c, bytes=None): """Read a raw string from the GPIB bus. If specified, reads only the given number of bytes. Otherwise, reads until the device stops sending. """ if 'addr' not in c: raise DeviceNotSelectedError("No GPIB address selected") if c['addr'] not in self.mydevices: raise Exception('Could not find device %s' % c['addr']) # Ex: mcdermott5125 GPIB Bus - GPIB0::2::SIM900::4 gpibBusServName = c['addr'].split(' - ')[0] slot = c['addr'][-1] p = self.client[gpibBusServName].packet() p.address(self.mydevices[c['addr']]) p.timeout(c['timeout']) escape = self.escapeString() p.write("CONN %s,'%s'" % (str(slot), escape)) p.read_raw(bytes) p.write(escape) resp = yield p.send() returnValue(resp['read_raw'])