Ejemplo n.º 1
0
        public async Task Test_SummaryMDPStatistics_SiteModelWithSingleCell_FullExtents_NoMDPTargetOverride()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = BuildModelForSingleCellMDP(MDP_INCREMENT);

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

            var operation = new MDPStatisticsOperation();

            var mdpSummaryResult = await operation.ExecuteAsync(SimpleMDPStatisticsArgument(siteModel, 0, 0.0, 0.0));

            mdpSummaryResult.Should().NotBeNull();
            mdpSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            mdpSummaryResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoResult);
            mdpSummaryResult.ConstantTargetMDP.Should().Be(CellPassConsts.NullMDP);
            mdpSummaryResult.IsTargetMDPConstant.Should().BeTrue();
            mdpSummaryResult.Counts.Should().BeNull();
            mdpSummaryResult.Percents.Should().BeNull();
            mdpSummaryResult.AboveTargetPercent.Should().Be(0);
            mdpSummaryResult.WithinTargetPercent.Should().Be(0);
            mdpSummaryResult.BelowTargetPercent.Should().Be(0);
            mdpSummaryResult.TotalAreaCoveredSqMeters.Should().Be(0);
        }
Ejemplo n.º 2
0
        public async Task Test_SummaryMDPStatistics_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-MDP.tag"),
            };

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

            var mdpSummaryResult = await operation.ExecuteAsync(SimpleMDPStatisticsArgument(siteModel, target, minPercentage, maxPercentage));

            mdpSummaryResult.Should().NotBeNull();
            mdpSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            mdpSummaryResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            mdpSummaryResult.ConstantTargetMDP.Should().Be(target == 0 ? MACHINE_TARGET_MDP : target);
            mdpSummaryResult.IsTargetMDPConstant.Should().BeTrue();
            mdpSummaryResult.Counts.Should().BeNull();
            mdpSummaryResult.Percents.Should().BeNull();
            mdpSummaryResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            mdpSummaryResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            mdpSummaryResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            mdpSummaryResult.TotalAreaCoveredSqMeters.Should().BeApproximately(1283 * SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
        }
Ejemplo n.º 3
0
        public async Task Test_DetailedMDPStatistics_SiteModelWithSingleCell_FullExtents
            (short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = BuildModelForSingleCellMDP(MDP_INCREMENT);

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

            var operation = new MDPStatisticsOperation();

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

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

            mdpDetailResult.Should().NotBeNull();

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

            // Check summary related fields are zero
            mdpDetailResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            mdpDetailResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoResult);
            mdpDetailResult.ConstantTargetMDP.Should().Be(CellPassConsts.NullMDP);
            mdpDetailResult.IsTargetMDPConstant.Should().BeTrue();
            mdpDetailResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            mdpDetailResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            mdpDetailResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            mdpDetailResult.TotalAreaCoveredSqMeters.Should().BeApproximately(0, 0.000001); // This being zero seems strange...
        }
Ejemplo n.º 4
0
        public async Task Test_SummaryMDPStatistics_SiteModelWithSingleCell_FullExtents_WithMDPTargetOverrides
            (short mdpIncrement, short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = BuildModelForSingleCellMDP(mdpIncrement);

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

            var operation = new MDPStatisticsOperation();

            var mdpSummaryResult = await operation.ExecuteAsync(SimpleMDPStatisticsArgument(siteModel, target, minPercentage, maxPercentage));

            mdpSummaryResult.Should().NotBeNull();
            mdpSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            mdpSummaryResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            mdpSummaryResult.ConstantTargetMDP.Should().Be(target);
            mdpSummaryResult.IsTargetMDPConstant.Should().BeTrue();
            mdpSummaryResult.Counts.Should().BeNull();
            mdpSummaryResult.Percents.Should().BeNull();
            mdpSummaryResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            mdpSummaryResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            mdpSummaryResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            mdpSummaryResult.TotalAreaCoveredSqMeters.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
        }
Ejemplo n.º 5
0
        public async Task Test_DetailedMDPStatistics_SiteModelWithSingleTAGFile_FullExtents
            (short target, double minPercentage, double maxPercentage, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

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

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

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

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

            mdpDetailResult.Should().NotBeNull();

            // Checks counts and percentages
            long[] expectedCounts    = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 321, 400, 535, 6 };
            long   expectedCountsSum = 0;

            for (int i = 0; i < expectedCounts.Length; i++)
            {
                expectedCountsSum += (i + 1) * expectedCounts[i];
            }

            // Is sum of counts the same?
            long cmvDetailResultSum = 0;

            for (int i = 0; i < mdpDetailResult.Counts.Length; i++)
            {
                cmvDetailResultSum += (i + 1) * mdpDetailResult.Counts[i];
            }

            cmvDetailResultSum.Should().Be(expectedCountsSum);

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

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

            // Check summary related fields are zero
            mdpDetailResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            mdpDetailResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            mdpDetailResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            mdpDetailResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            mdpDetailResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            mdpDetailResult.TotalAreaCoveredSqMeters.Should().BeApproximately(1283 * SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
            mdpDetailResult.ConstantTargetMDP.Should().Be(MACHINE_TARGET_MDP);
            mdpDetailResult.IsTargetMDPConstant.Should().BeTrue();
        }
Ejemplo n.º 6
0
        public async Task <JsonResult> GetMDPSummary([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 MDPStatisticsOperation();
                    var result    = await operation.ExecuteAsync(
                        new MDPStatisticsArgument()
                    {
                        ProjectID = siteModel.ID,
                        Filters   = new FilterSet()
                        {
                            Filters = new[] { new CombinedFilter() }
                        },
                        Overrides = overrides
                    }
                        );

                    if (result != null)
                    {
                        string resultString = $"<b>MDP Summary Results (in {sw.Elapsed}) :</b><br/>";
                        resultString += "<b>================================================</b><br/>";
                        resultString += $"<b>Above MDP Percentage:</b> {result.AboveTargetPercent}<br/>";
                        resultString += $"<b>Within MDP Percentage Range:</b> {result.WithinTargetPercent}<br/>";
                        resultString += $"<b>Below MDP 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));
        }
Ejemplo n.º 7
0
        public async Task Test_SummaryMDPStatistics_EmptySiteModel_FullExtents_NoMDPTargetOverride()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

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

            var mdpSummaryResult = await operation.ExecuteAsync(SimpleMDPStatisticsArgument(siteModel, 0, 0.0, 0.0));

            mdpSummaryResult.Should().NotBeNull();
            mdpSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.FailedToRequestDatamodelStatistics);
        }
Ejemplo n.º 8
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var request = item as MDPSummaryRequest;

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

            var siteModel = GetSiteModel(request.ProjectUid);

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

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

            if (mdpSummaryResult != null)
            {
                if (mdpSummaryResult.ResultStatus == RequestErrorStatus.OK)
                {
                    return(ConvertResult(mdpSummaryResult));
                }

                throw CreateServiceException <SummaryMDPExecutor>(mdpSummaryResult.ResultStatus);
            }

            throw CreateServiceException <SummaryMDPExecutor>();
        }
Ejemplo n.º 9
0
        public void Test_SummaryMDPStatistics_Creation()
        {
            var operation = new MDPStatisticsOperation();

            operation.Should().NotBeNull();
        }