예제 #1
0
        public async Task Test_SummaryCMVStatistics_SiteModelWithSingleTAGFile_FullExtents_WithCMVTargetOverrides
            (short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var operation = new CMVStatisticsOperation();

            var cmvSummaryResult = await operation.ExecuteAsync(SimpleCMVStatisticsArgument(siteModel, target, minPercentage, maxPercentage));

            cmvSummaryResult.Should().NotBeNull();
            cmvSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            cmvSummaryResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            cmvSummaryResult.ConstantTargetCMV.Should().Be(target == 0 ? MACHINE_TARGET_CMV : target);
            cmvSummaryResult.IsTargetCMVConstant.Should().BeTrue();
            cmvSummaryResult.Counts.Should().BeNull();
            cmvSummaryResult.Percents.Should().BeNull();
            cmvSummaryResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            cmvSummaryResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            cmvSummaryResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            cmvSummaryResult.TotalAreaCoveredSqMeters.Should().BeApproximately(2164 * SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
        }
예제 #2
0
        public async Task Test_SummaryCMVStatistics_SiteModelWithSingleCell_FullExtents_NoCMVTargetOverride()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = BuildModelForSingleCellCMV(CMV_INCREMENT);

            siteModel.MachinesTargetValues[0].VibrationStateEvents.PutValueAtDate(VSS.TRex.Common.Consts.MIN_DATETIME_AS_UTC, VibrationState.On);

            var operation = new CMVStatisticsOperation();

            var cmvSummaryResult = await operation.ExecuteAsync(SimpleCMVStatisticsArgument(siteModel, 0, 0.0, 0.0));

            cmvSummaryResult.Should().NotBeNull();
            cmvSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            cmvSummaryResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoResult);
            cmvSummaryResult.ConstantTargetCMV.Should().Be(CellPassConsts.NullCCV);
            cmvSummaryResult.IsTargetCMVConstant.Should().BeTrue();
            cmvSummaryResult.Counts.Should().BeNull();
            cmvSummaryResult.Percents.Should().BeNull();
            cmvSummaryResult.AboveTargetPercent.Should().Be(0);
            cmvSummaryResult.WithinTargetPercent.Should().Be(0);
            cmvSummaryResult.BelowTargetPercent.Should().Be(0);
            cmvSummaryResult.TotalAreaCoveredSqMeters.Should().Be(0);
        }
예제 #3
0
        public async Task Test_DetailedCMVStatistics_SiteModelWithSingleCell_FullExtents
            (short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = BuildModelForSingleCellCMV(CMV_INCREMENT);

            siteModel.MachinesTargetValues[0].VibrationStateEvents.PutValueAtDate(VSS.TRex.Common.Consts.MIN_DATETIME_AS_UTC, VibrationState.On);

            var operation = new CMVStatisticsOperation();

            var arg = SimpleCMVStatisticsArgument(siteModel, target, minPercentage, maxPercentage);

            arg.CMVDetailValues = new[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 };
            var cmvDetailResult = await operation.ExecuteAsync(arg);

            cmvDetailResult.Should().NotBeNull();

            // Checks counts and percentages
            cmvDetailResult.Counts.Sum().Should().Be(1);
            cmvDetailResult.Counts[9].Should().Be(1);
            cmvDetailResult.Percents.Sum().Should().BeApproximately(100.0, 0.000001);
            cmvDetailResult.Percents[9].Should().BeApproximately(100.0, 0.000001);

            // Check summary related fields are zero
            cmvDetailResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            cmvDetailResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoResult);
            cmvDetailResult.ConstantTargetCMV.Should().Be(CellPassConsts.NullCCV);
            cmvDetailResult.IsTargetCMVConstant.Should().BeTrue();
            cmvDetailResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            cmvDetailResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            cmvDetailResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            cmvDetailResult.TotalAreaCoveredSqMeters.Should().BeApproximately(0.0, 0.000001); // This being zero seems strange...
        }
