Provides access to a COM DA server.
Inheritance: ComClient
 /// <summary>
 /// Initializes a new instance of the <see cref="ComHdaBrowserClient"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="itemId">The qualified area name.</param>
 public ComHdaBrowserClient(
     ComHdaClient client,
     string itemId)
 {
     m_client = client;
     m_itemId = itemId; 
 }
示例#2
0
	    /// <summary>
	    /// Initializes the object with the containing subscription object.
	    /// </summary>
        public ComHdaDataCallback(ComHdaClient server)
	    { 
            // save group.
            m_server = server;

		    // create connection point.
            m_connectionPoint = new ConnectionPoint(server.Unknown, typeof(OpcRcw.Hda.IOPCHDA_DataCallback).GUID);

		    // advise.
		    m_connectionPoint.Advise(this);
	    }
        /// <summary>
        /// Reads the history of an HDA item annotations.
        /// </summary>
        private ServiceResult HistoryReadAnnotations(
            ServerSystemContext context,
            ComHdaClient client,
            ReadRawModifiedDetails details,
            TimestampsToReturn timestampsToReturn,
            HistoryReadValueId nodeToRead,
            HdaParsedNodeId parsedNodeId,
            HistoryReadResult result)
        {
            // create the request or load it from a continuation point.
            HdaHistoryReadAnnotationRequest request = null;

            if (nodeToRead.ContinuationPoint == null)
            {
                // create a new request.
                request = new HdaHistoryReadAnnotationRequest(parsedNodeId.RootId, details, nodeToRead);

                // fetch all of the data at once.
                result.StatusCode = client.ReadAnnotationHistory(request);
            }
            else
            {
                request = LoadContinuationPoint(context, nodeToRead.ContinuationPoint) as HdaHistoryReadAnnotationRequest;

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

            // select a subset of the results.
            if (StatusCode.IsGood(result.StatusCode))
            {
                request.Results = new DataValueCollection();
                request.GetHistoryResults(context, nodeToRead, request.Results);
            }

            // fill in the results.
            if (request.Results != null)
            {
                HistoryData data = new HistoryData();
                data.DataValues = request.Results;
                result.HistoryData = new ExtensionObject(data);
            }

            // create a new continuation point.
            if (!request.Completed)
            {
                result.ContinuationPoint = SaveContinuationPoint(context, request);
            }

            return result.StatusCode;
        }
        /// <summary>
        /// Reads the history of an HDA item.
        /// </summary>
        private ServiceResult HistoryReadItem(
            ServerSystemContext context,
            ComHdaClient client,
            ReadRawModifiedDetails details,
            TimestampsToReturn timestampsToReturn,
            HistoryReadValueId nodeToRead,
            HdaParsedNodeId parsedNodeId,
            HistoryReadResult result)
        { 
            // create the request or load it from a continuation point.
            HdaHistoryReadRawModifiedRequest request = null;

            if (nodeToRead.ContinuationPoint == null)
            {
                request = new HdaHistoryReadRawModifiedRequest(parsedNodeId.RootId, details, nodeToRead);
            }
            else
            {
                request = LoadContinuationPoint(context, nodeToRead.ContinuationPoint) as HdaHistoryReadRawModifiedRequest;

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

            // fetch the data.
            result.StatusCode = client.ReadHistory(request);

            // fill in the results.
            if (request.Results != null)
            {
                HistoryData data = (request.IsReadModified)?new HistoryModifiedData():new HistoryData();

                if (request.IsReadModified)
                {
                    ((HistoryModifiedData)data).ModificationInfos = request.ModificationInfos;
                }

                data.DataValues = request.Results;
                result.HistoryData = new ExtensionObject(data);
            }

            // create a new continuation point.
            if (!request.Completed)
            {
                result.ContinuationPoint = SaveContinuationPoint(context, request);
            }

            return result.StatusCode;
        }
        /// <summary>
        /// Releases the handles.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="requests">The requests.</param>
        private void ReleaseHandles(ComHdaClient client, List<HdaSubscribeAttributeRequest> requests)
        {
            List<int> serverHandles = null;

            lock (m_lock)
            {
                for (int ii = 0; ii < requests.Count; ii++)
                {
                    if (requests[ii].ServerHandle != null)
                    {
                        if (serverHandles == null)
                        {
                            serverHandles = new List<int>();
                        }

                        serverHandles.Add(requests[ii].ServerHandle.Value);
                        requests[ii].ServerHandle = null;
                    }
                }
            }

            if (serverHandles == null)
            {
                return;
            }

            client.ReleaseItemHandles(serverHandles.ToArray());
        }
        /// <summary>
        /// Assigns the handles to the requests.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="requests">The requests.</param>
        private void AssignHandles(ComHdaClient client, Dictionary<string, HdaSubscribeAttributeRequest> requests)
        {
            List<string> itemIds = null;

            lock (m_lock)
            {
                foreach (KeyValuePair<string,HdaSubscribeAttributeRequest> entry in requests)
                {
                    if (entry.Value.ServerHandle == null)
                    {
                        if (itemIds == null)
                        {
                            itemIds = new List<string>();
                        }

                        itemIds.Add(entry.Key);
                    }
                }
            }

            if (itemIds == null)
            {
                return;
            }

            HdaItem[] items = client.GetItems(itemIds.ToArray());

            lock (m_lock)
            {
                for (int ii = 0; ii < items.Length; ii++)
                {
                    HdaSubscribeAttributeRequest request = null;

                    if (!requests.TryGetValue(itemIds[ii], out request))
                    {
                        continue;
                    }

                    if (items[ii].Error < 0)
                    {
                        request.ServerHandle = null;
                        continue;
                    }

                    request.ServerHandle = items[ii].ServerHandle;
                }
            }
        }
示例#7
0
        /// <summary>
        /// Finds the children for hda item configuration.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="children">The children.</param>
        /// <param name="attributes">The attribute values.</param>
        private void FindChildrenForHdaItemConfiguration(ComHdaClient client, List<BaseInstanceState> children, HdaAttributeValue[] attributes)
        {          
            BaseInstanceState child = null;

            if (IsRequired(ReferenceTypeIds.HasProperty, false))
            {
                for (int ii = 0; ii < attributes.Length; ii++)
                {
                    if (attributes[ii].Error < 0 || attributes[ii].Error == ResultIds.S_NODATA)
                    {
                        continue;
                    }

                    bool skip = true;

                    switch (attributes[ii].AttributeId)
                    {
                        case Constants.OPCHDA_DERIVE_EQUATION:
                        case Constants.OPCHDA_STEPPED:
                        case Constants.OPCHDA_MAX_TIME_INT:
                        case Constants.OPCHDA_MIN_TIME_INT:
                        case Constants.OPCHDA_EXCEPTION_DEV:
                        case Constants.OPCHDA_EXCEPTION_DEV_TYPE:
                        {
                            skip = false;
                            break;
                        }
                    }

                    if (skip)
                    {
                        continue;
                    }

                    child = client.FindItemAttribute(m_itemId, attributes[ii].AttributeId, m_namespaceIndex);

                    if (child != null)
                    {
                        children.Add(child);
                    }
                }
            }
        }