} // end QueryProperties /// <summary> /// Changes value cache value of this element instance /// </summary> /// <param name="aNewValue"></param> /// <returns> /// E_INVALIDARG - Invalid valueQT was passed /// S_OK - Value changed /// OTS_E_EXCEPTION - Unexpected error occurred /// </returns> /// <include /// file='TBNS.doc.xml' /// path='//class[@name="DaAddressSpaceElement"]/ /// method[@name="ValueChanged"]/doc/*' /// /> public virtual int ValueChanged(ValueQT aNewValue) { if (this.ObjectHandle == 0) { return (int) EnumResultCode.E_FAIL; } // end if OTValueData valueData = new OTValueData(); valueData.m_quality = (ushort) aNewValue.Quality; valueData.m_timestamp = new OTDateTime(aNewValue.TimeStamp); valueData.m_value = Marshal.AllocCoTaskMem(ValueQT.VARIANT_SIZE); Marshal.GetNativeVariantForObject(aNewValue.Data, valueData.m_value); int result = OTBFunctions.OTSValuesChanged(1, new uint[1] {ObjectHandle}, new OTValueData[1] {valueData}); OTBFunctions.OTVariantClear(valueData.m_value); Marshal.FreeCoTaskMem(valueData.m_value); return result; } // end ValueChanged
} // end QueryAddressSpaceElementChildren /// <summary> /// Changes the cache value for the Address space elements provided /// </summary> /// <param name="anElementList">the namespace elements</param> /// <param name="aValueList">the corresponding values</param> /// <returns> /// E_INVALIDARG - Invalid valueQT was passed /// S_OK - Value changed /// OTS_E_EXCEPTION - Unexpected error occurred /// </returns> /// <include /// file='TBNS.doc.xml' /// path='//class[@name="DaAddressSpaceRoot"]/ /// method[@name="ValuesChanged.array"]/doc/*' /// /> public int ValuesChanged(DaAddressSpaceElement[] anElementList, ValueQT[] aValueList) { if (anElementList.Length != aValueList.Length) { return (int) EnumResultCode.E_INVALIDARG; } // end if int count = anElementList.Length; if (count == 0) { return (int) EnumResultCode.S_FALSE; } // end if OTValueData[] aoValues = new OTValueData[count]; uint[] ahObjects = new uint[count]; for (int i = 0; i < count; i++) { ahObjects[i] = anElementList[i].ObjectHandle; aoValues[i] = new OTValueData(); aoValues[i].m_quality = (ushort) aValueList[i].Quality; aoValues[i].m_timestamp = new OTDateTime(aValueList[i].TimeStamp); aoValues[i].m_value = Marshal.AllocCoTaskMem(ValueQT.VARIANT_SIZE); Marshal.GetNativeVariantForObject(aValueList[i].Data, aoValues[i].m_value); } // end for int result = OTBFunctions.OTSValuesChanged(count, ahObjects, aoValues); for (int i = 0; i < count; i++) { OTBFunctions.OTVariantClear(aoValues[i].m_value); Marshal.FreeCoTaskMem(aoValues[i].m_value); } // end for return result; } // end ValuesChanged
} // end CompleteRequest /// <summary> /// Changes the cache value for the Address space elements provided /// </summary> /// <returns> /// E_INVALIDARG - Invalid valueQT was passed /// S_OK - Value changed /// OTS_E_EXCEPTION - Unexpected error occurred /// The Result should be checked with ResultCode.SUCCEEDED /// or with ResultCode.FAILED /// </returns> /// <include /// file='TBNS.doc.xml' /// path='//class[@name="DaTransaction"]/ /// method[@name="ValuesChanged"]/doc/*' /// /> public int ValuesChanged() { int result; int count = 0; OTValueData[] values = null; uint[] handles = null; try { lock (m_requestListJanitor) { count = m_requestList.Count; values = new OTValueData[count]; handles = new uint[count]; for (int i = 0; i < count; i++) { OTValueData valueData = new OTValueData(); DaRequest request = m_requestList[i] as DaRequest; if (request != null) { valueData.m_quality = (ushort) request.Value.Quality; valueData.m_timestamp = new OTDateTime(request.Value.TimeStamp); valueData.m_value = Marshal.AllocCoTaskMem(ValueQT.VARIANT_SIZE); Marshal.GetNativeVariantForObject(request.Value.Data, valueData.m_value); handles[i] = request.AddressSpaceElement.ObjectHandle; request.Result = EnumResultCode.S_OK; } else { valueData.m_quality = (ushort) EnumQuality.BAD; valueData.m_value = Marshal.AllocCoTaskMem(ValueQT.VARIANT_SIZE); Marshal.GetNativeVariantForObject(null, valueData.m_value); handles[i] = 0; } // end if ... else values[i] = valueData; } // end for result = OTBFunctions.OTSValuesChanged(count, handles, values); } // end lock } catch (Exception e) { Application.Instance.Trace( EnumTraceLevel.ERR, EnumTraceGroup.OPCSERVER, "DaTransaction.ValuesChanged", "Exception caught: " + e.ToString()); result = (int) EnumResultCode.E_FAIL; } finally { for (int i = 0; i < count; i++) { OTBFunctions.OTVariantClear(values[i].m_value); Marshal.FreeCoTaskMem(values[i].m_value); } // end for } // end try ... catch ... finally return result; } // end ValuesChanged