Exemple #1
0
        /// <summary>
        /// Executor that implements requesting and rendering sub grid information to create the cell datum
        /// </summary>
        public async Task <CellDatumResponse_ApplicationService> ExecuteAsync(CellDatumRequestArgument_ApplicationService arg)
        {
            Log.LogInformation($"Performing Execute for DataModel:{arg.ProjectID}, Mode={arg.Mode}");

            var result = new CellDatumResponse_ApplicationService
            {
                ReturnCode = CellDatumReturnCode.UnexpectedError, DisplayMode = arg.Mode, Northing = arg.Point.Y, Easting = arg.Point.X
            };

            var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(arg.ProjectID);

            if (siteModel == null)
            {
                Log.LogError($"Failed to locate site model {arg.ProjectID}");
                return(result);
            }

            if (!arg.CoordsAreGrid)
            {
                //WGS84 coords need to be converted to NEE
                var pointToConvert = new XYZ(arg.Point.X, arg.Point.Y, 0);
                arg.Point       = DIContext.Obtain <ICoreXWrapper>().LLHToNEE(siteModel.CSIB(), pointToConvert.ToCoreX_XYZ(), CoreX.Types.InputAs.Radians).ToTRex_XYZ();
                result.Northing = arg.Point.Y;
                result.Easting  = arg.Point.X;
            }

            var existenceMap = siteModel.ExistenceMap;

            // Determine the on-the-ground cell
            siteModel.Grid.CalculateIndexOfCellContainingPosition(arg.Point.X, arg.Point.Y, out int OTGCellX, out int OTGCellY);

            if (!existenceMap[OTGCellX >> SubGridTreeConsts.SubGridIndexBitsPerLevel, OTGCellY >> SubGridTreeConsts.SubGridIndexBitsPerLevel])
            {
                result.ReturnCode = CellDatumReturnCode.NoValueFound;
                return(result);
            }

            //Now get the production data for this cell
            var argClusterCompute = new CellDatumRequestArgument_ClusterCompute(
                arg.ProjectID, arg.Mode, arg.Point, OTGCellX, OTGCellY, arg.Filters, arg.ReferenceDesign, arg.Overrides, arg.LiftParams);
            var request  = new CellDatumRequest_ClusterCompute();
            var response = await request.ExecuteAsync(argClusterCompute, new SubGridSpatialAffinityKey(SubGridSpatialAffinityKey.DEFAULT_SPATIAL_AFFINITY_VERSION_NUMBER_TICKS, arg.ProjectID, OTGCellX, OTGCellY));

            result.ReturnCode   = response.ReturnCode;
            result.Value        = response.Value;
            result.TimeStampUTC = response.TimeStampUTC;

            return(result);
        }
Exemple #2
0
        public void Test_CellDatumRequestArgument_ApplicationService()
        {
            var argument = new CellDatumRequestArgument_ApplicationService
            {
                ProjectID       = Guid.NewGuid(),
                Mode            = DisplayMode.Height,
                CoordsAreGrid   = false,
                Point           = new XYZ(1.234, 5.678),
                Filters         = new FilterSet(new CombinedFilter(), new CombinedFilter()),
                ReferenceDesign = new DesignOffset(),
                Overrides       = new OverrideParameters {
                    OverrideMachineCCV = true, OverridingMachineCCV = 123
                }
            };

            SimpleBinarizableInstanceTester.TestClass(argument, "Custom CellDatumRequestArgument_ApplicationService not same after round trip serialisation");
        }
Exemple #3
0
        public void Test_CellDatumRequestArgument_ApplicationService_CreationWithArgs()
        {
            Guid        siteModelID     = Guid.NewGuid();
            DisplayMode mode            = DisplayMode.MachineSpeed;
            bool        coordsAreGrid   = false;
            XYZ         latLngPoint     = new XYZ(12345.6789, 98765.4321);
            IFilterSet  filters         = new FilterSet();
            var         referenceDesign = new DesignOffset(Guid.NewGuid(), 12.34);
            var         overrides       = new OverrideParameters {
                OverrideMachineMDP = true, OverridingMachineMDP = 321
            };
            var arg = new CellDatumRequestArgument_ApplicationService(siteModelID, mode, coordsAreGrid, latLngPoint, filters, referenceDesign, overrides);

            Assert.NotNull(arg);
            Assert.Equal(siteModelID, arg.ProjectID);
            Assert.Equal(mode, arg.Mode);
            Assert.Equal(coordsAreGrid, arg.CoordsAreGrid);
            Assert.Equal(latLngPoint, arg.Point);
            Assert.Equal(filters, arg.Filters);
            Assert.Equal(referenceDesign.DesignID, arg.ReferenceDesign.DesignID);
            Assert.Equal(referenceDesign.Offset, arg.ReferenceDesign.Offset);
            Assert.Equal(overrides.OverrideMachineMDP, arg.Overrides.OverrideMachineMDP);
            Assert.Equal(overrides.OverridingMachineMDP, arg.Overrides.OverridingMachineMDP);
        }
Exemple #4
0
        public void Test_CellDatumRequestArgument_ApplicationService_Creation()
        {
            var arg = new CellDatumRequestArgument_ApplicationService();

            Assert.NotNull(arg);
        }