Esempio n. 1
0
        public void LogExtensions_IsIncreasing_Returns_Bool_For_131_Log_Direction()
        {
            var log = new Witsml131.Log
            {
                Direction = Witsml131.ReferenceData.LogIndexDirection.increasing
            };

            Assert.IsTrue(log.IsIncreasing());

            log.Direction = Witsml131.ReferenceData.LogIndexDirection.decreasing;
            Assert.IsFalse(log.IsIncreasing());
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a <see cref="ChannelDataReader" /> for a <see cref="Witsml131.Log" />.
        /// </summary>
        /// <param name="log">The <see cref="Witsml131.Log" /> instance.</param>
        /// <returns>A <see cref="ChannelDataReader" />.</returns>
        public static ChannelDataReader GetReader(this Witsml131.Log log)
        {
            if (log?.LogData == null || !log.LogData.Any())
            {
                return(null);
            }

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

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

            // Split index curve from other value curves
            var indexCurve    = log.LogCurveInfo.GetByMnemonic(log.IndexCurve?.Value);
            var logCurveInfos = log.LogCurveInfo.Where(x => x != indexCurve).OrderBy(x => x.ColumnIndex.GetValueOrDefault()).ToList();
            var mnemonics     = logCurveInfos.Select(x => x.Mnemonic).ToArray();
            var units         = logCurveInfos.Select(x => x.Unit).ToArray();
            var dataTypes     = logCurveInfos.Select(x => x.TypeLogData?.ToString()).ToArray();
            var nullValues    = logCurveInfos.Select(x => x.NullValue).ToArray();

            return(new ChannelDataReader(log.LogData, mnemonics.Length + 1, mnemonics, units, dataTypes, nullValues, log.GetUri())
                   // Add index curve to separate collection
                   .WithIndex(indexCurve.Mnemonic, indexCurve.Unit, increasing, isTimeIndex));
        }