Preview most recently acquired data
S = peekdata(GObj, NRec)
S = peekdata(GObj, NRec) returns
NRec most recently acquired records for the
without removing those records from the OPC Toolbox™ software engine.
be a scalar
a structure array containing data for each record, in the same format
as the structure returned by
NRec is greater than the number of records
currently available, a warning will be generated and all available
records will be returned.
peekdata when you want to return
logged data but you do not want to remove the data from the buffer.
RecordsAvailable property value will
not be affected by the number of samples returned by
peekdata is a non-blocking function that
immediately returns records and execution control to the MATLAB® workspace.
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);
Wait for 2 seconds and peek at the two most recent records:
pause(2); s = peekdata(grp,2) s.Items(1).Value