Program Structure: Events Vs. Sequential - Agilent Technologies 86038A User Manual

Optical dispersion analyzer
Table of Contents

Advertisement

Remote Operation
138

Program Structure: events vs. sequential

A traditional remote control application consists of a list of actions that
you send to the instrument, expecting it to execute them in that order and
to tell you when it is done. This makes programming easy - you can do your
whole measurement in a single function or sub-routine. Because
everything always happens serially in the same order, this style of
programming is often called sequential or functional programming.
A more advanced approach is to take advantage of multitasking to overlap
different instruments and pre and post calculations done in the computer.
This is more complex to program, but can have significant execution time
advantages. In this scenario, the base of your application becomes a state
machine that launches the appropriate activities, then wakes up when the
activities complete and determines what to do next. The state machine
wakes up when it receives events, such as a thread completing a
calculation or an instrument completing a sweep. Because of this use of
events, this style of programming is often called event based.
The ODA is configured as an event based remote client because you can
make an event based client behave sequentially, but it is difficult to make a
sequential client efficiently multi task.
For a specific example, consider a typical sequence programming GPIB
using SCPI (which you cannot do with the ODA.) Taking a sweep may look
like:
writeOda(oda, "STAR 1520 nm")
writeOda(oda, "STOP 1535 nm")
writeOda(oda, "INIT:IMM; *OPC?")
value = readOda(oda) // block on sweep complete
This example tells the instrument the sweep parameters, triggers the
sweep and then blocks until the OPC? returns a 1, indicating the sweep is
complete.
To do the same thing in the ODA, you send the commands and then wait
for the ODA to indicate that it has completed the sweep:
odaClient.MeasurementRange.XStart = 1520
odaClient.MeasurementRange.XStop = 1535
odaClient.Actions.Measure
sleep(1000)
loop
sleep(100)
elapsedTime += 100
while elapsedTime < MAX_TIME and odaClient.Status.TriggerComplete !=
TRUE
Notice that the loop has a sleep statement, which stops the program for
100 ms, letting other programs run, and a timeout if nothing happens for
too long. You cannot query a TriggerComplete flag too soon after
requesting a sweep because the flag is not clear until the sweep actually
starts.
Recommended Control Sequence
Agilent 86038A Optical Dispersion Analyzer, Third Edition

Advertisement

Table of Contents
loading

Table of Contents