Esempio n. 1
0
        public void LastPassValidCCVPercentage()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time = baseTime.AddSeconds(x),
                    CCV  = (short)(x + 1)
                },
                TargetValues = new CellTargets
                {
                    TargetCCV = (short)(10 + x)
                }
            }).ToArray());

            info.LastPassValidCCVPercentage().Should().Be(2 / (10.0 + 1));

            info.FilteredPassData[1].FilteredPass.CCV       = CellPassConsts.NullCCV;
            info.FilteredPassData[1].TargetValues.TargetCCV = CellPassConsts.NullCCV;

            info.LastPassValidCCVPercentage().Should().Be(1 / 10.0);

            info.FilteredPassData[0].TargetValues.TargetCCV = 0;
            info.LastPassValidCCVPercentage().Should().Be(CellPassConsts.NullCCVPercentage);

            info.FilteredPassData[0].TargetValues.TargetCCV = CellPassConsts.NullCCV;
            info.LastPassValidCCVPercentage().Should().Be(CellPassConsts.NullCCVPercentage);

            info.FilteredPassData[0].FilteredPass.CCV = CellPassConsts.NullCCV;
            info.LastPassValidCCVPercentage().Should().Be(CellPassConsts.NullCCVPercentage);
        }
Esempio n. 2
0
        public void Creation()
        {
            var info = new FilteredMultiplePassInfo();

            info.PassCount.Should().Be(0);
            info.FilteredPassData.Should().BeNull();
        }
Esempio n. 3
0
        public void LastPassValidCCVDetails()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time = baseTime.AddSeconds(x),
                    CCV  = (short)x
                },
                TargetValues = new CellTargets
                {
                    TargetCCV = (short)(10 + x)
                }
            }).ToArray());

            info.LastPassValidCCVDetails(out short aValue, out short aTarget);
            aValue.Should().Be(1);
            aTarget.Should().Be(11);

            info.FilteredPassData[1].FilteredPass.CCV = CellPassConsts.NullCCV;

            info.LastPassValidCCVDetails(out aValue, out aTarget);
            aValue.Should().Be(0);
            aTarget.Should().Be(10);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructs a profiler layer from a given set of filtered passes and the location of the cell on the profile line
        /// </summary>
        /// <param name="filteredPassInfo"></param>
        /// <param name="oTGX"></param>
        /// <param name="oTGY"></param>
        /// <param name="station"></param>
        /// <param name="interceptLength"></param>
        /// <param name="includesProductionData"></param>
        public ProfileCell(FilteredMultiplePassInfo filteredPassInfo,
                           int oTGX, int oTGY,
                           double station, double interceptLength,
                           bool includesProductionData = true) : this()
        {
            if (includesProductionData)
            {
                AddLayer(filteredPassInfo);
            }

            Station                = station;
            InterceptLength        = interceptLength;
            OTGCellX               = oTGX;
            OTGCellY               = oTGY;
            IncludesProductionData = includesProductionData;

            // Set the first/last/lowest/height attributes for the cell
            if (filteredPassInfo.PassCount > 0)
            {
                CellFirstElev = filteredPassInfo.FilteredPassData[0].FilteredPass.Height;
                CellLastElev  = filteredPassInfo.FilteredPassData[filteredPassInfo.PassCount - 1].FilteredPass.Height;

                foreach (var Pass in filteredPassInfo.FilteredPassData)
                {
                    if (CellLowestElev == Consts.NullHeight || CellLowestElev > Pass.FilteredPass.Height)
                    {
                        CellLowestElev = Pass.FilteredPass.Height;
                    }
                    if (CellHighestElev == Consts.NullHeight || CellHighestElev < Pass.FilteredPass.Height)
                    {
                        CellHighestElev = Pass.FilteredPass.Height;
                    }
                }
            }
        }
Esempio n. 5
0
        public void AddOneCellPass_CellPass()
        {
            var info = new FilteredMultiplePassInfo();

            info.AddPass(ATestCellPass());
            info.PassCount.Should().Be(1);
            info.FilteredPassData.Should().NotBeNull();
        }
Esempio n. 6
0
        public void Assign()
        {
            var info = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => FilteredPassDataTests.DummyFilteredPassData()).ToArray());

            var info2 = new FilteredMultiplePassInfo();

            info2.Assign(info);
            info.Should().BeEquivalentTo(info2);
        }
Esempio n. 7
0
        public void AddCellPassesForcingReallocation()
        {
            var info = new FilteredMultiplePassInfo();

            for (int i = 0; i < Consts.VLPDPSNODE_CELL_PASS_AGGREGATOR_LIST_SIZE_INCREMENT_DEFAULT + 1; i++)
            {
                info.AddPass(ATestCellPass());
            }
            info.PassCount.Should().Be(Consts.VLPDPSNODE_CELL_PASS_AGGREGATOR_LIST_SIZE_INCREMENT_DEFAULT + 1);
            info.FilteredPassData.Should().NotBeNull();
        }
