Beispiel #1
0
        /// <summary>
        /// Reads the next batch of values from the server.
        /// </summary>
        private bool ReadNext(
            Session session,
            ExtensionObject details,
            List<HdaReadRequest> requests,
            bool releaseContinuationPoints)
        {
            // get the value.
            HistoryReadValueIdCollection nodesToRead = new HistoryReadValueIdCollection();

            for (int ii = 0; ii < requests.Count; ii++)
            {
                HdaReadRequest request = requests[ii];

                if (request.IsComplete || request.Error < 0)
                {
                    continue;
                }

                if (NodeId.IsNull(request.NodeId))
                {
                    request.Error = ResultIds.S_NODATA;
                    continue;
                }

                HistoryReadValueId nodeToRead = new HistoryReadValueId();
                nodeToRead.NodeId = request.NodeId;
                nodeToRead.ContinuationPoint = request.ContinuationPoint;
                nodeToRead.Handle = request;
                nodesToRead.Add(nodeToRead);
            }

            // check if something to do.
            if (nodesToRead.Count == 0)
            {
                return false;
            }

            HistoryReadResultCollection results = null;
            DiagnosticInfoCollection diagnosticInfos = null;

            session.HistoryRead(
                null,
                details,
                TimestampsToReturn.Source,
                releaseContinuationPoints,
                nodesToRead,
                out results,
                out diagnosticInfos);

            Session.ValidateResponse(results, nodesToRead);
            Session.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead);

            // check if nothing more to do.
            if (releaseContinuationPoints)
            {
                return false;
            }

            // process results.
            bool continuationPoints = false;

            for (int ii = 0; ii < nodesToRead.Count; ii++)
            {
                HdaReadRequest request = (HdaReadRequest)nodesToRead[ii].Handle;

                if (request.Values == null)
                {
                    request.Values = new List<DaValue>();
                }

                request.Error = ProcessReadResults(
                    session, 
                    results[ii], 
                    request.AttributeId, 
                    request.Values, 
                    request.ModificationInfos);
                
                request.ContinuationPoint = results[ii].ContinuationPoint;

                // check if continuation point provided.
                if (request.ContinuationPoint != null && request.ContinuationPoint.Length > 0)
                {
                    request.Error = ResultIds.S_MOREDATA;
                    continuationPoints = true;
                }
                else
                {
                    request.IsComplete = true;
                }
            }

            return continuationPoints;
        }