Esempio n. 1
0
        public void EtpUris_GetUri_Can_Get_Log_141_Uri()
        {
            var log = new Witsml141.Log {
                Uid = _data.Uid(), UidWell = _data.Uid(), UidWellbore = _data.Uid()
            };
            var uri = log.GetUri();

            Assert.IsTrue($"eml://witsml14/well({ log.UidWell })/wellbore({ log.UidWellbore })/log({ log.Uid })".EqualsIgnoreCase(uri.ToString()));
            Assert.AreEqual("log", uri.ObjectType);
            Assert.AreEqual(log.Uid, uri.ObjectId);
            Assert.AreEqual(uri, ((IDataObject)log).GetUri());
            Assert.AreEqual(uri, ((IWellObject)log).GetUri());
        }
Esempio n. 2
0
 /// <summary>
 /// Sets the log data.
 /// </summary>
 /// <param name="log">The log.</param>
 /// <param name="keepGridData">True if not clearing data when querying partial results</param>
 /// <param name="errorHandler">The error handler.</param>
 private void SetLogData(Witsml141.Log log, bool keepGridData, Action <WitsmlException> errorHandler)
 {
     ClearDataTable(log.GetUri(), keepGridData);
     Task.Run(() =>
     {
         try
         {
             log.GetReaders().ForEach(SetChannelData);
         }
         catch (WitsmlException ex)
         {
             _log.WarnFormat("Error setting log data: {0}", ex);
             errorHandler(ex);
         }
     });
 }
Esempio n. 3
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));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Gets the <see cref="EtpUri"/> for a given <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo"/>
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="log">The log.</param>
 /// <returns>An <see cref="EtpUri"/> instance.</returns>
 public static EtpUri GetUri(this Witsml141.ComponentSchemas.LogCurveInfo entity, Witsml141.Log log)
 {
     return(log.GetUri()
            .Append(ObjectTypes.LogCurveInfo, entity.Mnemonic.Value, true));
 }