writeasync - Asynchronously write values to group or items

Syntax

TransID = writeasync(GObj,Values)
TransID = writeasync(IObj,Values)

Description

TransID = writeasync(GObj,Values) asynchronously writes values to all the items contained in the dagroup object GObj. Values is a cell array of values and is the same size as the number of items in GObj. TransID is a unique transaction ID for the asynchronous request.

TransID = writeasync(IObj,Values) asynchronously writes values to all the items contained in the vector of daitem objects specified by IObj.

To ensure that a specific value is written to the correct item object, you should construct the Values cell array based on the order of the items returned by the Item property. Because the values are written to the device, this operation might be time consuming.

The data types of the values do not need to match the canonical data type of the associated items. If a data type conversion cannot be performed, a warning is issued.

When the asynchronous write operation completes, a write async event is generated by the server. If an M-file callback function is specified for the WriteAsyncFcn property, then the function executes when the event is generated.

Examples

Configure a client and a group and items, for the Matrikon™ Simulation Server.

da = opcda('localhost', 'Matrikon.OPC.Simulation');
connect(da);
grp = addgroup(da, 'ExWrite');
itm = additem(grp, {'Bucket Brigade.Real8', ...
    'Bucket Brigade.String'});

Configure the WriteAsyncFcn callback to read from the group

grp.WriteAsyncFcn = 'r=read(grp,''device'')';

Write values asynchronously.

writeasync(grp, {123.456, 'MATLAB is great!'})

See Also

cancelasync, read, readasync, refresh, write

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS