described in Read Data from an Item, you can obtain information about
OPC server item values upon request. The OPC Data Access specification
provides another mechanism for clients to get information on server
item values. This mechanism allows the OPC server to notify a client
when a server item value or quality has updated. This mechanism is
called a data change event. OPC Toolbox™ software
supports data change event notification by executing a MATLAB® function
when a data change event is received from a connected OPC server.
This section describes how to use the data change event notification.
A data change event occurs at the
dagroup object properties, you can
control whether a data change event is generated for a particular
group, the minimum time between successive events, and the MATLAB function
to run when the event notification is received and processed by OPC Toolbox software.
You can also control which items in a particular group should be monitored
for data changes. In this way, you can control the number and frequency
of data change events that MATLAB has to process. On a busy OPC
server, you can also turn off data change notification for groups
that you are not currently interested in.
The following sections describe how to control data change notification.
Control Data Change Notification for a Group describes
how to turn off data change notification for a
Temporarily Disable Items in a Group describes how to control which items in a group must be monitored for data changes.
Customize the Data Change Event Response provided information on how to configure the MATLAB function to run when a data change event occurs.
The following properties of a
control whether a server notifies the group of data changes on items
in that group:
UpdateRate property defines
the rate at which an OPC server must monitor server item values and
generate data change events. Even if a server item's value changes
more frequently than the update rate, the OPC server will only generate
a data change at the interval specified by the update rate.
Subscription property defines
whether the OPC server will generate a data change event for the group.
When you create a
dagroup object, the
is set to
'on'. When you set the
'off', you tell the OPC server not to generate
data change events for that group.
Active property must be
data change events to be generated. When you create a
Active property is set to
When you set the
Active property to
you remove any ability to read data from the group, whether through
read operations or data change events.
You can temporarily disable items in a group without deleting
the item from the group. When you disable a
the OPC server no longer monitors changes in the associated server
item's value, and will therefore not generate data change events when
the value of that server item changes.
You can disable a
daitem object by setting
Active property to
You can reenable the
daitem object by setting the
You can force an OPC server to generate a data change event
for all active items in a group by using the
dagroup object as the first argument.
The OPC server will generate a data change event containing information
for every active item in the group.
You can pass an optional second argument to the
to instruct the OPC server where to source the data values that are
sent back in the data change event. By specifying a source of
you instruct the OPC server to update the values from the device.
By specifying a source of
'cache' (the default)
you instruct the OPC server to return values from the OPC server's
is logging, the data change event is logged to memory and/or disk
as a record. For information on logging, see Log OPC Server Data.
DataChangeFcn property is not empty, that
function is called with the data change event information. By default,
this property is empty, since data change events occur frequently.
You can customize the behavior of the toolbox by setting this property
to call a function that you choose. For information on the data change
event, see the reference page for the
If you disable data change events by setting the
Subscription property to
Active property to
none of the activities listed above can take place. You cannot change
dagroup object is logging, otherwise the
logging task may never complete.
One of the activities that occurs when OPC Toolbox software
receives a data change event from the OPC server is the running of
the function defined in the
By setting this property to a the name of a function that you have
written, you can fully customize the data change event behavior of
the toolbox. For example, you may configure a
to monitor a server item that is updated from an operator interface.
By pushing a button on the operator interface, the server item value
will change, initiating a data change event on that group. By configuring
DataChangeFcn property to run a MATLAB function
that performs control loop optimization, you can allow an operator
to initiate a control loop performance test on all critical control
loops in the plant.