Skip to content

Commit

Permalink
Merge pull request #2143 from eliasbruvik/FIX-2142-toWitsml
Browse files Browse the repository at this point in the history
FIX-2142 ToWitsml method on API ObjectOnWellbore models
  • Loading branch information
eliasbruvik authored Nov 30, 2023
2 parents 39d3ae2 + 6dfd852 commit 6dd2243
Show file tree
Hide file tree
Showing 45 changed files with 742 additions and 74 deletions.
6 changes: 6 additions & 0 deletions Src/Witsml/Data/Measures/WitsmlLinearAccelerationMeasure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Witsml.Data.Measures
{
public class WitsmlLinearAccelerationMeasure : Measure
{
}
}
6 changes: 6 additions & 0 deletions Src/Witsml/Data/Measures/WitsmlMagneticFluxDensityMeasure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Witsml.Data.Measures
{
public class WitsmlMagneticFluxDensityMeasure : Measure
{
}
}
4 changes: 4 additions & 0 deletions Src/Witsml/Data/WitsmlTrajectoryStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public string MsaCorUsedText
[XmlElement("magModelValid")] public string MagModelValid { get; set; }
[XmlElement("geoModelUsed")] public string GeoModelUsed { get; set; }
[XmlElement("statusTrajStation")] public string StatusTrajStation { get; set; }
[XmlElement("gravAxialRaw")] public WitsmlLinearAccelerationMeasure GravAxialRaw { get; set; }
[XmlElement("gravTran1Raw")] public WitsmlLinearAccelerationMeasure GravTran1Raw { get; set; }
[XmlElement("gravTran2Raw")] public WitsmlLinearAccelerationMeasure GravTran2Raw { get; set; }
[XmlElement("magAxialRaw")] public WitsmlMagneticFluxDensityMeasure MagAxialRaw { get; set; }
[XmlElement("rawData")] public WitsmlTrajRawData RawData { get; set; }
[XmlElement("corUsed")] public WitsmlStnTrajCorUsed CorUsed { get; set; }
[XmlElement("valid")] public WitsmlStnTrajValid Valid { get; set; }
Expand Down
12 changes: 12 additions & 0 deletions Src/WitsmlExplorer.Api/Models/BaseObjectOnWellbore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Witsml.Data;

namespace WitsmlExplorer.Api.Models
{
public class BaseObjectOnWellbore : ObjectOnWellbore
{
public override IWitsmlQueryType ToWitsml()
{
throw new System.NotImplementedException("BaseObjectOnWellbore is not supposed to be converted to a WITSML model");
}
}
}
34 changes: 32 additions & 2 deletions Src/WitsmlExplorer.Api/Models/BhaRun.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using Witsml.Data;
using Witsml.Data.Measures;

using WitsmlExplorer.Api.Models.Measure;
using WitsmlExplorer.Api.Services;

namespace WitsmlExplorer.Api.Models
{
public class BhaRun : ObjectOnWellbore
{
public string NumStringRun { get; init; }
public string Tubular { get; init; }
public string TubularUidRef { get; init; }
public RefNameString Tubular { get; init; }
public string DTimStart { get; init; }
public string DTimStop { get; init; }
public string DTimStartDrilling { get; init; }
Expand All @@ -19,5 +22,32 @@ public class BhaRun : ObjectOnWellbore
public string ReasonTrip { get; init; }
public string ObjectiveBha { get; init; }
public CommonData CommonData { get; init; }

public override WitsmlBhaRuns ToWitsml()
{
return new WitsmlBhaRun
{
UidWell = WellUid,
NameWell = WellName,
UidWellbore = WellboreUid,
NameWellbore = WellboreName,
Uid = Uid,
Name = Name,
NumStringRun = NumStringRun,
Tubular = Tubular?.ToWitsml(),
StatusBha = StatusBha,
NumBitRun = NumBitRun,
ReasonTrip = ReasonTrip,
ObjectiveBha = ObjectiveBha,
PlanDogleg = PlanDogleg?.ToWitsml<WitsmlAnglePerLengthMeasure>(),
ActDogleg = ActDogleg?.ToWitsml<WitsmlAnglePerLengthMeasure>(),
ActDoglegMx = ActDoglegMx?.ToWitsml<WitsmlAnglePerLengthMeasure>(),
DTimStart = StringHelpers.ToUniversalDateTimeString(DTimStart),
DTimStop = StringHelpers.ToUniversalDateTimeString(DTimStop),
DTimStartDrilling = StringHelpers.ToUniversalDateTimeString(DTimStartDrilling),
DTimStopDrilling = StringHelpers.ToUniversalDateTimeString(DTimStopDrilling),
CommonData = CommonData?.ToWitsml()
}.AsSingletonWitsmlList();
}
}
}
17 changes: 17 additions & 0 deletions Src/WitsmlExplorer.Api/Models/ChangeLog.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Witsml.Data;

