/// <summary> /// Initializes a new <see cref="LogCurveInfo" /> based on a <see cref="Energistics.DataAccess.WITSML141.ComponentSchemas.LogCurveInfo" />. /// </summary> /// <param name="logCurveInfo">The WITSML 1.4.1.1 log curve info</param> public LogCurveInfo(Energistics.DataAccess.WITSML141.ComponentSchemas.LogCurveInfo logCurveInfo) { logCurveInfo.NotNull(nameof(logCurveInfo)); _logCurveInfo141 = logCurveInfo; DataSchemaVersion = OptionsIn.DataVersion.Version141.Value; }
public void LogExtensions_GetIndexRange_Returns_Range_From_141_DepthLog() { double start, end; InitDepthIndexes(out start, out end); var log = new Witsml141.Log { LogCurveInfo = new List <Witsml141.ComponentSchemas.LogCurveInfo>() }; var result = new Witsml141.ComponentSchemas.LogCurveInfo().GetIndexRange(); Assert.IsNull(result.Start); Assert.IsNull(result.End); // Add logCurveInfo with just start index var lci0 = _log141Generator.CreateDoubleLogCurveInfo("DEPTH", "m"); lci0.NullValue = "-1000.00"; lci0.MinIndex = new Witsml141.ComponentSchemas.GenericMeasure(start, "m"); log.LogCurveInfo.Add(lci0); result = log.LogCurveInfo[0].GetIndexRange(); Assert.IsNotNull(result); Assert.IsTrue(result.Start.HasValue); Assert.IsFalse(result.End.HasValue); Assert.AreEqual(start, result.Start.Value); // Decreasing log result = log.LogCurveInfo[0].GetIndexRange(false); Assert.IsNotNull(result); Assert.IsTrue(result.End.HasValue); Assert.IsFalse(result.Start.HasValue); Assert.AreEqual(start, result.End.Value); // Update end index lci0.MaxIndex = new Witsml141.ComponentSchemas.GenericMeasure(end, "m"); result = log.LogCurveInfo[0].GetIndexRange(); Assert.IsNotNull(result); Assert.IsTrue(result.Start.HasValue); Assert.IsTrue(result.End.HasValue); Assert.AreEqual(start, result.Start.Value); Assert.AreEqual(end, result.End.Value); // Decreasing with end index result = log.LogCurveInfo[0].GetIndexRange(false); Assert.IsNotNull(result); Assert.IsTrue(result.Start.HasValue); Assert.IsTrue(result.End.HasValue); Assert.AreEqual(start, result.End.Value); Assert.AreEqual(end, result.Start.Value); }
/// <summary> /// Converts a 141 LogCurveInfo to a LogCurveItem /// </summary> /// <param name="logCurveInfo">The log curve information.</param> /// <param name="toOffset">The time span to convert the timestamp to if indexes are time.</param> /// <returns>LogCurveItem</returns> public static LogCurveItem ToLogCurveItem(this Witsml141.ComponentSchemas.LogCurveInfo logCurveInfo, TimeSpan toOffset) { var startIndex = logCurveInfo.GetStartIndex(); var endIndex = logCurveInfo.GetEndIndex(); return(new LogCurveItem( logCurveInfo.Mnemonic?.Value, logCurveInfo.CurveDescription, startIndex is Timestamp ? ((Timestamp?)startIndex).ToDisplayDateTime(toOffset) : startIndex?.ToString() ?? string.Empty, endIndex is Timestamp ? ((Timestamp?)endIndex).ToDisplayDateTime(toOffset) : endIndex?.ToString() ?? string.Empty, logCurveInfo.Unit, logCurveInfo.TypeLogData?.ToString("F"), logCurveInfo.NullValue)); }
/// <summary> /// Initializes a new <see cref="LogCurveInfo" /> based on either a <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo" /> /// or a <see cref="Energistics.DataAccess.WITSML141.ComponentSchemas.LogCurveInfo" />. /// </summary> /// <param name="logCurveInfo">The WITSML 1.3.1.1 or 1.4.1.1 log curve info</param> public LogCurveInfo(object logCurveInfo) { logCurveInfo.NotNull(nameof(logCurveInfo)); if (logCurveInfo is Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo) { _logCurveInfo131 = logCurveInfo as Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo; DataSchemaVersion = OptionsIn.DataVersion.Version131.Value; } else if (logCurveInfo is Energistics.DataAccess.WITSML141.ComponentSchemas.LogCurveInfo) { _logCurveInfo141 = logCurveInfo as Energistics.DataAccess.WITSML141.ComponentSchemas.LogCurveInfo; DataSchemaVersion = OptionsIn.DataVersion.Version141.Value; } else { throw new ArgumentException(@"Not a WITSML 1.3.1.1 or WITSML 1.4.1.1 log curve info", nameof(logCurveInfo)); } }
/// <summary> /// Gets the index range for the specified <see cref="Witsml141.ComponentSchemas.LogCurveInfo" />. /// </summary> /// <param name="logCurveInfo">The log curve.</param> /// <param name="increasing">if set to <c>true</c>, index values are increasing.</param> /// <param name="isTimeIndex">if set to <c>true</c> the log is using a datetime index.</param> /// <returns>The index range for the specified log curve.</returns> public static Range <double?> GetIndexRange(this Witsml141.ComponentSchemas.LogCurveInfo logCurveInfo, bool increasing = true, bool isTimeIndex = false) { // NOTE: logging here is too verbose! //_log.DebugFormat("Getting logCurveInfo index range: {0}", logCurveInfo?.Mnemonic?.Value); double?start = null; double?end = null; if (logCurveInfo == null) { return(new Range <double?>(null, null) .Sort(increasing)); } if (isTimeIndex) { if (logCurveInfo.MinDateTimeIndex.HasValue) { start = logCurveInfo.MinDateTimeIndex.ToUnixTimeMicroseconds(); } if (logCurveInfo.MaxDateTimeIndex.HasValue) { end = logCurveInfo.MaxDateTimeIndex.ToUnixTimeMicroseconds(); } } else { if (logCurveInfo.MinIndex != null) { start = logCurveInfo.MinIndex.Value; } if (logCurveInfo.MaxIndex != null) { end = logCurveInfo.MaxIndex.Value; } } return(increasing ? new Range <double?>(start, end) : new Range <double?>(end, start)); }
public void EtpUris_GetUri_Can_Get_LogCurveInfo_141_Uri() { var logCurve = new Witsml141.ComponentSchemas.LogCurveInfo { Mnemonic = new Witsml141.ComponentSchemas.ShortNameStruct("ROP") }; var log = new Witsml141.Log { Uid = _data.Uid(), UidWell = _data.Uid(), UidWellbore = _data.Uid(), LogCurveInfo = new List <Witsml141.ComponentSchemas.LogCurveInfo> { logCurve } }; var uri = logCurve.GetUri(log); Assert.IsTrue($"eml://witsml14/well({log.UidWell})/wellbore({log.UidWellbore})/log({log.Uid})/logCurveInfo({logCurve.Mnemonic})".EqualsIgnoreCase(uri.ToString())); Assert.AreEqual(ObjectTypes.LogCurveInfo, uri.ObjectType); Assert.AreEqual(logCurve.Mnemonic.Value, uri.ObjectId); }
public void LogExtensions_GetIndexRange_Returns_Range_From_141_TimeLog() { Timestamp start, end; InitTimeIndexes(out start, out end); var startAsLong = start.ToUnixTimeMicroseconds(); var endAsLong = end.ToUnixTimeMicroseconds(); var log = new Witsml141.Log { LogCurveInfo = new List <Witsml141.ComponentSchemas.LogCurveInfo>() }; var logCurveInfo = new Witsml141.ComponentSchemas.LogCurveInfo(); logCurveInfo = null; var result = logCurveInfo.GetIndexRange(); Assert.IsNull(result.Start); Assert.IsNull(result.End); // Add logCurveInfo with just start index var lci0 = _log141Generator.CreateDoubleLogCurveInfo("DEPTH", "m"); lci0.NullValue = "-1000.00"; lci0.MinDateTimeIndex = start; log.LogCurveInfo.Add(lci0); result = log.LogCurveInfo[0].GetIndexRange(true, true); Assert.IsNotNull(result); Assert.IsTrue(result.Start.HasValue); Assert.IsFalse(result.End.HasValue); Assert.AreEqual(startAsLong, result.Start.Value); // Decreasing log result = log.LogCurveInfo[0].GetIndexRange(false, true); Assert.IsNotNull(result); Assert.IsTrue(result.End.HasValue); Assert.IsFalse(result.Start.HasValue); Assert.AreEqual(startAsLong, result.End.Value); // Update end index lci0.MaxDateTimeIndex = end; result = log.LogCurveInfo[0].GetIndexRange(true, true); Assert.IsNotNull(result); Assert.IsTrue(result.Start.HasValue); Assert.IsTrue(result.End.HasValue); Assert.AreEqual(startAsLong, result.Start.Value); Assert.AreEqual(endAsLong, result.End.Value); // Decreasing with end index result = log.LogCurveInfo[0].GetIndexRange(false, true); Assert.IsNotNull(result); Assert.IsTrue(result.Start.HasValue); Assert.IsTrue(result.End.HasValue); Assert.AreEqual(startAsLong, result.End.Value); Assert.AreEqual(endAsLong, result.Start.Value); }
/// <summary> /// Gets the end index. /// </summary> /// <param name="logCurveInfo">The log curve information.</param> /// <returns>The end index as an object</returns> public static object GetEndIndex(this Energistics.DataAccess.WITSML141.ComponentSchemas.LogCurveInfo logCurveInfo) { return(logCurveInfo.MaxDateTimeIndexSpecified ? (object)logCurveInfo.MaxDateTimeIndex.Value : (object)logCurveInfo.MaxIndex?.Value); }
/// <summary> /// Gets the <see cref="EtpUri"/> for a given <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo"/> /// </summary> /// <param name="entity">The entity.</param> /// <param name="log">The log.</param> /// <returns>An <see cref="EtpUri"/> instance.</returns> public static EtpUri GetUri(this Witsml141.ComponentSchemas.LogCurveInfo entity, Witsml141.Log log) { return(log.GetUri() .Append(ObjectTypes.LogCurveInfo, entity.Mnemonic.Value, true)); }