refresh

Read all active items in group

Syntax

refresh(GObj)
refresh(GObj,'Source')

Description

refresh(GObj) asynchronously reads data for all active items contained in the dagroup object specified by GObj. Items whose Active property is set to 'off' will not be read. GObj can be an array of group objects. The data is read from the OPC server's cache. You can use refresh only if the Active property is set to 'on' for GObj.

When the refresh operation completes, a DataChange event is generated by the server. If a callback function file is specified for the DataChangeFcn property, then the function executes when the event is generated.

refresh is a special case of subscription that forces a DataChange event for all active items even if the data has not changed. Note that refresh ignores the Subscription property.

refresh(GObj,'Source') asynchronously reads data from the source specified by 'Source', which can be 'cache' or 'device'. If 'Source' is 'device', data is returned directly from the device. If 'Source' is 'cache', data is returned from the OPC server's cache. Note that reading data from the device can be slow.

Examples

Configure a client, group, and item, for the Matrikon™ Simulation Server:

da = opcda('localhost','Matrikon.OPC.Simulation');
connect(da);
grp = addgroup(da,'ExRefresh');
itm = additem(grp,'Random.Real8');

Turn off subscription for the group and add a DataChangeFcn callback:

grp.Subscription = 'off';
grp.DataChangeFcn = 'disp(grp.Item)'

Call refresh to get group and item updates:

refresh(grp)
refresh(grp)
Was this topic helpful?