/// <summary> /// Adds a request for the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="nodeToRead">The node to read.</param> /// <param name="value">The value.</param> /// <param name="queued">if set to <c>true</c> [queued].</param> /// <returns></returns> public StatusCode Add(NodeState source, ReadValueId nodeToRead, DataValue value, out bool queued) { queued = true; // read item value. DaItemState item = source as DaItemState; if (item != null) { return(Add(item, nodeToRead, out queued)); } // read vendor defined property value. DaPropertyState daProperty = source as DaPropertyState; if (daProperty != null) { return(Add(daProperty, nodeToRead, out queued)); } // read UA defined property value. PropertyState uaProperty = source as PropertyState; if (uaProperty != null) { return(Add(uaProperty, nodeToRead, out queued)); } queued = false; return(StatusCodes.Good); }
/// <summary> /// Adds the specified property. /// </summary> /// <param name="property">The property.</param> /// <param name="nodeToRead">The node to read.</param> /// <param name="queued">if set to <c>true</c> [queued].</param> /// <returns>Any error.</returns> private StatusCode Add(DaPropertyState property, ReadValueId nodeToRead, out bool queued) { queued = true; switch (nodeToRead.AttributeId) { case Attributes.Value: { nodeToRead.Handle = Add(property.ItemId, property.Property); break; } default: { queued = false; break; } } return(StatusCodes.Good); }
/// <summary> /// Adds a write request for a DA item. /// </summary> /// <param name="source">The source.</param> /// <param name="nodeToWrite">The node to write.</param> /// <param name="index">The index associated with the value.</param> /// <param name="queued">If set to <c>true</c> then the a request was added.</param> /// <returns> /// StatusCode.Good if the write is allowed. An error code otherwise. /// </returns> public StatusCode Add(NodeState source, WriteValue nodeToWrite, int index, out bool queued) { queued = true; DaItemState item = source as DaItemState; if (item != null) { return(Add(item, nodeToWrite, index)); } DaPropertyState property = source as DaPropertyState; if (property != null) { return(Add(property, nodeToWrite, index)); } queued = false; return(StatusCodes.Good); }
/// <summary> /// Gets the result. /// </summary> /// <param name="context">The context.</param> /// <param name="source">The source.</param> /// <param name="nodeToRead">The node to read.</param> /// <param name="value">The value.</param> /// <param name="diagnosticsMasks">The diagnostics masks.</param> /// <returns></returns> public ServiceResult GetResult( ISystemContext context, NodeState source, ReadValueId nodeToRead, DataValue value, DiagnosticsMasks diagnosticsMasks) { ReadRequest request = nodeToRead.Handle as ReadRequest; if (request == null) { return(StatusCodes.Good); } // read item value. DaItemState item = source as DaItemState; if (item != null) { return(request.GetResult(context, item, nodeToRead, value, diagnosticsMasks)); } // read vendor defined property value. DaPropertyState daProperty = source as DaPropertyState; if (daProperty != null) { return(request.GetResult(context, daProperty, nodeToRead, value, diagnosticsMasks)); } // read UA defined property value. PropertyState uaProperty = source as PropertyState; if (uaProperty != null) { return(request.GetResult(context, uaProperty, nodeToRead, value, diagnosticsMasks)); } return(StatusCodes.Good); }
/// <summary> /// Gets the result for the read operation. /// </summary> /// <param name="context">The context.</param> /// <param name="property">The property.</param> /// <param name="nodeToRead">The node to read.</param> /// <param name="value">The value.</param> /// <param name="diagnosticsMasks">The diagnostics masks.</param> /// <returns></returns> public ServiceResult GetResult( ISystemContext context, DaPropertyState property, ReadValueId nodeToRead, DataValue value, DiagnosticsMasks diagnosticsMasks) { ServiceResult result = null; switch (nodeToRead.AttributeId) { case Attributes.Value: { if (!String.IsNullOrEmpty(property.Property.ItemId)) { result = GetItemValue(m_value, value, diagnosticsMasks); } else { this.GetPropertyValue <object>(property.PropertyId, value, true); result = value.StatusCode; } // check if the property value is missing. if (value.StatusCode == StatusCodes.BadNotFound) { return(StatusCodes.BadAttributeIdInvalid); } if (ServiceResult.IsBad(result)) { return(result); } return(ApplyIndexRangeAndDataEncoding(context, nodeToRead, value)); } } return(StatusCodes.BadAttributeIdInvalid); }
/// <summary> /// Adds a write request for a DA property value. /// </summary> /// <param name="item">The item.</param> /// <param name="nodeToWrite">The node to write.</param> /// <param name="index">The index associated with the value.</param> /// <returns> /// StatusCode.Good if the write is allowed. An error code otherwise. /// </returns> private StatusCode Add(DaPropertyState item, WriteValue nodeToWrite, int index) { if (nodeToWrite.AttributeId != Attributes.Value) { return(StatusCodes.BadNotWritable); } if (String.IsNullOrEmpty(item.Property.ItemId)) { return(StatusCodes.BadNotWritable); } if (nodeToWrite.ParsedIndexRange != NumericRange.Empty) { return(StatusCodes.BadIndexRangeInvalid); } if (nodeToWrite.Value.ServerTimestamp != DateTime.MinValue) { return(StatusCodes.BadWriteNotSupported); } if (item.Property.DataType != 0) { if (!CheckDataType(item.Property.DataType, nodeToWrite.Value.WrappedValue)) { return(StatusCodes.BadTypeMismatch); } } WriteRequest request = new WriteRequest(item.Property.ItemId, nodeToWrite.Value, index); Add(request); nodeToWrite.Handle = request; return(StatusCodes.Good); }
/// <summary> /// Removes a request for the specified item property. /// </summary> /// <param name="item">The item property.</param> /// <param name="monitoredItem">The monitored item.</param> private void Remove(DaPropertyState item, MonitoredItem monitoredItem) { if (monitoredItem.AttributeId != Attributes.Value) { return; } // check if the server supports access by item id for the property. if (!String.IsNullOrEmpty(item.Property.ItemId)) { SubscribeItemRequest request = FindItemRequest(item.Property.ItemId, false); if (request != null) { request.Remove(monitoredItem); } } // must access with the property id. else { SubscribePropertyRequest request = FindPropertyRequest(item.ItemId, false); if (request != null) { request.Remove(m_context, monitoredItem); if (request.MonitoredItems.Count == 0) { m_subscribedProperties.Remove(item.ItemId); } } } }