Exemplo n.º 1
0
        /// <summary>
        /// Returns the history data source for a node.
        /// </summary>
        protected virtual ServiceResult GetHistoryDataSource(
            Opc.Ua.Server.ServerSystemContext context,
            BaseVariableState variable,
            out IHistoryDataSource datasource)
        {
            datasource = m_system.GetHistoryFile(variable);

            if (datasource == null)
            {
                return(StatusCodes.BadNotReadable);
            }

            return(ServiceResult.Good);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs a reader for the source.
 /// </summary>
 /// <param name="source">The source of the history data.</param>
 public HistoryDataReader(NodeId variableId, IHistoryDataSource source)
 {
     m_id         = Guid.NewGuid();
     m_variableId = variableId;
     m_source     = source;
 }
        /// <summary>
        /// Reads the raw data for a variable
        /// </summary>
        protected ServiceResult HistoryReadRaw(
            ISystemContext context,
            BaseVariableState source,
            ReadRawModifiedDetails details,
            TimestampsToReturn timestampsToReturn,
            bool releaseContinuationPoints,
            HistoryReadValueId nodeToRead,
            HistoryReadResult result)
        {
            ServerSystemContext serverContext = context as ServerSystemContext;

            HistoryDataReader reader = null;
            HistoryData       data   = new HistoryData();

            if (nodeToRead.ContinuationPoint != null && nodeToRead.ContinuationPoint.Length > 0)
            {
                // restore the continuation point.
                reader = RestoreDataReader(serverContext, nodeToRead.ContinuationPoint);

                if (reader == null)
                {
                    return(StatusCodes.BadContinuationPointInvalid);
                }

                // node id must match previous node id.
                if (reader.VariableId != nodeToRead.NodeId)
                {
                    Utils.SilentDispose(reader);
                    return(StatusCodes.BadContinuationPointInvalid);
                }

                // check if releasing continuation points.
                if (releaseContinuationPoints)
                {
                    Utils.SilentDispose(reader);
                    return(ServiceResult.Good);
                }
            }
            else
            {
                // get the source for the variable.
                IHistoryDataSource datasource = null;
                ServiceResult      error      = GetHistoryDataSource(serverContext, source, out datasource);

                if (ServiceResult.IsBad(error))
                {
                    return(error);
                }

                // create a reader.
                reader = new HistoryDataReader(nodeToRead.NodeId, datasource);

                // start reading.
                reader.BeginReadRaw(
                    serverContext,
                    details,
                    timestampsToReturn,
                    nodeToRead.ParsedIndexRange,
                    nodeToRead.DataEncoding,
                    data.DataValues);
            }

            // continue reading data until done or max values reached.
            bool complete = reader.NextReadRaw(
                serverContext,
                timestampsToReturn,
                nodeToRead.ParsedIndexRange,
                nodeToRead.DataEncoding,
                data.DataValues);

            // save continuation point.
            if (!complete)
            {
                SaveDataReader(serverContext, reader);
                result.StatusCode = StatusCodes.GoodMoreData;
            }

            // return the dat.
            result.HistoryData = new ExtensionObject(data);

            return(result.StatusCode);
        }
        /// <summary>
        /// Returns the history data source for a node.
        /// </summary>
        protected virtual ServiceResult GetHistoryDataSource(
            Opc.Ua.Server.ServerSystemContext context,
            BaseVariableState variable,
            out IHistoryDataSource datasource)
        {
            datasource = m_system.GetHistoryFile(variable);

            if (datasource == null)
            {
                return StatusCodes.BadNotReadable;
            }

            return ServiceResult.Good;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Constructs a reader for the source.
 /// </summary>
 /// <param name="source">The source of the history data.</param>
 public HistoryDataReader(NodeId variableId, IHistoryDataSource source)
 {
     m_id = Guid.NewGuid();
     m_variableId = variableId;
     m_source = source;
 }