Advanced Features

Auto-commit

Warning

Be aware that the commit() function and auto-commit feature are NOT thread-safe. Auto-commit may cease to work if you are changing instrument settings in multiple threads. In the case that auto-commit is OFF, it can happen that instrument settings are applied pre-emptively due to non-deterministic ordering of commit calls between threads.

It is advised that instrument settings only be modified in a single thread to avoid unexpected behaviour.

By default, any modifications to instrument settings (i.e. as a result of calling gen_ and set_ instrument methods) are automatically sent to the device to take effect. This is called the auto-commit feature of pymoku.

from pymoku import Moku
from pymoku.instruments import *

m = Moku.get_by_name('Moku')
i = Oscilloscope()
m.deploy_instrument(i)

i.set_timebase(-1,1)
# Timebase settings are 'committed' to the Moku automatically
i.set_samplerate(10)
# Samplerate settings are 'committed' to the Moku automatically

In some cases it may be desirable to wait until many settings have been configured, and then atomically apply them to your Moku:Lab device. This can be achieved by turning OFF the autocommit property of pymoku. Instrument setting changes will subsequently only take effect on the device when you explicitly commit them.

import pymoku
from pymoku import Moku
from pymoku.instruments import *

# Turn off the auto-commit feature
pymoku.autocommit = False

m = Moku.get_by_name('Moku')
i = Oscilloscope()
m.deploy_instrument(i)

i.set_timebase(-1,1)
# Settings have not yet been sent to the Moku
i.set_samplerate(10)
# Settings have not yet been sent to the Moku
i.commit()
# Timebase and samplerate settings have now been sent to the Moku

InstrumentData

class pymoku.instruments.InstrumentData(instrument)

Superclass representing a full frame of some kind of data. This class is never used directly, but rather it is subclassed depending on the type of data contained and the instrument from which it originated. For example, the Oscilloscope instrument will generate VoltsData objects, where VoltsData is a subclass of InstrumentData.

MokuInstrument

class pymoku.instruments.MokuInstrument

Superclass for all Instruments that may be attached to a Moku object.

Should never be instantiated directly; instead, instantiate the subclass of the instrument you wish to run (e.g. Oscilloscope, WaveformGenerator)