public void LogExtensions_IsIncreasing_Returns_Bool_If_141_Log_Is_Timelog()
        {
            var log = new Witsml141.Log
            {
                IndexType = Witsml141.ReferenceData.LogIndexType.datetime
            };

            Assert.IsTrue(log.IsTimeLog());

            log.IndexType = Witsml141.ReferenceData.LogIndexType.elapsedtime;
            Assert.IsTrue(log.IsTimeLog(true));

            log.IndexType = Witsml141.ReferenceData.LogIndexType.measureddepth;
            Assert.IsFalse(log.IsTimeLog());

            log.IndexType = null;
            Assert.IsTrue(log.IsTimeLog());

            log.LogData = new List <Witsml141.ComponentSchemas.LogData>()
            {
                new Witsml141.ComponentSchemas.LogData
                {
                    MnemonicList = "TIME,A,B,C",
                }
            };

            Assert.IsTrue(log.IsTimeLog());

            log.LogData = new List <Witsml141.ComponentSchemas.LogData>()
            {
                new Witsml141.ComponentSchemas.LogData
                {
                    Data = new List <string>()
                    {
                        "2016-01-01T00:00:00.001Z,1,2,3"
                    },
                    MnemonicList = "TIME,A,B,C",
                    UnitList     = "unitless,m,m,m"
                }
            };

            log.LogData = new List <Witsml141.ComponentSchemas.LogData>()
            {
                new Witsml141.ComponentSchemas.LogData
                {
                    Data = new List <string>()
                    {
                        "1023.1,1,2,3"
                    },
                    MnemonicList = "DEPTH,A,B,C",
                    UnitList     = "m,m,m,m"
                }
            };

            Assert.IsFalse(log.IsTimeLog());
        }
Exemple #2
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));
            }
        }