Ejemplo n.º 1
0
        public void LogExtensions_141_GetDataDelimiterOrDefault_When_Log_Is_Null()
        {
            var log = new Witsml141.Log();

            log = null;

            var result = log.GetDataDelimiterOrDefault();

            Assert.AreEqual(",", result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines whether the <see cref="Witsml141.Log"/> is a time log.
        /// </summary>
        /// <param name="log">The log.</param>
        /// <param name="includeElapsedTime">if set to <c>true</c>, include elapsed time.</param>
        /// <returns>
        /// <c>true</c> if the <see cref="Witsml141.Log"/> is a time log; otherwise, false.
        /// </returns>
        public static bool IsTimeLog(this Witsml141.Log log, bool includeElapsedTime = false)
        {
            if (log.IndexType.HasValue)
            {
                return(log.IndexType.Value == Witsml141.ReferenceData.LogIndexType.datetime ||
                       (log.IndexType.Value == Witsml141.ReferenceData.LogIndexType.elapsedtime && includeElapsedTime));
            }

            // Use LogIndexType default if logData not available
            if (log.LogData == null)
            {
                return(true);
            }

            var data = log.LogData.SelectMany(x => x.Data ?? new List <string>(0)).FirstOrDefault();

            return(data.IsFirstValueDateTime(log.GetDataDelimiterOrDefault()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets multiple readers for each LogData from a <see cref="Witsml141.Log"/> instance.
        /// </summary>
        /// <param name="log">The log.</param>
        /// <returns>An <see cref="IEnumerable{ChannelDataReader}"/>.</returns>
        public static IEnumerable <ChannelDataReader> GetReaders(this Witsml141.Log log)
        {
            if (log?.LogData == null)
            {
                yield break;
            }

            _log.DebugFormat("Creating ChannelDataReaders for {0}", log.GetType().FullName);

            var isTimeIndex = log.IsTimeLog();
            var increasing  = log.IsIncreasing();

            foreach (var logData in log.LogData)
            {
                if (logData?.Data == null || !logData.Data.Any())
                {
                    continue;
                }

                var mnemonics  = ChannelDataReader.Split(logData.MnemonicList);
                var units      = ChannelDataReader.Split(logData.UnitList);
                var dataTypes  = log.LogCurveInfo.Select(x => x.TypeLogData?.ToString()).ToArray();
                var nullValues = log.GetNullValues(mnemonics).ToArray();

                // Split index curve from other value curves
                var indexCurve = log.LogCurveInfo.GetByMnemonic(log.IndexCurve) ?? new Witsml141.ComponentSchemas.LogCurveInfo
                {
                    Mnemonic = new Witsml141.ComponentSchemas.ShortNameStruct(mnemonics.FirstOrDefault()),
                    Unit     = units.FirstOrDefault()
                };

                // Skip index curve when passing mnemonics to reader
                mnemonics  = mnemonics.Skip(1).ToArray();
                units      = units.Skip(1).ToArray();
                dataTypes  = dataTypes.Skip(1).ToArray();
                nullValues = nullValues.Skip(1).ToArray();

                yield return(new ChannelDataReader(logData.Data, mnemonics.Length + 1, mnemonics, units, dataTypes, nullValues, log.GetUri(), dataDelimiter: log.GetDataDelimiterOrDefault())
                             // Add index curve to separate collection
                             .WithIndex(indexCurve.Mnemonic.Value, indexCurve.Unit, increasing, isTimeIndex));
            }
        }