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."); }
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."); }
/// <summary> /// Convert the PD0 Fixed Leader and Variable Leader data type to the RTI Ancillary data set. /// </summary> /// <param name="fl">PD0 Fixed Leader.</param> /// <param name="vl">PD0 Variable Leader.</param> public void DecodePd0Ensemble(Pd0FixedLeader fl, Pd0VariableLeader vl) { // Get the time TimeSpan ts = new TimeSpan((int)vl.RtcY2kDay, (int)vl.RtcY2kHour, (int)vl.RtcY2kMinute, (int)vl.RtcY2kSecond); // Initialize data this.FirstBinRange = fl.Bin1Distance / 100.0f;; this.BinSize = fl.DepthCellLength / 100.0f; this.FirstPingTime = (float)ts.TotalSeconds; this.LastPingTime = FirstPingTime; this.Heading = vl.Heading; this.Pitch = vl.Pitch; this.Roll = vl.Roll; this.WaterTemp = vl.Temperature; this.SystemTemp = 0.0f; this.Salinity = vl.Salinity; this.Pressure = vl.Pressure / 0.0001f; this.TransducerDepth = vl.DepthOfTransducer / 10.0f; this.SpeedOfSound = vl.SpeedOfSound; }
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."); }
/// <summary> /// Convert the PD0 Bottom Track data type to the RTI Bottom Track data set. /// </summary> /// <param name="bt">PD0 Bottom Track.</param> /// <param name="xform">Coordinate Transform.</param> /// <param name="vl">Variable Leader.</param> public void DecodePd0Ensemble(Pd0BottomTrack bt, PD0.CoordinateTransforms xform, Pd0VariableLeader vl) { // Get the time to seconds TimeSpan ts = new TimeSpan((int)vl.RtcY2kDay, (int)vl.RtcY2kHour, (int)vl.RtcY2kMinute, (int)vl.RtcY2kSecond); FirstPingTime = (float)ts.TotalSeconds; LastPingTime = FirstPingTime; Heading = vl.Heading; Pitch = vl.Pitch; Roll = vl.Roll; WaterTemp = vl.Temperature; SystemTemp = 0.0f; Salinity = vl.Salinity; Pressure = vl.Pressure / 0.0001f; TransducerDepth = vl.DepthOfTransducer / 10.0f; SpeedOfSound = 0.0f; Status = new Status(0); NumBeams = DataSet.Ensemble.DEFAULT_NUM_BEAMS_BEAM; ActualPingCount = bt.BtPingsPerEnsemble; #region Range // Range Range[0] = bt.GetRangeBeam3() / 100.0f; Range[1] = bt.GetRangeBeam2() / 100.0f; Range[2] = bt.GetRangeBeam0() / 100.0f; Range[3] = bt.GetRangeBeam1() / 100.0f; #endregion #region SNR // SNR // PD0 Beam 2, RTI Beam 0 if (bt.BtAmplitudeBeam2 < PD0.BAD_AMPLITUDE) { SNR[0] = bt.BtAmplitudeBeam2 / 2.0f; } else { SNR[0] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 3, RTI Beam 1 if (bt.BtAmplitudeBeam3 < PD0.BAD_AMPLITUDE) { SNR[1] = bt.BtAmplitudeBeam3 / 2.0f; } else { SNR[1] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 1, RTI Beam 2 if (bt.BtAmplitudeBeam1 < PD0.BAD_AMPLITUDE) { SNR[2] = bt.BtAmplitudeBeam1 / 2.0f; } else { SNR[2] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 0, RTI Beam 3 if (bt.BtAmplitudeBeam0 < PD0.BAD_AMPLITUDE) { SNR[3] = bt.BtAmplitudeBeam0 / 2.0f; } else { SNR[3] = DataSet.Ensemble.BAD_VELOCITY; } #endregion #region Amplitude // Amplitude // PD0 Beam 2, RTI Beam 0 if (bt.BtRssiBeam2 < PD0.BAD_AMPLITUDE) { Amplitude[0] = bt.BtRssiBeam2 / 2.0f; } else { Amplitude[0] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 3, RTI Beam 1 if (bt.BtRssiBeam3 < PD0.BAD_AMPLITUDE) { Amplitude[1] = bt.BtRssiBeam3 / 2.0f; } else { Amplitude[1] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 1, RTI Beam 2 if (bt.BtRssiBeam1 < PD0.BAD_AMPLITUDE) { Amplitude[2] = bt.BtRssiBeam1 / 2.0f; } else { Amplitude[2] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 0, RTI Beam 3 if (bt.BtRssiBeam0 < PD0.BAD_AMPLITUDE) { Amplitude[3] = bt.BtRssiBeam0 / 2.0f; } else { Amplitude[3] = DataSet.Ensemble.BAD_VELOCITY; } #endregion #region Correlation // Correlation // PD0 Beam 2, RTI Beam 0 if (bt.BtCorrelationMagnitudeBeam2 < PD0.BAD_CORRELATION) { Correlation[0] = bt.BtCorrelationMagnitudeBeam2 / 255.0f; } else { Correlation[0] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 3, RTI Beam 1 if (bt.BtCorrelationMagnitudeBeam3 < PD0.BAD_CORRELATION) { Correlation[1] = bt.BtCorrelationMagnitudeBeam3 / 255.0f; } else { Correlation[1] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 1, RTI Beam 2 if (bt.BtCorrelationMagnitudeBeam1 < PD0.BAD_CORRELATION) { Correlation[2] = bt.BtCorrelationMagnitudeBeam1 / 255.0f; } else { Correlation[2] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 0, RTI Beam 3 if (bt.BtCorrelationMagnitudeBeam0 < PD0.BAD_CORRELATION) { Correlation[3] = bt.BtCorrelationMagnitudeBeam0 / 255.0f; } else { Correlation[3] = DataSet.Ensemble.BAD_VELOCITY; } #endregion #region Velocity // Velocity switch(xform) { // Beam Coordinate Transform case PD0.CoordinateTransforms.Coord_Beam: // PD0 Beam 2, RTI Beam 0 if(bt.BtVelocityBeam2 != PD0.BAD_VELOCITY) { BeamVelocity[0] = bt.BtVelocityBeam2 / 1000.0f; } else { BeamVelocity[0] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 3, RTI Beam 1 if(bt.BtVelocityBeam3 != PD0.BAD_VELOCITY) { BeamVelocity[1] = bt.BtVelocityBeam3 / 1000.0f; } else { BeamVelocity[1] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 1, RTI Beam 2 if(bt.BtVelocityBeam1 != PD0.BAD_VELOCITY) { BeamVelocity[2] = bt.BtVelocityBeam1 / 1000.0f; } else { BeamVelocity[2] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 0, RTI Beam 3 if(bt.BtVelocityBeam0 != PD0.BAD_VELOCITY) { BeamVelocity[3] = bt.BtVelocityBeam0 / 1000.0f; } else { BeamVelocity[3] = DataSet.Ensemble.BAD_VELOCITY; } break; // Instrument Coordinate Transform case PD0.CoordinateTransforms.Coord_Instrument: // PD0 Beam 1, RTI Beam 0 if(bt.BtVelocityBeam1 != PD0.BAD_VELOCITY) { InstrumentVelocity[0] = bt.BtVelocityBeam1 / 1000.0f; } else { InstrumentVelocity[0] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 0, RTI Beam 1 if(bt.BtVelocityBeam0 != PD0.BAD_VELOCITY) { InstrumentVelocity[1] = bt.BtVelocityBeam0 / 1000.0f; } else { InstrumentVelocity[1] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam -2, RTI Beam 2 if(bt.BtVelocityBeam2 != PD0.BAD_VELOCITY) { InstrumentVelocity[2] = (bt.BtVelocityBeam2 * -1) / 1000.0f; } else { InstrumentVelocity[2] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 3, RTI Beam 3 if(bt.BtVelocityBeam3 != PD0.BAD_VELOCITY) { InstrumentVelocity[3] = bt.BtVelocityBeam3 / 1000.0f; } else { InstrumentVelocity[3] = DataSet.Ensemble.BAD_VELOCITY; } break; // Earth Coordinate Transform case PD0.CoordinateTransforms.Coord_Earth: // Beam 0 if(bt.BtVelocityBeam0 != PD0.BAD_VELOCITY) { EarthVelocity[0] = bt.BtVelocityBeam0 / 1000.0f; } else { EarthVelocity[0] = DataSet.Ensemble.BAD_VELOCITY; } // Beam 1 if(bt.BtVelocityBeam1 != PD0.BAD_VELOCITY) { EarthVelocity[1] = bt.BtVelocityBeam1 / 1000.0f; } else { EarthVelocity[1] = DataSet.Ensemble.BAD_VELOCITY; } // Beam 2 if(bt.BtVelocityBeam2 != PD0.BAD_VELOCITY) { EarthVelocity[2] = bt.BtVelocityBeam2 / 1000.0f; } else { EarthVelocity[2] = DataSet.Ensemble.BAD_VELOCITY; } // Beam 3 if(bt.BtVelocityBeam3 != PD0.BAD_VELOCITY) { EarthVelocity[3] = bt.BtVelocityBeam3 / 1000.0f; } else { EarthVelocity[3] = DataSet.Ensemble.BAD_VELOCITY; } break; } #endregion #region Good Earth // PD0 Beam 2, RTI Beam 0 if (bt.BtPercentGoodBeam2 != PD0.BAD_PERCENT_GOOD) { EarthGood[0] = (bt.BtPercentGoodBeam2 / 100.0f) * bt.BtPingsPerEnsemble; } else { EarthGood[0] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 3, RTI Beam 1 if (bt.BtPercentGoodBeam3 != PD0.BAD_PERCENT_GOOD) { EarthGood[1] = (bt.BtPercentGoodBeam3 / 100.0f) * bt.BtPingsPerEnsemble; } else { EarthGood[1] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 1, RTI Beam 2 if (bt.BtPercentGoodBeam1 != PD0.BAD_PERCENT_GOOD) { EarthGood[2] = (bt.BtPercentGoodBeam1 / 100.0f) * bt.BtPingsPerEnsemble; } else { EarthGood[2] = DataSet.Ensemble.BAD_VELOCITY; } // PD0 Beam 0, RTI Beam 3 if (bt.BtPercentGoodBeam0 != PD0.BAD_PERCENT_GOOD) { EarthGood[3] = (bt.BtPercentGoodBeam0 / 100.0f) * bt.BtPingsPerEnsemble; } else { EarthGood[3] = DataSet.Ensemble.BAD_VELOCITY; } #endregion }
/// <summary> /// Convert the PD0 Bottom Track data type to the RTI Bottom Track data set. /// </summary> /// <param name="bt">PD0 Bottom Track.</param> /// <param name="xform">Coordinate Transform.</param> /// <param name="vl">Variable Leader.</param> public void DecodePd0Ensemble(Pd0BottomTrack bt, PD0.CoordinateTransforms xform, Pd0VariableLeader vl) { #region Velocity Data this.WaterMassDepthLayer = ((bt.BtRefLayerNear + bt.BtRefLayerFar) / 2.0f) / 10.0f; // Divide by 10 to convert DM to M // Set velocities and check for bad velocities if (bt.BtRefLayerVelocityBeam0 == PD0.BAD_VELOCITY) { this.VelocityX = Ensemble.EMPTY_VELOCITY; } else { this.VelocityX = bt.BtRefLayerVelocityBeam0 / 1000.0f; } if (bt.BtRefLayerVelocityBeam1 == PD0.BAD_VELOCITY) { this.VelocityY = Ensemble.EMPTY_VELOCITY; } else { this.VelocityY = bt.BtRefLayerVelocityBeam1 / 1000.0f; } if (bt.BtRefLayerVelocityBeam2 == PD0.BAD_VELOCITY) { this.VelocityZ = Ensemble.EMPTY_VELOCITY; } else { this.VelocityZ = bt.BtRefLayerVelocityBeam2 / 1000.0f; } if (bt.BtRefLayerVelocityBeam3 == PD0.BAD_VELOCITY) { this.VelocityQ = Ensemble.EMPTY_VELOCITY; } else { this.VelocityQ = bt.BtRefLayerVelocityBeam3 / 1000.0f; } #endregion BtRefLayerFar = bt.BtRefLayerFar; BtRefLayerMin = bt.BtRefLayerMin; BtRefLayerNear = bt.BtRefLayerNear; BtRefLayerCorrBeam0 = bt.BtRefLayerCorrBeam0; // Should divide by 255 to match RTB correlation range BtRefLayerCorrBeam1 = bt.BtRefLayerCorrBeam1; BtRefLayerCorrBeam2 = bt.BtRefLayerCorrBeam2; BtRefLayerCorrBeam3 = bt.BtRefLayerCorrBeam3; BtRefLayerEchoIntensityBeam0 = bt.BtRefLayerEchoIntensityBeam0; // Should divide by 2 to match RTB amplidtude dB range BtRefLayerEchoIntensityBeam1 = bt.BtRefLayerEchoIntensityBeam1; BtRefLayerEchoIntensityBeam2 = bt.BtRefLayerEchoIntensityBeam2; BtRefLayerEchoIntensityBeam3 = bt.BtRefLayerEchoIntensityBeam3; BtRefLayerPercentGoodBeam0 = bt.BtRefLayerPercentGoodBeam0; BtRefLayerPercentGoodBeam1 = bt.BtRefLayerPercentGoodBeam1; BtRefLayerPercentGoodBeam2 = bt.BtRefLayerPercentGoodBeam2; BtRefLayerPercentGoodBeam3 = bt.BtRefLayerPercentGoodBeam3; }
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."); }
/// <summary> /// Convert the PD0 Fixed Leader and Variable Leader data type to the RTI Ancillary data set. /// </summary> /// <param name="fl">PD0 Fixed Leader.</param> /// <param name="vl">PD0 Variable Leader.</param> public void DecodePd0Ensemble(Pd0FixedLeader fl, Pd0VariableLeader vl) { // Get the time TimeSpan ts = new TimeSpan((int)vl.RtcY2kDay, (int)vl.RtcY2kHour, (int)vl.RtcY2kMinute, (int)vl.RtcY2kSecond); // Initialize data this.FirstBinRange = fl.Bin1Distance / 100.0f; ; this.BinSize = fl.DepthCellLength / 100.0f; this.FirstPingTime = (float)ts.TotalSeconds; this.LastPingTime = FirstPingTime; this.Heading = vl.Heading; this.Pitch = vl.Pitch; this.Roll = vl.Roll; this.WaterTemp = vl.Temperature; this.SystemTemp = 0.0f; this.Salinity = vl.Salinity; this.Pressure = vl.Pressure / 0.0001f; this.TransducerDepth = vl.DepthOfTransducer / 10.0f; this.SpeedOfSound = 0.0f; }
/// <summary> /// Convert the PD0 Fixed Leader and Variable Leader data type to the RTI Ensemble data set. /// </summary> /// <param name="fl">PD0 Fixed Leader.</param> /// <param name="vl">PD0 Variable Leader.</param> public void DecodePd0Ensemble(Pd0FixedLeader fl, Pd0VariableLeader vl) { //this.UniqueId = UniqueId; this.EnsembleNumber = vl.GetEnsembleNumber(); this.NumBins = fl.NumberOfCells; this.NumBeams = fl.NumberOfBeams; this.DesiredPingCount = fl.PingsPerEnsemble; this.ActualPingCount = fl.PingsPerEnsemble; this.SysSerialNumber = new SerialNumber(fl.CpuBoardSerialNumber); // Get the Subsystem Subsystem ss = new Subsystem(); switch(fl.GetSystemFrequency()) { case Pd0FixedLeader.SystemFrequency.Freq_75kHz: ss = new Subsystem(Subsystem.SUB_75KHZ_4BEAM_30DEG_ARRAY_L); break; case Pd0FixedLeader.SystemFrequency.Freq_150kHz: ss = new Subsystem(Subsystem.SUB_150KHZ_4BEAM_30DEG_ARRAY_K); break; case Pd0FixedLeader.SystemFrequency.Freq_300kHz: ss = new Subsystem(Subsystem.SUB_300KHZ_4BEAM_20DEG_PISTON_4); break; case Pd0FixedLeader.SystemFrequency.Freq_600kHz: ss = new Subsystem(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3); break; case Pd0FixedLeader.SystemFrequency.Freq_1200kHz: ss = new Subsystem(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2); break; case Pd0FixedLeader.SystemFrequency.Freq_2400kHz: ss = new Subsystem(Subsystem.SUB_2MHZ_4BEAM_20DEG_PISTON_1); break; } // Add the subsystem found this.SysSerialNumber.AddSubsystem(ss); this.SysFirmware = new Firmware(ss.Code, 0, fl.CpuFirmwareVersion, fl.CpuFirmwareRevision); this.SubsystemConfig = new SubsystemConfiguration(ss, 0, 0); this.Status = new Status(vl.BitResult); this.Year = vl.RtcYear + 2000; this.Month = vl.RtcMonth; this.Day = vl.RtcDay; this.Hour = vl.RtcHour; this.Minute = vl.RtcMinute; this.Second = vl.RtcSecond; this.HSec = vl.RtcHundredths; // Set the time and date ValidateDateTime(Year, Month, Day, Hour, Minute, Second, HSec / 10); // Create UniqueId UniqueId = new UniqueID(EnsembleNumber, EnsDateTime); }
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."); }