예제 #1
0
        public void DecodePd0Test()
        {
            Pd0FixedLeader fl = new Pd0FixedLeader();
            Pd0VariableLeader vl = new Pd0VariableLeader();

            vl.EnsembleNumber = 345;
            fl.NumberOfCells = 30;
            fl.NumberOfBeams = 4;
            fl.PingsPerEnsemble = 5;
            fl.CpuBoardSerialNumber = "01000000000000000000000000000001";
            fl.CpuFirmwareVersion = 3;
            fl.CpuFirmwareRevision = 27;
            fl.SetSystemFrequency(Pd0FixedLeader.SystemFrequency.Freq_300kHz);
            vl.RtcYear = 14;
            vl.RtcMonth = 3;
            vl.RtcDay = 2;
            vl.RtcHour = 4;
            vl.RtcMinute = 3;
            vl.RtcSecond = 2;
            vl.RtcHundredths = 3;

            DataSet.EnsembleDataSet ens = new DataSet.EnsembleDataSet(DataSet.Ensemble.DATATYPE_INT,                         // 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.EnsembleDataID, 30, 4);               // Dataset ID
            ens.DecodePd0Ensemble(fl, vl);

            Assert.AreEqual(345, ens.EnsembleNumber, "Ensemble Number is incorrect.");
            Assert.AreEqual(30, ens.NumBins, "Number of bins is incorrect.");
            Assert.AreEqual(4, ens.NumBeams, "Number of beams is incorrect.");
            Assert.AreEqual(5, ens.DesiredPingCount, "Desired Ping count is incorrect.");
            Assert.AreEqual(5, ens.ActualPingCount, "Actual ping count is incorrect.");
            Assert.AreEqual("01400000000000000000000000000001", ens.SysSerialNumber.ToString(), "Serial number is incorrect.");
            Assert.AreEqual(0, ens.SysFirmware.FirmwareMajor, "Firmware major is incorrect.");
            Assert.AreEqual(3, ens.SysFirmware.FirmwareMinor, "Firmware minor is incorrect.");
            Assert.AreEqual(27, ens.SysFirmware.FirmwareRevision, "Firmware revision is incorrect.");
            Assert.AreEqual(Subsystem.SUB_300KHZ_4BEAM_20DEG_PISTON_4, ens.SubsystemConfig.SubSystem.Code, "Subsystem is incorrect.");
            Assert.AreEqual(2014, ens.Year, "Year is incorrect.");
            Assert.AreEqual(3, ens.Month, "Month is incorrect.");
            Assert.AreEqual(2, ens.Day, "Days is incorrect.");
            Assert.AreEqual(4, ens.Hour, "Hour is incorrect.");
            Assert.AreEqual(3, ens.Minute, "Minute is incorrect.");
            Assert.AreEqual(2, ens.Second, "Seconds is incorrect.");
            Assert.AreEqual(3, ens.HSec, "HSec is incorrect.");
        }
예제 #2
0
        public void DecodePd0Test()
        {
            Pd0FixedLeader fl = new Pd0FixedLeader();
            Pd0VariableLeader vl = new Pd0VariableLeader();

            fl.DepthCellLength = 23 * 100;
            vl.Heading = 223.3f;
            vl.Pitch = 123.45f;
            vl.Roll = 445.69f;
            vl.Temperature = 78.9f;
            vl.Pressure = 11;
            vl.DepthOfTransducer = 23 * 10;

            DataSet.AncillaryDataSet anc = new DataSet.AncillaryDataSet();
            anc.DecodePd0Ensemble(fl, vl);

            Assert.AreEqual(23, anc.BinSize, "Bin size is incorrect.");
            Assert.AreEqual(223.3f, anc.Heading, "Heading is incorrect.");
            Assert.AreEqual(123.45f, anc.Pitch, "Pitch is incorrect.");
            Assert.AreEqual(445.69f, anc.Roll, "Roll is incorrect.");
            Assert.AreEqual(78.9f, anc.WaterTemp, "Water Temp is incorrect.");
            Assert.AreEqual(110000, anc.Pressure, "Pressure is incorrect.");
            Assert.AreEqual(23, anc.TransducerDepth, "Transducer Depth is incorrect.");
        }
예제 #3
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.");
        }
예제 #4
0
        public void TestAddDataTypeFixed()
        {
            Pd0Header header = new Pd0Header();
            Pd0VariableLeader vl = new Pd0VariableLeader();
            Pd0FixedLeader fl = new Pd0FixedLeader();
            fl.NumberOfCells = 5;
            header.AddDataType(vl);
            header.AddDataType(fl);

            byte[] data = header.Encode();

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

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

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

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