Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
How we get history data in batches
October 1, 2015
6:22, EEST
Avatar
jijomonac
Member
Members
Forum Posts: 18
Member Since:
September 24, 2015
sp_UserOfflineSmall Offline

We want to get history data in batches, for that we set numValuesPerNode =10; But its not working, It returns entire Data

UnsignedInteger batchsize=new UnsignedInteger(10);
DataValue[] result = client.historyReadRaw(nodeId,
DateTime.MIN_VALUE, DateTime.currentTime(),
UnsignedInteger.ONE, true, null, TimestampsToReturn.Source);

October 1, 2015
8:45, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, that is true. The current implementation fetches the data in batches automatically and provides the data as a whole, when ready.

historyRead() is the raw interface for calling the service with your own parameters and doing it in batches on your own code.

This is the internal implementation:

HistoryReadDetails details = new ReadRawModifiedDetails(false,
startTime, endTime, numValuesPerNode, returnBounds);
return historyReadAll(nodeId, indexRange, timestampsToReturn, details);

where

private DataValue[] historyReadAll(NodeId nodeId, NumericRange indexRange,
TimestampsToReturn timestampsToReturn, HistoryReadDetails details)
throws ServiceException, StatusException,
DecodingException {
HistoryReadValueId id = new HistoryReadValueId();
id.setNodeId(nodeId);
if (indexRange != null)
id.setIndexRange(indexRange.toString());
List<DataValue> dataList = null;
HistoryData data;
byte[] continuationPoint;
// While continuationPoints returned
do {
HistoryReadResult[] results = historyRead(details,
timestampsToReturn, false, id);
checkOperationResult(results[0].getStatusCode());
if (results[0].getStatusCode().getValue()
.equals(StatusCodes.Good_NoData))
break;
ExtensionObject historyDataObject = results[0].getHistoryData();
if (historyDataObject == null)
break;
data = historyDataObject.decode(client.getEncoderContext());
continuationPoint = results[0].getContinuationPoint();
if ((continuationPoint == null) && (dataList == null))
return data.getDataValues();
if (dataList == null)
dataList = new ArrayList<DataValue>();
dataList.addAll(Arrays.asList(data.getDataValues()));
id.setContinuationPoint(continuationPoint);
if ((data.getDataValues().length == 0)
&& (continuationPoint != null)) {
logger.info(
"historyReadAll: Received empty HistoryData with continuationPoint");
break;
} else
logger.debug("historyReadAll: got {} values",
data.getDataValues().length);
} while (continuationPoint != null);

return dataList == null ? new DataValue[0]
: dataList.toArray(new DataValue[dataList.size()]);
}

October 1, 2015
12:32, EEST
Avatar
jijomonac
Member
Members
Forum Posts: 18
Member Since:
September 24, 2015
sp_UserOfflineSmall Offline

thank You!

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 738

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6451

Newest Members:

jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1