private ISiteModel BuildModelForCellsElevation(float elevationIncrement) { var baseTime = DateTime.UtcNow; var baseElevation = 1.0F; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; CellPass[, ][] cellPasses = new CellPass[32, 32][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), Height = baseElevation + (x + y) * elevationIncrement, // incrementally increase height across the sub grid PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
private ISiteModel BuildModelForCellsCMV(short cmvIncrement, short targetCMV = CellPassConsts.NullCCV) { var baseTime = DateTime.UtcNow; short baseCMV = 10; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; if (targetCMV != CellPassConsts.NullCCV) { siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCVStateEvents.PutValueAtDate(TRex.Common.Consts.MIN_DATETIME_AS_UTC, targetCMV); } CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), CCV = (short)(baseCMV + x * cmvIncrement), // incrementally increase CCV across the sub grid PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
public async Task CSVExportRequest_Execute_ExceedsLimit() { DILoggingFixture.SetMaxExportRowsConfig(1); AddApplicationGridRouting(); AddClusterComputeGridRouting(); var tempFileName = MockS3FileTransfer_UploadToBucket(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CSVExportRequest(); var baseDate = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 0, 0, 0), DateTimeKind.Utc); var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = new[] { new CellPass { Time = baseDate, Height = 1.0f } }; }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); var response = await request.ExecuteAsync(SimpleCSVExportRequestArgument(siteModel.ID)); response.Should().NotBeNull(); response.ResultStatus.Should().Be(RequestErrorStatus.ExportExceededRowLimit); CleanupMockedFile(tempFileName, siteModel.ID); }
public void MasksOutValues_WithoutSurveyedSurfaces() { SetupTestIgniteRouting(); var(siteModel, filter) = CreateSiteModelWithSimpleDesign(); // Create a sub grid at the Northwest origin so that it covers the small TIN design surrounding the // [CellSize / 2, CellSize / 2] point var baseTime = DateTime.UtcNow; var cellPasses = new CellPass[32, 32][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { Height = 1.0f, InternalSiteModelMachineIndex = siteModel.Machines[0].InternalSiteModelMachineIndex, Time = baseTime.AddMinutes(p), PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); // Construct a requestor and ask it to retrieve the sub grid from the site model, using the filter // with the surface design mask var utilities = DIContext.Obtain <IRequestorUtilities>(); var requestors = utilities.ConstructRequestors(null, siteModel, new OverrideParameters(), new LiftParameters(), utilities.ConstructRequestorIntermediaries(siteModel, new FilterSet(filter), false, GridDataType.Height), AreaControlSet.CreateAreaControlSet(), siteModel.ExistenceMap); requestors.Length.Should().Be(1); var response = requestors[0].RequestSubGridInternal (new SubGridCellAddress(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset), true, false); response.requestResult.Should().Be(ServerRequestResult.NoError); response.clientGrid.Should().NotBeNull(); // Ensure the filtered cell has data response.clientGrid.FilterMap[0, 0].Should().BeTrue(); (response.clientGrid as IClientHeightLeafSubGrid).Cells[0, 0].Should().Be(1.0f); // Ensure no other cells have data response.clientGrid.FilterMap.CountBits().Should().Be(1); var subGrid = response.clientGrid as IClientHeightLeafSubGrid; var count = 0; subGrid.ForEach((x, y) => count += subGrid.Cells[x, y] == 1.0f ? 1 : 0); count.Should().Be(1); }
public async Task CSVExportRequest_Execute_SingleSubGridSinglePass() { AddApplicationGridRouting(); AddClusterComputeGridRouting(); var tempFileName = MockS3FileTransfer_UploadToBucket(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CSVExportRequest(); var baseDate = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 0, 0, 0), DateTimeKind.Utc); var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = new[] { new CellPass { Time = baseDate, Height = 1.0f } }; }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); var response = await request.ExecuteAsync(SimpleCSVExportRequestArgument(siteModel.ID)); response.Should().NotBeNull(); response.ResultStatus.Should().Be(RequestErrorStatus.OK); // Read back the zip file using (var archive = ZipFile.Open(tempFileName, ZipArchiveMode.Read)) { var extractedFileName = tempFileName.Remove(tempFileName.Length - 4) + ".csv"; archive.Entries[0].ExtractToFile(extractedFileName); var lines = File.ReadAllLines(extractedFileName); lines.Length.Should().Be(SubGridTreeConsts.SubGridTreeCellsPerSubGrid + 1); lines[0].Should().BeEquivalentTo( "Time,CellN,CellE,Elevation,PassCount,LastRadioLtncy,DesignName,Machine,Speed,LastGPSMode,GPSAccTol,TargPassCount,TotalPasses,Lift,LastCMV,TargCMV,LastMDP,TargMDP,LastRMV,LastFreq,LastAmp,TargThickness,MachineGear,VibeState,LastTemp"); lines[1].Should() .BeEquivalentTo( "2000/Jan/01 01:00:00.000,0.170m,0.170m,1.000m,1,0,?,\"Unknown\",0.0km/h,Old Position,?,?,1,1,?,?,0.0,?,?,?,?,?,?,?,0.0°C"); lines[10].Length.Should().Be(118); lines[10].Should() .BeEquivalentTo( "2000/Jan/01 01:00:00.000,3.230m,0.170m,1.000m,1,0,?,\"Unknown\",0.0km/h,Old Position,?,?,1,1,?,?,0.0,?,?,?,?,?,?,?,0.0°C"); } CleanupMockedFile(tempFileName, siteModel.ID); }
public async Task CSVExportRequest_Execute_UnableToWriteResultToS3() { AddApplicationGridRouting(); AddClusterComputeGridRouting(); var tempFileName = MockS3FileTransfer_UploadToBucket("InvalidFilename*@"); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CSVExportRequest(); var baseDate = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 0, 0, 0), DateTimeKind.Utc); var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = new[] { new CellPass { Time = baseDate, Height = 1.0f } }; }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); var mockTransferProxy = new Mock <ITransferProxy>(); mockTransferProxy.Setup(t => t.UploadToBucket(It.IsAny <Stream>(), It.IsAny <string>(), It.IsAny <string>())).Callback(() => throw new IOException("S3 not available")); var mockTransferProxyFactory = new Mock <ITransferProxyFactory>(); mockTransferProxyFactory.Setup(x => x.NewProxy(It.IsAny <TransferProxyType>())).Returns(mockTransferProxy.Object); DIBuilder .Continue() .Add(x => x.AddSingleton(mockTransferProxyFactory.Object)) .Complete(); var response = await request.ExecuteAsync(SimpleCSVExportRequestArgument(siteModel.ID)); response.Should().NotBeNull(); response.ResultStatus.Should().Be(RequestErrorStatus.ExportUnableToLoadFileToS3); CleanupMockedFile(tempFileName, siteModel.ID); }
public async Task Execute_SingleSubGridSingleCell_ConstantElevation(double interval, int expectedRows) { AddApplicationGridRouting(); AddClusterComputeGridRouting(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; var baseTime = DateTime.UtcNow; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = new[] { new CellPass { Time = baseTime, Height = 100.0f } }; }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); var request = new GriddedReportRequest(); var argument = SimpleGriddedReportRequestArgument(siteModel.ID); argument.GridInterval = interval; var response = await request.ExecuteAsync(argument); response.Should().NotBeNull(); response.ReturnCode.Should().Be(ReportReturnCode.NoError); response.GriddedReportDataRowList.Should().NotBeNull(); response.GriddedReportDataRowList.Count.Should().Be(expectedRows); }