Ejemplo n.º 1
0
        /// <summary>
        /// Removes all sub grid directory and segment information in the site model
        /// </summary>
        private bool RemoveAllSpatialCellPassData(IStorageProxy storageProxy)
        {
            var subGridRemovalSuccessful = true;

            _siteModel.ExistenceMap.ScanAllSetBitsAsSubGridAddresses(address =>
            {
                var filename = ServerSubGridTree.GetLeafSubGridFullFileName(address);
                var leaf     = new ServerSubGridTreeLeaf(_siteModel.Grid, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable)
                {
                    OriginX = address.X,
                    OriginY = address.Y
                };
                leaf.LoadDirectoryFromFile(storageProxy, filename);

                leaf.Directory.SegmentDirectory.ForEach(segmentInfo =>
                {
                    var segmentFilename = ServerSubGridTree.GetLeafSubGridSegmentFullFileName(leaf.OriginAsCellAddress(), segmentInfo);
                    if (!leaf.RemoveSegmentFromStorage(storageProxy, segmentFilename, segmentInfo))
                    {
                        _log.LogError($"Failed to remove segment {segmentFilename} sub grid: {leaf.Moniker()}");
                        subGridRemovalSuccessful = false;
                    }
                });

                if (!leaf.RemoveDirectoryFromStorage(storageProxy, filename))
                {
                    _log.LogError($"Failed to remove directory for server sub grid leaf: {leaf.Moniker()}");
                    subGridRemovalSuccessful = false;
                }
            });

            return(subGridRemovalSuccessful);
        }
Ejemplo n.º 2
0
        public void Test_TerrainSwather_SwathExtentTooLarge()
        {
            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new Machine();
            var grid      = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var SiteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            var processor = new TAGProcessor(siteModel, machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            var fence   = new Fence(new BoundingWorldExtent3D(0, 0, 10000, 2));
            var swather = new TerrainSwather(processor, MachineTargetValueChangesAggregator, siteModel, grid, fence);

            CreateSwathContext(0, 0, 0,
                               10000, 0, 0,
                               0, 2, 0,
                               10000, 2, 0,
                               out SimpleTriangle HeightInterpolator1,
                               out SimpleTriangle HeightInterpolator2,
                               out SimpleTriangle TimeInterpolator1,
                               out SimpleTriangle TimeInterpolator2);

            bool swathResult = swather.PerformSwathing(HeightInterpolator1, HeightInterpolator2, TimeInterpolator1, TimeInterpolator2, false, PassType.Front, MachineSide.None);

            swathResult.Should().BeTrue();
            processor.ProcessedEpochCount.Should().Be(0);
            processor.ProcessedCellPassesCount.Should().Be(0);
        }
Ejemplo n.º 3
0
        public void Test_TAGProcessor_DoPostProcessFileAction()
        {
            var SiteModel = new SiteModel(StorageMutability.Immutable);
            var Machine   = new Machine();
            var SiteModelGridAggregator             = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(SiteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            TAGProcessor processor = new TAGProcessor(SiteModel, Machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            // Set the state of the processor to emulate the end of processing this TAG file at which point the processor should emit
            // a "Stop recording event". In this instance, the NoGPSModeSet flag will also be true which should trigger emission of
            // a 'NoGPS' GPS mode state event and a 'UTS' positioning technology state event

            DateTime eventDate = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc);

            // Setting the first data time will create the start event
            processor.DataTime = eventDate;

            DateTime eventDate2 = eventDate.AddMinutes(1);

            processor.DataTime = eventDate2;
            processor.DoPostProcessFileAction(true);

            Assert.True(MachineTargetValueChangesAggregator.GPSModeStateEvents.LastStateValue() == GPSMode.NoGPS &&
                        MachineTargetValueChangesAggregator.GPSModeStateEvents.LastStateDate() == eventDate,
                        "DoPostProcessFileAction did not set GPSMode event");

            Assert.True(MachineTargetValueChangesAggregator.PositioningTechStateEvents.LastStateValue() == PositioningTech.UTS &&
                        MachineTargetValueChangesAggregator.PositioningTechStateEvents.LastStateDate() == eventDate,
                        "DoPostProcessFileAction did not set positioning tech event");

            Assert.True(MachineTargetValueChangesAggregator.StartEndRecordedDataEvents.LastStateValue() == ProductionEventType.EndEvent /*EndRecordedData*/ &&
                        MachineTargetValueChangesAggregator.StartEndRecordedDataEvents.LastStateDate() == eventDate2,
                        "DoPostProcessFileAction did not set end recorded data event");
        }
Ejemplo n.º 4
0
        public void Test_ServerSubGridTreeLeaf_AllocateLeafLatestPassGrid()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.AllocateLeafLatestPassGrid();

            Assert.Equal(leaf.Directory.GlobalLatestCells[0, 0].Time, Consts.MIN_DATETIME_AS_UTC);
        }
Ejemplo n.º 5
0
        public void Test_ServerSubGridTreeLeaf_AllocateLeafFullPassStacks()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.AllocateLeafFullPassStacks();

            Assert.NotNull(leaf.Cells);
        }
