Example #1
0
        private CompactionReportResult ConvertTRexGridResult(CompactionReportGridRequest request, Stream stream)
        {
            log.LogDebug($"{nameof(ConvertTRexGridResult)}: Retrieving response data from TRex");

            var griddedReportResult = new GriddedReportResult(ReportType.Gridded);

            griddedReportResult.Read((stream as MemoryStream)?.ToArray());

            var gridRows = new GridRow[griddedReportResult.GriddedData.NumberOfRows];

            // Populate an array of grid rows from the data
            for (var i = 0; i < griddedReportResult.GriddedData.NumberOfRows; i++)
            {
                gridRows[i] = GridRow.CreateRow(griddedReportResult.GriddedData.Rows[i], request);
            }

            var startTime = request.Filter != null && request.Filter.StartUtc.HasValue
        ? request.Filter.StartUtc.Value
        : DateTime.Now;
            var endTime = request.Filter != null && request.Filter.EndUtc.HasValue
        ? request.Filter.EndUtc.Value
        : DateTime.Now;

            var gridReport = GridReport.CreateGridReport(startTime, endTime, gridRows);

            return(CompactionReportResult.CreateExportDataResult(gridReport, 1));
        }
Example #2
0
        public void Constructor_should_return_fully_populated_object()
        {
            var gridRow = new TGridRow
            {
                Northing    = 12.34,
                Easting     = 56.78,
                Elevation   = 90.12,
                CutFill     = 34.56,
                CMV         = 78,
                MDP         = 90,
                PassCount   = 12345,
                Temperature = 21
            };

            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, true, true, true, true, true, true, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);
            var result  = GridRow.CreateRow(gridRow, request);

            Assert.AreEqual(gridRow.Northing, result.Northing);
            Assert.AreEqual(gridRow.Easting, result.Easting);
            Assert.AreEqual(gridRow.Elevation, result.Elevation);
            Assert.AreEqual(gridRow.CutFill, result.CutFill);
            Assert.AreEqual((double)gridRow.CMV / 10, result.CMV);
            Assert.AreEqual((double)gridRow.MDP / 10, result.MDP);
            Assert.AreEqual(gridRow.PassCount, result.PassCount);
            Assert.AreEqual((double)gridRow.Temperature / 10, result.Temperature);

            Assert.IsTrue(result.ElevationReport);
            Assert.IsTrue(result.CutFillReport);
            Assert.IsTrue(result.CMVReport);
            Assert.IsTrue(result.MDPReport);
            Assert.IsTrue(result.PassCountReport);
            Assert.IsTrue(result.TemperatureReport);
        }
Example #3
0
        public void ShouldSerializeElevation_returns_correct_result_When_Elevation_is_set(bool reportElevation, double elevation, bool expectedResult)
        {
            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, reportElevation, false, false, false, false, false, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);

#if RAPTOR
            var row = GridRow.CreateRow(new TGridRow {
                Elevation = elevation
            }, request);
#else
            var row = GridRow.CreateRow(new GriddedReportDataRowBase {
                Elevation = elevation
            }, request);
#endif
            Assert.AreEqual(expectedResult, row.ShouldSerializeElevation());
        }
Example #4
0
        public void ShouldSerializeMDP_returns_correct_result_When_MDP_is_set(bool reportMdp, short mdp, bool expectedResult)
        {
            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, false, false, reportMdp, false, false, false, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);

#if RAPTOR
            var row = GridRow.CreateRow(new TGridRow {
                MDP = mdp
            }, request);
#else
            var row = GridRow.CreateRow(new GriddedReportDataRowBase {
                Mdp = mdp
            }, request);
#endif

            Assert.AreEqual(expectedResult, row.ShouldSerializeMDP());
        }
Example #5
0
        public void ShouldSerializeCMV_returns_correct_result_When_CMV_is_set(bool reportCmv, short cmv, bool expectedResult)
        {
            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, false, reportCmv, false, false, false, false, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);