namespace WitsmlExplorer.Api.Models
{
// ChangeLog extends ObjectOnWellbore despite not having uid and name fields in WITSML
Expand All @@ -8,5 +10,20 @@ public class ChangeLog : ObjectOnWellbore
public string NameObject { get; init; }
public string LastChangeType { get; init; }
public CommonData CommonData { get; init; }

public override WitsmlChangeLogs ToWitsml()
{
return new WitsmlChangeLog
{
UidObject = UidObject ?? Uid,
UidWellbore = WellboreUid,
UidWell = WellUid,
NameObject = NameObject ?? Name,
NameWellbore = WellboreName,
NameWell = WellName,
LastChangeType = LastChangeType,
CommonData = CommonData?.ToWitsml()
}.AsSingletonWitsmlList();
}
}
}
22 changes: 22 additions & 0 deletions Src/WitsmlExplorer.Api/Models/CommonData.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
using Witsml.Data;

using WitsmlExplorer.Api.Services;

namespace WitsmlExplorer.Api.Models
{
public class CommonData
Expand All @@ -11,4 +15,22 @@ public class CommonData
public string AcquisitionTimeZone { get; init; }
public string DefaultDatum { get; init; }
}

public static class CommonDataExtensions
{
public static WitsmlCommonData ToWitsml(this CommonData commonData)
{
return new WitsmlCommonData
{
SourceName = commonData.SourceName,
DTimCreation = StringHelpers.ToUniversalDateTimeString(commonData.DTimCreation),
DTimLastChange = StringHelpers.ToUniversalDateTimeString(commonData.DTimLastChange),
ItemState = commonData.ItemState,
ServiceCategory = commonData.ServiceCategory,
Comments = commonData.Comments,
AcquisitionTimeZone = commonData.AcquisitionTimeZone,
DefaultDatum = commonData.DefaultDatum
};
}
}
}
16 changes: 16 additions & 0 deletions Src/WitsmlExplorer.Api/Models/CommonTime.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
using Witsml.Data;

using WitsmlExplorer.Api.Services;

namespace WitsmlExplorer.Api.Models
{
public class CommonTime
{
public string DTimCreation { get; init; }
public string DTimLastChange { get; init; }
}

public static class CommonTimeExtensions
{
public static WitsmlCommonTime ToWitsml(this CommonTime commonTime)
{
return new WitsmlCommonTime
{
DTimCreation = StringHelpers.ToUniversalDateTimeString(commonTime.DTimCreation),
DTimLastChange = StringHelpers.ToUniversalDateTimeString(commonTime.DTimLastChange)
};
}
}
}
71 changes: 71 additions & 0 deletions Src/WitsmlExplorer.Api/Models/Fluid.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System.Collections.Generic;
using System.Linq;

using Witsml.Data;
using Witsml.Data.Measures;

using WitsmlExplorer.Api.Models.Measure;
using WitsmlExplorer.Api.Services;

namespace WitsmlExplorer.Api.Models
{
Expand Down Expand Up @@ -63,4 +68,70 @@ public class Fluid
public LengthMeasure Sulfide { get; init; }
public string Comments { get; init; }
}

