private bool ToDeleteCurveData(LogCurveInfo curve, XElement element, bool isTimeLog, bool hasDefaultRange) { var hasRange = isTimeLog ? curve.MinDateTimeIndex.HasValue || curve.MaxDateTimeIndex.HasValue : curve.MinIndex != null || curve.MaxIndex != null; if (hasRange) { return(true); } if (string.IsNullOrWhiteSpace(element.Attribute("uid")?.Value)) { if (element.Elements().All(e => e.Name.LocalName == "mnemonic")) { return(true); } } else { return(hasDefaultRange); } return(false); }
/// <summary> /// Converts a logCurveInfo to a channel metadata record. /// </summary> /// <param name="entity">The entity.</param> /// <param name="curve">The curve.</param> /// <param name="indexMetadata">The index metadata.</param> /// <returns></returns> protected override ChannelMetadataRecord ToChannelMetadataRecord(Log entity, LogCurveInfo curve, IndexMetadataRecord indexMetadata) { var uri = curve.GetUri(entity); var isTimeLog = IsTimeLog(entity, true); var curveIndexes = GetCurrentIndexRange(entity); var dataObject = new DataObject(); var unixTime = entity.CommonData.DateTimeLastChange.ToUnixTimeMicroseconds(); StoreStoreProvider.SetDataObject(dataObject, curve, uri, curve.Mnemonic.Value, 0, unixTime.GetValueOrDefault()); return(new ChannelMetadataRecord() { ChannelUri = uri, ContentType = uri.ContentType, DataType = curve.TypeLogData.GetValueOrDefault(LogDataType.@double).ToString().Replace("@", string.Empty), Description = curve.CurveDescription ?? curve.Mnemonic.Value, ChannelName = curve.Mnemonic.Value, Uom = Units.GetUnit(curve.Unit), MeasureClass = curve.ClassWitsml ?? ObjectTypes.Unknown, Source = curve.DataSource ?? ObjectTypes.Unknown, DomainObject = dataObject, Status = entity.ObjectGrowing.GetValueOrDefault() ? ChannelStatuses.Active : ChannelStatuses.Inactive, StartIndex = curveIndexes[curve.Mnemonic.Value].Start.IndexToScale(indexMetadata.Scale, isTimeLog), EndIndex = curveIndexes[curve.Mnemonic.Value].End.IndexToScale(indexMetadata.Scale, isTimeLog), Indexes = new List <IndexMetadataRecord>() { indexMetadata }, CustomData = new Dictionary <string, DataValue>() }); }
private Resource ToResource(Log log, LogCurveInfo curve) { return(DiscoveryStoreProvider.New( uuid: curve.Uid, uri: curve.GetUri(log), resourceType: ResourceTypes.DataObject, name: curve.Mnemonic)); }
private IResource ToResource(IEtpAdapter etpAdapter, Log log, LogCurveInfo curve) { return(etpAdapter.CreateResource( uuid: null, uri: curve.GetUri(log), resourceType: ResourceTypes.DataObject, name: curve.Mnemonic, lastChanged: log.GetLastChangedMicroseconds())); }
private bool HasData(LogCurveInfo curve, bool isTimeLog) { if (isTimeLog) { return(curve.MinDateTimeIndex.HasValue && curve.MaxDateTimeIndex.HasValue); } return(curve.MinIndex != null && curve.MaxIndex != null); }
/// <summary> /// Converts a logCurveInfo to an index metadata record. /// </summary> /// <param name="entity">The entity.</param> /// <param name="indexCurve">The index curve.</param> /// <param name="scale">The scale.</param> /// <returns></returns> protected override IndexMetadataRecord ToIndexMetadataRecord(Log entity, LogCurveInfo indexCurve, int scale = 3) { return(new IndexMetadataRecord() { Uri = indexCurve.GetUri(entity), Mnemonic = indexCurve.Mnemonic.Value, Description = indexCurve.CurveDescription, Uom = Units.GetUnit(indexCurve.Unit), Scale = scale, IndexType = IsTimeLog(entity, true) ? ChannelIndexTypes.Time : ChannelIndexTypes.Depth, Direction = IsIncreasing(entity) ? IndexDirections.Increasing : IndexDirections.Decreasing, CustomData = new Dictionary <string, DataValue>(0), }); }
private static void AssertAxisDefintion(Log expectedLog, LogCurveInfo curve, string xmlOut, int expectedCurveCount = 2) { var logList = EnergisticsConverter.XmlToObject <LogList>(xmlOut); Assert.IsNotNull(logList); Assert.IsTrue(logList.Log.Count > 0); var log = logList.Log.FirstOrDefault(x => x.Uid == expectedLog.Uid); Assert.IsNotNull(log); Assert.AreEqual(expectedCurveCount, log.LogCurveInfo.Count); var logCurveInfo = log.LogCurveInfo.FirstOrDefault(x => x.Mnemonic == curve.Mnemonic); Assert.IsNotNull(logCurveInfo); Assert.IsTrue(logCurveInfo.AxisDefinition.Count > 0); var axisDef = logCurveInfo.AxisDefinition.FirstOrDefault(); Assert.IsNotNull(axisDef); Assert.AreEqual(curve.AxisDefinition[0].Uid, axisDef.Uid); Assert.AreEqual(curve.AxisDefinition[0].Count, axisDef.Count); Assert.AreEqual(curve.AxisDefinition[0].DoubleValues, axisDef.DoubleValues); }
/// <summary> /// Gets the channel URI. /// </summary> /// <param name="channel">The channel.</param> /// <param name="entity">The data object.</param> /// <returns>The channel URI.</returns> protected override EtpUri GetChannelUri(LogCurveInfo channel, Log entity) { return(channel.GetUri(entity)); }
/// <summary> /// Gets the index range. /// </summary> /// <param name="curve">The curve.</param> /// <param name="increasing">if set to <c>true</c> [increasing].</param> /// <param name="isTimeIndex">if set to <c>true</c> [is time index].</param> /// <returns></returns> protected override Range <double?> GetIndexRange(LogCurveInfo curve, bool increasing = true, bool isTimeIndex = false) { return(curve.GetIndexRange(increasing, isTimeIndex)); }
/// <summary> /// Gets the mnemonic. /// </summary> /// <param name="curve">The curve.</param> /// <returns></returns> protected override string GetMnemonic(LogCurveInfo curve) { //Logger.DebugFormat("Getting logCurveInfo mnemonic: {0}", curve?.Mnemonic?.Value); return(curve?.Mnemonic?.Value); }
private LogCurveInfo GetCurveInfo(LogCurveInfo curve, List <LogCurveInfo> curves) { return(curves.FirstOrDefault(l => l.Uid == curve.Uid || l.Mnemonic.Value == curve.Mnemonic.Value)); }
private XElement GetCurveElement(LogCurveInfo curve, List <XElement> elements) { return(elements.FirstOrDefault(e => e.Attribute("uid")?.Value == curve.Uid || e.Elements().Any(c => c.Name.LocalName == "mnemonic" && c.Value == curve.Mnemonic.Value))); }
/// <summary> /// Converts a logCurveInfo to a channel metadata record. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="entity">The entity.</param> /// <param name="curve">The curve.</param> /// <param name="indexMetadata">The index metadata.</param> /// <returns></returns> protected override IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Log entity, LogCurveInfo curve, IIndexMetadataRecord indexMetadata) { var uri = curve.GetUri(entity); var isTimeLog = IsTimeLog(entity, true); var curveIndexes = GetCurrentIndexRange(entity); var unixTime = entity.CommonData.DateTimeLastChange.ToUnixTimeMicroseconds(); var dataObject = etpAdapter.CreateDataObject(); etpAdapter.SetDataObject(dataObject, curve, uri, curve.Mnemonic, 0, unixTime.GetValueOrDefault()); var metadata = etpAdapter.CreateChannelMetadata(uri); metadata.DataType = curve.TypeLogData.GetValueOrDefault(LogDataType.@double).ToString().Replace("@", string.Empty); metadata.Description = curve.CurveDescription ?? curve.Mnemonic; metadata.ChannelName = curve.Mnemonic; metadata.Uom = Units.GetUnit(curve.Unit); metadata.MeasureClass = curve.ClassWitsml?.Name ?? ObjectTypes.Unknown; metadata.Source = curve.DataSource ?? ObjectTypes.Unknown; metadata.DomainObject = dataObject; metadata.Status = etpAdapter.GetChannelStatus(entity.ObjectGrowing.GetValueOrDefault()); metadata.StartIndex = curveIndexes[curve.Mnemonic].Start.IndexToScale(indexMetadata.Scale, isTimeLog); metadata.EndIndex = curveIndexes[curve.Mnemonic].End.IndexToScale(indexMetadata.Scale, isTimeLog); metadata.Indexes = etpAdapter.ToList(new List <IIndexMetadataRecord> { indexMetadata }); return(metadata); }
/// <summary> /// Converts a logCurveInfo to an index metadata record. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="entity">The entity.</param> /// <param name="indexCurve">The index curve.</param> /// <param name="scale">The scale.</param> /// <returns></returns> protected override IIndexMetadataRecord ToIndexMetadataRecord(IEtpAdapter etpAdapter, Log entity, LogCurveInfo indexCurve, int scale = 3) { var metadata = etpAdapter.CreateIndexMetadata( uri: indexCurve.GetUri(entity), isTimeIndex: IsTimeLog(entity, true), isIncreasing: IsIncreasing(entity)); metadata.Mnemonic = indexCurve.Mnemonic; metadata.Description = indexCurve.CurveDescription; metadata.Uom = Units.GetUnit(indexCurve.Unit); metadata.Scale = scale; return(metadata); }
public void Log131DataAdapter_AddToStore_Add_DepthLog_With_Unordered_LogCurveInfo() { AddParents(); DevKit.InitHeader(Log, LogIndexType.measureddepth); DevKit.InitDataMany(Log, DevKit.Mnemonics(Log), DevKit.Units(Log), 10); // Reverse logCurveInfo order Log.LogCurveInfo.Reverse(); DevKit.AddAndAssert(Log); var indexCurve = Log.LogCurveInfo.FirstOrDefault(x => x.Mnemonic == Log.IndexCurve.Value); // Create two new curves var newCurve1 = new LogCurveInfo() { Mnemonic = "Test", Unit = "gAPI", ColumnIndex = 3, NullValue = "|" }; var newCurve2 = new LogCurveInfo() { Mnemonic = "Test2", Unit = "gAPI", ColumnIndex = 2, NullValue = "|" }; // Update 2 new curves to the log header var update = new Log() { UidWell = Log.UidWell, UidWellbore = Log.UidWellbore, Uid = Log.Uid, LogCurveInfo = new List <LogCurveInfo>() { indexCurve, newCurve1, newCurve2 } }; DevKit.UpdateAndAssert(update); // Add data update.LogData = new List <string>(); for (int i = 1; i < 11; i++) { var val1 = i % 2 == 0 ? "|" : i.ToString(); var val2 = i % 2 == 1 ? "|" : i.ToString(); update.LogData.Add($"{i},{val1},{val2}"); } DevKit.UpdateAndAssert(update); // Query by example to get values from the index curve and 2 new curves var queryIn = "<logs version=\"1.3.1.1\" xmlns=\"http://www.witsml.org/schemas/131\" > " + Environment.NewLine + $" <log uidWell=\"{Log.UidWell}\" uidWellbore=\"{Log.UidWellbore}\" uid=\"{Log.Uid}\">" + Environment.NewLine + " <nameWell />" + Environment.NewLine + " <nameWellbore />" + Environment.NewLine + " <name />" + Environment.NewLine + " <objectGrowing />" + Environment.NewLine + " <serviceCompany />" + Environment.NewLine + " <runNumber />" + Environment.NewLine + " <creationDate />" + Environment.NewLine + " <indexType />" + Environment.NewLine + " <startIndex uom=\"\" />" + Environment.NewLine + " <endIndex uom=\"\" />" + Environment.NewLine + " <startDateTimeIndex />" + Environment.NewLine + " <endDateTimeIndex />" + Environment.NewLine + " <direction />" + Environment.NewLine + " <indexCurve columnIndex=\"\" />" + Environment.NewLine + " <logCurveInfo>" + Environment.NewLine + $" <mnemonic>{indexCurve.Mnemonic}</mnemonic>" + Environment.NewLine + " <unit />" + Environment.NewLine + " <columnIndex />" + Environment.NewLine + " </logCurveInfo>" + Environment.NewLine + " <logCurveInfo>" + Environment.NewLine + $" <mnemonic>{newCurve2.Mnemonic}</mnemonic>" + Environment.NewLine + " <unit />" + Environment.NewLine + " <columnIndex />" + Environment.NewLine + " </logCurveInfo>" + Environment.NewLine + " <logCurveInfo>" + Environment.NewLine + $" <mnemonic>{newCurve1.Mnemonic}</mnemonic>" + Environment.NewLine + " <unit />" + Environment.NewLine + " <columnIndex />" + Environment.NewLine + " </logCurveInfo>" + Environment.NewLine + " <logData />" + Environment.NewLine + " </log>" + Environment.NewLine + "</logs>"; var result = DevKit.GetFromStore(ObjectTypes.Log, queryIn, null, "returnElements=requested"); Assert.AreEqual((short)ErrorCodes.Success, result.Result); Assert.IsNotNull(result); var logs = EnergisticsConverter.XmlToObject <LogList>(result.XMLout); Assert.IsNotNull(logs); var log = logs.Log.FirstOrDefault(); Assert.IsNotNull(log); Assert.IsNotNull(log.LogData); Assert.AreEqual(3, log.LogCurveInfo.Count); Assert.AreEqual(10, log.LogData.Count); foreach (var lc in log.LogCurveInfo) { var curve = update.LogCurveInfo.FirstOrDefault(x => x.Mnemonic == lc.Mnemonic); Assert.IsNotNull(curve); // Ensure that the value from the update matches the response using columnIndex for (int i = 0; i < 10; i++) { Assert.AreEqual(log.LogData[i].Split(',')[lc.ColumnIndex.Value - 1], update.LogData[i].Split(',')[curve.ColumnIndex.Value - 1]); } } }