Instrument Control Toolbox | ![]() ![]() |
Creating and Executing Action Functions
You can specify the action function to be executed when a specific event type occurs by including the name of the M-file as the value for the associated action property. For example, to execute the action function myaction
every time the EOSCharCode
property value is read from your instrument
g.BytesAvailableActionMode = 'eosCharCode';
g.BytesAvailableAction = 'myaction';
M-file action functions require at least two input arguments. The first argument is the instrument object. The second argument is a variable that captures the event information given in Table 3-10, GPIB Event Information,. This event information pertains only to the event that caused the action function to execute. The function header for myaction
is shown below.
function myaction(obj,event)
You can pass additional parameters to the action function by including them as elements of a cell array. For example, to pass the MATLAB variable time
to myaction
time = datestr(now,0);g.BytesAvailableActionMode = 'eosCharCode';
g.BytesAvailableAction = {'myaction',time};
The corresponding function header is
function myaction(obj,event,time)
If you pass additional parameters to the action function, then they must be included in the function header after the two required arguments.
![]() | Storing Event Information | Enabling Action Functions After They Error | ![]() |