public static class FluidExtensions
{
public static WitsmlFluid ToWitsml(this Fluid fluid)
{
return new WitsmlFluid
{
Uid = fluid.Uid,
Type = fluid.Type,
LocationSample = fluid.LocationSample,
DTim = StringHelpers.ToUniversalDateTimeString(fluid.DTim),
Md = fluid.Md?.ToWitsml<WitsmlMeasuredDepthCoord>(),
Tvd = fluid.Tvd?.ToWitsml<WitsmlWellVerticalDepthCoord>(),
PresBopRating = fluid.PresBopRating?.ToWitsml<WitsmlPressureMeasure>(),
MudClass = fluid.MudClass,
Density = fluid.Density?.ToWitsml<Witsml.Data.Measures.Measure>(),
VisFunnel = fluid.VisFunnel?.ToWitsml<Witsml.Data.Measures.Measure>(),
TempVis = fluid.TempVis?.ToWitsml<Witsml.Data.Measures.Measure>(),
Pv = fluid.Pv?.ToWitsml<Witsml.Data.Measures.Measure>(),
Yp = fluid.Yp?.ToWitsml<Witsml.Data.Measures.Measure>(),
Gel10Sec = fluid.Gel10Sec?.ToWitsml<Witsml.Data.Measures.Measure>(),
Gel10Min = fluid.Gel10Min?.ToWitsml<Witsml.Data.Measures.Measure>(),
Gel30Min = fluid.Gel30Min?.ToWitsml<Witsml.Data.Measures.Measure>(),
FilterCakeLtlp = fluid.FilterCakeLtlp?.ToWitsml<Witsml.Data.Measures.Measure>(),
FiltrateLtlp = fluid.FiltrateLtlp?.ToWitsml<Witsml.Data.Measures.Measure>(),
TempHthp = fluid.TempHthp?.ToWitsml<Witsml.Data.Measures.Measure>(),
PresHthp = fluid.PresHthp?.ToWitsml<Witsml.Data.Measures.Measure>(),
FiltrateHthp = fluid.FiltrateHthp?.ToWitsml<Witsml.Data.Measures.Measure>(),
FilterCakeHthp = fluid.FilterCakeHthp?.ToWitsml<Witsml.Data.Measures.Measure>(),
SolidsPc = fluid.SolidsPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
WaterPc = fluid.WaterPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
OilPc = fluid.OilPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
SandPc = fluid.SandPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
SolidsLowGravPc = fluid.SolidsLowGravPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
SolidsCalcPc = fluid.SolidsCalcPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
BaritePc = fluid.BaritePc?.ToWitsml<Witsml.Data.Measures.Measure>(),
Lcm = fluid.Lcm?.ToWitsml<Witsml.Data.Measures.Measure>(),
Mbt = fluid.Mbt?.ToWitsml<Witsml.Data.Measures.Measure>(),
Ph = fluid.Ph,
TempPh = fluid.TempPh?.ToWitsml<Witsml.Data.Measures.Measure>(),
Pm = fluid.Pm?.ToWitsml<Witsml.Data.Measures.Measure>(),
PmFiltrate = fluid.PmFiltrate?.ToWitsml<Witsml.Data.Measures.Measure>(),
Mf = fluid.Mf?.ToWitsml<Witsml.Data.Measures.Measure>(),
AlkalinityP1 = fluid.AlkalinityP1?.ToWitsml<Witsml.Data.Measures.Measure>(),
AlkalinityP2 = fluid.AlkalinityP2?.ToWitsml<Witsml.Data.Measures.Measure>(),
Chloride = fluid.Chloride?.ToWitsml<Witsml.Data.Measures.Measure>(),
Calcium = fluid.Calcium?.ToWitsml<Witsml.Data.Measures.Measure>(),
Magnesium = fluid.Magnesium?.ToWitsml<Witsml.Data.Measures.Measure>(),
Potassium = fluid.Potassium?.ToWitsml<Witsml.Data.Measures.Measure>(),
Rheometers = fluid.Rheometers?.Select(rheometer => rheometer?.ToWitsml()).ToList(),
BrinePc = fluid.BrinePc?.ToWitsml<Witsml.Data.Measures.Measure>(),
Lime = fluid.Lime?.ToWitsml<Witsml.Data.Measures.Measure>(),
ElectStab = fluid.ElectStab?.ToWitsml<Witsml.Data.Measures.Measure>(),
CalciumChloride = fluid.CalciumChloride?.ToWitsml<Witsml.Data.Measures.Measure>(),
Company = fluid.Company,
SolidsHiGravPc = fluid.SolidsHiGravPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
Polymer = fluid.Polymer?.ToWitsml<Witsml.Data.Measures.Measure>(),
PolyType = fluid.PolyType,
SolCorPc = fluid.SolCorPc?.ToWitsml<Witsml.Data.Measures.Measure>(),
OilCtg = fluid.OilCtg?.ToWitsml<Witsml.Data.Measures.Measure>(),
HardnessCa = fluid.HardnessCa?.ToWitsml<Witsml.Data.Measures.Measure>(),
Sulfide = fluid.Sulfide?.ToWitsml<Witsml.Data.Measures.Measure>(),
Comments = fluid.Comments,
};
}
}
}
24 changes: 24 additions & 0 deletions Src/WitsmlExplorer.Api/Models/FluidsReport.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System.Collections.Generic;
using System.Linq;

