public void LogExtensions_IsIncreasing_Returns_Bool_For_141_Log_Direction()
        {
            var log = new Witsml141.Log
            {
                Direction = Witsml141.ReferenceData.LogIndexDirection.increasing
            };

            Assert.IsTrue(log.IsIncreasing());

            log.Direction = Witsml141.ReferenceData.LogIndexDirection.decreasing;
            Assert.IsFalse(log.IsIncreasing());
        }
Beispiel #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));
            }
        }