Instructor Notes
This is a placeholder file. Please add content here.
What is QMI?Main Features
Instructor Note
Advantages of this are that instruments can be grouped in logical groups in separate contexts and there is therefore no need to make one big program that contains all the instruments, tasks and whatever logic or timing is necessary. The programs can that way be made modular, with easy addition or removal of contexts.
'Hello World'
Instructor Note
Also a nice info to view now is
Controlling an instrument
Instructor Note
A bit shorter listing of the attributes of the object, you can use
but it is not easy to read and has also internal and non-RPC variable and callable methods present.
You can also get “help” of any method present. Try:
Configuring and logging
Accessing an instrument remotely
Create a task and a 'service'
Instructor Note
Note that we used a with context manager for the
starting and stopping of QMI, and for make_instrument.
These context managers takes care of the start() and
stop() calls for QMI and open() and
close() calls of the instrument, so they do not need to be
separately called anymore.
TIP: You can use the with context manager also for QMI
tasks. You can replace in task_demo.py the task part
with:
PYTHON
with qmi.make_task("demo_task", DemoRpcControlTask, task_runner=CustomRpcControlTaskRunner) as task:
_logger.info("the task has been started")
while task.is_running() and not ctx.shutdown_requested():
sample = nsg.get_sample()
amplitude = nsg.get_amplitude()
print(" " * int(40.0 + 0.25 * sample) + "*")
if abs(sample) > 10:
task.set_amplitude(amplitude * 0.99)
else:
task.set_amplitude(amplitude * 1.01)
time.sleep(0.01)
_logger.info("the task has been stopped")
Now, the with context manager will take care of
starting, stopping and joining the task thread.