Esempio n. 1
0
        public void BuildLiftsForSinglePassCell_CMVPercentChange(float[] heights, short[] cmvs)
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var baseTime  = DateTime.UtcNow;

            var cellPasses = new[]
            {
                new CellPass
                {
                    Time   = baseTime,
                    Height = heights[0],
                    CCV    = cmvs[0]
                },
                new CellPass
                {
                    Time   = baseTime.AddHours(1),
                    Height = heights[1],
                    CCV    = cmvs[1]
                },
                new CellPass
                {
                    Time   = baseTime.AddHours(2),
                    Height = heights[2],
                    CCV    = cmvs[2]
                },
                new CellPass
                {
                    Time   = baseTime.AddHours(3),
                    Height = heights[3],
                    CCV    = cmvs[3]
                }
            };

            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);

            IClientLeafSubGrid clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.CCVPercentChange) as ClientCMVLeafSubGrid;

            var serverGrid = TRex.SubGridTrees.Server.Utilities.SubGridUtilities.LocateSubGridContaining(
                siteModel.PrimaryStorageProxy, siteModel.Grid,
                SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                siteModel.Grid.NumLevels, false, false) as IServerLeafSubGrid;

            var builder = new CellLiftBuilder(siteModel, GridDataType.CCVPercentChange, new FilteredValuePopulationControl(),
                                              new FilterSet(new CombinedFilter()), new CellPassFastEventLookerUpper(siteModel));

            var cell = new ProfileCell();

            var segmentIterator  = new SubGridSegmentIterator(serverGrid, serverGrid.Directory, siteModel.PrimaryStorageProxy);
            var cellPassIterator = new SubGridSegmentCellPassIterator_NonStatic(segmentIterator);

            var filteredValueAssignmentContext = new FilteredValueAssignmentContext();

            builder.Build(cell, new LiftParameters(), clientGrid, filteredValueAssignmentContext, cellPassIterator, true).Should().BeTrue();

            cell.Layers.Count().Should().Be(1);
            cell.Layers[0].PassCount.Should().Be(4);
            filteredValueAssignmentContext.FilteredValue.FilteredPassData.FilteredPass.CCV.Should().Be(cmvs[cmvs.Length - 1]);
            filteredValueAssignmentContext.PreviousFilteredValue.FilteredPassData.FilteredPass.CCV.Should().Be(cmvs[cmvs.Length - 2]);
        }
Esempio n. 2
0
        protected override void SetupForCellPassStackExamination()
        {
            base.SetupForCellPassStackExamination();

            if (!_commonCellPassStackExaminationDone)
            {
                // Modify the cell pass iterator to obey the time range established by the StartDate/EndDate arguments
                _cellPassIterator.SetTimeRange(true, StartDate, EndDate);

                // Construct a reversing segment and cell pass iterator used to locate necessary cell passes earlier than the first cell pass
                // according to the primary cell pass iterator _cellPassIterator. Allow it's time range to be all of history prior to StartDate
                // Note that both the reversing and progressive sub grid operator are provide the same sub grid. This permits both iterators
                // to leverage the inherent cache of segment information within the sub grid.
                _reversingSegmentIterator = new SubGridSegmentIterator(_subGridAsLeaf, _subGridAsLeaf.Directory, _storageProxy)
                {
                    IterationDirection = IterationDirection.Backwards
                };

                _reversingCellPassIterator = new SubGridSegmentCellPassIterator_NonStatic(_reversingSegmentIterator, _maxNumberOfPassesToReturn);
                _reversingCellPassIterator.SetTimeRange(true, DateTime.MinValue, StartDate.AddTicks(-100));

                _commonCellPassStackExaminationDone = true;
            }

            _segmentIterator.IterationDirection = IterationDirection.Forwards;

            _reversingSegmentIterator.SubGrid   = _subGridAsLeaf;
            _reversingSegmentIterator.Directory = _subGridAsLeaf.Directory;
        }
Esempio n. 3
0
        public void Test_SubGridSegmentCellPassIterator_NonStaticTests_SetCellCoordinatesInSubgrid()
        {
            SubGridSegmentCellPassIterator_NonStatic iterator = new SubGridSegmentCellPassIterator_NonStatic();

            iterator.SetCellCoordinatesInSubGrid(12, 23);

            Assert.True(iterator.CellX == 12 && iterator.CellY == 23, "CellX/Y not set correctly");
        }