Ejemplo n.º 6
0
        public void Test_SubGridSegmentIterator_SubGridSegmentIterator()
        {
            ServerSubGridTree  tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            IServerLeafSubGrid leaf = new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable);

            SubGridSegmentIterator iterator = new SubGridSegmentIterator(leaf, leaf.Directory, StorageProxy.Instance(StorageMutability.Mutable));

            Assert.True(iterator.Directory == leaf.Directory &&
                        iterator.SubGrid == leaf, "SubGrid segment iterator not correctly initialised");
        }
Ejemplo n.º 7
0
        public void Test_TAGProcessor_Creation()
        {
            var SiteModel = new SiteModel(StorageMutability.Immutable);
            var Machine   = new Machine();
            var SiteModelGridAggregator             = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(SiteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            TAGProcessor processor = new TAGProcessor(SiteModel, Machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            Assert.NotNull(processor);
        }
Ejemplo n.º 8
0
        public void Test_TAGProcessor_DoEpochPreProcessAction()
        {
            var SiteModel = new SiteModel(StorageMutability.Immutable);
            var Machine   = new Machine();
            var SiteModelGridAggregator             = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(SiteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            TAGProcessor processor = new TAGProcessor(SiteModel, Machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            Assert.True(processor.DoEpochPreProcessAction(), "EpochPreProcessAction returned false in default TAGProcessor state");

            // Current PreProcessAction activity is limited to handling proofing runs. This will be handled by proofing run tests elsewhere
        }
Ejemplo n.º 9
0
        public void Test_ServerSubGridTreeLeaf_AllocateLatestPassGrid()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.AllocateLeafFullPassStacks();
            leaf.CreateDefaultSegment();
            leaf.AllocateLatestPassGrid(leaf.Directory.SegmentDirectory.First());

            Assert.True(leaf.Directory.SegmentDirectory.First().Segment != null &&
                        leaf.Directory.SegmentDirectory.First().Segment.LatestPasses != null,
                        "Segment cell passes not created by AllocateLatestPassGrid");
        }
Ejemplo n.º 10
0
        public void LoadDirectoryFromFile_FailureModes_StreamDoesNotExist()
        {
            var tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            var mockStorage = new Mock <IStorageProxy>();

            MemoryStream stream;

            mockStorage.Setup(x => x.ReadSpatialStreamFromPersistentStore(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <long>(), It.IsAny <long>(), It.IsAny <long>(),
                                                                          FileSystemStreamType.SubGridDirectory, out stream)).Returns(FileSystemErrorStatus.FileDoesNotExist);

            leaf.LoadDirectoryFromFile(mockStorage.Object, "filename").Should().BeFalse();
        }
Ejemplo n.º 11
0
        public void Test_TerrainSwather_Creation()
        {
            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new Machine();
            var grid      = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var fence     = new Fence();
            var SiteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            var processor = new TAGProcessor(siteModel, machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            var swather = new TerrainSwather(processor, MachineTargetValueChangesAggregator, siteModel, grid, fence);

            Assert.True(swather != null, "TerrainSwather not created as expected");
        }
Ejemplo n.º 12
0
        private ServerSubGridTreeLeaf CreateADefaultEmptyLeaf()
        {
            // Add a cell pass and check the CellHasValue flags the cell as having a value
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.Clear();
            leaf.AllocateLeafFullPassStacks();
            leaf.CreateDefaultSegment();
            leaf.AllocateFullPassStacks(leaf.Directory.SegmentDirectory.First());
            leaf.AllocateLeafLatestPassGrid();

            return(leaf);
        }
Ejemplo n.º 13
0
        public void Test_SubGridSegmentIterator_SetTimeRange()
        {
            ServerSubGridTree  tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            IServerLeafSubGrid leaf = new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable);

            SubGridSegmentIterator iterator = new SubGridSegmentIterator(leaf, leaf.Directory, StorageProxy.Instance(StorageMutability.Mutable));

            DateTime start = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc);
            DateTime end   = DateTime.SpecifyKind(new DateTime(2000, 1, 2, 1, 1, 1), DateTimeKind.Utc);

            iterator.SetTimeRange(start, end);

            Assert.True(iterator.IterationState.StartSegmentTime == start && iterator.IterationState.EndSegmentTime == end,
                        "Start and end time not set correctly");
        }
Ejemplo n.º 14
0
        public void Test_SubGridSegmentIterator_SetIteratorElevationRange()
        {
            ServerSubGridTree  tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            IServerLeafSubGrid leaf = new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable);

            SubGridSegmentIterator iterator = new SubGridSegmentIterator(leaf, leaf.Directory, StorageProxy.Instance(StorageMutability.Mutable));

            const double lowerElevation = 9.0;
            const double upperElevation = 19.0;

            iterator.SetIteratorElevationRange(lowerElevation, upperElevation);

            Assert.True(iterator.IterationState.MinIterationElevation == lowerElevation && iterator.IterationState.MaxIterationElevation == upperElevation,
                        "Elevation lower and upper bounds not set correctly");
        }
Ejemplo n.º 15
0
        public void Test_ServerSubGridTreeLeaf_CreateDefaultSegment()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            Assert.True(0 == leaf.Directory.SegmentDirectory.Count);

            leaf.CreateDefaultSegment();

            Assert.True(1 == leaf.Directory.SegmentDirectory.Count);

            Assert.True(leaf.Directory.SegmentDirectory.First().StartTime == Consts.MIN_DATETIME_AS_UTC &&
                        leaf.Directory.SegmentDirectory.First().EndTime == Consts.MAX_DATETIME_AS_UTC,
                        "Default segment does not have history spanning time range");
        }
