/// <summary> /// Return a subsystem for this firmware version. /// This will use the SubsystemCode to create a /// subsystem to return. /// /// FOR BACKWARDS COMPATITBILITY /// Old subsystems in the ensemble were set by the Subsystem Index in Firmware. /// This means the that a subsystem code of 0 could be passed because /// the index was 0 to designate the first subsystem index. Firmware revision 0.2.13 changed /// SubsystemIndex to SubsystemCode. This will check which Firmware version this ensemble is /// and convert to the new type using SubsystemCode. /// /// If the firmwawre is a debug firmware, the Major number will be set to 99. So also 99.2.13 or less uses the old form. /// </summary> /// <param name="serial">Serial number to get the subsystem code if the firmware version is less than 0.2.13.</param> /// <returns>Subsystem for this firmware.</returns> public Subsystem GetSubsystem(SerialNumber serial) { // The DVL serial number is a special serial number // used to designate the ensemble as a DVL ensemble // Give the DVL subsystem code as the DVL if (serial == SerialNumber.DVL) { // Get the Subsystem code from the serialnumber, there should only be 1 subsystem string code = serial.SubSystems.Substring(0, 1); SubsystemCode = Subsystem.ConvertSubsystemCode(code[0]); // Create a subsystem with the code return(new Subsystem(SubsystemCode)); } if ((FirmwareMajor <= 0 || FirmwareMajor == DEBUG_MAJOR_VER) && FirmwareMinor <= 2 && FirmwareRevision <= 13) { // Set the correct subsystem based off the serial number // Get the index for the subsystem byte index = SubsystemCode; // Ensure the index is not out of range of the subsystem string if (serial.SubSystems.Length > index) { // Get the Subsystem code from the serialnumber based off the index found string code = serial.SubSystems.Substring(index, 1); // Create a subsystem with the code and index return(new Subsystem(Subsystem.ConvertSubsystemCode(code[0]), index)); } } return(new Subsystem(SubsystemCode)); }
public void TestConvertCharToSubsystemCode() { // Create a serial number char value = '2'; byte subsystemCode = Subsystem.ConvertSubsystemCode(value); Assert.AreEqual(50, subsystemCode, "Subsystem Code value is incorrect."); Assert.AreEqual(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2, subsystemCode, "Subsystem Code is incorrect."); }
public void TestConvertStringToSubsystemCode() { // Create a serial number string serialStr = "01200000000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); byte subsystemCode = Subsystem.ConvertSubsystemCode(serialNum.SubsystemsString(), 0); Assert.AreEqual(50, subsystemCode, "Subsystem Code value is incorrect."); Assert.AreEqual(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2, subsystemCode, "Subsystem Code is incorrect."); }
/// <summary> /// Decode the CEPO command and populate the dictionary. /// /// Ex: /// CEPO 222 /// 1 Subsystem /// 3 SubsystemConfigurations for Subsystem 2 /// /// CEPO 232 /// 2 Subsystems /// 2 SubsystemConfigurations for Subsystem 2 and /// 1 SubsystemConfiguration for Subsystem 3 /// /// </summary> /// <param name="cepo">CEPO command to decode.</param> /// <param name="serial">Serial number to determine the system type.</param> /// <returns>Dictionary of all subsystem configurations found.</returns> private Dictionary <string, AdcpSubsystemConfig> DecodeCepo(string cepo, SerialNumber serial) { // Clear the current dictionary SubsystemConfigDict.Clear(); // Add each configuration in the command for (int x = 0; x < cepo.Length; x++) { AddConfig(Subsystem.ConvertSubsystemCode(cepo, x), x, serial); } // Return the populated dictionary return(SubsystemConfigDict); }
/// <summary> /// Get the Subsystem code. The subsystem code is gotten in 2 /// different ways depending on the firmware version. /// /// Firmare Version less than or equal to 0.2.13 /// The code stored is the index within the serial number. /// Get the serial numbers subsystems and use the index /// to get the code. /// /// If the firmwawre is a debug firmware, the Major number will be set to 99. So also 99.2.13 or less uses the old form. /// /// Firmware Version greater than 0.2.13 /// The code stored is the code. /// </summary> /// <param name="serial">Serial number used if the firmware version is less than 0.2.13</param> /// <returns>Subsystem code.</returns> public byte GetSubsystemCode(SerialNumber serial) { // The DVL serial number is a special case // No Subsystem or Subsystem configuration is given // for a DVL message. This will be a generic response // to a DVL message if (serial == SerialNumber.DVL) { // Get the Subsystem code from the serialnumber, there should only be 1 subsystem string code = serial.SubSystems.Substring(0, 1); SubsystemCode = Subsystem.ConvertSubsystemCode(code[0]); return(SubsystemCode); } // If the firmware version is less than 0.2.13, // then the code store is actually the index and we must use // the serial number to get the code // A DVL serial number is a special case where nothing should change if ((FirmwareMajor <= 0 || FirmwareMajor == DEBUG_MAJOR_VER) && FirmwareMinor <= 2 && FirmwareRevision <= 13 && !serial.IsEmpty()) { // Set the correct subsystem based off the serial number // Get the index for the subsystem byte index = SubsystemCode; // Ensure the index is not out of range of the subsystem string if (serial.SubSystems.Length > index) { // Get the Subsystem code from the serialnumber based off the index found string code = serial.SubSystems.Substring(index, 1); return(Subsystem.ConvertSubsystemCode(code[0])); } } // Based off the firmware version, the code stored is the correct code return(SubsystemCode); }