/// <summary> /// Test the RTC. This will set the time to the RTC. It will /// then check the time agaisnt the system time. The times should be /// within a second of each other. So if ADCP time is before /// </summary> /// <returns>Result of the test.</returns> public SystemTestResult SysTestRtcUtcTime() { SystemTestResult result = new SystemTestResult(); // Set the system time if (SetUtcSystemDateTime()) { //// Now get the time and verify it is within 1 second of the previous time //// Clear buffer //ReceiveBufferString = ""; //// Send STIME to get the time //SendData(string.Format("{0}", RTI.Commands.AdcpCommands.CMD_STIME)); //// Wait for an output //Thread.Sleep(RTI.AdcpSerialPort.WAIT_STATE * 2); //DateTime currDt = DateTime.Now.ToUniversalTime(); // Get the current date and time //DateTime adcpDt = RTI.Commands.AdcpCommands.DecodeSTIME(ReceiveBufferString); // Decode the date and time from the ADCP DateTime adcpDt = GetAdcpDateTime(); // Decode the date and time from the ADCP DateTime currDt = DateTime.Now.ToUniversalTime(); // Get the current date and time // Set the Results as the ADCP Date and Time result.Results = adcpDt; // Verify the Date and Time are within a second of each other // This could fail on the rare occassion that the hour changes in the second between getting the two times if (adcpDt > currDt || adcpDt.Year != currDt.Year || adcpDt.Month != currDt.Month || adcpDt.Day != currDt.Day || adcpDt.Hour != currDt.Hour || adcpDt.Minute != currDt.Minute || adcpDt.Second > currDt.Second) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("RTC time does not match current time. Expected: {0} Found {1}", currDt.ToString(), adcpDt.ToString())); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_RTC_TIME); } } else { // Could not send a command to the ADCP result.TestResult = false; result.ErrorListStrings.Add("Communication with ADCP failed."); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_NO_COMM); } return result; }
/// <summary> /// Configure the ADCP to send a single Water Profile ping. This will turn off Water Track and Bottom Track. /// Then Ping the system. Then reset the default values. There are no results for this test. You must subscribe /// to receive the ensemble and check the status. /// </summary> /// <returns>No results are set.</returns> public SystemTestResult SysTestSingleWaterProfilePing() { SystemTestResult result = new SystemTestResult(); // Now get the time and verify it is within 1 second of the previous time // Clear buffer ReceiveBufferString = ""; // Set defaults, turn off bt and wt and ping SendData(string.Format("{0}", RTI.Commands.AdcpCommands.CMD_CDEFAULT)); // Set defaults SendData(string.Format("{0} 0", RTI.Commands.AdcpSubsystemCommands.CMD_CBTON)); // Turn off Bottom Track SendData(string.Format("{0} 0", RTI.Commands.AdcpSubsystemCommands.CMD_CWTON)); // Turn off Water Track SendData(string.Format("{0} 1", RTI.Commands.AdcpSubsystemCommands.CMD_CWPON)); // Turn On Water Profile SendData(string.Format("{0}", RTI.Commands.AdcpCommands.CMD_PING)); // Get a ping // Wait for an output Thread.Sleep(RTI.AdcpSerialPort.WAIT_STATE); // Send CDEFAULT to put back in default mode SendData(string.Format("{0}", RTI.Commands.AdcpCommands.CMD_CDEFAULT)); return result; }
/// <summary> /// Verify all the registers are present and the /// board serial numbers and revisions are correct. /// </summary> /// <param name="testSerialRev">Flag if we should test the serial and revision of the board.</param> /// <param name="memDevsExpected">The expected results.</param> /// <returns>Result of the test.</returns> public SystemTestResult SysTestI2cMemoryDevices(bool testSerialRev, RTI.Commands.I2cMemDevs memDevsExpected) { SystemTestResult result = new SystemTestResult(); // Clear buffer ReceiveBufferString = ""; // Send the command ENGI2CSHOW SendData("ENGI2CSHOW"); // Wait for an output Thread.Sleep(RTI.AdcpSerialPort.WAIT_STATE); // Get the buffer output string buffer = ReceiveBufferString; if (buffer.Length <= 0) { result.TestResult = false; result.ErrorListStrings.Add("Communication with ADCP failed."); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_NO_COMM); } else { RTI.Commands.I2cMemDevs memDevsResult = RTI.Commands.AdcpCommands.DecodeENGI2CSHOW(ReceiveBufferString); // Set the results so the user can see the serial number and revision actually seen result.Results = memDevsResult; // Check if we are testing the revision and serial number // Because the user cannot know the correct serial and rev, // this test cannot always pass if the software is not updated with the latest revisions // If we are not testing for the correct serial and revision, then verify that anything is set, // If the revision or serial number is 0, then the serial or revision is not set. if (testSerialRev) { // Backplane serial if (memDevsExpected.BackPlaneBoard.SerialNum != memDevsResult.BackPlaneBoard.SerialNum) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Backplane board serial number does not match system serial number. Expected: {0} Found: {1}", memDevsExpected.BackPlaneBoard.SerialNum, memDevsResult.BackPlaneBoard.SerialNum)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_BACKPLANE_BRD); } // Backplane Rev if (memDevsExpected.BackPlaneBoard.Revision.CompareTo(memDevsResult.BackPlaneBoard.Revision) != 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Backplane board revision does not match. Expected: {0} Found: {1}", memDevsExpected.BackPlaneBoard.Revision, memDevsResult.BackPlaneBoard.Revision)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_BACKPLANE_BRD); } // I/O serial if (memDevsExpected.IoBoard.SerialNum != memDevsResult.IoBoard.SerialNum) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("I/O board serial number does not match system serial number. Expected: {0} Found: {1}", memDevsExpected.IoBoard.SerialNum, memDevsResult.IoBoard.SerialNum)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_IO_BRD); } // I/0 Rev if (memDevsExpected.IoBoard.Revision.CompareTo(memDevsResult.IoBoard.Revision) != 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("I/0 board revision does not match. Expected: {0} Found: {1}", memDevsExpected.IoBoard.Revision, memDevsResult.IoBoard.Revision)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_IO_BRD); } // RVCR serial if (memDevsExpected.RcvrBoard.SerialNum != memDevsResult.RcvrBoard.SerialNum) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Receiver board serial number does not match system serial number. Expected: {0} Found: {1}", memDevsExpected.RcvrBoard.SerialNum, memDevsResult.RcvrBoard.SerialNum)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_RCVR_BRD); } // RVCR Rev if (memDevsExpected.RcvrBoard.Revision.CompareTo(memDevsResult.RcvrBoard.Revision) != 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Receiver board revision does not match. Expected: {0} Found: {1}", memDevsExpected.RcvrBoard.Revision, memDevsResult.RcvrBoard.Revision)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_RCVR_BRD); } // Low Power Reg serial if (memDevsExpected.LowPwrRegBoard.SerialNum != memDevsResult.LowPwrRegBoard.SerialNum) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Low Power Regulator board serial number does not match system serial number. Expected: {0} Found: {1}", memDevsExpected.LowPwrRegBoard.SerialNum, memDevsResult.LowPwrRegBoard.SerialNum)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_LOW_PWR_REG_BRD); } // Low Power Reg Rev if (memDevsExpected.LowPwrRegBoard.Revision.CompareTo(memDevsResult.LowPwrRegBoard.Revision) != 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Low Power Regulator board revision does not match. Expected: {0} Found: {1}", memDevsExpected.LowPwrRegBoard.Revision, memDevsResult.LowPwrRegBoard.Revision)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_LOW_PWR_REG_BRD); } // Virtual Ground serial if (memDevsExpected.VirtualGndBoard.SerialNum != memDevsResult.VirtualGndBoard.SerialNum) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Virtual Ground board serial number does not match system serial number. Expected: {0} Found: {1}", memDevsExpected.VirtualGndBoard.SerialNum, memDevsResult.VirtualGndBoard.SerialNum)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_VIRTUAL_GND_BRD); } // Virtual Ground Rev if (memDevsExpected.VirtualGndBoard.Revision.CompareTo(memDevsResult.VirtualGndBoard.Revision) != 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Virtual Ground board revision does not match. Expected: {0} Found: {1}", memDevsExpected.VirtualGndBoard.Revision, memDevsResult.VirtualGndBoard.Revision)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_VIRTUAL_GND_BRD); } // Xmitter serial if (memDevsExpected.XmitterBoard.SerialNum != memDevsResult.XmitterBoard.SerialNum) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Xmitter board serial number does not match system serial number. Expected: {0} Found: {1}", memDevsExpected.XmitterBoard.SerialNum, memDevsResult.XmitterBoard.SerialNum)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_XMITTER_BRD); } // Xmitter Rev if (memDevsExpected.XmitterBoard.Revision.CompareTo(memDevsResult.XmitterBoard.Revision) != 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Xmitter board revision does not match. Expected: {0} Found: {1}", memDevsExpected.XmitterBoard.Revision, memDevsResult.XmitterBoard.Revision)); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_XMITTER_BRD); } } else { // Backplane serial if (memDevsResult.BackPlaneBoard.SerialNum == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Backplane board serial number is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_BACKPLANE_BRD); } // Backplane Rev if (memDevsResult.BackPlaneBoard.Revision.CompareTo("0") == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Backplane board revision is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_BACKPLANE_BRD); } // I/O serial if (memDevsResult.IoBoard.SerialNum == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("I/O board serial number is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_IO_BRD); } // I/0 Rev if (memDevsResult.IoBoard.Revision.CompareTo("0") == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("I/0 board revision is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_IO_BRD); } // RVCR serial if (memDevsResult.RcvrBoard.SerialNum == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Receiver board serial number is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_RCVR_BRD); } // RVCR Rev if (memDevsResult.RcvrBoard.Revision.CompareTo("0") == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Receiver board revision is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_RCVR_BRD); } // Low Power Reg serial if (memDevsResult.LowPwrRegBoard.SerialNum == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Low Power Regulator board serial number is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_LOW_PWR_REG_BRD); } // Low Power Reg Rev if (memDevsResult.LowPwrRegBoard.Revision.CompareTo("0") == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Low Power Regulator board revision is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_LOW_PWR_REG_BRD); } // Virtual Ground serial if (memDevsResult.VirtualGndBoard.SerialNum == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Virtual Ground board serial number is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_VIRTUAL_GND_BRD); } // Virtual Ground Rev if (memDevsResult.VirtualGndBoard.Revision.CompareTo("0") == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Virtual Ground board revision is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_VIRTUAL_GND_BRD); } // Xmitter serial if (memDevsResult.XmitterBoard.SerialNum == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Xmitter board serial number is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_SERIAL_XMITTER_BRD); } // Xmitter Rev if (memDevsResult.XmitterBoard.Revision.CompareTo("0") == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Xmitter board revision is not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.INCORRECT_REV_XMITTER_BRD); } } } return result; }
/// <summary> /// Verify the Firmware version matches. This will send a BREAK to the ADCP and /// decode the BREAK statement for the firmware version. /// </summary> /// <param name="isTestVersion">Flag if we should test the version agaisnt the one given.</param> /// <param name="major">Major version.</param> /// <param name="minor">Minor version.</param> /// <param name="revision">Revision version.</param> /// <returns>Firmware test result.</returns> public SystemTestResult SysTestFirmwareVersion(bool isTestVersion, ushort major = 0, ushort minor = 0, ushort revision = 0) { SystemTestResult result = new SystemTestResult(); // Clear buffer ReceiveBufferString = ""; // Send a Break SendBreak(); // Wait for an output Thread.Sleep(RTI.AdcpSerialPort.WAIT_STATE); // Get the buffer output string buffer = ReceiveBufferString; if (buffer.Length <= 0) { result.TestResult = false; result.ErrorListStrings.Add("Communication with ADCP failed."); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_NO_COMM); } else { // Decode a break statement for version RTI.Commands.BreakStmt breakStmt = RTI.Commands.AdcpCommands.DecodeBREAK(ReceiveBufferString); // Check if we should check the versions for specific values if (isTestVersion) { // Check each value with the one given if (breakStmt.FirmwareVersion.FirmwareMajor < major) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Firmware Major version does not match. Expected: {0} Found: {1}", major, breakStmt.FirmwareVersion.FirmwareMajor)); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_FIRMWARE_MAJOR); } if (breakStmt.FirmwareVersion.FirmwareMinor < minor) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Firmware Minor version does not match. Expected: {0} Found: {1}", minor, breakStmt.FirmwareVersion.FirmwareMinor)); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_FIRMWARE_MINOR); } if (breakStmt.FirmwareVersion.FirmwareRevision < revision) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Firmware Revision version does not match. Expected: {0} Found: {1}", revision, breakStmt.FirmwareVersion.FirmwareRevision)); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_FIRMWARE_REVISION); } } else { // Check if the major, minor and revision are all 0 // If all are 0, then the version is not set if (breakStmt.FirmwareVersion.FirmwareMajor == 0 && breakStmt.FirmwareVersion.FirmwareMinor == 0 && breakStmt.FirmwareVersion.FirmwareRevision == 0) { result.TestResult = false; result.ErrorListStrings.Add(string.Format("Firmware version not set.")); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_FIRMWARE_VERSION); } } // Pass the results result.Results = breakStmt; } return result; }
/// <summary> /// Test if the system firmware files exist. This check the /// directory listing for all the files. If the firmware files /// do not exist, the result will report which files are missing. /// </summary> /// <returns>Result of the test. File missing if any missing.</returns> public SystemTestResult SysTestFirmwareFiles() { SystemTestResult result = new SystemTestResult(); // Download the directory listing to _dirListingString DownloadDirectoryListing(); // Parse the directory listing string for all file info // Each line should contain a piece of file info string[] lines = _dirListingString.Split('\n'); // Ensure data exist if (lines.Length <= 0) { result.ErrorListStrings.Add("Firmware files missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_FILES_MISSING); result.TestResult = false; } else { // Data exist, verify the correct files exist bool helpExist = false; bool engHelpExist = false; bool maintExist = false; bool rtisysExist = false; bool bootExist = false; bool sysconfExist = false; bool bbcodeExist = false; for(int x = 0; x < lines.Length; x++) { if (lines[x].Contains("HELP")) { helpExist = true; } // HELP.TXT if (lines[x].Contains("ENGHELP")) { engHelpExist = true; } // ENGHELP.TXT if (lines[x].Contains("MAINT")) { maintExist = true; } // MAINT.TXT if (lines[x].Contains("RTISYS")) { rtisysExist = true; } // RTISYS.BIN if (lines[x].Contains("BOOT")) { bootExist = true; } // BOOT.BIN if (lines[x].Contains("SYSCONF")) { sysconfExist = true; } // SYSCONF.BIN if (lines[x].Contains("BBCODE")) { bbcodeExist = true; } // BBCODE.BIN } // HELP.TXT missing if (!helpExist) { result.ErrorListStrings.Add("HELP.TXT missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_HELP_MISSING); result.TestResult = false; } // EngHelp.TXT missing if (!engHelpExist) { result.ErrorListStrings.Add("ENGHELP.TXT missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_ENGHELP_MISSING); result.TestResult = false; } // maint.TXT missing if (!maintExist) { result.ErrorListStrings.Add("MAINT.TXT missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_MAINT_MISSING); result.TestResult = false; } // RTISYS.BIN missing if (!rtisysExist) { result.ErrorListStrings.Add("RTISYS.BIN missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_RTISYS_MISSING); result.TestResult = false; } // BOOT.BIN missing if (!bootExist) { result.ErrorListStrings.Add("BOOT.BIN missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_BOOT_MISSING); result.TestResult = false; } // SYSCONF.BIN missing if (!sysconfExist) { result.ErrorListStrings.Add("SYSCONF.BIN missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_SYSCONF_MISSING); result.TestResult = false; } // BBCODE.BIN missing if (!bbcodeExist) { result.ErrorListStrings.Add("BBCODE.BIN missing."); result.ErrorCodes.Add(SystemTestErrorCodes.FIRMWARE_BBCODE_MISSING); result.TestResult = false; } } // Clear the string _dirListingString = ""; return result; }
/// <summary> /// Decode the ENGPNI command. Verify that heading, pitch and roll are not 0. /// If all the values are 0, then the compass is not outputing data. /// </summary> /// <returns>Return the results of the test.</returns> public SystemTestResult SysTestCompass() { SystemTestResult result = new SystemTestResult(); // Clear buffer ReceiveBufferString = ""; // Send the command ENGPNI SendData(RTI.Commands.AdcpCommands.CMD_ENGPNI); // Wait for an output Thread.Sleep(RTI.AdcpSerialPort.WAIT_STATE); // Decode the result RTI.Commands.HPR hpr = RTI.Commands.AdcpCommands.DecodeEngPniResult(ReceiveBufferString); // Check if all the values are 0 if (hpr.Heading == 0 && hpr.Pitch == 0 && hpr.Roll == 0) { result.TestResult = false; result.ErrorListStrings.Add("Compass not outputing data."); result.ErrorCodes.Add(SystemTestErrorCodes.COMPASS_NO_OUTPUT); } return result; }
/// <summary> /// Test if we have communication with the ADCP. This will send a break /// to the ADCP. If nothing is received from the ADCP, then we do not /// have communication and send a fail result. /// </summary> /// <returns>Result from the test.</returns> public SystemTestResult SysTestAdcpCommunication() { SystemTestResult result = new SystemTestResult(); // Clear buffer ReceiveBufferString = ""; // Send a Break SendBreak(); // Wait for an output Thread.Sleep(RTI.AdcpSerialPort.WAIT_STATE); // Get the buffer output string buffer = ReceiveBufferString; if (buffer.Length <= 0) { result.TestResult = false; result.ErrorListStrings.Add("Communication with ADCP failed."); result.ErrorCodes.Add(SystemTestErrorCodes.ADCP_NO_COMM); } else { RTI.Commands.BreakStmt breakStmt = RTI.Commands.AdcpCommands.DecodeBREAK(ReceiveBufferString); // Pass the results result.Results = breakStmt; } return result; }