using Witsml.Data;
using Witsml.Data.Measures;

using WitsmlExplorer.Api.Models.Measure;
using WitsmlExplorer.Api.Services;

namespace WitsmlExplorer.Api.Models
{
Expand All @@ -12,5 +17,24 @@ public class FluidsReport : ObjectOnWellbore
public string NumReport { get; init; }
public List<Fluid> Fluids { get; set; }
public CommonData CommonData { get; init; }

public override WitsmlFluidsReports ToWitsml()
{
return new WitsmlFluidsReport
{
UidWell = WellUid,
NameWell = WellName,
UidWellbore = WellboreUid,
NameWellbore = WellboreName,
Uid = Uid,
Name = Name,
DTim = StringHelpers.ToUniversalDateTimeString(DTim),
Md = Md?.ToWitsml<WitsmlMeasuredDepthCoord>(),
Tvd = Tvd?.ToWitsml<WitsmlWellVerticalDepthCoord>(),
NumReport = NumReport,
Fluids = Fluids?.Select(fluid => fluid?.ToWitsml())?.ToList(),
CommonData = CommonData?.ToWitsml()
}.AsSingletonWitsmlList();
}
}
}
45 changes: 31 additions & 14 deletions Src/WitsmlExplorer.Api/Models/FormationMarker.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
using Witsml.Data;
using Witsml.Data.Measures;

using WitsmlExplorer.Api.Models.Measure;

namespace WitsmlExplorer.Api.Models
{
public class FormationMarker : ObjectOnWellbore
{
public MeasureWithDatum MdPrognosed { get; init; }

public MeasureWithDatum TvdPrognosed { get; init; }

public MeasureWithDatum MdTopSample { get; init; }

public MeasureWithDatum TvdTopSample { get; init; }

public LengthMeasure ThicknessBed { get; init; }

public LengthMeasure ThicknessApparent { get; init; }

public LengthMeasure ThicknessPerpen { get; init; }

public MeasureWithDatum MdLogSample { get; init; }

public MeasureWithDatum TvdLogSample { get; init; }

public LengthMeasure Dip { get; init; }

public LengthMeasure DipDirection { get; init; }

public StratigraphicStruct Lithostratigraphic { get; init; }

public StratigraphicStruct Chronostratigraphic { get; init; }

public string Description { get; init; }

public CommonData CommonData { get; init; }

public override WitsmlFormationMarkers ToWitsml()
{
return new WitsmlFormationMarker
{
UidWell = WellUid,
NameWell = WellName,
UidWellbore = WellboreUid,
NameWellbore = WellboreName,
Uid = Uid,
Name = Name,
MdPrognosed = MdPrognosed?.ToWitsml<WitsmlMeasuredDepthCoord>(),
TvdPrognosed = TvdPrognosed?.ToWitsml<WitsmlWellVerticalDepthCoord>(),
MdTopSample = MdTopSample?.ToWitsml<WitsmlMeasuredDepthCoord>(),
TvdTopSample = TvdTopSample?.ToWitsml<WitsmlWellVerticalDepthCoord>(),
ThicknessBed = ThicknessBed?.ToWitsml<WitsmlLengthMeasure>(),
ThicknessApparent = ThicknessApparent?.ToWitsml<WitsmlLengthMeasure>(),
ThicknessPerpen = ThicknessPerpen?.ToWitsml<WitsmlLengthMeasure>(),
MdLogSample = MdLogSample?.ToWitsml<WitsmlMeasuredDepthCoord>(),
TvdLogSample = TvdLogSample?.ToWitsml<WitsmlWellVerticalDepthCoord>(),
Dip = Dip?.ToWitsml<WitsmlPlaneAngleMeasure>(),
DipDirection = DipDirection?.ToWitsml<WitsmlPlaneAngleMeasure>(),
Lithostratigraphic = Lithostratigraphic?.ToWitsmlLithostratigraphyStruct(),
Chronostratigraphic = Chronostratigraphic?.ToWitsmlChronostratigraphyStruct(),
Description = Description,
CommonData = CommonData?.ToWitsml()
}.AsSingletonWitsmlList();
}
}
}
Loading

0 comments on commit 6dd2243

Please sign in to comment.