07/07/2016
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.
05/30/2017
This should be a working sample:
1 Guest(s)