/// <summary> /// Gets the local data value. /// </summary> /// <param name="remoteValue">The remote value.</param> /// <returns>The local data value.</returns> public DaValue GetLocalDataValue(DataValue remoteValue) { DaValue localValue = new DaValue(); localValue.Error = ComDaProxy.MapReadStatusToErrorCode(remoteValue.StatusCode); if (localValue.Error >= 0) { localValue.HdaQuality = ComUtils.GetHdaQualityCode(remoteValue.StatusCode); localValue.Timestamp = remoteValue.SourceTimestamp; localValue.Error = ResultIds.S_OK; if (localValue.Timestamp == DateTime.MinValue) { localValue.Timestamp = remoteValue.ServerTimestamp; } try { localValue.Value = GetLocalValue(remoteValue.WrappedValue); } catch { localValue.Error = ResultIds.E_BADTYPE; } } return(localValue); }
/// <summary> /// Gets the remote data value. /// </summary> /// <param name="localValue">The local value.</param> /// <param name="remoteType">The remote data type.</param> /// <returns>The remote data value.</returns> /// <exception cref="COMException">Thrown if a conversion error occurs.</exception> public DataValue GetRemoteDataValue(DaValue localValue, TypeInfo remoteType) { DataValue remoteValue = new DataValue(); remoteValue.SourceTimestamp = localValue.Timestamp; if (localValue.Error < 0) { throw ComUtils.CreateComException(localValue.Error); } remoteValue.StatusCode = ComUtils.GetHdaQualityCode(localValue.HdaQuality); try { remoteValue.WrappedValue = GetRemoteValue(new Variant(localValue.Value), remoteType); } catch (Exception e) { throw ComUtils.CreateComException(e, ResultIds.E_BADTYPE); } return(remoteValue); }