Ejemplo n.º 16
0
        public void Test_ServerSubGridTreeLeaf_ServerSubGridTreeLeaf()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.Clear();

            Assert.True(leaf.Cells == null &&
                        leaf.Directory != null &&
                        leaf.Dirty == false &&
                        leaf.LeafEndTime == Consts.MIN_DATETIME_AS_UTC &&
                        leaf.LeafStartTime == Consts.MAX_DATETIME_AS_UTC &&
                        leaf.Level == SubGridTreeConsts.SubGridTreeLevels &&
                        leaf.IsLeafSubGrid(),
                        "Leaf not initialized as expected");
        }
Ejemplo n.º 17
0
        public void Test_AggregatedDataIntegrator_AddTaskToProcessList()
        {
            var integrator = new AggregatedDataIntegrator();

            SiteModel     siteModel = new SiteModel(/*"TestName", "TestDesc", */ Guid.NewGuid(), StorageMutability.Immutable, 1.0);
            IMachinesList machines  = new MachinesList();

            machines.Add(new Machine("TestName", "TestHardwareID", 0, 0, Guid.NewGuid(), 0, false));
            ServerSubGridTree            tree   = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            MachinesProductionEventLists events = new MachinesProductionEventLists(siteModel, 1);

            integrator.AddTaskToProcessList(siteModel, siteModel.ID, machines, tree, 0, events);

            Assert.Equal(1, integrator.CountOfTasksToProcess);
            Assert.True(integrator.CanAcceptMoreAggregatedCellPasses, "CanAcceptMoreAggregatedCellPasses is false");
        }
