Exemple #1
0
        public ProfileRequestResponse <T> Invoke(ProfileRequestArgument_ClusterCompute arg)
        {
            _log.LogInformation("In ProfileRequestComputeFunc.Invoke()");

            try
            {
                // Quantized mesh requests can be a significant resource commitment. Ensure TPaaS will be listening...
                PerformTPaaSRequestLivelinessCheck(arg);

                var executor = new ComputeProfileExecutor_ClusterCompute <T>(arg.ProfileStyle, arg.ProjectID, arg.ProfileTypeRequired, arg.NEECoords, arg.Filters,
                                                                             arg.ReferenceDesign, arg.ReturnAllPassesAndLayers, arg.VolumeType, arg.Overrides, arg.LiftParams);

                _log.LogInformation("Executing profiler.ExecuteAsync()");

                return(executor.ExecuteAsync().WaitAndUnwrapException());
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception requesting profile at cluster compute layer");
                return(new ProfileRequestResponse <T> {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
            finally
            {
                _log.LogInformation("Exiting ProfileRequestComputeFunc.Invoke()");
            }
        }
Exemple #2
0
        public void Test_ProfileRequestArgument_ClusterCompute()
        {
            var coords = new XYZ[3];

            for (var i = 0; i < coords.Length; i++)
            {
                coords[i] = new XYZ(0.0, 0.0, 0.0);
            }

            var argument = new ProfileRequestArgument_ClusterCompute()
            {
                ProjectID                = Guid.NewGuid(),
                Filters                  = new FilterSet(new CombinedFilter()),
                ReferenceDesign          = new DesignOffset(Guid.NewGuid(), 1.5),
                ProfileTypeRequired      = GridDataType.Height,
                NEECoords                = coords,
                ReturnAllPassesAndLayers = false,
                Overrides                = new OverrideParameters {
                    CMVRange = new CMVRangePercentageRecord(35.7, 104.9), OverrideMachineCCV = true, OverridingMachineCCV = 142
                }
            };

            SimpleBinarizableInstanceTester.TestClass(argument, "Custom ProfileRequestArgument_ClusterCompute not same after round trip serialisation");
        }
Exemple #3
0
        /// <summary>
        /// Executes the profiler
        /// </summary>
        public async Task <ProfileRequestResponse <T> > ExecuteAsync(ProfileRequestArgument_ApplicationService arg)
        {
            _log.LogInformation("Start execution");

            try
            {
                if (arg.Filters?.Filters != null && arg.Filters.Filters.Length > 0)
                {
                    // Prepare the filters for use in profiling operations. Failure to prepare any filter results in this request terminating
                    if (!arg.Filters.Filters.Select(x => FilterUtilities.PrepareFilterForUse(x, arg.ProjectID)).All(x => x == RequestErrorStatus.OK))
                    {
                        return(new ProfileRequestResponse <T> {
                            ResultStatus = RequestErrorStatus.FailedToPrepareFilter
                        });
                    }
                }

                var arg2 = new ProfileRequestArgument_ClusterCompute
                {
                    ProfileTypeRequired      = arg.ProfileTypeRequired,
                    ProfileStyle             = arg.ProfileStyle,
                    ProjectID                = arg.ProjectID,
                    Filters                  = arg.Filters,
                    ReferenceDesign          = arg.ReferenceDesign,
                    ReturnAllPassesAndLayers = arg.ReturnAllPassesAndLayers,
                    TRexNodeID               = arg.TRexNodeID,
                    VolumeType               = arg.VolumeType,
                    Overrides                = arg.Overrides,
                    LiftParams               = arg.LiftParams
                };

                // Perform coordinate conversion on the argument before broadcasting it:
                if (arg.PositionsAreGrid)
                {
                    arg2.NEECoords = new[] { arg.StartPoint, arg.EndPoint }.Select(x => new XYZ(x.Lon, x.Lat)).ToArray();
                }
                else
                {
                    var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(arg.ProjectID);

                    if (siteModel != null)
                    {
                        arg2.NEECoords = DIContext.Obtain <ICoreXWrapper>().WGS84ToCalibration(
                            siteModel.CSIB(),
                            new[] { arg.StartPoint, arg.EndPoint }
                            .ToCoreX_WGS84Point(),
                            CoreX.Types.InputAs.Radians)
                                         .ToTRex_XYZ();
                    }
                }

                var request         = new ProfileRequest_ClusterCompute <T>();
                var profileResponse = await request.ExecuteAsync(arg2);

                profileResponse.GridDistanceBetweenProfilePoints = MathUtilities.Hypot(arg2.NEECoords[1].X - arg2.NEECoords[0].X, arg2.NEECoords[1].Y - arg2.NEECoords[0].Y);

                //... and then sort them to get the final result, as well as removing initial and duplicate null values
                // Remove null cells in the profiles list. Null cells are defined by cells with null CellLastHeight.
                // All duplicate null cells will be replaced by a by single null cell entry
                int firstNonNullIndex = 0;
                var _profileCells     = profileResponse?.ProfileCells?.OrderBy(x => x.Station).ToList();
                if (_profileCells != null)
                {
                    profileResponse.ProfileCells = _profileCells.Where((x, i) =>
                    {
                        // Remove all leading nulls
                        if (_profileCells[i].IsNull() && i == firstNonNullIndex)
                        {
                            firstNonNullIndex++;
                            return(false);
                        }

                        // Collapse all interior nulls to single nulls, unless the null is at the end. Leave any single terminating null
                        return(i == 0 || !_profileCells[i].IsNull() || (_profileCells[i].IsNull() && !_profileCells[i - 1].IsNull()));
                    }).ToList();
                }

                // Return the care package to the caller
                return(profileResponse);
            }
            finally
            {
                _log.LogInformation("End execution");
            }
        }