Exemple #1
0
        /// <summary>
        /// Initializes a new <see cref="LogCurveInfo" /> based on a <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo" />.
        /// </summary>
        /// <param name="logCurveInfo">The WITSML 1.3.1.1 log curve info</param>
        public LogCurveInfo(Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo logCurveInfo)
        {
            logCurveInfo.NotNull(nameof(logCurveInfo));

            _logCurveInfo131  = logCurveInfo;
            DataSchemaVersion = OptionsIn.DataVersion.Version131.Value;
        }
        public void LogExtensions_GetIndexRange_Returns_Range_From_131_DepthLog()
        {
            double start, end;

            InitDepthIndexes(out start, out end);

            var log = new Witsml131.Log
            {
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>()
            };

            var result = new Witsml131.ComponentSchemas.LogCurveInfo().GetIndexRange();

            Assert.IsNull(result.Start);
            Assert.IsNull(result.End);

            // Add logCurveInfo with just start index
            var lci0 = _log131Generator.CreateDoubleLogCurveInfo("DEPTH", "m", 0);

            lci0.NullValue = "-1000.00";
            lci0.MinIndex  = new Witsml131.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 Witsml131.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);
        }
Exemple #3
0
        /// <summary>
        /// Converts a 131 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 Witsml131.ComponentSchemas.LogCurveInfo logCurveInfo, TimeSpan toOffset)
        {
            var startIndex = logCurveInfo.GetStartIndex();
            var endIndex   = logCurveInfo.GetEndIndex();

            return(new LogCurveItem(
                       logCurveInfo.Mnemonic,
                       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));
        }
Exemple #4
0
        /// <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));
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets the index range for the specified <see cref="Witsml131.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> when using a datetime index.</param>
        /// <returns>The index range for the specified log curve.</returns>
        public static Range <double?> GetIndexRange(this Witsml131.ComponentSchemas.LogCurveInfo logCurveInfo, bool increasing = true, bool isTimeIndex = false)
        {
            // NOTE: logging here is too verbose!
            //_log.DebugFormat("Getting logCurveInfo index range: {0}", logCurveInfo?.Mnemonic);

            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));
        }
Exemple #6
0
        public void EtpUris_GetUri_Can_Get_LogCurveInfo_131_Uri()
        {
            var logCurve = new Witsml131.ComponentSchemas.LogCurveInfo {
                Mnemonic = "ROP"
            };

            var log = new Witsml131.Log
            {
                Uid          = _data.Uid(),
                UidWell      = _data.Uid(),
                UidWellbore  = _data.Uid(),
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo> {
                    logCurve
                }
            };

            var uri = logCurve.GetUri(log);

            Assert.IsTrue($"eml://witsml13/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, uri.ObjectId);
        }
        public void LogExtensions_GetIndexRange_Returns_Range_From_131_TimeLog()
        {
            Timestamp start, end;

            InitTimeIndexes(out start, out end);
            var startAsLong = start.ToUnixTimeMicroseconds();
            var endAsLong   = end.ToUnixTimeMicroseconds();

            var log = new Witsml131.Log
            {
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>()
            };

            var logCurveInfo = new Witsml131.ComponentSchemas.LogCurveInfo();

            logCurveInfo = null;
            var result = logCurveInfo.GetIndexRange();

            Assert.IsNull(result.Start);
            Assert.IsNull(result.End);

            // Add logCurveInfo with just start index
            var lci0 = _log131Generator.CreateDoubleLogCurveInfo("DEPTH", "m", 0);

            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);
        }
Exemple #8
0
 /// <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.WITSML131.ComponentSchemas.LogCurveInfo logCurveInfo)
 {
     return(logCurveInfo.MaxDateTimeIndexSpecified
         ? (object)logCurveInfo.MaxDateTimeIndex.Value
         : (object)logCurveInfo.MaxIndex?.Value);
 }
Exemple #9
0
 /// <summary>
 /// Gets the <see cref="EtpUri"/> for a given <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo"/>.
 /// </summary>
 /// <param name="entity">The <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo"/> entity.</param>
 /// <param name="log">The log.</param>
 /// <returns>An <see cref="EtpUri"/> instance.</returns>
 public static EtpUri GetUri(this Witsml131.ComponentSchemas.LogCurveInfo entity, Witsml131.Log log)
 {
     return(log.GetUri()
            .Append(ObjectTypes.LogCurveInfo, entity.Mnemonic, true));
 }