public void TestIsEmptySubsystem() { SerialNumber serial = new SerialNumber("01200000000000000000000000000000"); Assert.IsFalse(serial.IsEmpty(), "IsEmpty() is incorrect."); }
public void TestIsEmptySpare() { SerialNumber serial = new SerialNumber("01000000000000000000100000000000"); Assert.IsTrue(serial.IsEmpty(), "IsEmpty() is incorrect."); }
/// <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; }
/// <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); }