コード例 #1
0
        public void LogExtensions_IsIncreasing_Returns_Bool_If_131_Log_Is_Timelog()
        {
            var log = new Witsml131.Log
            {
                IndexType = Witsml131.ReferenceData.LogIndexType.datetime
            };

            Assert.IsTrue(log.IsTimeLog());

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

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

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

            log.LogData = new List <string>()
            {
                "2016-01-01T00:00:00.001Z,1,2,3"
            };

            Assert.IsTrue(log.IsTimeLog());

            log.LogData = new List <string>()
            {
                "1023.3,1,2,3"
            };

            Assert.IsFalse(log.IsTimeLog());
        }
コード例 #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));
        }