Esempio n. 8
0
        public void AddOneCellPass_FilteredCellPass()
        {
            var info             = new FilteredMultiplePassInfo();
            var filteredPassData = new FilteredPassData
            {
                FilteredPass = ATestCellPass()
            };

            info.AddPass(filteredPassData);
            info.PassCount.Should().Be(1);
            info.FilteredPassData.Should().NotBeNull();
        }
Esempio n. 9
0
        public void CreationWithPasses()
        {
            var pass             = ATestCellPass();
            var filteredPassData = new FilteredPassData();

            filteredPassData.FilteredPass = pass;

            var info = new FilteredMultiplePassInfo(new [] { filteredPassData });

            info.PassCount.Should().Be(1);
            info.FilteredPassData.Should().NotBeNull();
            info.FilteredPassData[0].Should().BeEquivalentTo(filteredPassData);
        }
Esempio n. 10
0
        public void LastPassTime()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time = baseTime.AddSeconds(x)
                }
            }).ToArray());

            info.LastPassTime().Should().Be(baseTime.AddSeconds(1));
        }
Esempio n. 11
0
        public void LastPassValidAmp()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time      = baseTime.AddSeconds(x),
                    Amplitude = (ushort)(x + 1)
                }
            }).ToArray());

            info.LastPassValidAmp().Should().Be(2);
            info.FilteredPassData[1].FilteredPass.Amplitude = CellPassConsts.NullAmplitude;
            info.LastPassValidAmp().Should().Be(1);
            info.FilteredPassData[0].FilteredPass.Amplitude = CellPassConsts.NullAmplitude;
            info.LastPassValidAmp().Should().Be(CellPassConsts.NullAmplitude);
        }
Esempio n. 12
0
        public void LastPassValidRadioLatency()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time         = baseTime.AddSeconds(x),
                    RadioLatency = (byte)(x + 1)
                }
            }).ToArray());

            info.LastPassValidRadioLatency().Should().Be(2);
            info.FilteredPassData[1].FilteredPass.RadioLatency = CellPassConsts.NullRadioLatency;
            info.LastPassValidRadioLatency().Should().Be(1);
            info.FilteredPassData[0].FilteredPass.RadioLatency = CellPassConsts.NullRadioLatency;
            info.LastPassValidRadioLatency().Should().Be(CellPassConsts.NullRadioLatency);
        }
Esempio n. 13
0
        public void LastPassValidGPSMode()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time    = baseTime.AddSeconds(x),
                    gpsMode = x == 0 ? GPSMode.DGPS : GPSMode.AutonomousPosition
                }
            }).ToArray());

            info.LastPassValidGPSMode().Should().Be(GPSMode.AutonomousPosition);
            info.FilteredPassData[1].FilteredPass.gpsMode = CellPassConsts.NullGPSMode;
            info.LastPassValidGPSMode().Should().Be(GPSMode.DGPS);
            info.FilteredPassData[0].FilteredPass.gpsMode = CellPassConsts.NullGPSMode;
            info.LastPassValidGPSMode().Should().Be(CellPassConsts.NullGPSMode);
        }
Esempio n. 14
0
        public void FromToBinary()
        {
            var baseTime = DateTime.UtcNow;
            var info     = new FilteredMultiplePassInfo();

            info.SetFilteredPasses(Enumerable.Range(0, 2).Select(x => new FilteredPassData
            {
                FilteredPass = new CellPass
                {
                    Time = baseTime.AddSeconds(x),
                    CCV  = (short)x
                },
                TargetValues = new CellTargets
                {
                    TargetCCV = (short)(10 + x)
                },
                EventValues = new CellEvents(),
                MachineType = MachineType.Dozer
            }).ToArray());

            TestBinarizable_ReaderWriterHelper.RoundTripSerialise(info);
        }
Esempio n. 15
0
        /// <summary>
        /// Constructs a new layer from the set of cell passes contained in a multiple cell pass filtering result
        /// </summary>
        /// <param name="filteredPassValues"></param>
        public void AddLayer(FilteredMultiplePassInfo filteredPassValues)
        {
            if (Layers.Count() != 0)
            {
                Log.LogError("Cannot add a layer via FilteredPassValues if there are already layers in the cell");
                return;
            }

            if (filteredPassValues.PassCount == 0)
            {
                return;
            }

            IProfileLayer NewLayer = RequestNewLayer(out int LayerRecycledIndex);

            NewLayer.StartCellPassIdx = 0;
            NewLayer.EndCellPassIdx   = filteredPassValues.PassCount - 1;

            NewLayer.Assign(filteredPassValues);

            AddLayer(NewLayer, LayerRecycledIndex);
        }
