public void CelLGapExists_Should_handle_null_prevCell() { var currCell = new ProfileCellData(); Assert.IsFalse(ProfilesHelper.CellGapExists(null, currCell, out double prevStationIntercept)); Assert.AreEqual(0.0, prevStationIntercept); }
public void CellGapExists(double prevStation, double prevInterceptLength, double currStation, bool expectedResult, double expectedPrevStationIntercept) { var prevCell = new ProfileCellData { Station = prevStation, InterceptLength = prevInterceptLength }; var currCell = new ProfileCellData { Station = currStation }; Assert.AreEqual(expectedResult, ProfilesHelper.CellGapExists(prevCell, currCell, out double prevStationIntercept)); Assert.AreEqual(expectedPrevStationIntercept, prevStationIntercept); }
private CompactionProfileResult <CompactionSummaryVolumesProfileCell> ProcessSummaryVolumesProfileCells(List <SummaryVolumeProfileCell> profileCells, double gridDistanceBetweenProfilePoints, VolumeCalcType calcType) { var profile = new CompactionProfileResult <CompactionSummaryVolumesProfileCell>(); profile.results = new List <CompactionSummaryVolumesProfileCell>(); SummaryVolumeProfileCell prevCell = null; foreach (var currCell in profileCells) { var gapExists = ProfilesHelper.CellGapExists(prevCell, currCell, out var prevStationIntercept); if (gapExists) { var gapCell = new CompactionSummaryVolumesProfileCell(SumVolGapCell); gapCell.station = prevStationIntercept; profile.results.Add(gapCell); } var lastPassHeight1 = currCell.LastCellPassElevation1 == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LastCellPassElevation1; var lastPassHeight2 = currCell.LastCellPassElevation2 == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LastCellPassElevation2; var designHeight = currCell.DesignElev == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.DesignElev; float cutFill = float.NaN; switch (calcType) { case VolumeCalcType.GroundToGround: cutFill = float.IsNaN(lastPassHeight1) || float.IsNaN(lastPassHeight2) ? float.NaN : lastPassHeight2 - lastPassHeight1; break; case VolumeCalcType.GroundToDesign: cutFill = float.IsNaN(lastPassHeight1) || float.IsNaN(designHeight) ? float.NaN : designHeight - lastPassHeight1; break; case VolumeCalcType.DesignToGround: cutFill = float.IsNaN(designHeight) || float.IsNaN(lastPassHeight2) ? float.NaN : lastPassHeight2 - designHeight; break; } profile.results.Add(new CompactionSummaryVolumesProfileCell { cellType = prevCell == null ? ProfileCellType.MidPoint : ProfileCellType.Edge, station = currCell.Station, lastPassHeight1 = lastPassHeight1, lastPassHeight2 = lastPassHeight2, designHeight = designHeight, cutFill = cutFill }); prevCell = currCell; } //Add a last point at the intercept length of the last cell so profiles are drawn correctly if (prevCell != null && prevCell.InterceptLength > ProfilesHelper.ONE_MM) { var lastCell = new CompactionSummaryVolumesProfileCell(profile.results[profile.results.Count - 1]) { station = prevCell.Station + prevCell.InterceptLength }; profile.results.Add(lastCell); } if (profile.results.Count > 0) { profile.results[profile.results.Count - 1].cellType = ProfileCellType.MidPoint; } profile.gridDistanceBetweenProfilePoints = gridDistanceBetweenProfilePoints; var sb = new StringBuilder(); sb.Append($"After summary volumes profile conversion: {profile.results.Count}"); foreach (var cell in profile.results) { sb.Append($",{cell.cellType}"); } log.LogDebug(sb.ToString()); return(profile); }
private CompactionProfileResult <CompactionProfileCell> ProcessProductionDataProfileCells(List <ProfileCellData> profileCells, double gridDistanceBetweenProfilePoints, LiftBuildSettings liftBuildSettings) { var profile = new CompactionProfileResult <CompactionProfileCell>(); profile.results = new List <CompactionProfileCell>(); ProfileCellData prevCell = null; foreach (var currCell in profileCells) { var gapExists = ProfilesHelper.CellGapExists(prevCell, currCell, out double prevStationIntercept); if (gapExists) { var gapCell = new CompactionProfileCell(GapCell); gapCell.station = prevStationIntercept; profile.results.Add(gapCell); } var lastPassHeight = currCell.LastPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LastPassHeight; var lastCompositeHeight = currCell.CompositeLastPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeLastPassHeight; var designHeight = currCell.DesignHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.DesignHeight; bool noCCVValue = currCell.TargetCCV == 0 || currCell.TargetCCV == VelociraptorConstants.NO_CCV || currCell.CCV == VelociraptorConstants.NO_CCV; bool noCCVElevation = currCell.CCVElev == VelociraptorConstants.NULL_SINGLE || noCCVValue; bool noMDPValue = currCell.TargetMDP == 0 || currCell.TargetMDP == VelociraptorConstants.NO_MDP || currCell.MDP == VelociraptorConstants.NO_MDP; bool noMDPElevation = currCell.MDPElev == VelociraptorConstants.NULL_SINGLE || noMDPValue; bool noTemperatureValue = currCell.MaterialTemperature == VelociraptorConstants.NO_TEMPERATURE; bool noTemperatureElevation = currCell.MaterialTemperatureElev == VelociraptorConstants.NULL_SINGLE || noTemperatureValue; bool noPassCountValue = currCell.TopLayerPassCount == VelociraptorConstants.NO_PASSCOUNT; //Either have none or both speed values var noSpeedValue = currCell.CellMaxSpeed == VelociraptorConstants.NO_SPEED; var speedMin = noSpeedValue ? float.NaN : (float)(currCell.CellMinSpeed / ConversionConstants.KM_HR_TO_CM_SEC); var speedMax = noSpeedValue ? float.NaN : (float)(currCell.CellMaxSpeed / ConversionConstants.KM_HR_TO_CM_SEC); var cmvPercent = noCCVValue ? float.NaN : (float)currCell.CCV / (float)currCell.TargetCCV * 100.0F; var mdpPercent = noMDPValue ? float.NaN : (float)currCell.MDP / (float)currCell.TargetMDP * 100.0F; var firstPassHeight = currCell.FirstPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.FirstPassHeight; var highestPassHeight = currCell.HighestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.HighestPassHeight; var lowestPassHeight = currCell.LowestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LowestPassHeight; var cutFill = float.IsNaN(lastCompositeHeight) || float.IsNaN(designHeight) ? float.NaN : lastCompositeHeight - designHeight; var cmv = noCCVValue ? float.NaN : currCell.CCV / 10.0F; var cmvHeight = noCCVElevation ? float.NaN : currCell.CCVElev; var mdpHeight = noMDPElevation ? float.NaN : currCell.MDPElev; var temperature = noTemperatureValue ? float.NaN : currCell.MaterialTemperature / 10.0F; // As temperature is reported in 10th... var temperatureHeight = noTemperatureElevation ? float.NaN : currCell.MaterialTemperatureElev; var topLayerPassCount = noPassCountValue ? -1 : currCell.TopLayerPassCount; var cmvPercentChange = currCell.CCV == VelociraptorConstants.NO_CCV ? float.NaN : (currCell.PrevCCV == VelociraptorConstants.NO_CCV ? 100.0f : (float)(currCell.CCV - currCell.PrevCCV) / (float)currCell.PrevCCV * 100.0f); var passCountIndex = noPassCountValue || float.IsNaN(lastPassHeight) ? ValueTargetType.NoData : (currCell.TopLayerPassCount < currCell.TopLayerPassCountTargetRangeMin ? ValueTargetType.BelowTarget : (currCell.TopLayerPassCount > currCell.TopLayerPassCountTargetRangeMax ? ValueTargetType.AboveTarget : ValueTargetType.OnTarget)); var temperatureIndex = noTemperatureValue || noTemperatureElevation ? ValueTargetType.NoData : (currCell.MaterialTemperature < currCell.MaterialTemperatureWarnMin ? ValueTargetType.BelowTarget : (currCell.MaterialTemperature > currCell.MaterialTemperatureWarnMax ? ValueTargetType.AboveTarget : ValueTargetType.OnTarget)); var cmvIndex = noCCVValue || noCCVElevation ? ValueTargetType.NoData : (cmvPercent < liftBuildSettings.CCVRange.Min ? ValueTargetType.BelowTarget : (cmvPercent > liftBuildSettings.CCVRange.Max ? ValueTargetType.AboveTarget : ValueTargetType.OnTarget)); var mdpIndex = noMDPValue || noMDPElevation ? ValueTargetType.NoData : (mdpPercent < liftBuildSettings.MDPRange.Min ? ValueTargetType.BelowTarget : (mdpPercent > liftBuildSettings.MDPRange.Max ? ValueTargetType.AboveTarget : ValueTargetType.OnTarget)); var speedIndex = noSpeedValue || float.IsNaN(lastPassHeight) ? ValueTargetType.NoData : (currCell.CellMaxSpeed > liftBuildSettings.MachineSpeedTarget.MaxTargetMachineSpeed ? ValueTargetType.AboveTarget : (currCell.CellMinSpeed < liftBuildSettings.MachineSpeedTarget.MinTargetMachineSpeed && currCell.CellMaxSpeed < liftBuildSettings.MachineSpeedTarget.MinTargetMachineSpeed ? ValueTargetType.BelowTarget : ValueTargetType.OnTarget)); profile.results.Add(new CompactionProfileCell { cellType = prevCell == null ? ProfileCellType.MidPoint : ProfileCellType.Edge, station = currCell.Station, firstPassHeight = firstPassHeight, highestPassHeight = highestPassHeight, lastPassHeight = lastPassHeight, lowestPassHeight = lowestPassHeight, lastCompositeHeight = lastCompositeHeight, designHeight = designHeight, cutFill = cutFill, cmv = cmv, cmvPercent = cmvPercent, cmvHeight = cmvHeight, mdpPercent = mdpPercent, mdpHeight = mdpHeight, temperature = temperature, temperatureHeight = temperatureHeight, topLayerPassCount = topLayerPassCount, cmvPercentChange = cmvPercentChange, minSpeed = speedMin, maxSpeed = speedMax, passCountIndex = passCountIndex, temperatureIndex = temperatureIndex, cmvIndex = cmvIndex, mdpIndex = mdpIndex, speedIndex = speedIndex }); prevCell = currCell; } //Add a last point at the intercept length of the last cell so profiles are drawn correctly if (prevCell != null && prevCell.InterceptLength > ProfilesHelper.ONE_MM) { var lastCell = new CompactionProfileCell(profile.results[profile.results.Count - 1]) { station = prevCell.Station + prevCell.InterceptLength }; profile.results.Add(lastCell); } if (profile.results.Count > 0) { profile.results[profile.results.Count - 1].cellType = ProfileCellType.MidPoint; } profile.gridDistanceBetweenProfilePoints = gridDistanceBetweenProfilePoints; var sb = new StringBuilder(); sb.Append($"After profile conversion: {profile.results.Count}"); foreach (var cell in profile.results) { sb.Append($",{cell.cellType}"); } log.LogDebug(sb.ToString()); return(profile); }
private static ProfileResult ProcessProfileCells(List <ProfileCellData> profileCells, double gridDistanceBetweenProfilePoints, Guid callerId) { var profile = new ProfileResult() { callId = callerId, cells = null }; profile.cells = new List <ProfileCell>(); ProfileCellData prevCell = null; foreach (var currCell in profileCells) { var gapExists = ProfilesHelper.CellGapExists(prevCell, currCell, out double prevStationIntercept); if (gapExists) { profile.cells.Add(new ProfileCell() { station = prevStationIntercept, firstPassHeight = float.NaN, highestPassHeight = float.NaN, lastPassHeight = float.NaN, lowestPassHeight = float.NaN, firstCompositeHeight = float.NaN, highestCompositeHeight = float.NaN, lastCompositeHeight = float.NaN, lowestCompositeHeight = float.NaN, designHeight = float.NaN, cmvPercent = float.NaN, cmvHeight = float.NaN, previousCmvPercent = float.NaN, mdpPercent = float.NaN, mdpHeight = float.NaN, temperature = float.NaN, temperatureHeight = float.NaN, temperatureLevel = -1, topLayerPassCount = -1, topLayerPassCountTargetRange = new TargetPassCountRange(VelociraptorConstants.NO_PASSCOUNT, VelociraptorConstants.NO_PASSCOUNT), passCountIndex = -1, topLayerThickness = float.NaN }); } bool noCCVValue = currCell.TargetCCV == 0 || currCell.TargetCCV == VelociraptorConstants.NO_CCV || currCell.CCV == VelociraptorConstants.NO_CCV; bool noCCElevation = currCell.CCVElev == VelociraptorConstants.NULL_SINGLE || noCCVValue; bool noMDPValue = currCell.TargetMDP == 0 || currCell.TargetMDP == VelociraptorConstants.NO_MDP || currCell.MDP == VelociraptorConstants.NO_MDP; bool noMDPElevation = currCell.MDPElev == VelociraptorConstants.NULL_SINGLE || noMDPValue; bool noTemperatureValue = currCell.MaterialTemperature == VelociraptorConstants.NO_TEMPERATURE; bool noTemperatureElevation = currCell.MaterialTemperatureElev == VelociraptorConstants.NULL_SINGLE || noTemperatureValue; bool noPassCountValue = currCell.TopLayerPassCount == VelociraptorConstants.NO_PASSCOUNT; profile.cells.Add(new ProfileCell { station = currCell.Station, firstPassHeight = currCell.FirstPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.FirstPassHeight, highestPassHeight = currCell.HighestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.HighestPassHeight, lastPassHeight = currCell.LastPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LastPassHeight, lowestPassHeight = currCell.LowestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LowestPassHeight, firstCompositeHeight = currCell.CompositeFirstPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeFirstPassHeight, highestCompositeHeight = currCell.CompositeHighestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeHighestPassHeight, lastCompositeHeight = currCell.CompositeLastPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeLastPassHeight, lowestCompositeHeight = currCell.CompositeLowestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeLowestPassHeight, designHeight = currCell.DesignHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.DesignHeight, cmvPercent = noCCVValue ? float.NaN : (float)currCell.CCV / (float)currCell.TargetCCV * 100.0F, cmvHeight = noCCElevation ? float.NaN : currCell.CCVElev, previousCmvPercent = noCCVValue ? float.NaN : (float)currCell.PrevCCV / (float)currCell.PrevTargetCCV * 100.0F, mdpPercent = noMDPValue ? float.NaN : (float)currCell.MDP / (float)currCell.TargetMDP * 100.0F, mdpHeight = noMDPElevation ? float.NaN : currCell.MDPElev, temperature = noTemperatureValue ? float.NaN : currCell.MaterialTemperature / 10.0F,// As temperature is reported in 10th... temperatureHeight = noTemperatureElevation ? float.NaN : currCell.MaterialTemperatureElev, temperatureLevel = noTemperatureValue ? -1 : (currCell.MaterialTemperature < currCell.MaterialTemperatureWarnMin ? 2 : (currCell.MaterialTemperature > currCell.MaterialTemperatureWarnMax ? 0 : 1)), topLayerPassCount = noPassCountValue ? -1 : currCell.TopLayerPassCount, topLayerPassCountTargetRange = new TargetPassCountRange(currCell.TopLayerPassCountTargetRangeMin, currCell.TopLayerPassCountTargetRangeMax), passCountIndex = noPassCountValue ? -1 : (currCell.TopLayerPassCount < currCell.TopLayerPassCountTargetRangeMin ? 2 : (currCell.TopLayerPassCount > currCell.TopLayerPassCountTargetRangeMax ? 0 : 1)), topLayerThickness = currCell.TopLayerThickness == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.TopLayerThickness }); prevCell = currCell; } //Add a last point at the intercept length of the last cell so profiles are drawn correctly if (prevCell != null) { ProfileCell lastCell = profile.cells[profile.cells.Count - 1]; profile.cells.Add(new ProfileCell() { station = prevCell.Station + prevCell.InterceptLength, firstPassHeight = lastCell.firstPassHeight, highestPassHeight = lastCell.highestPassHeight, lastPassHeight = lastCell.lastPassHeight, lowestPassHeight = lastCell.lowestPassHeight, firstCompositeHeight = lastCell.firstCompositeHeight, highestCompositeHeight = lastCell.highestCompositeHeight, lastCompositeHeight = lastCell.lastCompositeHeight, lowestCompositeHeight = lastCell.lowestCompositeHeight, designHeight = lastCell.designHeight, cmvPercent = lastCell.cmvPercent, cmvHeight = lastCell.cmvHeight, mdpPercent = lastCell.mdpPercent, mdpHeight = lastCell.mdpHeight, temperature = lastCell.temperature, temperatureHeight = lastCell.temperatureHeight, temperatureLevel = lastCell.temperatureLevel, topLayerPassCount = lastCell.topLayerPassCount, topLayerPassCountTargetRange = lastCell.topLayerPassCountTargetRange, passCountIndex = lastCell.passCountIndex, topLayerThickness = lastCell.topLayerThickness, previousCmvPercent = lastCell.previousCmvPercent }); } profile.gridDistanceBetweenProfilePoints = gridDistanceBetweenProfilePoints; return(profile); }