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."); }
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); }