Ejemplo n.º 18
0
        public void LoadFile()
        {
            using var stream = new FileStream(FILENAME, FileMode.Open, FileAccess.Read);
            var file = new VolvoEarthworksCSVReader(stream);

            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new Machine();
            var siteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var machineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            var processor = new TAGProcessor(siteModel, machine, siteModelGridAggregator, machineTargetValueChangesAggregator);

            file.Read(null, processor);

            processor.ProcessedEpochCount.Should().Be(19325);
            siteModelGridAggregator.CountLeafSubGridsInMemory().Should().Be(11);
        }
Ejemplo n.º 19
0
        public void Test_TAGProcessor_TestZeroValuesInvalid()
        {
            var          SiteModel = new SiteModel(StorageMutability.Immutable);
            var          Machine   = new Machine();
            var          SiteModelGridAggregator             = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable);
            var          MachineTargetValueChangesAggregator = new ProductionEventLists(SiteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            TAGProcessor processor = new TAGProcessor(SiteModel, Machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            Assert.True(processor.ICMDPValues.GetLatest() == CellPassConsts.NullMDP, "MDP Initial value incorrect");
            Assert.True(processor.ICCCVValues.GetLatest() == CellPassConsts.NullCCV, "CCV Initial value incorrect");
            Assert.True(processor.ICCCAValues.GetLatest() == CellPassConsts.NullCCA, "CCA Initial value incorrect");
            processor.SetICMDPValue(0);
            processor.SetICCCVValue(0);
            processor.SetICCCAValue(0);
            Assert.True(processor.ICMDPValues.GetLatest() == CellPassConsts.NullMDP, "Zero should not be a valid for MDP");
            Assert.True(processor.ICCCVValues.GetLatest() == CellPassConsts.NullCCV, "Zero should not be a valid for CCV");
            Assert.True(processor.ICCCAValues.GetLatest() == CellPassConsts.NullCCA, "Zero should not be a valid for CCA");
        }
Ejemplo n.º 20
0
        public void Test_ServerSubGridTreeLeaf_AllocateFullPassStacks()
        {
            ServerSubGridTree tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            var leaf = tree.CreateNewSubGrid(SubGridTreeConsts.SubGridTreeLevels) as ServerSubGridTreeLeaf;

            leaf.Clear();
            leaf.AllocateLeafFullPassStacks();
            leaf.CreateDefaultSegment();
            leaf.AllocateFullPassStacks(leaf.Directory.SegmentDirectory.First());

            Assert.True(leaf.Cells != null &&
                        leaf.Directory != null &&
                        leaf.Dirty == false &&
                        leaf.LeafEndTime == Consts.MIN_DATETIME_AS_UTC &&
                        leaf.LeafStartTime == Consts.MAX_DATETIME_AS_UTC &&
                        leaf.Level == SubGridTreeConsts.SubGridTreeLevels &&
                        leaf.IsLeafSubGrid(),
                        "Leaf not initialized as expected after AllocateFullPassStacks");
        }
Ejemplo n.º 21
0
        public void Test_SubGridSegmentIterator_InitialiseIterator()
        {
            ServerSubGridTree  tree = new ServerSubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, ServerSubGridTreeLeaf>(), StorageMutability.Mutable);
            IServerLeafSubGrid leaf = new ServerSubGridTreeLeaf(tree, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable);

            SubGridSegmentIterator iterator = new SubGridSegmentIterator(leaf, leaf.Directory,
                                                                         StorageProxy.Instance(StorageMutability.Mutable))
            {
                IterationDirection = IterationDirection.Forwards
            };

            iterator.InitialiseIterator();
            Assert.Equal(-1, iterator.IterationState.Idx);

            iterator.IterationDirection = IterationDirection.Backwards;
            iterator.InitialiseIterator();

            Assert.Equal(iterator.IterationState.Idx, leaf.Directory.SegmentDirectory.Count);
        }