#if RAPTOR
            var row = GridRow.CreateRow(new TGridRow {
                CMV = cmv
            }, request);
#else
            var row = GridRow.CreateRow(new GriddedReportDataRowBase {
                Cmv = cmv
            }, request);
#endif

            Assert.AreEqual(expectedResult, row.ShouldSerializeCMV());
        }
Example #6
0
        public void Temperature_returns_original_value_divided_by_10(short temperature, double expectedResult)
        {
            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, false, false, false, true, false, false, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);

#if RAPTOR
            var row = GridRow.CreateRow(new TGridRow {
                Temperature = temperature
            }, request);
#else
            var row = GridRow.CreateRow(new GriddedReportDataRowBase {
                Temperature = temperature
            }, request);
#endif

            Assert.AreEqual(expectedResult, row.Temperature);
        }
Example #7
0
        public void ShouldSerializeTemperature_returns_correct_result_When_Temperature_is_set(bool reportTemperature, short temperature, bool expectedResult)
        {
            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, false, false, false, false, reportTemperature, false, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);

#if RAPTOR
            var row = GridRow.CreateRow(new TGridRow {
                Temperature = temperature
            }, request);
#else
            var row = GridRow.CreateRow(new GriddedReportDataRowBase {
                Temperature = temperature
            }, request);
#endif

            Assert.AreEqual(expectedResult, row.ShouldSerializeTemperature());
        }
Example #8
0
        public void ShouldSerializePassCount_returns_correct_result_When_PassCount_is_set(bool reportPasscount, short passCount, bool expectedResult)
        {
            var request = CompactionReportGridRequest.CreateCompactionReportGridRequest(0, null, null, 0, null, false, false, false, reportPasscount, false, false, null, null, GridReportOption.Unused, 0, 0, 0, 0, 0);

#if RAPTOR
            var row = GridRow.CreateRow(new TGridRow {
                PassCount = passCount
            }, request);
#else
            var row = GridRow.CreateRow(new GriddedReportDataRowBase {
                PassCount = passCount
            }, request);
#endif

            Assert.AreEqual(expectedResult, row.ShouldSerializePassCount());
        }
Example #9
0
        private CompactionReportResult ConvertGridResult(CompactionReportGridRequest request, Stream stream)
        {
            log.LogDebug($"{nameof(ConvertGridResult)}");

            // Unpack the data for the report and construct a stream containing the result
            var reportPackager = new TRaptorReportsPackager(TRaptorReportType.rrtGridReport)
            {
                ReturnCode = TRaptorReportReturnCode.rrrcUnknownError
            };

            reportPackager.GridReport.ElevationReport   = request.ReportElevation;
            reportPackager.GridReport.CutFillReport     = request.ReportCutFill;
            reportPackager.GridReport.CMVReport         = request.ReportCMV;
            reportPackager.GridReport.MDPReport         = request.ReportMDP;
            reportPackager.GridReport.PassCountReport   = request.ReportPassCount;
            reportPackager.GridReport.TemperatureReport = request.ReportTemperature;

            log.LogDebug($"{nameof(ConvertGridResult)}: Retrieving response data");

            reportPackager.ReadFromStream(stream);

            var gridRows = new GridRow[reportPackager.GridReport.NumberOfRows];

            // Populate an array of grid rows from the data
            for (var i = 0; i < reportPackager.GridReport.NumberOfRows; i++)
            {
                gridRows[i] = GridRow.CreateRow(reportPackager.GridReport.Rows[i], request);
            }

            var startTime = request.Filter != null && request.Filter.StartUtc.HasValue
        ? request.Filter.StartUtc.Value
        : DateTime.Now;
            var endTime = request.Filter != null && request.Filter.EndUtc.HasValue
        ? request.Filter.EndUtc.Value
        : DateTime.Now;

            var gridReport = GridReport.CreateGridReport(startTime, endTime, gridRows);

            return(CompactionReportResult.CreateExportDataResult(gridReport, 1));
        }