Esempio n. 4
0
        public void Test_SubGridSegmentCellPassIterator_NonStaticTests_Creation()
        {
            SubGridSegmentCellPassIterator_NonStatic iterator = new SubGridSegmentCellPassIterator_NonStatic();

            Assert.True(iterator.CellX == 0 && iterator.CellY == 0, "CellX/Y not initialised correctly");
            Assert.Equal(iterator.MaxNumberOfPassesToReturn, int.MaxValue);
            Assert.Null(iterator.SegmentIterator);
        }
Esempio n. 5
0
        public void Test_SubGridSegmentCellPassIterator_NonStaticTests_SetIteratorElevationRange()
        {
            var tree     = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>());
            var iterator = new SubGridSegmentCellPassIterator_NonStatic(new SubGridSegmentIterator(new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable), new SubGridDirectory(), null));

            iterator.SetIteratorElevationRange(12.0, 23.0);

            Assert.True(iterator.SegmentIterator.IterationState.MinIterationElevation == 12.0 &&
                        iterator.SegmentIterator.IterationState.MaxIterationElevation == 23.0, "CellX/Y not set correctly");
        }
Esempio n. 6
0
        public void Test_SubGridSegmentCellPassIterator_NonStaticTests_SetTimeRangeTest()
        {
            var tree     = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>());
            var iterator = new SubGridSegmentCellPassIterator_NonStatic(new SubGridSegmentIterator(new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable), new SubGridDirectory(), null));

            iterator.SetTimeRange(true, DateTime.SpecifyKind(new DateTime(2000, 1, 1), DateTimeKind.Utc), DateTime.SpecifyKind(new DateTime(2000, 1, 2), DateTimeKind.Utc));

            Assert.True(iterator.IteratorStartTime == DateTime.SpecifyKind(new DateTime(2000, 1, 1), DateTimeKind.Utc) &&
                        iterator.IteratorEndTime == DateTime.SpecifyKind(new DateTime(2000, 1, 2), DateTimeKind.Utc),
                        "Iteration start and end date not set correctly");
        }
Esempio n. 7
0
        public void Test_SubGridSegmentCellPassIterator_NonStaticTests_Initialise()
        {
            var tree     = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>());
            var iterator = new SubGridSegmentCellPassIterator_NonStatic(new SubGridSegmentIterator(new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable), new SubGridDirectory(), null));

            iterator.SegmentIterator.IterationDirection = IterationDirection.Forwards;
            iterator.Initialise();

            iterator.SegmentIterator.IterationDirection = IterationDirection.Backwards;
            iterator.Initialise();
        }
Esempio n. 8
0
        public void BuildLiftsForMultiplePassCell(float height1, float height2, float height3, float first, float last, float lowest, float heighest)
        {
            var siteModel  = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var baseTime   = DateTime.UtcNow;
            var cellPasses = new[]
            {
                new CellPass
                {
                    Time   = baseTime,
                    Height = height1
                },
                new CellPass
                {
                    Time   = baseTime.AddHours(1),
                    Height = height2
                },
                new CellPass
                {
                    Time   = baseTime.AddHours(2),
                    Height = height3
                }
            };

            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);

            IClientLeafSubGrid clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.Height) as ClientHeightLeafSubGrid;

            var serverGrid = TRex.SubGridTrees.Server.Utilities.SubGridUtilities.LocateSubGridContaining(
                siteModel.PrimaryStorageProxy, siteModel.Grid,
                SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                siteModel.Grid.NumLevels, false, false) as IServerLeafSubGrid;

            var builder = new CellLiftBuilder(siteModel, GridDataType.Height, new FilteredValuePopulationControl(),
                                              new FilterSet(new CombinedFilter()), new CellPassFastEventLookerUpper(siteModel));

            var cell = new ProfileCell();

            var segmentIterator  = new SubGridSegmentIterator(serverGrid, serverGrid.Directory, siteModel.PrimaryStorageProxy);
            var cellPassIterator = new SubGridSegmentCellPassIterator_NonStatic(segmentIterator);

            builder.Build(cell, new LiftParameters(), clientGrid, new FilteredValueAssignmentContext(), cellPassIterator, false).Should().BeTrue();

            cell.Layers.Count().Should().Be(1);
            cell.Layers[0].PassCount.Should().Be(3);
            cell.Layers[0].MinimumPassHeight.Should().Be(lowest);
            cell.Layers[0].MaximumPassHeight.Should().Be(heighest);
            cell.Layers[0].FirstPassHeight.Should().Be(first);
            cell.Layers[0].LastPassHeight.Should().Be(last);
        }
