ErrorFcn

Callback function file to execute when error event occurs

Description

You configure ErrorFcn to execute a callback function file when an error event occurs. An error event is generated when an asynchronous transaction fails. For example, an asynchronous read on items that cannot be read generates an error event. An error event is not generated for configuration errors such as setting an invalid property value, nor for synchronous read and write operations.

When an Error event occurs, the function specified in ErrorFcn is passed two parameters: Obj and EventInfo. Obj is the object associated with the event, and EventInfo is an event structure containing the fields Type and Data. The Type field is set to 'Error'. The Data field contains a structure with the following fields:

Field Name

Description

LocalEventTime

The local time (as a date vector) the event occurred.

TransID

The transaction ID associated with the event.

GroupName

The group name.

Items

A structure containing information on each item that generated an error during that transaction.

The Items structure array contains the following fields:

Field Name

Description

ItemID

The item name.

Error

The error message.

The default value for ErrorFcn is @opccallback.

Note that error event information is also stored in the EventLog property.

Characteristics

Access

Read/write

Applies to

opcda

Data type

string, function handle, or cell array

Values

@opccallback is the default callback function.

See Also

Functions

opccallback, showopcevents

Properties

EventLog, Timeout

Was this topic helpful?