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

Photonic dispersion and loss analyzer
Table of Contents

Advertisement

Program Structure: events vs. sequential

Agilent 86038B Photonic Dispersion and Loss Analyzer, Second Edition
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 PDLA 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 multitask.
For a specific example, consider a typical sequence
programming GPIB using SCPI (which you cannot do with the
PDLA.) Taking a sweep may look like:
writePdla(pdla, "STAR 1520 nm")
writePdla(pdla, "STOP 1535 nm")
writePdla(pdla, "INIT:IMM; *OPC?")
value = readPdla(pdla) // 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 PDLA, you send the commands and
then wait for the PDLA to indicate that it has completed the
sweep:
pdlaClient.MeasurementRange.XStart = 1520
pdlaClient.MeasurementRange.XStop = 1535
pdlaClient.Actions.Measure
sleep(1000)
loop
sleep(100)
elapsedTime += 100
while elapsedTime < MAX_TIME and pdlaClient.Status.TriggerComplete != TRUE
147

Advertisement

Table of Contents
loading

Table of Contents