Exemplo n.º 1
0
        public void LogExtensions_141_GetNullValues_Can_Return_Null_Values_In_The_Order_Of_Mnemonics()
        {
            var log = new Witsml141.Log
            {
                LogCurveInfo = new List <Witsml141.ComponentSchemas.LogCurveInfo>()
            };

            var lci0 = _log141Generator.CreateDoubleLogCurveInfo("DEPTH", "m");

            lci0.NullValue = "-1000.00";
            log.LogCurveInfo.Add(lci0);
            var lci1 = _log141Generator.CreateDoubleLogCurveInfo("CH1", "m/h");

            lci1.NullValue = "-1111.11";
            log.LogCurveInfo.Add(lci1);
            var lci2 = _log141Generator.CreateDoubleLogCurveInfo("CH2", "gAPI");

            lci2.NullValue = "-2222.22";
            log.LogCurveInfo.Add(lci2);
            var lci3 = _log141Generator.CreateDoubleLogCurveInfo("CH3", "gAPI");

            lci3.NullValue = "-3333.33";
            log.LogCurveInfo.Add(lci3);
            var lci4 = _log141Generator.CreateDoubleLogCurveInfo("CH4", "gAPI");

            log.LogCurveInfo.Add(lci4);

            string[] mnemonic      = new string[] { "CH3", "CH4", "CH1" };
            var      nullValueList = log.GetNullValues(mnemonic).ToArray();

            Assert.AreEqual(3, nullValueList.Length);
            Assert.AreEqual("-3333.33", nullValueList[0]);
            Assert.AreEqual("null", nullValueList[1]);
            Assert.AreEqual("-1111.11", nullValueList[2]);
        }
Exemplo n.º 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));
            }
        }