Download OPC Toolbox User`s Guide

Transcript
opcstruct2timeseries
opcstruct2timeseries
Convert OPC data from structure to time series format
Syntax
TS = opcstruct2timeseries(S)
Description
TS = opcstruct2timeseries(S) converts the OPC data structure S into a cell array
of timeseries objects. S must be a structure in the format that the getdata and opcread
functions return. S must contain the fields LocalEventTime and Items. The Items
field of S must contain the fields ItemID, Value, Quality, and TimeStamp.
The cell array TS contains as many time series objects as there are unique item IDs
in the data structure, with the name of each time series object indicating the item ID.
The time series object contains the quality, although this value is offset by 128 from the
quality value that the OPC server returns. However, the quality strings are the same.
Because each logged record might not contain information for every item, the time series
objects have only as many data points as there are records containing information about
that particular item ID.
Examples
Configure and start a logging task for 30 seconds of data:
da = opcda('localhost', 'Matrikon.OPC.Simulation');
connect(da);
grp = addgroup(da, 'ExOPCREAD');
itm1 = additem(grp, 'Triangle Waves.Real8');
itm2 = additem(grp, 'Saw-Toothed Waves.Int2');
grp.LoggingMode = 'memory';
grp.UpdateRate = 0.5;
grp.RecordsToAcquire = 60;
start(grp);
wait(grp);
17-105