예제 #4
0
        public async Task Test_SummaryCMVStatistics_SiteModelWithSingleCell_FullExtents_WithCMVTargetOverrides
            (short cmvIncrement, short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = BuildModelForSingleCellCMV(cmvIncrement);

            siteModel.MachinesTargetValues[0].VibrationStateEvents.PutValueAtDate(VSS.TRex.Common.Consts.MIN_DATETIME_AS_UTC, VibrationState.On);

            var operation = new CMVStatisticsOperation();

            var cmvSummaryResult = await operation.ExecuteAsync(SimpleCMVStatisticsArgument(siteModel, target, minPercentage, maxPercentage));

            cmvSummaryResult.Should().NotBeNull();
            cmvSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            cmvSummaryResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            cmvSummaryResult.ConstantTargetCMV.Should().Be(target);
            cmvSummaryResult.IsTargetCMVConstant.Should().BeTrue();
            cmvSummaryResult.Counts.Should().BeNull();
            cmvSummaryResult.Percents.Should().BeNull();
            cmvSummaryResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            cmvSummaryResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            cmvSummaryResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            cmvSummaryResult.TotalAreaCoveredSqMeters.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
        }
예제 #5
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var request = item as CMVDetailsRequest;

            if (request == null)
            {
                ThrowRequestTypeCastException <CMVDetailsRequest>();
            }

            var siteModel = GetSiteModel(request.ProjectUid);

            var filter = ConvertFilter(request.Filter, siteModel);

            var operation        = new CMVStatisticsOperation();
            var cmvDetailsResult = await operation.ExecuteAsync(new CMVStatisticsArgument()
            {
                ProjectID       = siteModel.ID,
                Filters         = new FilterSet(filter),
                CMVDetailValues = request.CustomCMVDetailTargets,
                Overrides       = AutoMapperUtility.Automapper.Map <OverrideParameters>(request.Overrides),
                LiftParams      = ConvertLift(request.LiftSettings, request.Filter?.LayerType)
            });

            if (cmvDetailsResult != null)
            {
                if (cmvDetailsResult.ResultStatus == RequestErrorStatus.OK)
                {
                    return(new CMVDetailedResult(cmvDetailsResult.Percents, cmvDetailsResult.ConstantTargetCMV, cmvDetailsResult.IsTargetCMVConstant));
                }

                throw CreateServiceException <DetailedCMVExecutor>(cmvDetailsResult.ResultStatus);
            }

            throw CreateServiceException <DetailedCMVExecutor>();
        }
예제 #6
0
        public async Task <JsonResult> GetCMVSummary([FromRoute] string siteModelID, [FromBody] OverrideParameters overrides)
        {
            string resultToReturn;

            if (!Guid.TryParse(siteModelID, out var UID))
            {
                resultToReturn = $"<b>Invalid Site Model UID: {siteModelID}</b>";
            }
            else
            {
                var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(UID, false);

                if (siteModel == null)
                {
                    resultToReturn = $"<b>Site model {UID} is unavailable</b>";
                }
                else
                {
                    var sw = new Stopwatch();
                    sw.Start();

                    var operation = new CMVStatisticsOperation();

                    var result = await operation.ExecuteAsync(
                        new CMVStatisticsArgument()
                    {
                        ProjectID = siteModel.ID,
                        Filters   = new FilterSet(new CombinedFilter()),
                        Overrides = overrides
                    }
                        );

                    if (result != null)
                    {
                        string resultString = $"<b>CMV Summary Results (in {sw.Elapsed}) :</b><br/>";
                        resultString += "<b>================================================</b><br/>";
                        resultString += $"<b>Above CMV Percentage:</b> {result.AboveTargetPercent}<br/>";
                        resultString += $"<b>Within CMV Percentage Range:</b> {result.WithinTargetPercent}<br/>";
                        resultString += $"<b>Below CMV Percentage:</b> {result.BelowTargetPercent}<br/>";
                        resultString += $"<b>Total Area Covered in Sq Meters:</b> {result.TotalAreaCoveredSqMeters}<br/>";

                        resultToReturn = resultString;
                    }
                    else
                    {
                        resultToReturn = "<b>No result</b>";
                    }
                }
            }

            return(new JsonResult(resultToReturn));
        }
예제 #7
0
        public async Task Test_SummaryCMVStatistics_EmptySiteModel_FullExtents_NoCMVTargetOverride()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var operation = new CMVStatisticsOperation();

            var cmvSummaryResult = await operation.ExecuteAsync(SimpleCMVStatisticsArgument(siteModel, 0, 0.0, 0.0));

            cmvSummaryResult.Should().NotBeNull();
            cmvSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.FailedToRequestDatamodelStatistics);
        }
