Main Content

readRaw

Read raw data of specified time range from HDA server

Description

DObj = readRaw(HdaClient,ItmList,StartTime,EndTime) reads data from the items defined by ItmList, stored on the OPC HDA server connected to OPC HDA client HdaClient, between StartTime (inclusive) and EndTime (exclusive). DObj is returned as an opc.hda.Data array, with one element per item specified in ItmList.

DObj = readRaw(HdaClient,ItmList,StartTime,EndTime,ExtendedBounds) allows you to specify boundary extension. If ExtendedBounds is true, then the first data point on or outside the defined start and end times is returned. If ExtendedBounds is false, then only values that were timestamped between StartTime (inclusive) and EndTime (exclusive) are included.

One or more timestamps returned for each item can be unique to that item. To retrieve aligned data from an OPC HDA server, use readAtTime or readProcessed.

example

Examples

collapse all

Read data over the past day from two items in the OPC HDA server.

Create an OPC HDA client and connect the client to the server.

hdaObj = opchda('localhost','Matrikon.OPC.Simulation');
connect(hdaObj);

Read the last day’s data from two specified items.

DObj = readRaw(hdaObj,{'Random.Real8','Random.Real4'},datetime("now")-days(1),datetime("now"));

Input Arguments

collapse all

OPC HDA client, specified as an OPC HDA client object.

Example: opchda()

HDA items, specified as a character vector, string, or supporting array of either.

Example: {'Random.Real8','Random.Real4'}

Data Types: char | string | cell

Time boundaries, specified as datetime values returned by datetime function.

Example: datetime(2018,11,30)

Data Types: datetime

Extend time boundaries to assure inclusion of start and end times, specified as false or true.

This flag instructs the historical server whether to completely span the required start and end time, or return only values that are contained within the specified start and end time (start time included but not end time). If ExtendedBounds is true, the returned values are guaranteed to include the timestamp at or before the specified start time, and at or after the specified end time. If ExtendedBounds is false, there is no guarantee that the values include the exact specified start time, and definitely do not include the specified end time. The rules applied by this flag are:

  • If ExtendedBounds is false (default), the server returns all recorded data from the start time up to, but not including, the end time.

  • If ExtendedBounds is true, the server returns all data from the start time up to (and including) the end time. If no data value exists exactly at the start time, the previous value is returned; if no data value exists exactly at the end time, the next value is be returned; even if these values are outside the specified start and end times.

  • If ExtendedBounds is true and no data exists on the start time or before it, the server includes a value of Empty at the start timestamp, and a quality of OPCHDA_NOBOUND (“No Bound”). Similarly for the end time.

Example: true

Data Types: logical

Output Arguments

collapse all

Raw OPC HDA data returned as an array of OPC HDA data objects, with one element per item.

Version History

Introduced in R2011a