Error "Object reference not set" in IAggregateCalculator.GetProcessedValue call|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Error "Object reference not set" in IAggregateCalculator.GetProcessedValue call
Avatar
Oisin O'Reilly
New Member
Members
Forum Posts: 2
Member Since:
07/07/2016
sp_UserOfflineSmall Offline
1
07/11/2022 - 02:11
sp_Permalink sp_Print

Hi,

We’re using the OPC UA Nuget packages to build a .NET OPC UA Historical Server. I was hoping to use the provided IAggregateCalculator classes to perform the aggregate calculations, however I’m getting an “Object Reference not set” error in the “GetProcessedValue” call in the AggregateCalculator class.  Sample code is provided here. This is hugely simplified to exclude our own data processing, but the exception happens for this code.

On closer inspection, the exception is happenining in the “IsGood” call for the Calculator class. Specifically I think it’s because the AggregateConfiguration object is not being passed through. I’m having trouble debugging the OPC UA library, so I don’t know exactly why. If anyone could help with this I’ld be grateful. We have coded up our own aggregate logic, but it would be neater to use the standard solution.

Note that I can use the “Aggregators.CreateStandardCalculator” call to leverage the logic for the standard aggregates, however this only provides logic for a limited number of aggregates.

/// <summary>
/// Reads the processed history for the variable value.
/// </summary>
protected virtual ServiceResult HistoryReadProcessed(
ISystemContext context,
BaseVariableState source,
ReadProcessedDetails details,
TimestampsToReturn timestampsToReturn,
bool releaseContinuationPoints,
HistoryReadValueId nodeToRead,
ref HistoryReadResult result)
{

// Create aggregate calculator
// _server is the IServerInternal from the Node manager
var aggCalc = m_server.AggregateManager.CreateCalculator(details.AggregateType[0], details.StartTime, details.EndTime,    details.ProcessingInterval, !details.AggregateConfiguration.UseSlopedExtrapolation, details.AggregateConfiguration);
aggCalc.QueueRawValue(new DataValue() { SourceTimestamp = DateTime.Now, Value = 10, StatusCode = StatusCodes.Good });

var processValue = aggCalc.GetProcessedValue(true);  // <=======”Object reference not set” error

 

Thanks in advance!

Oisin O’Reilly, Automsoft.

Avatar
Randy Armstrong
Admin
Forum Posts: 1580
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
07/11/2022 - 05:04
sp_Permalink sp_Print

This should be a working sample:

https://github.com/OPCFoundati…..icalAccess

Avatar
Oisin O'Reilly
New Member
Members
Forum Posts: 2
Member Since:
07/07/2016
sp_UserOfflineSmall Offline
3
07/13/2022 - 06:31
sp_Permalink sp_Print sp_EditHistory

Thanks Randy, I mimicked the Historical Server behaviour and this seemed to resolve it – the problem appears to be when you set UseServerCapabilitiesDefaults = “true” in the AggregateConfiguration object.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 44
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4891