Retrieve logged records from OPC Toolbox engine to MATLAB workspace
S = getdata(GObj)
S = getdata(GObj,NRec)
TSCell = getdata(GObj,'
TSCell = getdata(GObj, NRec,'
[ItmID,Val,Qual,TStamp,ETime] = getdata(GObj,'
[ItmID,Val,Qual,TStamp,ETime] = getdata(GObj,NRec,'
S = getdata(GObj) returns
the number of records specified in the
the OPC Toolbox™ software engine.
be a scalar
S is an
NRec is the number of records returned.
a date vector corresponding to the local event time for that record.
1 structure array
containing the fields shown below.
The fully qualified tag name, as a character vector.
The data value. The data type is defined by the item's
The data quality, as a character vector. For a description, see OPC Quality.
The time the value was changed, as a date vector.
S = getdata(GObj,NRec) retrieves
NRec records from the toolbox engine.
TSCell = getdata(GObj,' and
TSCell = getdata(GObj, NRec,' assign the data received
from the toolbox engine to a cell array of time series objects.
as many time series objects as there are items in the group, with
the name of each time series object set to the item ID. The quality
value stored in the time series object is offset from the quality
value returned by the OPC server by 128. The quality displayed by
each is the same. Because each record logged 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
[ItmID,Val,Qual,TStamp,ETime] = getdata(GObj,' and
[ItmID,Val,Qual,TStamp,ETime] = getdata(GObj,NRec,' assign
the data retrieved from the toolbox engine to separate arrays. Valid
data types are
ItmID is a
array of item names.
Val is an
of values with the data type specified. If a data type of
Val is a cell array containing
data in the returned data type for each item. Otherwise,
a numeric array of the specified data type.
Qual is an
of quality character vectors for each value in
TStamp is an
of MATLAB® date numbers representing the time when the relevant
value and quality were stored on the OPC server.
ETime is an
of MATLAB date numbers, corresponding to the local event time
for each record.
Each record logged may not contain information for every item returned, since data for that item may not have changed from the previous update. When data is returned as a numeric matrix, the missing item columns for that record are filled as follows.
Behavior for Missing Items
The corresponding value entry is set to the previous
value of that item, or to
The corresponding quality entry is set to
The corresponding time stamp entry is set to the first valid time stamp for that record.
getdata is a blocking function that returns
execution control to the MATLAB workspace when one of the following
conditions is met:
The requested number of records becomes available.
The logging operation is automatically stopped by the engine. If fewer records are available than the number requested, a warning is generated and all available records are returned.
You issue Ctrl+C. The logging task does not stop, and no data is removed from the toolbox engine.
getdata completes, the object's
is reduced by the number of records returned by
Configure and start a logging task for 60 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.RecordsToAcquire = 60; start(grp);
Retrieve the first two records into a structure. This operation waits for at least two records.
s = getdata(grp,2)
Retrieve all the remaining data into a double array and plot it with a legend.
[itmID,val,qual,tStamp] = getdata(grp,'double'); plot(tStamp(:,1),val(:,1),tStamp(:,2),val(:,2)); legend(itmID); datetick x keeplimits