Data Acquisition Toolbox
  Function/Property:
    Search    Help Desk 

Action Properties and Functions

When an event occurs, you can execute a related function known as an action function. Action functions are M-files that can perform essentially any task during your data acquisition session. For example, you can use action functions to process data, display data, or display a message. All events have an associated action property.

You can specify the action function to be executed when an event occurs by including the name of an M-file as the value for the associated action property. You can also specify additional parameters to be passed as input arguments to the action function. The action function and additional parameters must be specified as elements of a cell array.

where:

Action functions require at least two arguments. The first argument must be a device object. The second argument is a variable that captures the event information contained by EventLog. This event information pertains only to the event that caused the action function to be executed. The action function prototype is shown below.

If additional parameters are passed to the action function, then these arguments must be included after the two required arguments.

Note:
If additional input parameters are passed to an action function, you are not required to use varargin. Instead, you can explicitly include the parameters in the function prototype as shown above.

Example action functions are given later in this section. The analog input properties related to action functions are shown below.

Table 5-9: Action-Related Properties
Property
Description
OutOfDataAction

Specifies the M-file to execute when data output has stopped

RuntimeErrorAction

Specifies the M-file to execute when a runtime error occurs

SamplesOutputAction

Specifies the M-file to execute when the number of samples specified by SamplesOutputActionCount is output

SamplesOutputActionCount

Sample-based frequency with which SamplesOutputAction is called

StartAction

Specifies the M-file to execute just prior to the device and engine start

StopAction

Specifies the M-file to execute just after the device and engine stop

TimerAction

Specifies the M-file to execute when the time specified by
TimerPeriod occurs

TimerPeriod

Time-based frequency with which TimerAction is called

TriggerAction

Specifies the M-file to execute just after a trigger occurs

The relationship between events and action properties is described below for each event type.

Data-Output Event

A data-output event is generated immediately after a predefined number of samples are output.

This event executes the M-file specified for the SamplesOutputAction property every time the number of samples specified by SamplesOutputActionCount is output.

Timer Event

A time-based event is generated immediately after a predefined period of time has passed.

This event executes the M-file specified for the TimerAction property every time the number of seconds specified for the TimerPeriod property passes. Time is measured relative to when the hardware device starts running.

Start and Stop Events

Start and stop events are described together since these two events occur for all data acquisition sessions. A start event is generated immediately after the start command is issued, while the stop event is generated immediately after the stop command is issued.

The start event executes the M-file specified for the StartAction property prior to starting the hardware and engine. Once this M-file has completed execution, the Running property is set to On.

The stop event executes the M-file specified for the StopAction property. Under most circumstances, the M-file is not guaranteed to complete execution until sometime after the hardware and engine stop and the Running property is set to Off.

Trigger Event

A trigger event is generated immediately after a trigger is issued.

This event executes the M-file specified for the TriggerAction property. Under most circumstances, the M-file is not guaranteed to complete execution until sometime after the trigger occurs and Sending is set to On by the engine.

Runtime Error Event

A runtime error event is generated immediately after a runtime error occurs. Runtime errors include hardware errors and timeouts. Runtime errors do not include configuration errors.

This event executes the M-file specified for the RuntimeErrorAction property.

Out-of-Data Event

An out-of-data event is generated immediately after an out-of-data condition is detected for any channel group member. An out-of-data condition occurs when the data stream has been interrupted before being completely output to the
D/A hardware.

This event executes the M-file specified for the OutOfDataAction property.



[ Previous | Help Desk | Next ]