예제 #8
0
        public async Task Test_DetailedCMVStatistics_SiteModelWithSingleTAGFile_FullExtents
            (short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var operation = new CMVStatisticsOperation();

            var arg = SimpleCMVStatisticsArgument(siteModel, target, minPercentage, maxPercentage);

            arg.CMVDetailValues = new[] { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500 };
            var cmvDetailResult = await operation.ExecuteAsync(arg);

            cmvDetailResult.Should().NotBeNull();

            // Checks counts and percentages
            long[] expectedCounts = { 0, 2, 365, 1450, 325, 16, 6, 0, 0, 0, 0, 0, 0, 0, 0 };
            cmvDetailResult.Counts.Should().BeEquivalentTo(expectedCounts);

            // Are all counts the same and do percentages match?
            long totalCount = cmvDetailResult.Counts.Sum();

            for (int i = 0; i < expectedCounts.Length; i++)
            {
                expectedCounts[i].Should().Be(cmvDetailResult.Counts[i]);
                cmvDetailResult.Percents[i].Should().BeApproximately(100.0 * expectedCounts[i] / (1.0 * totalCount), 0.001);
            }

            // Check summary related fields are zero
            cmvDetailResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            cmvDetailResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            cmvDetailResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            cmvDetailResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            cmvDetailResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            cmvDetailResult.TotalAreaCoveredSqMeters.Should().BeApproximately(2164 * SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
            cmvDetailResult.ConstantTargetCMV.Should().Be(MACHINE_TARGET_CMV);
            cmvDetailResult.IsTargetCMVConstant.Should().BeTrue();
        }
예제 #9
0
        public async Task <JsonResult> GetCMVDetails([FromRoute] string siteModelID, [FromBody] OverrideParameters overrides)
        {
            const int CMV_DENOMINATOR = 10;
            string    resultToReturn;

            if (!Guid.TryParse(siteModelID, out var UID))
            {
                resultToReturn = $"<b>Invalid Site Model UID: {siteModelID}</b>";
            }
            else
            {
                var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(UID, false);
                var cmvBands  = new[] { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 1000, 1200 };

                if (siteModel == null)
                {
                    resultToReturn = $"<b>Site model {UID} is unavailable</b>";
                }
                else
                {
                    var sw = new Stopwatch();
                    sw.Start();

                    var operation = new CMVStatisticsOperation();
                    var result    = await operation.ExecuteAsync(
                        new CMVStatisticsArgument()
                    {
                        ProjectID = siteModel.ID,
                        Filters   = new FilterSet()
                        {
                            Filters = new[] { new CombinedFilter() }
                        },
                        CMVDetailValues = cmvBands,
                        Overrides       = overrides
                    }
                        );

                    if (result != null)
                    {
                        string resultString = $"<b>CMV Details Results (in {sw.Elapsed}) :</b><br/>";
                        resultString += "<b>================================================</b><br/>";

                        var anyTwoDigitsNumber   = cmvBands.ToList().Find(s => (s / CMV_DENOMINATOR) >= TWO_DIGITS_NUMBER);
                        var anyThreeDigitsNumber = cmvBands.ToList().Find(s => (s / CMV_DENOMINATOR) >= THREE_DIGITS_NUMBER);

                        for (int i = 0; i < cmvBands.Length; i++)
                        {
                            string space = anyThreeDigitsNumber > 0 && cmvBands[i] / CMV_DENOMINATOR < THREE_DIGITS_NUMBER ? "&nbsp;&nbsp;" : string.Empty;

                            if (anyTwoDigitsNumber > 0 && cmvBands[i] / CMV_DENOMINATOR < TWO_DIGITS_NUMBER)
                            {
                                space += "&nbsp;&nbsp;";
                            }

                            resultString += $"<b>{space}{cmvBands[i] / CMV_DENOMINATOR}</b> - {result.Percents[i]:##0.#0}%<br/>";
                        }

                        resultToReturn = resultString;
                    }
                    else
                    {
                        resultToReturn = "<b>No result</b>";
                    }
                }
            }

            return(new JsonResult(resultToReturn));
        }