Example of Emulated Instrument

When an instrument is loaded but it can be found the class moves to a emulated instrument mode that logs write and read commands

In [1]:
from pyMez import *
Importing pyMez, this should take roughly 30 seconds
Importing Code.DataHandlers.GeneralModels
It took 3.793 s to import Code.DataHandlers.GeneralModels
Importing Code.DataHandlers.HTMLModels
It took 0.466 s to import Code.DataHandlers.HTMLModels
Importing Code.DataHandlers.NISTModels
It took 13.808 s to import Code.DataHandlers.NISTModels
Importing Code.DataHandlers.TouchstoneModels
It took 0.008 s to import Code.DataHandlers.TouchstoneModels
Importing Code.DataHandlers.XMLModels
It took 0.316 s to import Code.DataHandlers.XMLModels
Importing Code.DataHandlers.ZipModels
It took 0.049 s to import Code.DataHandlers.ZipModels
Importing Code.InstrumentControl.Experiments
It took 3.144 s to import Code.InstrumentControl.Experiments
Importing Code.InstrumentControl.Instruments
It took 0.078 s to import Code.InstrumentControl.Instruments
Importing Code.Utils.Names
It took 0.011 s to import Code.Utils.Names
It took 21.674 s to import all of the active modules
In [2]:
# This loads the sheet that has GPIB::16 address
emulated_instrument=VisaInstrument("GPIB::16")
Unable to load resource entering emulation mode ...
In [3]:
# This is the idn established on the xml description sheet
emulated_instrument.idn
Out[3]:
'Agilent Technologies,E8361A,US43140754,A.07.50.67'
In [4]:
# This gets the default state defined in the xml sheet
# instead of returning values it returns a buffer read and time stamp
emulated_instrument.get_state()
Out[4]:
{'SENS:AVER': 'Buffer Read at 2019-01-25T00:30:15.559000',
 'SENS:BAND': 'Buffer Read at 2019-01-25T00:30:15.560000',
 'SENS:CORR:STAT': 'Buffer Read at 2019-01-25T00:30:15.562000',
 'SENS:SWE:TYPE': 'Buffer Read at 2019-01-25T00:30:15.561000',
 'SOUR:POW': 'Buffer Read at 2019-01-25T00:30:15.563000',
 'SOUR:POW:CORR:STAT': 'Buffer Read at 2019-01-25T00:30:15.564000',
 'SOUR:POW:SLOP': 'Buffer Read at 2019-01-25T00:30:15.565000'}
In [5]:
# This is a fake write command
emulated_instrument.write("MyFake:GPIB:COMMAND")
In [6]:
# The history attribute saves a log of all communication
emulated_instrument.history
Out[6]:
[{'Action': 'self.write',
  'Argument': 'SENS:AVER?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.223000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.224000',
  'Timestamp': '2019-01-25T00:30:09.224000'},
 {'Action': 'self.write',
  'Argument': 'SENS:BAND?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.225000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.225000',
  'Timestamp': '2019-01-25T00:30:09.225000'},
 {'Action': 'self.write',
  'Argument': 'SENS:SWE:TYPE?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.226000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.226000',
  'Timestamp': '2019-01-25T00:30:09.226000'},
 {'Action': 'self.write',
  'Argument': 'SENS:CORR:STAT?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.227000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.227000',
  'Timestamp': '2019-01-25T00:30:09.227000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.228000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.228000',
  'Timestamp': '2019-01-25T00:30:09.228000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW:CORR:STAT?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.229000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.229000',
  'Timestamp': '2019-01-25T00:30:09.229000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW:SLOP?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.230000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.230000',
  'Timestamp': '2019-01-25T00:30:09.230000'},
 {'Action': 'self.write',
  'Argument': 'SENS:AVER?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.231000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.231000',
  'Timestamp': '2019-01-25T00:30:09.231000'},
 {'Action': 'self.write',
  'Argument': 'SENS:BAND?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.232000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.232000',
  'Timestamp': '2019-01-25T00:30:09.232000'},
 {'Action': 'self.write',
  'Argument': 'SENS:SWE:TYPE?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.233000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.233000',
  'Timestamp': '2019-01-25T00:30:09.233000'},
 {'Action': 'self.write',
  'Argument': 'SENS:CORR:STAT?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.234000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.234000',
  'Timestamp': '2019-01-25T00:30:09.234000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.235000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.235000',
  'Timestamp': '2019-01-25T00:30:09.235000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW:CORR:STAT?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.236000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.236000',
  'Timestamp': '2019-01-25T00:30:09.236000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW:SLOP?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:09.237000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:09.237000',
  'Timestamp': '2019-01-25T00:30:09.237000'},
 {'Action': 'self.write',
  'Argument': 'SENS:AVER?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.559000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.559000',
  'Timestamp': '2019-01-25T00:30:15.559000'},
 {'Action': 'self.write',
  'Argument': 'SENS:BAND?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.560000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.560000',
  'Timestamp': '2019-01-25T00:30:15.560000'},
 {'Action': 'self.write',
  'Argument': 'SENS:SWE:TYPE?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.561000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.561000',
  'Timestamp': '2019-01-25T00:30:15.561000'},
 {'Action': 'self.write',
  'Argument': 'SENS:CORR:STAT?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.562000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.562000',
  'Timestamp': '2019-01-25T00:30:15.562000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.563000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.563000',
  'Timestamp': '2019-01-25T00:30:15.563000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW:CORR:STAT?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.564000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.564000',
  'Timestamp': '2019-01-25T00:30:15.564000'},
 {'Action': 'self.write',
  'Argument': 'SOUR:POW:SLOP?',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:15.565000'},
 {'Action': 'self.read',
  'Argument': None,
  'Response': 'Buffer Read at 2019-01-25T00:30:15.565000',
  'Timestamp': '2019-01-25T00:30:15.565000'},
 {'Action': 'self.write',
  'Argument': 'MyFake:GPIB:COMMAND',
  'Response': None,
  'Timestamp': '2019-01-25T00:30:19.553000'}]
In [7]:
# the emulation mode attribute is set to true so that derived classes can integrate it
emulated_instrument.emulation_mode
Out[7]:
True