Ejemplo n.º 22
0
        private void Initialise()
        {
            ProcessedEpochCount    = 0;
            ProcessedCellPassCount = 0;

            // Note: Intermediary TAG file processing contexts don't store their data to any persistence context
            // so the SiteModel constructed to contain the data processed from a TAG file does not need a
            // storage proxy assigned to it
            SiteModel = DIContext.Obtain <ISiteModelFactory>().NewSiteModel(StorageMutability.Mutable);

            SiteModelGridAggregator = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable)
            {
                CellSize = SiteModel.CellSize
            };

            MachinesTargetValueChangesAggregator = new MachinesProductionEventLists(SiteModel, 0);

            Machines = new MachinesList();
        }
Ejemplo n.º 23
0
        public void Test_TAGProcessor_ProcessEpochContext_WithValidPosition()
        {
            var SiteModel = new SiteModel(StorageMutability.Immutable);

            SiteModel.IgnoreInvalidPositions = false;

            var Machine = new Machine();
            var SiteModelGridAggregator             = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(SiteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            TAGProcessor processor = new TAGProcessor(SiteModel, Machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            // Set the blade left and right tip locations to a trivial epoch, the epoch and do it again to trigger a swathing scan, then
            // check to see if it generated anything!

            Fence interpolationFence = new Fence();

            interpolationFence.SetRectangleFence(0, 0, 1, 1);

            DateTime StartTime = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc);

            processor.DataLeft  = new XYZ(0, 0, 5);
            processor.DataRight = new XYZ(1, 0, 5);
            processor.DataTime  = StartTime;

            Assert.True(processor.ProcessEpochContext(), "ProcessEpochContext returned false in default TAGProcessor state (1)");

            DateTime EndTime = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 3), DateTimeKind.Utc);

            processor.DataLeft  = new XYZ(0, 1, 5);
            processor.DataRight = new XYZ(1, 1, 5);
            processor.DataTime  = EndTime;

            Assert.True(processor.ProcessEpochContext(), "ProcessEpochContext returned false in default TAGProcessor state (2)");

            Assert.Equal(9, processor.ProcessedCellPassesCount);

            Assert.Equal(2, processor.ProcessedEpochCount);
        }