Esempio n. 16
0
        /// <summary>
        /// Assigns the cell passes contained in a set of filtered pass values into this layer
        /// </summary>
        public void Assign(FilteredMultiplePassInfo cellPassValues)
        {
            Clear();

            if (Owner.Layers.Count() != 0)
            {
                throw new TRexSubGridProcessingException("Cannot assign layers if there are already layers in the cell");
            }

            if (cellPassValues.PassCount > 0)
            {
                var filteredPasses = new FilteredPassData[cellPassValues.PassCount];
                Array.Copy(cellPassValues.FilteredPassData, filteredPasses, cellPassValues.PassCount);
                Owner.SetFilteredPasses(filteredPasses);

                StartCellPassIdx = 0;
                EndCellPassIdx   = cellPassValues.PassCount - 1;

                CellPass    LastPass     = Owner.Passes.FilteredPassData[EndCellPassIdx].FilteredPass;
                CellTargets TargetValues = Owner.Passes.FilteredPassData[EndCellPassIdx].TargetValues;

                Height            = LastPass.Height;
                LastLayerPassTime = LastPass.Time;
                CCV                 = LastPass.CCV;
                MDP                 = LastPass.MDP;
                CCA                 = LastPass.CCA;
                TargetCCV           = TargetValues.TargetCCV;
                TargetMDP           = TargetValues.TargetMDP;
                TargetCCA           = TargetValues.TargetCCA;
                RadioLatency        = LastPass.RadioLatency;
                Frequency           = LastPass.Frequency;
                RMV                 = LastPass.RMV;
                Amplitude           = LastPass.Amplitude;
                MaterialTemperature = LastPass.MaterialTemperature;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Serializes content from the writer
        /// </summary>
        public override void InternalFromBinary(IBinaryRawReader reader)
        {
            base.InternalFromBinary(reader);

            var version = VersionSerializationHelper.CheckVersionByte(reader, VERSION_NUMBER);

            if (version == 1)
            {
                Layers = new ProfileLayers();
                var numberOfLayers = reader.ReadInt();

                for (var i = 1; i <= numberOfLayers; i++)
                {
                    var layer = new ProfileLayer(this);
                    layer.FromBinary(reader);

                    Layers.Add(layer, -1);
                }

                CellLowestElev           = reader.ReadFloat();
                CellHighestElev          = reader.ReadFloat();
                CellLastElev             = reader.ReadFloat();
                CellFirstElev            = reader.ReadFloat();
                CellLowestCompositeElev  = reader.ReadFloat();
                CellHighestCompositeElev = reader.ReadFloat();
                CellLastCompositeElev    = reader.ReadFloat();
                CellFirstCompositeElev   = reader.ReadFloat();

                CellCCV                       = reader.ReadShort();
                CellTargetCCV                 = reader.ReadShort();
                CellPreviousMeasuredCCV       = reader.ReadShort();
                CellPreviousMeasuredTargetCCV = reader.ReadShort();

                CellCCVElev = reader.ReadFloat();

                CellMDP       = reader.ReadShort();
                CellTargetMDP = reader.ReadShort();
                CellMDPElev   = reader.ReadFloat();

                CellCCA       = reader.ReadByte();
                CellTargetCCA = reader.ReadShort();
                CellCCAElev   = reader.ReadFloat();

                CellTopLayerThickness  = reader.ReadFloat();
                IncludesProductionData = reader.ReadBoolean();

                TopLayerPassCount = (ushort)reader.ReadInt();
                TopLayerPassCountTargetRangeMin = (ushort)reader.ReadInt();
                TopLayerPassCountTargetRangeMax = (ushort)reader.ReadInt();

                CellMaxSpeed = (ushort)reader.ReadInt();
                CellMinSpeed = (ushort)reader.ReadInt();

                (Passes ?? (Passes = new FilteredMultiplePassInfo())).FromBinary(reader);

                FilteredPassFlags       = reader.ReadBooleanArray();
                FilteredPassCount       = reader.ReadInt();
                FilteredHalfPassCount   = reader.ReadInt();
                AttributeExistenceFlags = (ProfileCellAttributeExistenceFlags)reader.ReadInt();

                CellMaterialTemperature        = (ushort)reader.ReadInt();
                CellMaterialTemperatureWarnMin = (ushort)reader.ReadInt();
                CellMaterialTemperatureWarnMax = (ushort)reader.ReadInt();

                CellMaterialTemperatureElev = reader.ReadFloat();
            }
        }