Esempio n. 9
0
        protected virtual void SetupForCellPassStackExamination()
        {
            if (!_commonCellPassStackExaminationDone)
            {
                _populationControl.PreparePopulationControl(_gridDataType, _liftParams, _filter.AttributeFilter, _clientGrid.EventPopulationFlags);

                _filter.AttributeFilter.RequestedGridDataType = _gridDataType;

                // Create and configure the segment iterator to be used
                _segmentIterator = new SubGridSegmentIterator(_subGridAsLeaf, _subGridAsLeaf.Directory, _storageProxy);

                if (_filter.AttributeFilter.HasMachineFilter)
                {
                    _segmentIterator.SetMachineRestriction(_filter.AttributeFilter.GetMachineIDsSet());
                }

                // Create and configure the cell pass iterator to be used

                _cellPassIterator = new SubGridSegmentCellPassIterator_NonStatic(_segmentIterator, _maxNumberOfPassesToReturn);
                _cellPassIterator.SetTimeRange(_filter.AttributeFilter.HasTimeFilter, _filter.AttributeFilter.StartTime, _filter.AttributeFilter.EndTime);

                _commonCellPassStackExaminationDone = true;
            }

            if (_filter.AttributeFilter.ReturnEarliestFilteredCellPass ||
                (_filter.AttributeFilter.HasElevationTypeFilter && _filter.AttributeFilter.ElevationType == ElevationType.First))
            {
                _segmentIterator.IterationDirection = IterationDirection.Forwards;
            }
            else
            {
                _segmentIterator.IterationDirection = IterationDirection.Backwards;
            }

            _segmentIterator.SubGrid   = _subGridAsLeaf;
            _segmentIterator.Directory = _subGridAsLeaf.Directory;

            // Some display types require lift processing to be able to select the appropriate cell pass containing the filtered value required.
            if (_clientGrid.WantsLiftProcessingResults())
            {
                _segmentIterator.IterationDirection         = IterationDirection.Forwards;
                _cellPassIterator.MaxNumberOfPassesToReturn = _maxNumberOfPassesToReturn;
            }
        }
Esempio n. 10
0
        protected SubGridRetrieverBase(ISiteModel siteModel,
                                       GridDataType gridDataType,
                                       ICombinedFilter filter,
                                       ICellPassAttributeFilterProcessingAnnex filterAnnex,
                                       bool hasOverrideSpatialCellRestriction,
                                       BoundingIntegerExtent2D overrideSpatialCellRestriction,
                                       bool prepareGridForCacheStorageIfNoSieving,
                                       int maxNumberOfPassesToReturn,
                                       IStorageProxy storageProxy,
                                       AreaControlSet areaControlSet,
                                       IFilteredValuePopulationControl populationControl,
                                       ISubGridTreeBitMask pDExistenceMap,
                                       IOverrideParameters overrides,
                                       ILiftParameters liftParams)
        {
            _segmentIterator  = null;
            _cellPassIterator = null;

            _siteModel    = siteModel;
            _gridDataType = gridDataType;
            _filter       = filter;
            _filterAnnex  = filterAnnex;
            _hasOverrideSpatialCellRestriction     = hasOverrideSpatialCellRestriction;
            _overrideSpatialCellRestriction        = overrideSpatialCellRestriction;
            _prepareGridForCacheStorageIfNoSieving = prepareGridForCacheStorageIfNoSieving;
            _maxNumberOfPassesToReturn             = maxNumberOfPassesToReturn;
            _storageProxy      = storageProxy;
            _populationControl = populationControl;
            _areaControlSet    = areaControlSet;
            _pdExistenceMap    = pDExistenceMap;
            _overrides         = overrides;
            _liftParams        = liftParams;

            // Create and configure the assignment context which is used to contain a filtered pass and
            // its attendant machine events and target values prior to assignment to the client sub grid.
            _assignmentContext = new FilteredValueAssignmentContext {
                Overrides = overrides, LiftParams = liftParams
            };

            _filter.AttributeFilter.SiteModel = siteModel;

            _canUseGlobalLatestCells = _filter.AttributeFilter.LastRecordedCellPassSatisfiesFilter;
        }