Ejemplo n.º 24
0
        public void Test_TAGProcessor_ProcessEpochContext_WithoutValidTimestamp()
        {
            var SiteModel = new SiteModel(StorageMutability.Immutable);

            SiteModel.IgnoreInvalidPositions = false;

            var Machine = new Machine();
            var SiteModelGridAggregator             = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(SiteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            TAGProcessor processor = new TAGProcessor(SiteModel, Machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            // Set the blade left and right tip locations to a trivial epoch, the epoch and do it again to trigger a swathing scan, then
            // check to see if it generated anything!

            Fence interpolationFence = new Fence();

            interpolationFence.SetRectangleFence(0, 0, 1, 1);
            processor.DataLeft  = new XYZ(0, 0, 5);
            processor.DataRight = new XYZ(1, 0, 5);

            Assert.False(processor.ProcessEpochContext(), "ProcessEpochContext returned true without a valid epoch timestamp");
        }
Ejemplo n.º 25
0
        public void DefaultImmutableStrategy()
        {
            var tree = new ServerSubGridTree(Guid.NewGuid(), StorageMutability.Immutable);

            tree.CachingStrategy.Should().Be(ServerSubGridTreeCachingStrategy.CacheSubGridsInIgniteGridCache);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Cleaves all dirty segments requiring cleaving within the given sub grid
        /// </summary>
        public void PerformSegmentCleaving(IStorageProxy storageProxyForSubGridSegments, IServerLeafSubGrid subGrid, int subGridSegmentPassCountLimit = 0)
        {
            var iterator = new SubGridSegmentIterator(subGrid, storageProxyForSubGridSegments)
            {
                IterationDirection = IterationDirection.Forwards,
                ReturnDirtyOnly    = true,
                RetrieveAllPasses  = true
            };

            var origin = new SubGridCellAddress(subGrid.OriginX, subGrid.OriginY);

            if (!iterator.MoveToFirstSubGridSegment())
            {
                return;
            }

            do
            {
                var segment = iterator.CurrentSubGridSegment;

                var cleavedTimeRangeStart = segment.SegmentInfo.StartTime;
                var cleavedTimeRangeEnd   = segment.SegmentInfo.EndTime;

                if (!segment.RequiresCleaving(out var totalPassCount, out var maximumPassCount))
                {
                    continue;
                }

                if (subGrid.Cells.CleaveSegment(segment, NewSegmentsFromCleaving, PersistedClovenSegments, subGridSegmentPassCountLimit))
                {
                    iterator.SegmentListExtended();

                    if (_segmentCleavingOperationsToLog)
                    {
                        _log.LogInformation(
                            $"Info: Performed cleave on segment ({cleavedTimeRangeStart}-{cleavedTimeRangeEnd}) of sub grid {ServerSubGridTree.GetLeafSubGridFullFileName(origin)}. TotalPassCount = {totalPassCount} MaximumPassCount = {maximumPassCount}");
                    }
                }
                else
                {
                    // The segment cleave failed. While this is not a serious problem (as the sub grid will be
                    // cleaved at some point in the future when it is modified again via tag file processing etc)
                    // it will be noted in the log.

                    _log.LogWarning(
                        $"Cleave on segment ({cleavedTimeRangeStart}-{cleavedTimeRangeEnd}) of sub grid {ServerSubGridTree.GetLeafSubGridFullFileName(origin)} failed. TotalPassCount = {totalPassCount} MaximumPassCount = {maximumPassCount}");
                }

                if (_segmentCleavingOperationsToLog)
                {
                    if (segment.RequiresCleaving(out totalPassCount, out maximumPassCount))
                    {
                        _log.LogWarning(
                            $"Cleave on segment ({cleavedTimeRangeStart}-{cleavedTimeRangeEnd}) of sub grid {subGrid.Moniker()} failed to reduce cell pass count below maximums (max passes = {totalPassCount}/{subGridSegmentPassCountLimit}, per cell = {maximumPassCount}/{_subGridMaxSegmentCellPassesLimit})");
                    }
                }
            } while (iterator.MoveToNextSubGridSegment());
        }
Ejemplo n.º 27
0
        public void ExtractSpatialData()
        {
            //  overallMap.ScanAllSetBitsAsSubGridAddresses(address => subGridGrouper.IntegrateSubGridGroup(result.ConstructPathToCell(address.X, address.Y, SubGridPathConstructionType.CreateLeaf) as IServerLeafSubGrid));

            // First write out the subGrid directory stream

            var basePath = Path.Combine(_projectOutputPath, "Spatial");

            Directory.CreateDirectory(basePath);

            _siteModel.ExistenceMap.ScanAllSetBitsAsSubGridAddresses(address =>
            {
                var fileName = ServerSubGridTree.GetLeafSubGridFullFileName(address);
                var FSError  = _siteModel.PrimaryStorageProxy.ReadSpatialStreamFromPersistentStore(_siteModel.ID, fileName, address.X, address.Y, -1, -1, 1,
                                                                                                   FileSystemStreamType.SubGridDirectory, out var MS);

                if (FSError != FileSystemErrorStatus.OK || MS == null)
                {
                    Log.LogError($"Failed to read directory stream for {fileName} with error {FSError}, or read stream is null");
                    Console.WriteLine($"Failed to read directory stream for {fileName} with error {FSError}, or read stream is null");
                    return;
                }

                using (MS)
                {
                    File.WriteAllBytes(Path.Combine(basePath, fileName), MS.ToArray());

                    // Write out all segment streams for the subGrid

                    using (var subGrid = new ServerSubGridTreeLeaf())
                    {
                        subGrid.SetIsMutable(true);

                        MS.Position = 0;
                        if (subGrid.LoadDirectoryFromStream(MS))
                        {
                            subGrid.Directory.SegmentDirectory.ForEach(segment =>
                            {
                                var segmentFileName = segment.FileName(address.X, address.Y);
                                var FSErrorSegment  = _siteModel.PrimaryStorageProxy.ReadSpatialStreamFromPersistentStore
                                                          (_siteModel.ID, segmentFileName, address.X, address.Y, segment.StartTime.Ticks, segment.EndTime.Ticks, segment.Version,
                                                          FileSystemStreamType.SubGridDirectory, out var MSSegment);

                                if (FSErrorSegment != FileSystemErrorStatus.OK)
                                {
                                    Log.LogError($"Failed to read segment stream for {segmentFileName} with error {FSErrorSegment}");
                                    Console.WriteLine($"Failed to read segment stream for {segmentFileName} with error {FSErrorSegment}");
                                    return;
                                }

                                using (MSSegment)
                                {
                                    File.WriteAllBytes(Path.Combine(basePath, segmentFileName), MSSegment.ToArray());
                                }
                            });
                        }
                        else
                        {
                            Log.LogError($"Failed to read directory stream for {fileName}");
                        }
                    }
                }
            });
        }
Ejemplo n.º 28
0
        public void Test_TerrainSwather_PerformSwathing()
        {
            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new VSS.TRex.Machines.Machine();
            var grid      = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var SiteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            var processor = new TAGProcessor(siteModel, machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            var fence = new Fence();

            fence.SetRectangleFence(0, 0, 10, 2);

            TerrainSwather swather = new TerrainSwather(processor, MachineTargetValueChangesAggregator, siteModel, grid, fence);

            CreateSwathContext(0, 0, 0,
                               10, 0, 0,
                               0, 2, 0,
                               10, 2, 0,
                               out SimpleTriangle HeightInterpolator1,
                               out SimpleTriangle HeightInterpolator2,
                               out SimpleTriangle TimeInterpolator1,
                               out SimpleTriangle TimeInterpolator2);

            // Compute swath with full cell pass on the front (blade) measurement location
            bool swathResult = swather.PerformSwathing(HeightInterpolator1, HeightInterpolator2, TimeInterpolator1, TimeInterpolator2, false, PassType.Front, MachineSide.None);

            // Did the swathing operation succeed?
            Assert.True(swathResult, "Perform swathing failed");

            // Did it produce the expected set of swathed cells?
            Assert.Equal(1, grid.Root.CountChildren());

            // Computation of the latest pass information which aids locating cells with non-null values
            try
            {
                IStorageProxy storageProxy = StorageProxy.Instance(StorageMutability.Mutable);
                grid.Root.ScanSubGrids(grid.FullCellExtent(), x =>
                {
                    ((IServerLeafSubGrid)x).ComputeLatestPassInformation(true, storageProxy);
                    return(true);
                });
            }
            catch (Exception E)
            {
                Assert.False(true, $"Exception {E} occured computing latest cell information");
            }

            grid.CalculateIndexOfCellContainingPosition(grid.CellSize / 2, grid.CellSize / 2, out int _, out int _);

            int nonNullCellCount = 0;

            try
            {
                grid.Root.ScanSubGrids(grid.FullCellExtent(), x =>
                {
                    nonNullCellCount += ((IServerLeafSubGrid)x).CountNonNullCells();
                    return(true);
                });
            }
            catch (Exception e)
            {
                Assert.False(true, $"Exception {e} occured counting non-null cells");
            }

            Assert.Equal(174, nonNullCellCount);

            // Todo: Iterate over the cells and confirm their content is as expected
        }