Event information log


EventLog contains a structure array that stores information related to OPC Toolbox™ software events. Every element in the structure array corresponds to an event.

Each element in the EventLog structure contains the fields Type and Data. The Type value can be 'WriteAsync', 'ReadAsync', 'CancelAsync', 'Shutdown', 'Start', 'Stop', or 'Error'.

Data stores event-specific information as a structure. For information on the fields contained in Data, refer to the associated callback property reference pages. For example, to find information on the fields contained in Data for a Start event, refer to the StartFcn property.

You specify the maximum number of events to store with the EventLogMax property.

Note that some events are not stored in the EventLog. If you want to store these events, you must specify a callback for that event.

You can execute a callback function when an event occurs by specifying a function for the associated callback property. For example, to execute a callback when a read async event is generated, you use the ReadAsyncFcn property.

If the event log is full (the number of events in the log equals the value of the EventLogMax property) and a new event is received, the oldest event is removed to make space for the new event. You clear the event log using the cleareventlog function.




Applies to


Data type

Structure array


The default value is an empty matrix ([]).


The following example creates a client and configures a group with two items. A 30-second logging task is run, and after 10 seconds the item values are read. When the logging task stops, the event log is retrieved and examined.

da = opcda('localhost', 'Matrikon.OPC.Simulation');
grp = addgroup(da, 'EvtLogExample');
itm1 = additem(grp, 'Random.Real8');
itm2 = additem(grp, 'Triangle Waves.UInt1');
set(grp, 'UpdateRate', 1, 'RecordsToAcquire', 30);
tid = readasync(grp);
el = get(da, 'EventLog')
el = get(da, 'EventLog')

el = 
1x3 struct array with fields:

Now examine the first event, which is the start event.

ans = 
    Type: 'Start'
    Data: [1x1 struct]

The Data field contains the following information.

ans = 
     LocalEventTime: [2004 1 13 16 16 25.1790]
          GroupName: 'EvtLogExample'
    RecordsAcquired: 0

The second event is a ReadAsync event. Examine the Data structure and the first element of the Items structure.

ans = 
    Type: 'ReadAsync'
    Data: [1x1 struct]

ans = 
    LocalEventTime: [2004 1 13 16 16 35.2100]
           TransID: 2
         GroupName: 'EvtLogExample'
             Items: [2x1 struct]

ans = 
       ItemID: 'Random.Real8'
        Value: 2.4619e+003
      Quality: 'Good: Non-specific'
    TimeStamp: [2004 1 13 16 16 35.1870]