Esempio n. 1
0
        public void DecodeRtiTestEarth()
        {
            Pd0Velocity vel = new Pd0Velocity();

            DataSet.EarthVelocityDataSet earth = new DataSet.EarthVelocityDataSet(DataSet.Ensemble.DATATYPE_FLOAT,              // Type of data stored (Float or Int)
                                                                                  30,                                           // Number of bins
                                                                                  4,                                            // Number of beams
                                                                                  DataSet.Ensemble.DEFAULT_IMAG,                // Default Image
                                                                                  DataSet.Ensemble.DEFAULT_NAME_LENGTH,         // Default Image length
                                                                                  DataSet.Ensemble.EarthVelocityID);            // Dataset ID


            earth.EarthVelocityData[0, 0] = 0.123f;
            earth.EarthVelocityData[0, 1] = 0.456f;
            earth.EarthVelocityData[0, 2] = 0.789f;
            earth.EarthVelocityData[0, 3] = 0.147f;
            earth.EarthVelocityData[1, 0] = 0.258f;
            earth.EarthVelocityData[1, 1] = 0.369f;
            earth.EarthVelocityData[1, 2] = 0.741f;
            earth.EarthVelocityData[1, 3] = 0.852f;

            vel.DecodeRtiEnsemble(earth);

            // beam order 3,2,0,1; XYZ order 1,0,-2,3, ENU order 0,1,2,3

            Assert.AreEqual(123, vel.Velocities[0, 0], "Bin 0, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(456, vel.Velocities[0, 1], "Bin 0, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(789, vel.Velocities[0, 2], "Bin 0, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(147, vel.Velocities[0, 3], "Bin 0, Beam 3 Velocity is incorrect.");
            Assert.AreEqual(258, vel.Velocities[1, 0], "Bin 1, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(369, vel.Velocities[1, 1], "Bin 1, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(741, vel.Velocities[1, 2], "Bin 1, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(852, vel.Velocities[1, 3], "Bin 1, Beam 3 Velocity is incorrect.");
        }
Esempio n. 2
0
        public void DecodePd0Test()
        {
            Pd0Velocity vel = new Pd0Velocity(30);

            vel.Velocities[0, 0] = 123;
            vel.Velocities[0, 1] = 456;
            vel.Velocities[0, 2] = 789;
            vel.Velocities[0, 3] = 147;
            vel.Velocities[1, 0] = 258;
            vel.Velocities[1, 1] = 369;
            vel.Velocities[1, 2] = 741;
            vel.Velocities[1, 3] = 852;

            DataSet.EarthVelocityDataSet earth = new DataSet.EarthVelocityDataSet(30);
            earth.DecodePd0Ensemble(vel);

            // beam order 3,2,0,1; XYZ order 1,0,-2,3, ENU order 0,1,2,3

            Assert.AreEqual(0.123f, earth.EarthVelocityData[0, 0], "Bin 0, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(0.456f, earth.EarthVelocityData[0, 1], "Bin 0, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(0.789f, earth.EarthVelocityData[0, 2], "Bin 0, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(0.147f, earth.EarthVelocityData[0, 3], "Bin 0, Beam 3 Velocity is incorrect.");
            Assert.AreEqual(0.258f, earth.EarthVelocityData[1, 0], "Bin 1, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(0.369f, earth.EarthVelocityData[1, 1], "Bin 1, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(0.741f, earth.EarthVelocityData[1, 2], "Bin 1, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(0.852f, earth.EarthVelocityData[1, 3], "Bin 1, Beam 3 Velocity is incorrect.");
        }
Esempio n. 3
0
        public void DecodeRtiTestBeam()
        {
            Pd0Velocity vel = new Pd0Velocity();

            DataSet.BeamVelocityDataSet beam = new DataSet.BeamVelocityDataSet(DataSet.Ensemble.DATATYPE_FLOAT,                 // Type of data stored (Float or Int)
                                                                                30,                                             // Number of bins
                                                                                4,                                              // Number of beams
                                                                                DataSet.Ensemble.DEFAULT_IMAG,                  // Default Image
                                                                                DataSet.Ensemble.DEFAULT_NAME_LENGTH,           // Default Image length
                                                                                DataSet.Ensemble.BeamVelocityID);               // Dataset ID

            beam.BeamVelocityData[0, 0] = 0.123f;
            beam.BeamVelocityData[0, 1] = 0.456f;
            beam.BeamVelocityData[0, 2] = 0.789f;
            beam.BeamVelocityData[0, 3] = 0.147f;
            beam.BeamVelocityData[1, 0] = 0.258f;
            beam.BeamVelocityData[1, 1] = 0.369f;
            beam.BeamVelocityData[1, 2] = 0.741f;
            beam.BeamVelocityData[1, 3] = 0.852f;

            vel.DecodeRtiEnsemble(beam);

            // beam order 3,2,0,1; XYZ order 1,0,-2,3, ENU order 0,1,2,3

            Assert.AreEqual(147, vel.Velocities[0, 0], "Bin 0, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(789, vel.Velocities[0, 1], "Bin 0, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(123, vel.Velocities[0, 2], "Bin 0, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(456, vel.Velocities[0, 3], "Bin 0, Beam 3 Velocity is incorrect.");
            Assert.AreEqual(852, vel.Velocities[1, 0], "Bin 1, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(741, vel.Velocities[1, 1], "Bin 1, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(258, vel.Velocities[1, 2], "Bin 1, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(369, vel.Velocities[1, 3], "Bin 1, Beam 3 Velocity is incorrect.");
        }
Esempio n. 4
0
        public void DecodePd0Test()
        {
            Pd0Velocity vel = new Pd0Velocity(30);

            vel.Velocities[0, 0] = 123;
            vel.Velocities[0, 1] = 456;
            vel.Velocities[0, 2] = 789;
            vel.Velocities[0, 3] = 147;
            vel.Velocities[1, 0] = 258;
            vel.Velocities[1, 1] = 369;
            vel.Velocities[1, 2] = 741;
            vel.Velocities[1, 3] = 852;

            DataSet.InstrumentVelocityDataSet instr = new DataSet.InstrumentVelocityDataSet(30);
            instr.DecodePd0Ensemble(vel);

            // beam order 3,2,0,1; XYZ order 1,0,-2,3, ENU order 0,1,2,3

            Assert.AreEqual(0.456f, instr.InstrumentVelocityData[0, 0], "Bin 0, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(0.123f, instr.InstrumentVelocityData[0, 1], "Bin 0, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(-0.789f, instr.InstrumentVelocityData[0, 2], "Bin 0, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(0.147f, instr.InstrumentVelocityData[0, 3], "Bin 0, Beam 3 Velocity is incorrect.");
            Assert.AreEqual(0.369f, instr.InstrumentVelocityData[1, 0], "Bin 1, Beam 0 Velocity is incorrect.");
            Assert.AreEqual(0.258f, instr.InstrumentVelocityData[1, 1], "Bin 1, Beam 1 Velocity is incorrect.");
            Assert.AreEqual(-0.741f, instr.InstrumentVelocityData[1, 2], "Bin 1, Beam 2 Velocity is incorrect.");
            Assert.AreEqual(0.852f, instr.InstrumentVelocityData[1, 3], "Bin 1, Beam 3 Velocity is incorrect.");
        }
Esempio n. 5
0
        public void TestEncodeVelCorrEchoPg()
        {
            PD0 pd0 = new PD0();

            pd0.FixedLeader.NumberOfCells = 5;

            Pd0Velocity vel = new Pd0Velocity(5);

            vel.Velocities[0, 0] = 32;
            vel.Velocities[0, 1] = -32;
            pd0.AddDataType(vel);

            Pd0Correlation corr = new Pd0Correlation(5);

            corr.Correlation[0, 0] = 32;
            corr.Correlation[0, 1] = 255;
            pd0.AddDataType(corr);

            Pd0EchoIntensity ei = new Pd0EchoIntensity(5);

            ei.EchoIntensity[0, 0] = 32;
            ei.EchoIntensity[0, 1] = 255;
            pd0.AddDataType(ei);

            Pd0PercentGood pg = new Pd0PercentGood(5);

            pg.PercentGood[0, 0] = 32;
            pg.PercentGood[0, 1] = 255;
            pd0.AddDataType(pg);

            byte[] encode = pd0.Encode();

            int flOffset   = pd0.Header.GetFixedLeader().Offset;
            int velOffset  = pd0.Header.GetVelocity().Offset;
            int corrOffset = pd0.Header.GetCorrelation().Offset;
            int eiOffset   = pd0.Header.GetEchoIntensity().Offset;
            int pgOffset   = pd0.Header.GetPercentGood().Offset;

            Assert.AreEqual(0, encode[flOffset], "Fixed Leader ID LSB is incorrect");
            Assert.AreEqual(0, encode[flOffset + 1], "Fixed Leader ID MSB is incorrect");
            Assert.AreEqual(5, encode[flOffset + 9], "Number of depth cells is incorrect");

            Assert.AreEqual(32, MathHelper.LsbMsbShort(encode[velOffset + 2], encode[velOffset + 3]), "Velocity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(-32, MathHelper.LsbMsbShort(encode[velOffset + 4], encode[velOffset + 5]), "Velocity Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[corrOffset + 2], "Correlation Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[corrOffset + 3], "Correlation Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[eiOffset + 2], "Echo Intensity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[eiOffset + 3], "Echo Intensity Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[pgOffset + 2], "Percent Good Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[pgOffset + 3], "Percent Good Bin 0, Beam 1 is incorrect.");

            Assert.IsFalse(pd0.IsBottomTrackExist, "IsBottomTrackExist is incorrect.");
            Assert.IsTrue(pd0.IsCorrelationExist, "IsCorrelationExist is incorrect.");
            Assert.IsTrue(pd0.IsEchoIntensityExist, "IsEchoIntensityExist is incorrect.");
            Assert.IsTrue(pd0.IsPercentGoodExist, "IsPercentGoodExist is incorrect.");
        }
Esempio n. 6
0
        public void TestEncode()
        {
            Pd0Velocity vel = new Pd0Velocity();

            vel.Velocities = new short[5, 4];

            vel.Velocities[0, 0] = 232;
            vel.Velocities[0, 1] = -323;
            vel.Velocities[0, 2] = 456;
            vel.Velocities[0, 3] = -654;

            vel.Velocities[4, 0] = 1232;
            vel.Velocities[4, 1] = -1323;
            vel.Velocities[4, 2] = 1456;
            vel.Velocities[4, 3] = -1654;


            byte[] data = vel.Encode();

            // DS 0 Beam 0
            Assert.AreEqual(0xE8, data[2], "DS 0 Beam 0 LSB Encode is incorrect.");
            Assert.AreEqual(0x00, data[3], "DS 0 Beam 0 MSB Encode is incorrect.");

            // DS 0 Beam 1
            Assert.AreEqual(0xBD, data[4], "DS 0 Beam 1 LSB Encode is incorrect.");
            Assert.AreEqual(0xFE, data[5], "DS 0 Beam 1 MSB Encode is incorrect.");

            // DS 0 Beam 2
            Assert.AreEqual(0xC8, data[6], "DS 0 Beam 2 LSB Encode is incorrect.");
            Assert.AreEqual(0x01, data[7], "DS 0 Beam 2 MSB Encode is incorrect.");

            // DS 0 Beam 3
            Assert.AreEqual(0x72, data[8], "DS 0 Beam 3 LSB Encode is incorrect.");
            Assert.AreEqual(0xFD, data[9], "DS 0 Beam 3 MSB Encode is incorrect.");



            // DS 4 Beam 0
            Assert.AreEqual(0xD0, data[(4 * 8) + 2 + 0], "DS 4 Beam 0 LSB Encode is incorrect.");
            Assert.AreEqual(0x04, data[(4 * 8) + 2 + 1], "DS 4 Beam 0 MSB Encode is incorrect.");

            // DS 4 Beam 1
            Assert.AreEqual(0xD5, data[(4 * 8) + 2 + 2], "DS 4 Beam 1 LSB Encode is incorrect.");
            Assert.AreEqual(0xFA, data[(4 * 8) + 2 + 3], "DS 4 Beam 1 MSB Encode is incorrect.");

            // DS 4 Beam 2
            Assert.AreEqual(0xB0, data[(4 * 8) + 2 + 4], "DS 4 Beam 2 LSB Encode is incorrect.");
            Assert.AreEqual(0x05, data[(4 * 8) + 2 + 5], "DS 4 Beam 2 MSB Encode is incorrect.");

            // DS 4 Beam 3
            Assert.AreEqual(0x8A, data[(4 * 8) + 2 + 6], "DS 4 Beam 3 LSB Encode is incorrect.");
            Assert.AreEqual(0xF9, data[(4 * 8) + 2 + 7], "DS 4 Beam 3 MSB Encode is incorrect.");
        }
Esempio n. 7
0
        public void TestGetVelocity()
        {
            Pd0Velocity vel = new Pd0Velocity();

            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] data = new byte[42];

            data[0] = Pd0Velocity.ID_LSB;
            data[1] = Pd0Velocity.ID_MSB;
            data[2] = 0xE8;                                   // DS0 Beam 0 LSB
            data[3] = 0x00;                                   // DS0 Beam 0 MSB
            data[4] = 0xBD;                                   // DS0 Beam 1 LSB
            data[5] = 0xFE;                                   // DS0 Beam 1 MSB
            data[6] = 0xC8;                                   // DS0 Beam 2 LSB
            data[7] = 0x01;                                   // DS0 Beam 2 MSB
            data[8] = 0x72;                                   // DS0 Beam 3 LSB
            data[9] = 0xFD;                                   // DS0 Beam 3 MSB

            data[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            data[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            data[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            data[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            data[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            data[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            data[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            data[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB


            vel.Decode(data);

            Assert.AreEqual(5, vel.Velocities.GetLength(0), "Number of Depth Cells is incorrect.");
            Assert.AreEqual(5, vel.GetNumDepthCells(), "GetNumDepthCells is incorrect.");
            Assert.AreEqual(232, vel.GetVelocity(0, 0), "DS 0 Beam 0 is incorrect.");
            Assert.AreEqual(-323, vel.GetVelocity(0, 1), "DS 0 Beam 1 is incorrect.");
            Assert.AreEqual(456, vel.GetVelocity(0, 2), "DS 0 Beam 2 is incorrect.");
            Assert.AreEqual(-654, vel.GetVelocity(0, 3), "DS 0 Beam 3 is incorrect.");

            Assert.AreEqual(1232, vel.GetVelocity(4, 0), "DS 4 Beam 0 is incorrect.");
            Assert.AreEqual(-1323, vel.GetVelocity(4, 1), "DS 4 Beam 1 is incorrect.");
            Assert.AreEqual(1456, vel.GetVelocity(4, 2), "DS 4 Beam 2 is incorrect.");
            Assert.AreEqual(-1654, vel.GetVelocity(4, 3), "DS 4 Beam 3 is incorrect.");
        }
Esempio n. 8
0
        public void TestEncodeVel()
        {
            PD0 pd0 = new PD0();

            pd0.FixedLeader.NumberOfCells = 5;

            Pd0Velocity vel = new Pd0Velocity(5);

            vel.Velocities[0, 0] = 32;
            vel.Velocities[0, 1] = -32;
            pd0.AddDataType(vel);

            byte[] encode = pd0.Encode();

            int flOffset  = pd0.Header.GetFixedLeader().Offset;
            int velOffset = pd0.Header.GetVelocity().Offset;

            Assert.AreEqual(0, encode[flOffset], "Fixed Leader ID LSB is incorrect");
            Assert.AreEqual(0, encode[flOffset + 1], "Fixed Leader ID MSB is incorrect");
            Assert.AreEqual(5, encode[flOffset + 9], "Number of depth cells is incorrect");

            Assert.AreEqual(32, MathHelper.LsbMsbShort(encode[velOffset + 2], encode[velOffset + 3]), "Velocity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(-32, MathHelper.LsbMsbShort(encode[velOffset + 4], encode[velOffset + 5]), "Velocity Bin 0, Beam 1 is incorrect.");
        }
Esempio n. 9
0
        /// <summary>
        /// Decode the given data into an object.
        /// </summary>
        /// <param name="data">Data to decode.</param>
        /// <param name="numDepthCells">NOT USED.</param>
        /// <param name="numBeams">NOT USED</param>
        public void Decode(byte[] data, int numDepthCells = 0, int numBeams = 4)
        {
            try
            {
                if (data.Length > HEADER_MIN_BYTE)
                {
                    // Ensure the correct data type is given
                    if (data[0] == ID_LSB && data[1] == ID_MSB)
                    {
                        // Number of bytes
                        NumberOfBytes = MathHelper.LsbMsbInt(data[2], data[3]);

                        //DataTypes.Clear();                                  // Clear anything currently stored
                        int numDT    = data[5];                          // Number of Data types
                        int dtOffset = HEADER_MIN_BYTE;                  // Start of the offsets
                        RTI.PD0.CoordinateTransforms xform = RTI.PD0.CoordinateTransforms.Coord_Earth;

                        // Determine the size of each data type.
                        // This will start at the end of the header
                        //int prevOffset = dtOffset + (numDT * SHORT_NUM_BYTE);

                        // Collect each offset
                        for (int x = 0; x < numDT; x++)
                        {
                            // Get the offset and add it to the list
                            byte   lsb    = data[dtOffset];
                            byte   msb    = data[dtOffset + 1];
                            ushort offset = MathHelper.LsbMsbUShort(lsb, msb);

                            if (data.Length > offset)
                            {
                                // Determine the data type
                                byte  lsbID = data[offset];
                                byte  msbID = data[offset + 1];
                                Pd0ID id    = Pd0ID.GetType(lsbID, msbID);

                                // Set the XFORM


                                // Create and add the data type to the ensemble
                                switch (id.Type)
                                {
                                case Pd0ID.Pd0Types.FixedLeader:
                                    // Copy the buffer
                                    byte[] flBuffer = new byte[Pd0FixedLeader.DATATYPE_SIZE];
                                    Buffer.BlockCopy(data, offset, flBuffer, 0, flBuffer.Length);

                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.FixedLeader))
                                    {
                                        GetFixedLeader().Decode(flBuffer);
                                        xform = GetFixedLeader().GetCoordinateTransform();
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0FixedLeader(flBuffer, offset));
                                    }

                                    break;

                                case Pd0ID.Pd0Types.VariableLeader:
                                    // Copy the buffer
                                    byte[] vlBuffer = new byte[Pd0VariableLeader.DATATYPE_SIZE];
                                    Buffer.BlockCopy(data, offset, vlBuffer, 0, vlBuffer.Length);

                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.VariableLeader))
                                    {
                                        GetVariableLeader().Decode(vlBuffer);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0VariableLeader(vlBuffer, offset));
                                    }

                                    break;

                                case Pd0ID.Pd0Types.BottomTrack:
                                    // Copy the buffer
                                    byte[] btBuffer = new byte[Pd0BottomTrack.DATATYPE_SIZE];
                                    Buffer.BlockCopy(data, offset, btBuffer, 0, btBuffer.Length);

                                    // Decode the data
                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.BottomTrack))
                                    {
                                        GetBottomTrack().Decode(btBuffer, GetFixedLeader().NumberOfBeams);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0BottomTrack(btBuffer, offset, GetFixedLeader().NumberOfBeams));
                                    }
                                    break;

                                case Pd0ID.Pd0Types.Velocity:
                                    // Copy the buffer
                                    byte[] velBuffer = new byte[Pd0Velocity.GetVelocitySize(GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams)];
                                    Buffer.BlockCopy(data, offset, velBuffer, 0, velBuffer.Length);

                                    // Decode the data
                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.Velocity))
                                    {
                                        GetVelocity().Decode(velBuffer, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0Velocity(velBuffer, offset, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams));
                                    }
                                    break;

                                case Pd0ID.Pd0Types.Correlation:
                                    // Copy the buffer
                                    byte[] corrBuffer = new byte[Pd0Correlation.GetCorrelationSize(GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams)];
                                    Buffer.BlockCopy(data, offset, corrBuffer, 0, corrBuffer.Length);

                                    // Decode the data
                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.Correlation))
                                    {
                                        GetCorrelation().Decode(corrBuffer, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0Correlation(corrBuffer, offset, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams));
                                    }
                                    break;

                                case Pd0ID.Pd0Types.EchoIntensity:
                                    // Copy the buffer
                                    byte[] eiBuffer = new byte[Pd0EchoIntensity.GetEchoIntensitySize(GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams)];
                                    Buffer.BlockCopy(data, offset, eiBuffer, 0, eiBuffer.Length);

                                    // Decode the data
                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.EchoIntensity))
                                    {
                                        GetEchoIntensity().Decode(eiBuffer, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0EchoIntensity(eiBuffer, offset, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams));
                                    }
                                    break;

                                case Pd0ID.Pd0Types.PercentGood:
                                    // Copy the buffer
                                    byte[] pgBuffer = new byte[Pd0PercentGood.GetPercentGoodSize(GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams)];
                                    Buffer.BlockCopy(data, offset, pgBuffer, 0, pgBuffer.Length);

                                    // Decode the data
                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.PercentGood))
                                    {
                                        GetPercentGood().Decode(pgBuffer, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0PercentGood(pgBuffer, offset, GetFixedLeader().NumberOfCells, GetFixedLeader().NumberOfBeams));
                                    }
                                    break;

                                case Pd0ID.Pd0Types.NmeaData:

                                    // Get the Dataset Size
                                    // Get the first 6 bytes to determine the size
                                    // Number of bytes to read for NMEA size
                                    byte[] nmeaSize = new byte[6];
                                    Buffer.BlockCopy(data, offset, nmeaSize, 0, 6);
                                    int nmeaDsSize = Pd0NmeaData.GetNmeaDataSize(nmeaSize);

                                    // Copy the buffer
                                    byte[] nmeaBuffer = new byte[nmeaDsSize];
                                    Buffer.BlockCopy(data, offset, nmeaBuffer, 0, nmeaBuffer.Length);

                                    // Decode the data
                                    if (DataTypes.ContainsKey(Pd0ID.Pd0Types.NmeaData))
                                    {
                                        GetNmeaData().Decode(nmeaBuffer);
                                    }
                                    else
                                    {
                                        AddDataType(new Pd0NmeaData(nmeaBuffer, offset));
                                    }
                                    break;

                                default:
                                    Debug.WriteLine(string.Format("Unknown PD0 ID {0}", id.Type));
                                    break;
                                }
                            }

                            // Move the offset to the next value
                            dtOffset += 2;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Error Decoding PD0 Data. ", ex);
            }
        }
Esempio n. 10
0
        public void TestDecodeVelocityPg()
        {
            PD0 pd0 = new PD0();
            pd0.FixedLeader.NumberOfCells = 5;

            #region Velocity

            Pd0Velocity vel = new Pd0Velocity();
            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] velData = new byte[42];

            velData[0] = Pd0Velocity.ID_LSB;
            velData[1] = Pd0Velocity.ID_MSB;
            velData[2] = 0xE8;                                   // DS0 Beam 0 LSB
            velData[3] = 0x00;                                   // DS0 Beam 0 MSB
            velData[4] = 0xBD;                                   // DS0 Beam 1 LSB
            velData[5] = 0xFE;                                   // DS0 Beam 1 MSB
            velData[6] = 0xC8;                                   // DS0 Beam 2 LSB
            velData[7] = 0x01;                                   // DS0 Beam 2 MSB
            velData[8] = 0x72;                                   // DS0 Beam 3 LSB
            velData[9] = 0xFD;                                   // DS0 Beam 3 MSB

            velData[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            velData[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            velData[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            velData[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            velData[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            velData[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            velData[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            velData[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(velData);

            #endregion
            pd0.AddDataType(vel);                       // Add Velocity

            #region Percent Good

            Pd0PercentGood pg = new Pd0PercentGood();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] pgData = new byte[22];

            pgData[0] = Pd0PercentGood.ID_LSB;
            pgData[1] = Pd0PercentGood.ID_MSB;
            pgData[2] = 0xE8;                                   // DS0 Beam 0
            pgData[3] = 0x7B;                                   // DS0 Beam 1
            pgData[4] = 0x7A;                                   // DS0 Beam 2
            pgData[5] = 0xDF;                                   // DS0 Beam 3

            pgData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            pgData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            pgData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            pgData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3

            pg.Decode(pgData);

            #endregion
            pd0.AddDataType(pg);                        // Add Percent Good

            byte[] data = pd0.Encode();

            // Size
            int size = Pd0VariableLeader.DATATYPE_SIZE;
            size += Pd0FixedLeader.DATATYPE_SIZE;
            size += 2;      // Spare
            //size += 2;      // Checksum
            size += pd0.Header.GetDataTypeSize();
            size += pd0.Velocity.GetDataTypeSize();
            size += pd0.PercentGood.GetDataTypeSize();

            Assert.AreEqual(4, pd0.Header.NumberOfDataTypes(), "Number of Data Types is incorrect.");
            Assert.AreEqual(5, pd0.Header.NumberOfDepthCells, "Number of depth cells is incorrect.");
            Assert.AreEqual(size, MathHelper.LsbMsbShort(data[2], data[3]), "Number of Bytes is incorrect.");
            Assert.AreEqual(4, data[5], "Number of Data Types is incorrect.");
            Assert.AreEqual(size + 2, data.Length, "Array Size is incorrect.");     // Add 2 for the checksum

            int flOffset = pd0.Header.GetDataTypeSize();
            Assert.AreEqual(flOffset, MathHelper.LsbMsbShort(data[6], data[7]), "Fixed Leader offset is incorrect.");

            int vlOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE;
            Assert.AreEqual(vlOffset, MathHelper.LsbMsbShort(data[8], data[9]), "Variable Leader offset is incorrect.");

            int velOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE;
            Assert.AreEqual(velOffset, MathHelper.LsbMsbShort(data[10], data[11]), "Velocity offset is incorrect.");

            int pgOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize();
            Assert.AreEqual(pgOffset, MathHelper.LsbMsbShort(data[12], data[13]), "Percent Good offset is incorrect.");
        }
Esempio n. 11
0
        public void TestDecodeVelocity()
        {
            PD0 pd0 = new PD0();

            pd0.FixedLeader.NumberOfCells = 5;

            #region Velocity

            Pd0Velocity vel = new Pd0Velocity();
            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] velData = new byte[42];

            velData[0] = Pd0Velocity.ID_LSB;
            velData[1] = Pd0Velocity.ID_MSB;
            velData[2] = 0xE8;                                   // DS0 Beam 0 LSB
            velData[3] = 0x00;                                   // DS0 Beam 0 MSB
            velData[4] = 0xBD;                                   // DS0 Beam 1 LSB
            velData[5] = 0xFE;                                   // DS0 Beam 1 MSB
            velData[6] = 0xC8;                                   // DS0 Beam 2 LSB
            velData[7] = 0x01;                                   // DS0 Beam 2 MSB
            velData[8] = 0x72;                                   // DS0 Beam 3 LSB
            velData[9] = 0xFD;                                   // DS0 Beam 3 MSB

            velData[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            velData[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            velData[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            velData[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            velData[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            velData[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            velData[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            velData[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(velData);

            #endregion

            pd0.AddDataType(vel);                       // Add Velocity

            byte[] data = pd0.Encode();

            // Size
            int size = Pd0VariableLeader.DATATYPE_SIZE;
            size += Pd0FixedLeader.DATATYPE_SIZE;
            size += 2;      // Spare
            //size += 2;      // Checksum
            size += pd0.Header.GetDataTypeSize();
            size += pd0.Velocity.GetDataTypeSize();


            Assert.AreEqual(3, pd0.Header.NumberOfDataTypes(), "Number of Data Types is incorrect.");
            Assert.AreEqual(5, pd0.Header.NumberOfDepthCells, "Number of depth cells is incorrect.");
            Assert.AreEqual(size, MathHelper.LsbMsbShort(data[2], data[3]), "Number of Bytes is incorrect.");
            Assert.AreEqual(3, data[5], "Number of Data Types is incorrect.");
            Assert.AreEqual(size + 2, data.Length, "Array Size is incorrect.");     // Add 2 for the checksum

            int flOffset = pd0.Header.GetDataTypeSize();
            Assert.AreEqual(flOffset, MathHelper.LsbMsbShort(data[6], data[7]), "Fixed Leader offset is incorrect.");

            int vlOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE;
            Assert.AreEqual(vlOffset, MathHelper.LsbMsbShort(data[8], data[9]), "Variable Leader offset is incorrect.");

            int velOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE;
            Assert.AreEqual(velOffset, MathHelper.LsbMsbShort(data[10], data[11]), "Velocity offset is incorrect.");
        }
Esempio n. 12
0
        public void TestDecodeVelocityPgCorrEiBt()
        {
            PD0 pd0 = new PD0();
            pd0.FixedLeader.NumberOfCells = 5;

            #region Velocity

            Pd0Velocity vel = new Pd0Velocity();
            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] velData = new byte[42];

            velData[0] = Pd0Velocity.ID_LSB;
            velData[1] = Pd0Velocity.ID_MSB;
            velData[2] = 0xE8;                                   // DS0 Beam 0 LSB
            velData[3] = 0x00;                                   // DS0 Beam 0 MSB
            velData[4] = 0xBD;                                   // DS0 Beam 1 LSB
            velData[5] = 0xFE;                                   // DS0 Beam 1 MSB
            velData[6] = 0xC8;                                   // DS0 Beam 2 LSB
            velData[7] = 0x01;                                   // DS0 Beam 2 MSB
            velData[8] = 0x72;                                   // DS0 Beam 3 LSB
            velData[9] = 0xFD;                                   // DS0 Beam 3 MSB

            velData[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            velData[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            velData[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            velData[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            velData[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            velData[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            velData[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            velData[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(velData);

            #endregion
            pd0.AddDataType(vel);                       // Add Velocity

            #region Percent Good

            Pd0PercentGood pg = new Pd0PercentGood();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] pgData = new byte[22];

            pgData[0] = Pd0PercentGood.ID_LSB;
            pgData[1] = Pd0PercentGood.ID_MSB;
            pgData[2] = 0xE8;                                   // DS0 Beam 0
            pgData[3] = 0x7B;                                   // DS0 Beam 1
            pgData[4] = 0x7A;                                   // DS0 Beam 2
            pgData[5] = 0xDF;                                   // DS0 Beam 3

            pgData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            pgData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            pgData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            pgData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3

            pg.Decode(pgData);

            #endregion
            pd0.AddDataType(pg);                        // Add Percent Good

            #region Correlation

            Pd0Correlation corr = new Pd0Correlation();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] corrData = new byte[22];

            corrData[0] = Pd0Velocity.ID_LSB;
            corrData[1] = Pd0Velocity.ID_MSB;
            corrData[2] = 0xE8;                                   // DS0 Beam 0
            corrData[3] = 0x7B;                                   // DS0 Beam 1
            corrData[4] = 0x7A;                                   // DS0 Beam 2
            corrData[5] = 0xDF;                                   // DS0 Beam 3

            corrData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            corrData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            corrData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            corrData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3

            corr.Decode(corrData);

            #endregion
            pd0.AddDataType(corr);                      // Add Correlation

            #region Echo Intensity

            Pd0EchoIntensity ei = new Pd0EchoIntensity();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] eiData = new byte[22];

            eiData[0] = Pd0Velocity.ID_LSB;
            eiData[1] = Pd0Velocity.ID_MSB;
            eiData[2] = 0xE8;                                   // DS0 Beam 0
            eiData[3] = 0x7B;                                   // DS0 Beam 1
            eiData[4] = 0x7A;                                   // DS0 Beam 2
            eiData[5] = 0xDF;                                   // DS0 Beam 3

            eiData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            eiData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            eiData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            eiData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3

            ei.Decode(eiData);

            #endregion
            pd0.AddDataType(ei);                        // Add Echo Intensity

            #region Bottom Track

            Pd0BottomTrack bt = new Pd0BottomTrack();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] btData = new byte[Pd0BottomTrack.DATATYPE_SIZE];

            bt.Decode(btData);

            #endregion
            pd0.AddDataType(bt);                        // Add Bottom Track

            byte[] data = pd0.Encode();

            // Size
            int size = pd0.FixedLeader.GetDataTypeSize();
            size += pd0.VariableLeader.GetDataTypeSize();
            size += 2;      // Spare
            size += pd0.Header.GetDataTypeSize();
            size += pd0.Velocity.GetDataTypeSize();
            size += pd0.PercentGood.GetDataTypeSize();
            size += pd0.Correlation.GetDataTypeSize();
            size += pd0.EchoIntensity.GetDataTypeSize();
            size += pd0.BottomTrack.GetDataTypeSize();

            Assert.AreEqual(7, pd0.Header.NumberOfDataTypes(), "Number of Data Types is incorrect.");
            Assert.AreEqual(5, pd0.Header.NumberOfDepthCells, "Number of depth cells is incorrect.");
            Assert.AreEqual(size, MathHelper.LsbMsbShort(data[2], data[3]), "Number of Bytes is incorrect.");
            Assert.AreEqual(7, data[5], "Number of Data Types is incorrect.");
            Assert.AreEqual(size + 2, data.Length, "Array Size is incorrect.");     // Add 2 for the checksum

            int flOffset = pd0.Header.GetDataTypeSize();
            Assert.AreEqual(flOffset, MathHelper.LsbMsbShort(data[6], data[7]), "Fixed Leader offset is incorrect.");

            int vlOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE;
            Assert.AreEqual(vlOffset, MathHelper.LsbMsbShort(data[8], data[9]), "Variable Leader offset is incorrect.");

            int velOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE;
            Assert.AreEqual(velOffset, MathHelper.LsbMsbShort(data[10], data[11]), "Velocity offset is incorrect.");

            int pgOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize();
            Assert.AreEqual(pgOffset, MathHelper.LsbMsbShort(data[12], data[13]), "Percent Good offset is incorrect.");

            int corrOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize() + pd0.PercentGood.GetDataTypeSize();
            Assert.AreEqual(corrOffset, MathHelper.LsbMsbShort(data[14], data[15]), "Correlation offset is incorrect.");

            int eiOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize() + pd0.PercentGood.GetDataTypeSize() + pd0.Correlation.GetDataTypeSize();
            Assert.AreEqual(eiOffset, MathHelper.LsbMsbShort(data[16], data[17]), "Echo Intensity offset is incorrect.");

            int btOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize() + pd0.PercentGood.GetDataTypeSize() + pd0.Correlation.GetDataTypeSize() + pd0.EchoIntensity.GetDataTypeSize();
            Assert.AreEqual(btOffset, MathHelper.LsbMsbShort(data[18], data[19]), "Bottom Track offset is incorrect.");
        }
Esempio n. 13
0
        public void TestDecodeVelocityPgCorrEiBt()
        {
            PD0 pd0 = new PD0();

            pd0.FixedLeader.NumberOfCells = 5;

            #region Velocity

            Pd0Velocity vel = new Pd0Velocity();
            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] velData = new byte[42];

            velData[0] = Pd0Velocity.ID_LSB;
            velData[1] = Pd0Velocity.ID_MSB;
            velData[2] = 0xE8;                                   // DS0 Beam 0 LSB
            velData[3] = 0x00;                                   // DS0 Beam 0 MSB
            velData[4] = 0xBD;                                   // DS0 Beam 1 LSB
            velData[5] = 0xFE;                                   // DS0 Beam 1 MSB
            velData[6] = 0xC8;                                   // DS0 Beam 2 LSB
            velData[7] = 0x01;                                   // DS0 Beam 2 MSB
            velData[8] = 0x72;                                   // DS0 Beam 3 LSB
            velData[9] = 0xFD;                                   // DS0 Beam 3 MSB

            velData[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            velData[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            velData[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            velData[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            velData[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            velData[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            velData[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            velData[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(velData);

            #endregion
            pd0.AddDataType(vel);                       // Add Velocity

            #region Percent Good

            Pd0PercentGood pg = new Pd0PercentGood();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] pgData = new byte[22];

            pgData[0] = Pd0PercentGood.ID_LSB;
            pgData[1] = Pd0PercentGood.ID_MSB;
            pgData[2] = 0xE8;                                   // DS0 Beam 0
            pgData[3] = 0x7B;                                   // DS0 Beam 1
            pgData[4] = 0x7A;                                   // DS0 Beam 2
            pgData[5] = 0xDF;                                   // DS0 Beam 3

            pgData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            pgData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            pgData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            pgData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3


            pg.Decode(pgData);

            #endregion
            pd0.AddDataType(pg);                        // Add Percent Good

            #region Correlation

            Pd0Correlation corr = new Pd0Correlation();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] corrData = new byte[22];

            corrData[0] = Pd0Velocity.ID_LSB;
            corrData[1] = Pd0Velocity.ID_MSB;
            corrData[2] = 0xE8;                                   // DS0 Beam 0
            corrData[3] = 0x7B;                                   // DS0 Beam 1
            corrData[4] = 0x7A;                                   // DS0 Beam 2
            corrData[5] = 0xDF;                                   // DS0 Beam 3

            corrData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            corrData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            corrData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            corrData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3


            corr.Decode(corrData);

            #endregion
            pd0.AddDataType(corr);                      // Add Correlation

            #region Echo Intensity

            Pd0EchoIntensity ei = new Pd0EchoIntensity();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] eiData = new byte[22];

            eiData[0] = Pd0Velocity.ID_LSB;
            eiData[1] = Pd0Velocity.ID_MSB;
            eiData[2] = 0xE8;                                   // DS0 Beam 0
            eiData[3] = 0x7B;                                   // DS0 Beam 1
            eiData[4] = 0x7A;                                   // DS0 Beam 2
            eiData[5] = 0xDF;                                   // DS0 Beam 3

            eiData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            eiData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            eiData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            eiData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3


            ei.Decode(eiData);

            #endregion
            pd0.AddDataType(ei);                        // Add Echo Intensity

            #region Bottom Track

            Pd0BottomTrack bt = new Pd0BottomTrack();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] btData = new byte[Pd0BottomTrack.DATATYPE_SIZE];

            bt.Decode(btData);

            #endregion
            pd0.AddDataType(bt);                        // Add Bottom Track

            byte[] data = pd0.Encode();

            // Size
            int size = pd0.FixedLeader.GetDataTypeSize();
            size += pd0.VariableLeader.GetDataTypeSize();
            size += 2;      // Spare
            size += pd0.Header.GetDataTypeSize();
            size += pd0.Velocity.GetDataTypeSize();
            size += pd0.PercentGood.GetDataTypeSize();
            size += pd0.Correlation.GetDataTypeSize();
            size += pd0.EchoIntensity.GetDataTypeSize();
            size += pd0.BottomTrack.GetDataTypeSize();


            Assert.AreEqual(7, pd0.Header.NumberOfDataTypes(), "Number of Data Types is incorrect.");
            Assert.AreEqual(5, pd0.Header.NumberOfDepthCells, "Number of depth cells is incorrect.");
            Assert.AreEqual(size, MathHelper.LsbMsbShort(data[2], data[3]), "Number of Bytes is incorrect.");
            Assert.AreEqual(7, data[5], "Number of Data Types is incorrect.");
            Assert.AreEqual(size + 2, data.Length, "Array Size is incorrect.");     // Add 2 for the checksum

            int flOffset = pd0.Header.GetDataTypeSize();
            Assert.AreEqual(flOffset, MathHelper.LsbMsbShort(data[6], data[7]), "Fixed Leader offset is incorrect.");

            int vlOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE;
            Assert.AreEqual(vlOffset, MathHelper.LsbMsbShort(data[8], data[9]), "Variable Leader offset is incorrect.");

            int velOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE;
            Assert.AreEqual(velOffset, MathHelper.LsbMsbShort(data[10], data[11]), "Velocity offset is incorrect.");

            int pgOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize();
            Assert.AreEqual(pgOffset, MathHelper.LsbMsbShort(data[12], data[13]), "Percent Good offset is incorrect.");

            int corrOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize() + pd0.PercentGood.GetDataTypeSize();
            Assert.AreEqual(corrOffset, MathHelper.LsbMsbShort(data[14], data[15]), "Correlation offset is incorrect.");

            int eiOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize() + pd0.PercentGood.GetDataTypeSize() + pd0.Correlation.GetDataTypeSize();
            Assert.AreEqual(eiOffset, MathHelper.LsbMsbShort(data[16], data[17]), "Echo Intensity offset is incorrect.");

            int btOffset = pd0.Header.GetDataTypeSize() + Pd0FixedLeader.DATATYPE_SIZE + Pd0VariableLeader.DATATYPE_SIZE + pd0.Velocity.GetDataTypeSize() + pd0.PercentGood.GetDataTypeSize() + pd0.Correlation.GetDataTypeSize() + pd0.EchoIntensity.GetDataTypeSize();
            Assert.AreEqual(btOffset, MathHelper.LsbMsbShort(data[18], data[19]), "Bottom Track offset is incorrect.");
        }
Esempio n. 14
0
        public void TestEncodeVel()
        {
            PD0 pd0 = new PD0();
            pd0.FixedLeader.NumberOfCells = 5;

            Pd0Velocity vel = new Pd0Velocity(5);
            vel.Velocities[0, 0] = 32;
            vel.Velocities[0, 1] = -32;
            pd0.AddDataType(vel);

            byte[] encode = pd0.Encode();

            int flOffset = pd0.Header.GetFixedLeader().Offset;
            int velOffset = pd0.Header.GetVelocity().Offset;

            Assert.AreEqual(0, encode[flOffset], "Fixed Leader ID LSB is incorrect");
            Assert.AreEqual(0, encode[flOffset + 1], "Fixed Leader ID MSB is incorrect");
            Assert.AreEqual(5, encode[flOffset + 9], "Number of depth cells is incorrect");

            Assert.AreEqual(32, MathHelper.LsbMsbShort(encode[velOffset + 2], encode[velOffset + 3]), "Velocity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(-32, MathHelper.LsbMsbShort(encode[velOffset + 4], encode[velOffset + 5]), "Velocity Bin 0, Beam 1 is incorrect.");
        }
Esempio n. 15
0
        public void TestAddDataTypeVel()
        {
            Pd0Header         header = new Pd0Header();
            Pd0VariableLeader vl     = new Pd0VariableLeader();
            Pd0FixedLeader    fl     = new Pd0FixedLeader();

            #region Velocity

            Pd0Velocity vel = new Pd0Velocity();
            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] data = new byte[42];

            data[0] = Pd0Velocity.ID_LSB;
            data[1] = Pd0Velocity.ID_MSB;
            data[2] = 0xE8;                                   // DS0 Beam 0 LSB
            data[3] = 0x00;                                   // DS0 Beam 0 MSB
            data[4] = 0xBD;                                   // DS0 Beam 1 LSB
            data[5] = 0xFE;                                   // DS0 Beam 1 MSB
            data[6] = 0xC8;                                   // DS0 Beam 2 LSB
            data[7] = 0x01;                                   // DS0 Beam 2 MSB
            data[8] = 0x72;                                   // DS0 Beam 3 LSB
            data[9] = 0xFD;                                   // DS0 Beam 3 MSB

            data[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            data[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            data[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            data[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            data[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            data[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            data[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            data[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(data);

            #endregion

            fl.NumberOfCells = 5;
            header.AddDataType(vl);
            header.AddDataType(fl);
            header.AddDataType(vel);

            byte[] hdrData = header.Encode();

            // Size
            int size = Pd0VariableLeader.DATATYPE_SIZE;         // Variable Leader size
            size += Pd0FixedLeader.DATATYPE_SIZE;               // Fixed Leader size
            size += 2;                                          // Spare size
            size += header.GetDataTypeSize();                   // Header size
            size += vel.GetDataTypeSize();                      // Velocity size


            Assert.AreEqual(3, header.NumberOfDataTypes(), "Number of Data Types is incorrect.");
            Assert.AreEqual(5, header.NumberOfDepthCells, "Number of depth cells is incorrect.");
            Assert.AreEqual(size, MathHelper.LsbMsbShort(hdrData[2], hdrData[3]), "Number of Bytes is incorrect.");
            Assert.AreEqual(3, hdrData[5], "Number of Data Types is incorrect.");
            Assert.AreEqual(6 + (3 * 2), hdrData.Length, "Array Size is incorrect.");

            int vlOffset = header.GetDataTypeSize();
            Assert.AreEqual(vlOffset, MathHelper.LsbMsbShort(hdrData[6], hdrData[7]), "Variable Leader offset is incorrect.");

            int flOffset = header.GetDataTypeSize() + Pd0VariableLeader.DATATYPE_SIZE;
            Assert.AreEqual(flOffset, MathHelper.LsbMsbShort(hdrData[8], hdrData[9]), "Fixed Leader offset is incorrect.");

            int velOffset = header.GetDataTypeSize() + Pd0VariableLeader.DATATYPE_SIZE + Pd0FixedLeader.DATATYPE_SIZE;
            Assert.AreEqual(velOffset, MathHelper.LsbMsbShort(hdrData[10], hdrData[11]), "Velocity offset is incorrect.");
        }
Esempio n. 16
0
        public void TestEncodeVelCorrEcho()
        {
            PD0 pd0 = new PD0();
            pd0.FixedLeader.NumberOfCells = 5;

            Pd0Velocity vel = new Pd0Velocity(5);
            vel.Velocities[0, 0] = 32;
            vel.Velocities[0, 1] = -32;
            pd0.AddDataType(vel);

            Pd0Correlation corr = new Pd0Correlation(5);
            corr.Correlation[0, 0] = 32;
            corr.Correlation[0, 1] = 255;
            pd0.AddDataType(corr);

            Pd0EchoIntensity ei = new Pd0EchoIntensity(5);
            ei.EchoIntensity[0, 0] = 32;
            ei.EchoIntensity[0, 1] = 255;
            pd0.AddDataType(ei);

            byte[] encode = pd0.Encode();

            int flOffset = pd0.Header.GetFixedLeader().Offset;
            int velOffset = pd0.Header.GetVelocity().Offset;
            int corrOffset = pd0.Header.GetCorrelation().Offset;
            int eiOffset = pd0.Header.GetEchoIntensity().Offset;

            Assert.AreEqual(0, encode[flOffset], "Fixed Leader ID LSB is incorrect");
            Assert.AreEqual(0, encode[flOffset + 1], "Fixed Leader ID MSB is incorrect");
            Assert.AreEqual(5, encode[flOffset + 9], "Number of depth cells is incorrect");

            Assert.AreEqual(32, MathHelper.LsbMsbShort(encode[velOffset + 2], encode[velOffset + 3]), "Velocity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(-32, MathHelper.LsbMsbShort(encode[velOffset + 4], encode[velOffset + 5]), "Velocity Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[corrOffset + 2], "Correlation Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[corrOffset + 3], "Correlation Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[eiOffset + 2], "Echo Intensity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[eiOffset + 3], "Echo Intensity Bin 0, Beam 1 is incorrect.");

            Assert.IsFalse(pd0.IsBottomTrackExist, "IsBottomTrackExist is incorrect.");
            Assert.IsTrue(pd0.IsCorrelationExist, "IsCorrelationExist is incorrect.");
            Assert.IsTrue(pd0.IsEchoIntensityExist, "IsEchoIntensityExist is incorrect.");
            Assert.IsFalse(pd0.IsPercentGoodExist, "IsPercentGoodExist is incorrect.");
        }
Esempio n. 17
0
        public void TestAddDataTypeCorr()
        {
            Pd0Header header = new Pd0Header();
            Pd0VariableLeader vl = new Pd0VariableLeader();
            Pd0FixedLeader fl = new Pd0FixedLeader();

            #region Velocity

            Pd0Velocity vel = new Pd0Velocity();
            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] data = new byte[42];

            data[0] = Pd0Velocity.ID_LSB;
            data[1] = Pd0Velocity.ID_MSB;
            data[2] = 0xE8;                                   // DS0 Beam 0 LSB
            data[3] = 0x00;                                   // DS0 Beam 0 MSB
            data[4] = 0xBD;                                   // DS0 Beam 1 LSB
            data[5] = 0xFE;                                   // DS0 Beam 1 MSB
            data[6] = 0xC8;                                   // DS0 Beam 2 LSB
            data[7] = 0x01;                                   // DS0 Beam 2 MSB
            data[8] = 0x72;                                   // DS0 Beam 3 LSB
            data[9] = 0xFD;                                   // DS0 Beam 3 MSB

            data[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            data[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            data[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            data[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            data[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            data[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            data[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            data[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(data);

            #endregion

            #region Correlation

            Pd0Correlation corr = new Pd0Correlation();

            // 2 Byte Header
            // 4 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] corrData = new byte[22];

            corrData[0] = Pd0Velocity.ID_LSB;
            corrData[1] = Pd0Velocity.ID_MSB;
            corrData[2] = 0xE8;                                   // DS0 Beam 0
            corrData[3] = 0x7B;                                   // DS0 Beam 1
            corrData[4] = 0x7A;                                   // DS0 Beam 2
            corrData[5] = 0xDF;                                   // DS0 Beam 3

            corrData[(4 * 4) + 2 + 0] = 0x6F;                     // DS4 Beam 0
            corrData[(4 * 4) + 2 + 1] = 0xDE;                     // DS4 Beam 1
            corrData[(4 * 4) + 2 + 2] = 0x15;                     // DS4 Beam 2
            corrData[(4 * 4) + 2 + 3] = 0x22;                     // DS4 Beam 3

            corr.Decode(corrData);

            #endregion

            fl.NumberOfCells = 5;
            header.AddDataType(vl);
            header.AddDataType(fl);
            header.AddDataType(vel);
            header.AddDataType(corr);

            byte[] hdrData = header.Encode();

            // Size
            int size = Pd0VariableLeader.DATATYPE_SIZE;         // Variable Leader size
            size += Pd0FixedLeader.DATATYPE_SIZE;               // Fixed Leader size
            size += 2;                                          // Spare size
            size += header.GetDataTypeSize();                   // Header size
            size += vel.GetDataTypeSize();                      // Velocity size
            size += corr.GetDataTypeSize();                     // Correlation size

            Assert.AreEqual(4, header.NumberOfDataTypes(), "Number of Data Types is incorrect.");
            Assert.AreEqual(5, header.NumberOfDepthCells, "Number of depth cells is incorrect.");
            Assert.AreEqual(size, MathHelper.LsbMsbShort(hdrData[2], hdrData[3]), "Number of Bytes is incorrect.");
            Assert.AreEqual(4, hdrData[5], "Number of Data Types is incorrect.");
            Assert.AreEqual(6 + (4 * 2), hdrData.Length, "Array Size is incorrect.");

            int vlOffset = header.GetDataTypeSize();
            Assert.AreEqual(vlOffset, MathHelper.LsbMsbShort(hdrData[6], hdrData[7]), "Variable Leader offset is incorrect.");

            int flOffset = header.GetDataTypeSize() + Pd0VariableLeader.DATATYPE_SIZE;
            Assert.AreEqual(flOffset, MathHelper.LsbMsbShort(hdrData[8], hdrData[9]), "Fixed Leader offset is incorrect.");

            int velOffset = header.GetDataTypeSize() + Pd0VariableLeader.DATATYPE_SIZE + Pd0FixedLeader.DATATYPE_SIZE;
            Assert.AreEqual(velOffset, MathHelper.LsbMsbShort(hdrData[10], hdrData[11]), "Velocity offset is incorrect.");

            int corrOffset = header.GetDataTypeSize() + Pd0VariableLeader.DATATYPE_SIZE + Pd0FixedLeader.DATATYPE_SIZE + vel.GetDataTypeSize() ;
            Assert.AreEqual(corrOffset, MathHelper.LsbMsbShort(hdrData[12], hdrData[13]), "Correlation offset is incorrect.");
        }
Esempio n. 18
0
        public void TestEncodeVelCorrEchoPgBt()
        {
            PD0 pd0 = new PD0();
            pd0.FixedLeader.NumberOfCells = 5;

            Pd0Velocity vel = new Pd0Velocity(5);
            vel.Velocities[0, 0] = 32;
            vel.Velocities[0, 1] = -32;
            pd0.AddDataType(vel);

            Pd0Correlation corr = new Pd0Correlation(5);
            corr.Correlation[0, 0] = 32;
            corr.Correlation[0, 1] = 255;
            pd0.AddDataType(corr);

            Pd0EchoIntensity ei = new Pd0EchoIntensity(5);
            ei.EchoIntensity[0, 0] = 32;
            ei.EchoIntensity[0, 1] = 255;
            pd0.AddDataType(ei);

            Pd0PercentGood pg = new Pd0PercentGood(5);
            pg.PercentGood[0, 0] = 32;
            pg.PercentGood[0, 1] = 255;
            pd0.AddDataType(pg);

            Pd0BottomTrack bt = new Pd0BottomTrack();
            bt.BtPingsPerEnsemble = 20;
            bt.BtDelayBeforeReacquire = 20;
            bt.BtAmplitudeBeam0 = 255;
            pd0.AddDataType(bt);

            byte[] encode = pd0.Encode();

            int flOffset = pd0.Header.GetFixedLeader().Offset;
            int velOffset = pd0.Header.GetVelocity().Offset;
            int corrOffset = pd0.Header.GetCorrelation().Offset;
            int eiOffset = pd0.Header.GetEchoIntensity().Offset;
            int pgOffset = pd0.Header.GetPercentGood().Offset;
            int btOffset = pd0.Header.GetBottomTrack().Offset;

            Assert.AreEqual(0, encode[flOffset], "Fixed Leader ID LSB is incorrect");
            Assert.AreEqual(0, encode[flOffset + 1], "Fixed Leader ID MSB is incorrect");
            Assert.AreEqual(5, encode[flOffset + 9], "Number of depth cells is incorrect");

            Assert.AreEqual(32, MathHelper.LsbMsbShort(encode[velOffset + 2], encode[velOffset + 3]), "Velocity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(-32, MathHelper.LsbMsbShort(encode[velOffset + 4], encode[velOffset + 5]), "Velocity Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[corrOffset + 2], "Correlation Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[corrOffset + 3], "Correlation Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[eiOffset + 2], "Echo Intensity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[eiOffset + 3], "Echo Intensity Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(32, encode[pgOffset + 2], "Percent Good Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(255, encode[pgOffset + 3], "Percent Good Bin 0, Beam 1 is incorrect.");

            Assert.AreEqual(20, MathHelper.LsbMsbUShort(encode[btOffset + 2], encode[btOffset + 3]), "Bottom Track Pings per Ensemble is incorrect.");
            Assert.AreEqual(20, MathHelper.LsbMsbUShort(encode[btOffset + 4], encode[btOffset + 5]), "Bottom Track Delay Before Reacquire is incorrect.");
            Assert.AreEqual(255, encode[btOffset + 36], "Bottom Track Amplitude Beam 0 is incorrect.");

            Assert.IsTrue(pd0.IsBottomTrackExist, "IsBottomTrackExist is incorrect.");
            Assert.IsTrue(pd0.IsCorrelationExist, "IsCorrelationExist is incorrect.");
            Assert.IsTrue(pd0.IsEchoIntensityExist, "IsEchoIntensityExist is incorrect.");
            Assert.IsTrue(pd0.IsPercentGoodExist, "IsPercentGoodExist is incorrect.");
        }
Esempio n. 19
0
        public void TestGetVelocity()
        {
            Pd0Velocity vel = new Pd0Velocity();

            // 2 Byte Header
            // 8 Bytes per depth cell
            // 4 Beams per depth cell
            // 2 Bytes per beam
            byte[] data = new byte[42];

            data[0] = Pd0Velocity.ID_LSB;
            data[1] = Pd0Velocity.ID_MSB;
            data[2] = 0xE8;                                   // DS0 Beam 0 LSB
            data[3] = 0x00;                                   // DS0 Beam 0 MSB
            data[4] = 0xBD;                                   // DS0 Beam 1 LSB
            data[5] = 0xFE;                                   // DS0 Beam 1 MSB
            data[6] = 0xC8;                                   // DS0 Beam 2 LSB
            data[7] = 0x01;                                   // DS0 Beam 2 MSB
            data[8] = 0x72;                                   // DS0 Beam 3 LSB
            data[9] = 0xFD;                                   // DS0 Beam 3 MSB

            data[(4 * 8) + 2 + 0] = 0xD0;                     // DS4 Beam 0 LSB
            data[(4 * 8) + 2 + 1] = 0x04;                     // DS4 Beam 0 MSB
            data[(4 * 8) + 2 + 2] = 0xD5;                     // DS4 Beam 1 LSB
            data[(4 * 8) + 2 + 3] = 0xFA;                     // DS4 Beam 1 MSB
            data[(4 * 8) + 2 + 4] = 0xB0;                     // DS4 Beam 2 LSB
            data[(4 * 8) + 2 + 5] = 0x05;                     // DS4 Beam 2 MSB
            data[(4 * 8) + 2 + 6] = 0x8A;                     // DS4 Beam 3 LSB
            data[(4 * 8) + 2 + 7] = 0xF9;                     // DS4 Beam 3 MSB

            vel.Decode(data);

            Assert.AreEqual(5, vel.Velocities.GetLength(0), "Number of Depth Cells is incorrect.");
            Assert.AreEqual(5, vel.GetNumDepthCells(), "GetNumDepthCells is incorrect.");
            Assert.AreEqual(232, vel.GetVelocity(0, 0), "DS 0 Beam 0 is incorrect.");
            Assert.AreEqual(-323, vel.GetVelocity(0, 1), "DS 0 Beam 1 is incorrect.");
            Assert.AreEqual(456, vel.GetVelocity(0, 2), "DS 0 Beam 2 is incorrect.");
            Assert.AreEqual(-654, vel.GetVelocity(0, 3), "DS 0 Beam 3 is incorrect.");

            Assert.AreEqual(1232, vel.GetVelocity(4, 0), "DS 4 Beam 0 is incorrect.");
            Assert.AreEqual(-1323, vel.GetVelocity(4, 1), "DS 4 Beam 1 is incorrect.");
            Assert.AreEqual(1456, vel.GetVelocity(4, 2), "DS 4 Beam 2 is incorrect.");
            Assert.AreEqual(-1654, vel.GetVelocity(4, 3), "DS 4 Beam 3 is incorrect.");
        }
Esempio n. 20
0
        public void TestEncode()
        {
            Pd0Velocity vel = new Pd0Velocity();

            vel.Velocities = new short[5, 4];

            vel.Velocities[0, 0] = 232;
            vel.Velocities[0, 1] = -323;
            vel.Velocities[0, 2] = 456;
            vel.Velocities[0, 3] = -654;

            vel.Velocities[4, 0] = 1232;
            vel.Velocities[4, 1] = -1323;
            vel.Velocities[4, 2] = 1456;
            vel.Velocities[4, 3] = -1654;

            byte[] data = vel.Encode();

            // DS 0 Beam 0
            Assert.AreEqual(0xE8, data[2], "DS 0 Beam 0 LSB Encode is incorrect.");
            Assert.AreEqual(0x00, data[3], "DS 0 Beam 0 MSB Encode is incorrect.");

            // DS 0 Beam 1
            Assert.AreEqual(0xBD, data[4], "DS 0 Beam 1 LSB Encode is incorrect.");
            Assert.AreEqual(0xFE, data[5], "DS 0 Beam 1 MSB Encode is incorrect.");

            // DS 0 Beam 2
            Assert.AreEqual(0xC8, data[6], "DS 0 Beam 2 LSB Encode is incorrect.");
            Assert.AreEqual(0x01, data[7], "DS 0 Beam 2 MSB Encode is incorrect.");

            // DS 0 Beam 3
            Assert.AreEqual(0x72, data[8], "DS 0 Beam 3 LSB Encode is incorrect.");
            Assert.AreEqual(0xFD, data[9], "DS 0 Beam 3 MSB Encode is incorrect.");

            // DS 4 Beam 0
            Assert.AreEqual(0xD0, data[(4 * 8) + 2 + 0], "DS 4 Beam 0 LSB Encode is incorrect.");
            Assert.AreEqual(0x04, data[(4 * 8) + 2 + 1], "DS 4 Beam 0 MSB Encode is incorrect.");

            // DS 4 Beam 1
            Assert.AreEqual(0xD5, data[(4 * 8) + 2 + 2], "DS 4 Beam 1 LSB Encode is incorrect.");
            Assert.AreEqual(0xFA, data[(4 * 8) + 2 + 3], "DS 4 Beam 1 MSB Encode is incorrect.");

            // DS 4 Beam 2
            Assert.AreEqual(0xB0, data[(4 * 8) + 2 + 4], "DS 4 Beam 2 LSB Encode is incorrect.");
            Assert.AreEqual(0x05, data[(4 * 8) + 2 + 5], "DS 4 Beam 2 MSB Encode is incorrect.");

            // DS 4 Beam 3
            Assert.AreEqual(0x8A, data[(4 * 8) + 2 + 6], "DS 4 Beam 3 LSB Encode is incorrect.");
            Assert.AreEqual(0xF9, data[(4 * 8) + 2 + 7], "DS 4 Beam 3 MSB Encode is incorrect.");
        }