Opc.Ua.Server.CoreNodeManager.HistoryRead C# (CSharp) Method

HistoryRead() public method

public HistoryRead ( OperationContext context, HistoryReadDetails details, TimestampsToReturn timestampsToReturn, bool releaseContinuationPoints, IList nodesToRead, IList results, IList errors ) : void
context OperationContext
details HistoryReadDetails
timestampsToReturn TimestampsToReturn
releaseContinuationPoints bool
nodesToRead IList
results IList
errors IList
return void
        public void HistoryRead(
            OperationContext          context,
            HistoryReadDetails        details, 
            TimestampsToReturn        timestampsToReturn, 
            bool                      releaseContinuationPoints, 
            IList<HistoryReadValueId> nodesToRead, 
            IList<HistoryReadResult>  results, 
            IList<ServiceResult>      errors) 
        {
            if (context == null)     throw new ArgumentNullException("context");
            if (details == null)     throw new ArgumentNullException("details");
            if (nodesToRead == null) throw new ArgumentNullException("nodesToRead");
            if (results == null)     throw new ArgumentNullException("results");
            if (errors == null)      throw new ArgumentNullException("errors");

            ReadRawModifiedDetails readRawModifiedDetails = details as ReadRawModifiedDetails;
            ReadAtTimeDetails readAtTimeDetails = details as ReadAtTimeDetails;
            ReadProcessedDetails readProcessedDetails = details as ReadProcessedDetails;
            ReadEventDetails readEventDetails = details as ReadEventDetails;
            
            #if LEGACY_CORENODEMANAGER 
            Dictionary<object,List<RequestHandle>> historians = new Dictionary<object,List<RequestHandle>>();
            #endif
            
            try
            {
                m_lock.Enter();
                
                #if LEGACY_CORENODEMANAGER 
                Type sourceType = typeof(IDataHistoryProducer);

                if (readEventDetails != null)
                {
                    sourceType = typeof(IEventHistoryProducer);
                }                
                #endif

                for (int ii = 0; ii < nodesToRead.Count; ii++)
                {
                    HistoryReadValueId nodeToRead = nodesToRead[ii];

                    // skip items that have already been processed.
                    if (nodeToRead.Processed)
                    {
                        continue;
                    }
                    
                    // look up the node.
                    ILocalNode node = GetLocalNode(nodeToRead.NodeId) as ILocalNode;

                    if (node == null)
                    {
                        continue;
                    }
                    
                    // owned by this node manager.
                    nodeToRead.Processed = true;
                    
                    #if LEGACY_CORENODEMANAGER 
                    // find the historian.
                    if (!CheckSourceHandle(node, sourceType, ii, historians))
                    {
                        errors[ii] = StatusCodes.BadNotReadable;
                        continue;
                    }
                    #else
                    errors[ii] = StatusCodes.BadNotReadable;
                    #endif
                }
                
                #if LEGACY_CORENODEMANAGER 
                // check if nothing to do.
                if (historians.Count == 0)
                {
                    return;
                }
                #endif
            }
            finally
            {
                m_lock.Exit();
            }
            
            #if LEGACY_CORENODEMANAGER 
            // call the historians.
            foreach (KeyValuePair<object,List<RequestHandle>> entry in historians)
            {
                if (readRawModifiedDetails != null)
                {
                    ((IDataHistoryProducer)entry.Key).ReadRaw(
                        context,
                        readRawModifiedDetails,
                        timestampsToReturn,
                        releaseContinuationPoints,
                        entry.Value,
                        nodesToRead,
                        results,
                        errors);                            
                }

                else if (readAtTimeDetails != null)
                {
                    ((IDataHistoryProducer)entry.Key).ReadAtTime(
                        context,
                        readAtTimeDetails,
                        timestampsToReturn,
                        releaseContinuationPoints,
                        entry.Value,
                        nodesToRead,
                        results,
                        errors);                            
                }

                else if (readProcessedDetails != null)
                {
                    ((IDataHistoryProducer)entry.Key).ReadProcessed(
                        context,
                        readProcessedDetails,
                        timestampsToReturn,
                        releaseContinuationPoints,
                        entry.Value,
                        nodesToRead,
                        results,
                        errors);                            
                }

                else if (readEventDetails != null)
                {
                    ((IEventHistoryProducer)entry.Key).ReadEvents(
                        context,
                        readEventDetails,
                        timestampsToReturn,
                        releaseContinuationPoints,
                        entry.Value,
                        nodesToRead,
                        results,
                        errors);                            
                }
            } 
            #endif
        }